List of usage examples for org.eclipse.swt.widgets Composite setLayout
public void setLayout(Layout layout)
From source file:eu.stratosphere.addons.visualization.swt.SWTJobTabItem.java
public SWTJobTabItem(SWTVisualizationGUI visualizationGUI, GraphVisualizationData visualizationData, Composite parent, int style, boolean detectBottlenecks) { super(parent, style); this.setLayout(new FillLayout()); this.visualizationGUI = visualizationGUI; this.visualizationData = visualizationData; // Layout of GUI depends on availability of profiling data if (visualizationData.isProfilingAvailableForJob()) { final SashForm verticalSash = new SashForm(this, SWT.VERTICAL); // Create the tabs this.tabFolder = new TabFolder(verticalSash, SWT.BOTTOM); this.tabFolder.addListener(SWT.Selection, this); final TabItem graphItem = new TabItem(this.tabFolder, SWT.NONE); this.graphCanvas = new SWTGraphCanvas(visualizationData, this, tabFolder, SWT.NONE, detectBottlenecks); graphItem.setControl(this.graphCanvas); graphItem.setText("Execution Graph"); final TabItem topologyItem = new TabItem(tabFolder, SWT.NONE); this.topologyCanvas = new SWTTopologyCanvas(visualizationData, this, tabFolder, SWT.NONE); topologyItem.setControl(this.topologyCanvas); topologyItem.setText("Allocated Instances"); final Composite statisticsComposite = new Composite(verticalSash, SWT.NONE); statisticsComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); final NetworkTopology networkTopology = visualizationData.getNetworkTopology(); final InstanceVisualizationData summaryDataset = (InstanceVisualizationData) networkTopology .getAttachment();// w w w.j a va2 s . c om this.cpuChart = initializeCPUChart(statisticsComposite, summaryDataset.getCpuDataSet()); this.memoryChart = initializeMemoryChart(statisticsComposite, summaryDataset.getMemoryDataSet()); this.networkChart = initializeNetworkChart(statisticsComposite, summaryDataset.getNetworkDataSet()); verticalSash.setWeights(new int[] { 7, 3 }); } else { // Create the tabs this.tabFolder = new TabFolder(this, SWT.BOTTOM); final TabItem graphItem = new TabItem(this.tabFolder, SWT.NONE); this.graphCanvas = new SWTGraphCanvas(visualizationData, this, tabFolder, SWT.NONE, detectBottlenecks); graphItem.setControl(graphCanvas); graphItem.setText("Execution Graph"); final TabItem topologyItem = new TabItem(tabFolder, SWT.NONE); this.topologyCanvas = new SWTTopologyCanvas(visualizationData, this, tabFolder, SWT.NONE); topologyItem.setControl(this.topologyCanvas); topologyItem.setText("Allocated Instances"); this.cpuChart = null; this.memoryChart = null; this.networkChart = null; } }
From source file:SampleListViewer.java
private void addButtons() { Composite composite = new Composite(shell, SWT.NULL); FillLayout fillLayout = new FillLayout(SWT.VERTICAL); fillLayout.spacing = 2;/*from w w w .java 2 s. c o m*/ composite.setLayout(fillLayout); buttonAdd = new Button(composite, SWT.PUSH); buttonAdd.setText("Add"); buttonModify = new Button(composite, SWT.PUSH); buttonModify.setText("Modify"); buttonRemove = new Button(composite, SWT.PUSH); buttonRemove.setText("Remove"); buttonAdd.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // String text = OptionPane.showInputDialog(shell, "New language genre: ", "Add new element", null); // if(text != null) { // languages.add(new Language(text, true)); // } listViewer.refresh(false); } }); buttonModify.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection(); Language language = (Language) selection.getFirstElement(); if (language == null) { System.out.println("Please select a language first."); return; } // String text = OptionPane.showInputDialog(shell, "Rename: ", "Modify genre", language.genre); // if(text != null) { // language.genre = text; // } listViewer.update(language, null); } }); buttonRemove.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection(); Language language = (Language) selection.getFirstElement(); if (language == null) { System.out.println("Please select a language first."); return; } languages.remove(language); System.out.println("Removed: " + language); listViewer.refresh(false); } }); }
From source file:org.eclipse.swt.examples.addressbook.DataEntryDialog.java
private void createTextWidgets() { if (labels == null) return;/*from w w w . j a va2 s . c o m*/ Composite composite = new Composite(shell, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = new GridLayout(); layout.numColumns = 2; composite.setLayout(layout); if (values == null) values = new String[labels.length]; for (int i = 0; i < labels.length; i++) { Label label = new Label(composite, SWT.RIGHT); label.setText(labels[i]); Text text = new Text(composite, SWT.BORDER); GridData gridData = new GridData(); gridData.widthHint = 400; text.setLayoutData(gridData); if (values[i] != null) { text.setText(values[i]); } text.setData("index", Integer.valueOf(i)); addTextListener(text); } }
From source file:org.eclipse.swt.examples.addressbook.DataEntryDialog.java
private void createControlButtons() { Composite composite = new Composite(shell, SWT.NONE); composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); GridLayout layout = new GridLayout(); layout.numColumns = 2;//from w w w . j av a2 s. c o m composite.setLayout(layout); Button okButton = new Button(composite, SWT.PUSH); okButton.setText(resAddressBook.getString("OK")); okButton.addSelectionListener(widgetSelectedAdapter(e -> shell.close())); Button cancelButton = new Button(composite, SWT.PUSH); cancelButton.setText(resAddressBook.getString("Cancel")); cancelButton.addSelectionListener(widgetSelectedAdapter(e -> { values = null; shell.close(); })); shell.setDefaultButton(okButton); }
From source file:org.eclipse.swt.examples.controlexample.TextTab.java
/** * Creates the "Style" group.//from w w w . ja v a2 s . co m */ @Override void createStyleGroup() { super.createStyleGroup(); /* Create the extra widgets */ wrapButton = new Button(styleGroup, SWT.CHECK); wrapButton.setText("SWT.WRAP"); readOnlyButton = new Button(styleGroup, SWT.CHECK); readOnlyButton.setText("SWT.READ_ONLY"); passwordButton = new Button(styleGroup, SWT.CHECK); passwordButton.setText("SWT.PASSWORD"); searchButton = new Button(styleGroup, SWT.CHECK); searchButton.setText("SWT.SEARCH"); iconCancelButton = new Button(styleGroup, SWT.CHECK); iconCancelButton.setText("SWT.ICON_CANCEL"); iconSearchButton = new Button(styleGroup, SWT.CHECK); iconSearchButton.setText("SWT.ICON_SEARCH"); Composite alignmentGroup = new Composite(styleGroup, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; alignmentGroup.setLayout(layout); alignmentGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); leftButton = new Button(alignmentGroup, SWT.RADIO); leftButton.setText("SWT.LEFT"); centerButton = new Button(alignmentGroup, SWT.RADIO); centerButton.setText("SWT.CENTER"); rightButton = new Button(alignmentGroup, SWT.RADIO); rightButton.setText("SWT.RIGHT"); }
From source file:CheckFileTree.java
/** * Creates the main window's contents/* w ww . j a v a2 s. com*/ * * @param parent * the main window * @return Control */ protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); // Add a checkbox to toggle whether the labels preserve case Button preserveCase = new Button(composite, SWT.CHECK); preserveCase.setText("&Preserve case"); // Create the tree viewer to display the file tree final TreeViewer tv = new TreeViewer(composite); tv.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); tv.setContentProvider(new FileTreeContentProvider()); tv.setLabelProvider(new FileTreeLabelProvider()); tv.setInput("root"); // pass a non-null that will be ignored // When user checks the checkbox, toggle the preserve case attribute // of the label provider preserveCase.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { boolean preserveCase = ((Button) event.widget).getSelection(); FileTreeLabelProvider ftlp = (FileTreeLabelProvider) tv.getLabelProvider(); ftlp.setPreserveCase(preserveCase); } }); return composite; }
From source file:org.amanzi.awe.charts.ui.ChartsView.java
@Override public void createPartControl(final Composite parent) { parent.setLayout(new GridLayout(1, false)); controlsComposite = new Composite(parent, SWT.NONE); controlsComposite.setLayout(new GridLayout(1, false)); controlsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite buttonsContainer = new Composite(controlsComposite, SWT.NONE); buttonsContainer.setLayout(new GridLayout(4, true)); buttonsContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); createRadioButton(buttonsContainer, "Line", true, ChartType.TIME_CHART); createRadioButton(buttonsContainer, "Bar", false, ChartType.BAR_CHART); createRadioButton(buttonsContainer, "Stacked", false, ChartType.STACKED_CHART); createRadioButton(buttonsContainer, "Pie", false, ChartType.PIE_CHART); Composite filteringContainer = new Composite(controlsComposite, SWT.BORDER); filteringContainer.setLayout(new GridLayout(2, true)); filteringContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); groupSelectorWidget = new ItemsSelectorWidget(filteringContainer, this, GROUPS_LABEL); columnsSelectorWidget = new ItemsSelectorWidget(filteringContainer, this, CELLS_LABEL); groupSelectorWidget.initializeWidget(); columnsSelectorWidget.initializeWidget(); int width = parent.getShell().getSize().x; chartComposite = new ChartComposite(parent, SWT.FILL, null, ChartComposite.DEFAULT_WIDTH, ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH, ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, width, ChartComposite.DEFAULT_MAXIMUM_DRAW_HEIGHT, true, true, true, true, true, true); chartComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); chartComposite.setVisible(false);/* w w w .j ava 2 s. c om*/ chartComposite.addChartMouseListener(this); }
From source file:BackupFiles.java
/** * Creates the main window's contents/*from w w w . j av a2 s.c o m*/ * * @param parent * the main window * @return Control */ protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); // Create the source directory panel and its controls final Text sourceDir = createFilePanelHelper(composite, "Source Dir:"); // Create the CheckboxTableViewer to display the files in the source dir final CheckboxTableViewer ctv = CheckboxTableViewer.newCheckList(composite, SWT.BORDER); ctv.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); ctv.setContentProvider(new BackupFilesContentProvider()); ctv.setLabelProvider(new BackupFilesLabelProvider()); // Create the destination directory panel and its controls final Text destDir = createFilePanelHelper(composite, "Dest Dir:"); // Create the Copy button Button copy = new Button(composite, SWT.PUSH); copy.setText("Copy"); // Create the status field status = new Label(composite, SWT.NONE); status.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // When the source directory changes, change the input for the viewer sourceDir.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { ctv.setInput(((Text) event.widget).getText()); } }); // When copy is pressed, copy the files copy.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Get the checked elements Object[] files = ctv.getCheckedElements(); if (files.length > 0) { // Some files are checked; make sure we have a valid // destination File dest = new File(destDir.getText()); if (dest.isDirectory()) { // Go through each file for (int i = 0, n = files.length; i < n; i++) { copyFile((File) files[i], dest); } } else showMessage("You must select a valid destination directory"); } else showMessage("You must select some files to copy"); } }); return composite; }
From source file:CheckFileTree.java
/** * Creates the main window's contents/*from w w w. j a v a2 s .c o m*/ * * @param parent * the main window * @return Control */ protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); // Add a checkbox to toggle whether the labels preserve case Button preserveCase = new Button(composite, SWT.CHECK); preserveCase.setText("&Preserve case"); // Create the tree viewer to display the file tree final CheckboxTreeViewer tv = new CheckboxTreeViewer(composite); tv.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); tv.setContentProvider(new FileTreeContentProvider()); tv.setLabelProvider(new FileTreeLabelProvider()); tv.setInput("root"); // pass a non-null that will be ignored // When user checks the checkbox, toggle the preserve case attribute // of the label provider preserveCase.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { boolean preserveCase = ((Button) event.widget).getSelection(); FileTreeLabelProvider ftlp = (FileTreeLabelProvider) tv.getLabelProvider(); ftlp.setPreserveCase(preserveCase); } }); // When user checks a checkbox in the tree, check all its children tv.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { // If the item is checked . . . if (event.getChecked()) { // . . . check all its children tv.setSubtreeChecked(event.getElement(), true); } } }); return composite; }
From source file:org.eclipse.swt.examples.launcher.LauncherView.java
/** * Creates the example.//w w w .j a va 2s . co m * * @see ViewPart#createPartControl */ @Override public void createPartControl(Composite parent) { workbenchShell = getSite().getShell(); parent.setLayout(new SplitLayout()); Group launchGroup = new Group(parent, SWT.NONE); launchGroup.setText(LauncherPlugin.getResourceString("view.launchGroup.text")); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; launchGroup.setLayout(gridLayout); launchTree = new Tree(launchGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); gridData.horizontalSpan = 2; launchTree.setLayoutData(gridData); launchTree.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent event) { final ItemDescriptor item = getSelectedItem(); setDescriptionByItem(item); } @Override public void widgetDefaultSelected(SelectionEvent event) { final ItemDescriptor item = getSelectedItem(); setDescriptionByItem(item); if (item.getMainType() == null && item.getView() == null) { // Category selected, so just expand/colapse the node TreeItem treeItem = (TreeItem) event.item; boolean expanded = treeItem.getExpanded(); if (treeItem != null) treeItem.setExpanded(!expanded); treeItem.setImage(LauncherPlugin.images[expanded ? LauncherPlugin.liClosedFolder : LauncherPlugin.liOpenFolder]); } else { launchItem(getSelectedItem()); } } }); launchTree.addTreeListener(new TreeListener() { @Override public void treeCollapsed(TreeEvent event) { final TreeItem item = (TreeItem) event.item; if (item == null) return; item.setImage(LauncherPlugin.images[LauncherPlugin.liClosedFolder]); } @Override public void treeExpanded(TreeEvent event) { final TreeItem item = (TreeItem) event.item; if (item == null) return; item.setImage(LauncherPlugin.images[LauncherPlugin.liOpenFolder]); } }); runButton = new Button(launchGroup, SWT.PUSH); runButton.setText(LauncherPlugin.getResourceString("view.launchButton.text")); runButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent event) { launchItem(getSelectedItem()); } @Override public void widgetDefaultSelected(SelectionEvent event) { } }); Group descriptionGroup = new Group(parent, SWT.NONE); descriptionGroup.setText(LauncherPlugin.getResourceString("view.descriptionGroup.text")); descriptionGroup.setLayout(new FillLayout()); descriptionText = new Text(descriptionGroup, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY); setDescriptionByItem(null); setItemDescriptors(LauncherPlugin.getLaunchItemTree()); }