List of usage examples for org.eclipse.swt.widgets Composite Composite
public Composite(Composite parent, int style)
From source file:com.tocea.scertify.eclipse.scertifycode.ui.stats.views.GraphStatsView.java
/** * {@inheritDoc}/* w w w . j ava 2 s . c o m*/ * * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ public void createPartControl(final Composite parent) { super.createPartControl(parent); // set up the main layout final GridLayout layout = new GridLayout(1, false); layout.marginWidth = 0; layout.marginHeight = 0; parent.setLayout(layout); // the label this.mLabelDesc = new Label(parent, SWT.NONE); final GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.mLabelDesc.setLayoutData(gridData); // the main section this.mMainSection = new Composite(parent, SWT.NONE); this.mStackLayout = new StackLayout(); this.mStackLayout.marginHeight = 0; this.mStackLayout.marginWidth = 0; this.mMainSection.setLayout(this.mStackLayout); this.mMainSection.setLayoutData(new GridData(GridData.FILL_BOTH)); // create the master viewer this.mMasterComposite = createMasterView(this.mMainSection); // create the detail viewer this.mDetailViewer = createDetailView(this.mMainSection); this.mStackLayout.topControl = this.mMasterComposite; updateActions(); // initialize the view data refresh(Job.DECORATE); }
From source file:LayoutExample.java
/** * Creates the tab folder page./*from www . j av a 2 s . c o m*/ * * @param tabFolder * org.eclipse.swt.widgets.TabFolder * @return the new page for the tab folder */ Composite createTabFolderPage(TabFolder tabFolder) { /* Create a two column page with a SashForm */ tabFolderPage = new Composite(tabFolder, SWT.NULL); tabFolderPage.setLayout(new FillLayout()); sash = new SashForm(tabFolderPage, SWT.HORIZONTAL); /* Create the "layout" and "control" columns */ createLayoutGroup(); createControlGroup(); return tabFolderPage; }
From source file:ConnectionInfo.java
protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new FillLayout()); // the vertical sashform. SashForm verticalForm = new SashForm(composite, SWT.VERTICAL); // the horizontal sashform. SashForm horizontalForm = new SashForm(verticalForm, SWT.HORIZONTAL); // Local dir browser. Composite compositeLocalDir = new Composite(horizontalForm, SWT.NULL); GridLayout gridLayout = new GridLayout(); gridLayout.horizontalSpacing = 1;//from w w w .j av a 2s. co m gridLayout.verticalSpacing = 1; compositeLocalDir.setLayout(gridLayout); Group compositeLocalDirTop = new Group(compositeLocalDir, SWT.NULL); compositeLocalDirTop.setText("Local"); GridLayout gridLayout2 = new GridLayout(3, false); gridLayout2.marginHeight = 0; compositeLocalDirTop.setLayout(gridLayout2); compositeLocalDirTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); labelPathLocal = new Label(compositeLocalDirTop, SWT.NULL); labelPathLocal.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); labelPathLocal.setText("Path: "); Button buttonUpLocalDir = new Button(compositeLocalDirTop, SWT.PUSH); buttonUpLocalDir.setText(actionUpLocalDir.getText()); buttonUpLocalDir.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { actionUpLocalDir.run(); } }); Button buttonBrowseLocalDir = new Button(compositeLocalDirTop, SWT.PUSH); buttonBrowseLocalDir.setText(actionBrowseLocalDir.getText()); buttonBrowseLocalDir.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { actionBrowseLocalDir.run(); } }); Table table = new Table(compositeLocalDir, SWT.BORDER); TableColumn tcFile = new TableColumn(table, SWT.LEFT); tcFile.setText("Name"); TableColumn tcSize = new TableColumn(table, SWT.NULL); tcSize.setText("Size"); TableColumn tcDate = new TableColumn(table, SWT.NULL); tcDate.setText("Date"); tcFile.setWidth(200); tcSize.setWidth(100); tcDate.setWidth(100); table.setHeaderVisible(true); table.setLayoutData(new GridData(GridData.FILL_BOTH)); localDirBrowser = new LocalDirectoryBrowser(table); table.addListener(SWT.MouseDoubleClick, new Listener() { public void handleEvent(Event event) { IStructuredSelection selection = (IStructuredSelection) localDirBrowser.getSelection(); File file = (File) selection.getFirstElement(); if (file != null && file.isDirectory()) { localDirBrowser.setInput(file); labelPathLocal.setText("Path: " + file); } } }); // Remote directory browser. Composite compositeRemoteDir = new Composite(horizontalForm, SWT.NULL); gridLayout = new GridLayout(); gridLayout.horizontalSpacing = 1; gridLayout.verticalSpacing = 1; compositeRemoteDir.setLayout(gridLayout); Group compositeRemoteDirTop = new Group(compositeRemoteDir, SWT.NULL); compositeRemoteDirTop.setText("Remote"); gridLayout2 = new GridLayout(2, false); gridLayout2.marginHeight = 0; compositeRemoteDirTop.setLayout(gridLayout2); compositeRemoteDirTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); labelPathRemote = new Label(compositeRemoteDirTop, SWT.NULL); labelPathRemote.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); labelPathRemote.setText("Path: "); Button buttonUpRemoteDir = new Button(compositeRemoteDirTop, SWT.PUSH); buttonUpRemoteDir.setText(actionUpLocalDir.getText()); buttonUpRemoteDir.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { actionUpRemoteDir.run(); } }); Table tableRemote = new Table(compositeRemoteDir, SWT.BORDER); TableColumn tcFileRemote = new TableColumn(tableRemote, SWT.LEFT); tcFileRemote.setText("Name"); TableColumn tcSizeRemote = new TableColumn(tableRemote, SWT.NULL); tcSizeRemote.setText("Size"); TableColumn tcDateRemote = new TableColumn(tableRemote, SWT.NULL); tcDateRemote.setText("Date"); tcFileRemote.setWidth(200); tcSizeRemote.setWidth(100); tcDateRemote.setWidth(100); tableRemote.setHeaderVisible(true); tableRemote.setLayoutData(new GridData(GridData.FILL_BOTH)); remoteDirBrowser = new RemoteDirectoryBrowser(tableRemote); tableRemote.addListener(SWT.MouseDoubleClick, new Listener() { public void handleEvent(Event event) { IStructuredSelection selection = (IStructuredSelection) remoteDirBrowser.getSelection(); FTPFile file = (FTPFile) selection.getFirstElement(); if (file != null && file.isDirectory()) { try { ftp.changeWorkingDirectory(file.getName()); labelPathRemote.setText("Path: " + ftp.printWorkingDirectory()); remoteDirBrowser.setInput(ftp.listFiles()); } catch (IOException e) { logError(e.toString()); } } } }); // the log box. textLog = new StyledText(verticalForm, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); localDirBrowser.setInput(File.listRoots()[0]); labelPathLocal.setText("Path: " + File.listRoots()[0]); // resize sashform children. verticalForm.setWeights(new int[] { 4, 1 }); // adding drag and drop support. dragNDropSupport(); getToolBarControl().setBackground(new Color(getShell().getDisplay(), 230, 230, 230)); getShell().setImage(new Image(getShell().getDisplay(), "icons/ftp/ftp.gif")); getShell().setText("FTP Client v1.0"); return composite; }
From source file:com.planetmayo.debrief.satc_rcp.views.MaintainContributionsView.java
private void initPreferencesGroup(Composite parent) { GridData gridData = new GridData(); gridData.horizontalAlignment = SWT.FILL; gridData.grabExcessHorizontalSpace = true; Group group = new Group(parent, SWT.SHADOW_ETCHED_IN); GridLayout layout = new GridLayout(1, false); group.setLayoutData(gridData);/*from w w w . j av a2 s.c om*/ group.setLayout(layout); group.setText("Preferences"); final ScrolledComposite scrolled = new ScrolledComposite(group, SWT.H_SCROLL); scrolled.setLayoutData(new GridData(GridData.FILL_BOTH)); final Composite preferencesComposite = UIUtils.createScrolledBody(scrolled, SWT.NONE); preferencesComposite.setLayout(new GridLayout(6, false)); scrolled.addListener(SWT.Resize, new Listener() { @Override public void handleEvent(Event e) { scrolled.setMinSize(preferencesComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); } }); scrolled.setAlwaysShowScrollBars(true); scrolled.setContent(preferencesComposite); scrolled.setMinSize(preferencesComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); scrolled.setExpandHorizontal(true); scrolled.setExpandVertical(true); liveConstraints = new Button(preferencesComposite, SWT.TOGGLE); liveConstraints.setText("Auto-Recalc of Constraints"); liveConstraints.setEnabled(false); liveConstraints .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER)); recalculate = new Button(preferencesComposite, SWT.DEFAULT); recalculate.setText("Calculate Solution"); recalculate.setEnabled(false); recalculate.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (activeSolver != null) { // ok - make sure the performance tab is open graphTabs.setSelection(performanceTab); activeSolver.run(true, true); main.setSize(0, 0); main.getParent().layout(true, true); } } }); recalculate.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_CENTER)); cancelGeneration = new Button(preferencesComposite, SWT.PUSH); cancelGeneration.setText("Cancel"); cancelGeneration.setVisible(false); cancelGeneration.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (activeSolver != null) { activeSolver.cancel(); } } }); suppressCuts = new Button(preferencesComposite, SWT.CHECK); suppressCuts.setText("Suppress Cuts"); suppressCuts.setVisible(true); suppressCuts.setEnabled(false); suppressCuts.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (activeSolver != null) { boolean doSuppress = suppressCuts.getSelection(); activeSolver.setAutoSuppress(doSuppress); } } }); showOSCourse = new Button(preferencesComposite, SWT.CHECK); showOSCourse.setText("Plot O/S Course"); showOSCourse.setVisible(true); showOSCourse.setEnabled(false); showOSCourse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (activeSolver != null) { redoOwnshipStates(); } } }); Composite precisionPanel = new Composite(preferencesComposite, SWT.NONE); precisionPanel.setLayoutData(new GridData( GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER)); GridLayout precisionLayout = new GridLayout(2, false); precisionLayout.horizontalSpacing = 5; precisionPanel.setLayout(precisionLayout); Label precisionLabel = new Label(precisionPanel, SWT.NONE); precisionLabel.setText("Precision:"); precisionLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER)); precisionsCombo = new ComboViewer(precisionPanel); precisionsCombo.getCombo().setEnabled(false); precisionsCombo.setContentProvider(new ArrayContentProvider()); precisionsCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((Precision) element).getLabel(); } }); precisionsCombo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection sel = precisionsCombo.getSelection(); IStructuredSelection cSel = (IStructuredSelection) sel; Precision precision = (Precision) cSel.getFirstElement(); if (activeSolver != null) { activeSolver.setPrecision(precision); } } }); }
From source file:edu.isistan.carcha.plugin.editors.TraceabilityEditor.java
/** * Creates the impact Pie Chart page. It allows users to select a Crosscutting Concern and see Design Decision type distribution *//*w w w .j ava2 s. com*/ void impactPieChartPage() { ddDataset = new DefaultPieDataset(); impactDataset = new DefaultPieDataset(); JFreeChart ddChart = ChartFactory.createPieChart("Crosscutting Concerns", ddDataset, true, true, false); JFreeChart impactChart = ChartFactory.createPieChart("Design Decisions", impactDataset, true, true, false); PiePlot ddPlot = (PiePlot) ddChart.getPlot(); ddPlot.setStartAngle(290); ddPlot.setDirection(Rotation.CLOCKWISE); ddPlot.setForegroundAlpha(0.5f); PiePlot impactPlot = (PiePlot) impactChart.getPlot(); impactPlot.setStartAngle(290); impactPlot.setDirection(Rotation.CLOCKWISE); impactPlot.setForegroundAlpha(0.5f); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0} ({2})"); ddPlot.setLabelGenerator(gen); impactPlot.setLabelGenerator(gen); Composite composite = new Composite(getContainer(), SWT.NONE); FillLayout layout = new FillLayout(); composite.setLayout(layout); final ChartComposite cComposite = new ChartComposite(composite, SWT.NONE, ddChart, true); cComposite.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent event) { String[] parts = event.getEntity().getToolTipText().split(":"); HashMap<String, Integer> values = PluginUtil.getDDDistributionForCrossCuttingConcern(cp, parts[0]); logger.info("Impact Pie Chart for: " + parts[0]); impactDataset.clear(); for (String key : values.keySet()) { impactDataset.setValue(key, values.get(key)); } } @Override public void chartMouseMoved(ChartMouseEvent event) { } }); new ChartComposite(composite, SWT.NONE, impactChart, true); int index = addPage(composite); setPageText(index, "Graph"); }
From source file:com.planetmayo.debrief.satc_rcp.views.MaintainContributionsView.java
private void initUI(final Composite parent) { parent.setLayout(new FillLayout()); final SashForm sashForm = new SashForm(parent, SWT.VERTICAL); sashForm.SASH_WIDTH = 15;/*from w w w . j av a2s. c o m*/ sashForm.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GRAY)); main = new Composite(sashForm, SWT.NONE); GridLayout gridLayout = new GridLayout(1, true); gridLayout.verticalSpacing = 2; gridLayout.marginLeft = 5; gridLayout.marginRight = 5; main.setLayout(gridLayout); initPreferencesGroup(main); initVehicleGroup(main); initAnalystContributionsGroup(main); initAddContributionGroup(main); Composite lowerSection = new Composite(sashForm, SWT.NONE); lowerSection.setLayout(new FillLayout()); // ok - the next section needs to be in a sash - so we can resize it initGraphTabs(lowerSection); // set the relative sizes in the sash sashForm.setWeights(new int[] { 3, 1 }); // also sort out the header controls final IActionBars bars = getViewSite().getActionBars(); IToolBarManager manager = bars.getToolBarManager(); manager.add(SATC_Activator.createOpenHelpAction("org.mwc.debrief.help.SATC", null, this)); _exportBtn = new Action("Export SATC dataset", Action.AS_PUSH_BUTTON) { public void runWithEvent(final Event event) { exportSATC(); } }; _exportBtn.setToolTipText("Export SATC scenario to clipboard"); _exportBtn.setImageDescriptor(SATC_Activator.getImageDescriptor("icons/export.png")); manager.add(_exportBtn); }
From source file:DNDExample.java
private void createDropOperations(Composite parent) { parent.setLayout(new RowLayout(SWT.VERTICAL)); final Button moveButton = new Button(parent, SWT.CHECK); moveButton.setText("DND.DROP_MOVE"); moveButton.setSelection(true);//from w ww . j a va2 s . c o m dropOperation = DND.DROP_MOVE; moveButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_MOVE; } else { dropOperation = dropOperation & ~DND.DROP_MOVE; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_MOVE) != 0) { dropOperation |= DND.DROP_MOVE; moveButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } } }); final Button copyButton = new Button(parent, SWT.CHECK); copyButton.setText("DND.DROP_COPY"); copyButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_COPY; } else { dropOperation = dropOperation & ~DND.DROP_COPY; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_COPY) != 0) { dropOperation = DND.DROP_COPY; copyButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } } }); final Button linkButton = new Button(parent, SWT.CHECK); linkButton.setText("DND.DROP_LINK"); linkButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_LINK; } else { dropOperation = dropOperation & ~DND.DROP_LINK; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_LINK) != 0) { dropOperation = DND.DROP_LINK; linkButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } } }); Button b = new Button(parent, SWT.CHECK); b.setText("DND.DROP_DEFAULT"); defaultParent = new Composite(parent, SWT.NONE); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_DEFAULT; defaultParent.setVisible(true); } else { dropOperation = dropOperation & ~DND.DROP_DEFAULT; defaultParent.setVisible(false); } if (dropEnabled) { createDropTarget(); } } }); defaultParent.setVisible(false); GridLayout layout = new GridLayout(); layout.marginWidth = 20; defaultParent.setLayout(layout); Label label = new Label(defaultParent, SWT.NONE); label.setText("Value for default operation is:"); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_MOVE"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropDefaultOperation = DND.DROP_MOVE; dropOperation |= DND.DROP_MOVE; moveButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } } }); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_COPY"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropDefaultOperation = DND.DROP_COPY; dropOperation |= DND.DROP_COPY; copyButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } } }); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_LINK"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropDefaultOperation = DND.DROP_LINK; dropOperation |= DND.DROP_LINK; linkButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } } }); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_NONE"); b.setSelection(true); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button) e.widget; if (b.getSelection()) { dropDefaultOperation = DND.DROP_NONE; dropOperation &= ~DND.DROP_DEFAULT; if (dropEnabled) { createDropTarget(); } } } }); }
From source file:org.eclipse.swt.examples.dnd.DNDExample.java
private void createDropOperations(Composite parent) { parent.setLayout(new RowLayout(SWT.VERTICAL)); final Button moveButton = new Button(parent, SWT.CHECK); moveButton.setText("DND.DROP_MOVE"); moveButton.addSelectionListener(widgetSelectedAdapter(e -> { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_MOVE; } else {/*from w w w . j a v a 2 s. co m*/ dropOperation = dropOperation & ~DND.DROP_MOVE; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_MOVE) != 0) { dropOperation |= DND.DROP_MOVE; moveButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } })); final Button copyButton = new Button(parent, SWT.CHECK); copyButton.setText("DND.DROP_COPY"); copyButton.addSelectionListener(widgetSelectedAdapter(e -> { Button b = (Button) e.widget; if (b.getSelection()) { dropOperation |= DND.DROP_COPY; } else { dropOperation = dropOperation & ~DND.DROP_COPY; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_COPY) != 0) { dropOperation = DND.DROP_COPY; copyButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } })); final Button linkButton = new Button(parent, SWT.CHECK); linkButton.setText("DND.DROP_LINK"); linkButton.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropOperation |= DND.DROP_LINK; } else { dropOperation = dropOperation & ~DND.DROP_LINK; if (dropOperation == 0 || (dropDefaultOperation & DND.DROP_LINK) != 0) { dropOperation = DND.DROP_LINK; linkButton.setSelection(true); } } if (dropEnabled) { createDropTarget(); } })); Button b = new Button(parent, SWT.CHECK); b.setText("DND.DROP_DEFAULT"); defaultParent = new Composite(parent, SWT.NONE); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropOperation |= DND.DROP_DEFAULT; defaultParent.setVisible(true); } else { dropOperation = dropOperation & ~DND.DROP_DEFAULT; defaultParent.setVisible(false); } if (dropEnabled) { createDropTarget(); } })); defaultParent.setVisible(false); GridLayout layout = new GridLayout(); layout.marginWidth = 20; defaultParent.setLayout(layout); Label label = new Label(defaultParent, SWT.NONE); label.setText("Value for default operation is:"); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_MOVE"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropDefaultOperation = DND.DROP_MOVE; dropOperation |= DND.DROP_MOVE; moveButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } })); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_COPY"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropDefaultOperation = DND.DROP_COPY; dropOperation |= DND.DROP_COPY; copyButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } })); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_LINK"); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropDefaultOperation = DND.DROP_LINK; dropOperation |= DND.DROP_LINK; linkButton.setSelection(true); if (dropEnabled) { createDropTarget(); } } })); b = new Button(defaultParent, SWT.RADIO); b.setText("DND.DROP_NONE"); b.setSelection(true); b.addSelectionListener(widgetSelectedAdapter(e -> { Button eb = (Button) e.widget; if (eb.getSelection()) { dropDefaultOperation = DND.DROP_NONE; dropOperation &= ~DND.DROP_DEFAULT; if (dropEnabled) { createDropTarget(); } } })); // initialize state moveButton.setSelection(true); copyButton.setSelection(true); linkButton.setSelection(true); dropOperation = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; }
From source file:org.eclipse.swt.examples.layoutexample.Tab.java
/** * Refreshes the composite and draws all controls * in the layout example.//from w w w.j a va 2s . com */ void refreshLayoutComposite() { /* Remove children that are already laid out */ children = layoutComposite.getChildren(); for (Control child : children) { child.dispose(); } /* Add all children listed in the table */ TableItem[] items = table.getItems(); children = new Control[items.length]; String[] itemValues = new String[] { LayoutExample.getResourceString("Item", new String[] { "1" }), LayoutExample.getResourceString("Item", new String[] { "2" }), LayoutExample.getResourceString("Item", new String[] { "3" }) }; for (int i = 0; i < items.length; i++) { String control = items[i].getText(1); String controlName = items[i].getText(0); if (control.equals("Button")) { Button button = new Button(layoutComposite, SWT.PUSH); button.setText(controlName); children[i] = button; } else if (control.equals("Canvas")) { Canvas canvas = new Canvas(layoutComposite, SWT.BORDER); children[i] = canvas; } else if (control.equals("Combo")) { Combo combo = new Combo(layoutComposite, SWT.NONE); combo.setItems(itemValues); combo.setText(controlName); children[i] = combo; } else if (control.equals("Composite")) { Composite composite = new Composite(layoutComposite, SWT.BORDER); children[i] = composite; } else if (control.equals("CoolBar")) { CoolBar coolBar = new CoolBar(layoutComposite, SWT.NONE); ToolBar toolBar = new ToolBar(coolBar, SWT.BORDER); ToolItem item = new ToolItem(toolBar, 0); item.setText(LayoutExample.getResourceString("Item", new String[] { "1" })); item = new ToolItem(toolBar, 0); item.setText(LayoutExample.getResourceString("Item", new String[] { "2" })); CoolItem coolItem1 = new CoolItem(coolBar, 0); coolItem1.setControl(toolBar); toolBar = new ToolBar(coolBar, SWT.BORDER); item = new ToolItem(toolBar, 0); item.setText(LayoutExample.getResourceString("Item", new String[] { "3" })); item = new ToolItem(toolBar, 0); item.setText(LayoutExample.getResourceString("Item", new String[] { "4" })); CoolItem coolItem2 = new CoolItem(coolBar, 0); coolItem2.setControl(toolBar); Point size = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT); coolItem1.setSize(coolItem1.computeSize(size.x, size.y)); coolItem2.setSize(coolItem2.computeSize(size.x, size.y)); coolBar.setSize(coolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT)); children[i] = coolBar; } else if (control.equals("Group")) { Group group = new Group(layoutComposite, SWT.NONE); group.setText(controlName); children[i] = group; } else if (control.equals("Label")) { Label label = new Label(layoutComposite, SWT.NONE); label.setText(controlName); children[i] = label; } else if (control.equals("Link")) { Link link = new Link(layoutComposite, SWT.NONE); link.setText(controlName); children[i] = link; } else if (control.equals("List")) { org.eclipse.swt.widgets.List list = new org.eclipse.swt.widgets.List(layoutComposite, SWT.BORDER); list.setItems(itemValues); children[i] = list; } else if (control.equals("ProgressBar")) { ProgressBar progress = new ProgressBar(layoutComposite, SWT.NONE); progress.setSelection(50); children[i] = progress; } else if (control.equals("Scale")) { Scale scale = new Scale(layoutComposite, SWT.NONE); children[i] = scale; } else if (control.equals("Slider")) { Slider slider = new Slider(layoutComposite, SWT.NONE); children[i] = slider; } else if (control.equals("StyledText")) { StyledText styledText = new StyledText(layoutComposite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); styledText.setText(controlName); children[i] = styledText; } else if (control.equals("Table")) { Table table = new Table(layoutComposite, SWT.BORDER); table.setLinesVisible(true); TableItem item1 = new TableItem(table, 0); item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" })); TableItem item2 = new TableItem(table, 0); item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" })); children[i] = table; } else if (control.equals("Text")) { Text text = new Text(layoutComposite, SWT.BORDER); text.setText(controlName); children[i] = text; } else if (control.equals("ToolBar")) { ToolBar toolBar = new ToolBar(layoutComposite, SWT.BORDER); ToolItem item1 = new ToolItem(toolBar, 0); item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" })); ToolItem item2 = new ToolItem(toolBar, 0); item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" })); children[i] = toolBar; } else { Tree tree = new Tree(layoutComposite, SWT.BORDER); TreeItem item1 = new TreeItem(tree, 0); item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" })); TreeItem item2 = new TreeItem(tree, 0); item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" })); children[i] = tree; } } }
From source file:LayoutExample.java
/** * Refreshes the composite and draws all controls in the layout example. *///from w w w . j ava2 s. c om void refreshLayoutComposite() { /* Remove children that are already laid out */ children = layoutComposite.getChildren(); for (int i = 0; i < children.length; i++) { children[i].dispose(); } /* Add all children listed in the table */ TableItem[] items = table.getItems(); children = new Control[items.length]; String[] itemValues = new String[] { LayoutExample.getResourceString("Item", new String[] { "1" }), LayoutExample.getResourceString("Item", new String[] { "2" }), LayoutExample.getResourceString("Item", new String[] { "3" }) }; for (int i = 0; i < items.length; i++) { String control = items[i].getText(1); if (control.equals("Button")) { Button button = new Button(layoutComposite, SWT.PUSH); button.setText(LayoutExample.getResourceString("Button_Index", new String[] { new Integer(i).toString() })); children[i] = button; } else if (control.equals("Canvas")) { Canvas canvas = new Canvas(layoutComposite, SWT.BORDER); children[i] = canvas; } else if (control.equals("Combo")) { Combo combo = new Combo(layoutComposite, SWT.NONE); combo.setItems(itemValues); combo.setText( LayoutExample.getResourceString("Combo_Index", new String[] { new Integer(i).toString() })); children[i] = combo; } else if (control.equals("Composite")) { Composite composite = new Composite(layoutComposite, SWT.BORDER); children[i] = composite; } else if (control.equals("CoolBar")) { CoolBar coolBar = new CoolBar(layoutComposite, SWT.NONE); ToolBar toolBar = new ToolBar(coolBar, SWT.BORDER); ToolItem item = new ToolItem(toolBar, 0); item.setText(LayoutExample.getResourceString("Item", new String[] { "1" })); item = new ToolItem(toolBar, 0); item.setText(LayoutExample.getResourceString("Item", new String[] { "2" })); CoolItem coolItem1 = new CoolItem(coolBar, 0); coolItem1.setControl(toolBar); toolBar = new ToolBar(coolBar, SWT.BORDER); item = new ToolItem(toolBar, 0); item.setText(LayoutExample.getResourceString("Item", new String[] { "3" })); item = new ToolItem(toolBar, 0); item.setText(LayoutExample.getResourceString("Item", new String[] { "4" })); CoolItem coolItem2 = new CoolItem(coolBar, 0); coolItem2.setControl(toolBar); Point size = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT); coolItem1.setSize(coolItem1.computeSize(size.x, size.y)); coolItem2.setSize(coolItem2.computeSize(size.x, size.y)); coolBar.setSize(coolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT)); children[i] = coolBar; } else if (control.equals("Group")) { Group group = new Group(layoutComposite, SWT.NONE); group.setText( LayoutExample.getResourceString("Group_Index", new String[] { new Integer(i).toString() })); children[i] = group; } else if (control.equals("Label")) { Label label = new Label(layoutComposite, SWT.NONE); label.setText( LayoutExample.getResourceString("Label_Index", new String[] { new Integer(i).toString() })); children[i] = label; } else if (control.equals("List")) { List list = new List(layoutComposite, SWT.BORDER); list.setItems(itemValues); children[i] = list; } else if (control.equals("ProgressBar")) { ProgressBar progress = new ProgressBar(layoutComposite, SWT.NONE); progress.setSelection(50); children[i] = progress; } else if (control.equals("Scale")) { Scale scale = new Scale(layoutComposite, SWT.NONE); children[i] = scale; } else if (control.equals("Slider")) { Slider slider = new Slider(layoutComposite, SWT.NONE); children[i] = slider; } else if (control.equals("StyledText")) { StyledText styledText = new StyledText(layoutComposite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); styledText.setText(LayoutExample.getResourceString("StyledText_Index", new String[] { new Integer(i).toString() })); children[i] = styledText; } else if (control.equals("Table")) { Table table = new Table(layoutComposite, SWT.BORDER); table.setLinesVisible(true); TableItem item1 = new TableItem(table, 0); item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" })); TableItem item2 = new TableItem(table, 0); item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" })); children[i] = table; } else if (control.equals("Text")) { Text text = new Text(layoutComposite, SWT.BORDER); text.setText( LayoutExample.getResourceString("Text_Index", new String[] { new Integer(i).toString() })); children[i] = text; } else if (control.equals("ToolBar")) { ToolBar toolBar = new ToolBar(layoutComposite, SWT.BORDER); ToolItem item1 = new ToolItem(toolBar, 0); item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" })); ToolItem item2 = new ToolItem(toolBar, 0); item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" })); children[i] = toolBar; } else { Tree tree = new Tree(layoutComposite, SWT.BORDER); TreeItem item1 = new TreeItem(tree, 0); item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" })); TreeItem item2 = new TreeItem(tree, 0); item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" })); children[i] = tree; } } }