]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/editor/SheetTab.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.spreadsheet.ui / src / org / simantics / spreadsheet / ui / editor / SheetTab.java
1 package org.simantics.spreadsheet.ui.editor;
2
3 import org.eclipse.jface.layout.GridDataFactory;
4 import org.eclipse.jface.layout.GridLayoutFactory;
5 import org.eclipse.swt.SWT;
6 import org.eclipse.swt.graphics.Font;
7 import org.eclipse.swt.widgets.Composite;
8 import org.eclipse.swt.widgets.Display;
9 import org.eclipse.ui.IWorkbenchSite;
10 import org.simantics.browsing.ui.swt.widgets.Label;
11 import org.simantics.browsing.ui.swt.widgets.TrackedText;
12 import org.simantics.browsing.ui.swt.widgets.VariableIntegerPropertyTextModifier;
13 import org.simantics.browsing.ui.swt.widgets.VariableStringPropertyFactory;
14 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
15 import org.simantics.db.layer0.variable.Variable;
16 import org.simantics.db.management.ISessionContext;
17 import org.simantics.selectionview.PropertyTabContributorImpl;
18
19 public class SheetTab extends PropertyTabContributorImpl {
20
21         static class NoCellInput {
22                 
23                 public Variable sheet;
24                 public String location;
25                 
26                 public NoCellInput(Variable sheet, String location) {
27                         this.sheet = sheet;
28                         this.location = location;
29                 }
30                 
31         }
32         
33     public void createControls(Composite body, IWorkbenchSite site, final ISessionContext context, WidgetSupport support) {
34
35         Display display = body.getDisplay();
36         Font font = new Font(display, "Arial", 12, SWT.NONE); 
37
38         Composite composite = new Composite(body, SWT.NONE);
39         composite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
40         GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
41         GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(2).applyTo(composite);
42         
43         Composite headerComposite = new Composite(composite, 0);
44         headerComposite.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
45         GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(headerComposite);
46         GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(1).extendedMargins(2,2,2,2).applyTo(headerComposite);
47
48         Composite headerComposite2 = new Composite(headerComposite, 0);
49         headerComposite2.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
50         GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(headerComposite2);
51         GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(1).extendedMargins(3,3,3,3).applyTo(headerComposite2);
52
53         Label header = new Label(headerComposite2, support, 0);
54         header.setText("Sheet");
55         header.setFont(font);
56         header.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
57         GridDataFactory.fillDefaults().grab(true, false).span(2, 1).align(SWT.CENTER, SWT.CENTER).applyTo(header.getWidget());
58         
59         Label rowsLabel = new Label(composite, support, SWT.NONE);
60         rowsLabel.setText("Rows: ");
61         rowsLabel.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
62         GridDataFactory.fillDefaults().grab(false, false).applyTo(rowsLabel.getWidget());
63         
64         TrackedText rows = new TrackedText(composite, support, SWT.BORDER);
65         rows.setTextFactory(new VariableStringPropertyFactory("/DimensionsCell#RowCount"));
66         rows.addModifyListener(new VariableIntegerPropertyTextModifier("/DimensionsCell#RowCount"));
67         GridDataFactory.fillDefaults().grab(true, false).applyTo(rows.getWidget());
68         
69         Label columnsLabel = new Label(composite, support, SWT.NONE);
70         columnsLabel.setText("Columns: ");
71         columnsLabel.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
72         GridDataFactory.fillDefaults().grab(false, false).applyTo(columnsLabel.getWidget());
73         
74         TrackedText columns = new TrackedText(composite, support, SWT.BORDER);
75         columns.setTextFactory(new VariableStringPropertyFactory("/DimensionsCell#ColumnCount"));
76         columns.addModifyListener(new VariableIntegerPropertyTextModifier("/DimensionsCell#ColumnCount"));
77         GridDataFactory.fillDefaults().grab(true, false).applyTo(columns.getWidget());
78         
79         
80     }
81    
82 }