List of usage examples for org.eclipse.swt.widgets Composite Composite
public Composite(Composite parent, int style)
From source file:at.ac.tuwien.inso.subcat.ui.widgets.TrendView.java
public void addConfiguration(TrendChartConfigData config) { assert (config != null); LinkedList<Combo> combos = new LinkedList<Combo>(); // Title Row: Label lblGrpTitle = new Label(optionComposite, SWT.NONE); lblGrpTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Helper.setLabelStyle(lblGrpTitle, SWT.BOLD); lblGrpTitle.setText(config.getName()); Composite topOptions = new Composite(optionComposite, SWT.NONE); topOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); topOptions.setLayout(new GridLayout(config.getDropDowns().size(), true)); for (DropDownData dropData : config.getDropDowns()) { Combo comboDropDown = new Combo(topOptions, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); comboDropDown.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); comboDropDown.setData(dropData); combos.add(comboDropDown);/*from w w w. j a v a 2 s . c o m*/ for (DropDownData.Pair data : dropData.getData()) { comboDropDown.add(data.name); } comboDropDown.select(0); comboDropDown.addSelectionListener(this.comboListener); } // Separator: Helper.separator(optionComposite, 3); // Left Option Labels: new Label(optionComposite, SWT.NONE); Composite leftOptions = new Composite(optionComposite, SWT.NONE); leftOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); leftOptions.setLayout(new GridLayout(1, true)); for (OptionListConfigData.Pair pair : config.getOptionList().getData()) { Label lblOpt = new Label(leftOptions, SWT.NONE); lblOpt.setText(pair.name); } // Check Boxes: Composite selectionComposite = new Composite(optionComposite, SWT.NONE); selectionComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); selectionComposite.setLayout(new GridLayout(combos.size(), true)); OptionListConfig leftConfig = config.getOptionList().getConfig(); int x = 0; for (Combo combo : combos) { TrendChartPlotConfig topConfig = (TrendChartPlotConfig) config.getDropDowns().get(x).getConfig(); for (OptionListConfigData.Pair pair : config.getOptionList().getData()) { Button button = new Button(selectionComposite, SWT.CHECK); button.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); button.setData(new ChartIdentifier(topConfig, combo, leftConfig, pair.id, boxWeight++)); button.addSelectionListener(boxListener); } x++; } // Scrolling area size update: scrolledComposite.setMinSize(optionComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); }
From source file:at.ac.tuwien.inso.subcat.ui.widgets.TrendChart.java
public void addConfiguration(TrendChartConfigData config, List<String> flags) { assert (config != null); ArrayList<Combo> combos = new ArrayList<Combo>(); // Title Row: Label lblGrpTitle = new Label(optionComposite, SWT.NONE); lblGrpTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Helper.setLabelStyle(lblGrpTitle, SWT.BOLD); lblGrpTitle.setText(config.getName()); Composite topOptions = new Composite(optionComposite, SWT.NONE); topOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); topOptions.setLayout(new GridLayout(config.getDropDowns().size(), true)); for (DropDownData dropData : config.getDropDowns()) { if (dropData.getConfig().show(flags)) { Combo comboDropDown = new Combo(topOptions, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); comboDropDown.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); comboDropDown.setData(dropData); combos.add(comboDropDown);//ww w .ja va2s . c om for (DropDownData.Pair data : dropData.getData()) { comboDropDown.add(data.name); } comboDropDown.select(0); comboDropDown.addSelectionListener(this.comboListener); } } // Separator: Helper.separator(optionComposite, 3); // Left Option Labels: new Label(optionComposite, SWT.NONE); Composite leftOptions = new Composite(optionComposite, SWT.NONE); leftOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); leftOptions.setLayout(new GridLayout(1, true)); for (OptionListConfigData.Pair pair : config.getOptionList().getData()) { Label lblOpt = new Label(leftOptions, SWT.NONE); lblOpt.setText(pair.name); } // Check Boxes: Composite selectionComposite = new Composite(optionComposite, SWT.NONE); selectionComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); selectionComposite.setLayout(new GridLayout(combos.size(), true)); OptionListConfig leftConfig = config.getOptionList().getConfig(); for (OptionListConfigData.Pair pair : config.getOptionList().getData()) { int x = 0; for (Combo combo : combos) { TrendChartPlotConfig topConfig = (TrendChartPlotConfig) config.getDropDowns().get(x).getConfig(); Button button = new Button(selectionComposite, SWT.CHECK); button.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); button.setData(new ChartIdentifier(topConfig, combo, leftConfig, pair.id, boxWeight++)); button.addSelectionListener(boxListener); x++; } } // Scrolling area size update: scrolledComposite.setMinSize(optionComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); }
From source file:widgetTest3.java
/** * StackLayout ** */ public static void createStackLayout(Composite composite) { // Neues Composite erzeugen final Composite stackComposite = new Composite(composite, SWT.NULL); final StackLayout stackLayout = new StackLayout(); // Text-Buttons erzeugen final Button buttonA = new Button(stackComposite, SWT.PUSH); buttonA.setText("Taste A"); final Button buttonB = new Button(stackComposite, SWT.PUSH); buttonB.setText("Taste B"); // Auf Klickereignisse reagieren buttonA.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { stackLayout.topControl = buttonB; // Neues Layout erzwingen stackComposite.layout();/*from w ww. j a v a 2 s . c o m*/ // Fokus auf sichtbare Taste setzen buttonB.setFocus(); } }); buttonB.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { stackLayout.topControl = buttonA; // Neues Layout erzwingen stackComposite.layout(); // Fokus auf sichtbare Taste setzen buttonA.setFocus(); } }); // Layout initialisieren stackLayout.topControl = buttonA; stackLayout.marginWidth = 10; stackLayout.marginHeight = 5; // Layout setzen stackComposite.setLayout(stackLayout); }
From source file:ClipboardExample.java
void createFileTransfer(Composite copyParent, Composite pasteParent) { // File Transfer Label l = new Label(copyParent, SWT.NONE); l.setText("FileTransfer:"); //$NON-NLS-1$ Composite c = new Composite(copyParent, SWT.NONE); c.setLayout(new GridLayout(2, false)); GridData data = new GridData(GridData.FILL_HORIZONTAL); c.setLayoutData(data);/*ww w. j av a2 s. c o m*/ copyFileTable = new Table(c, SWT.MULTI | SWT.BORDER); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = data.widthHint = SIZE; data.horizontalSpan = 2; copyFileTable.setLayoutData(data); Button b = new Button(c, SWT.PUSH); b.setText("Select file(s)"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI); String result = dialog.open(); if (result != null && result.length() > 0) { // copyFileTable.removeAll(); String separator = System.getProperty("file.separator"); String path = dialog.getFilterPath(); String[] names = dialog.getFileNames(); for (int i = 0; i < names.length; i++) { TableItem item = new TableItem(copyFileTable, SWT.NONE); item.setText(path + separator + names[i]); } } } }); b = new Button(c, SWT.PUSH); b.setText("Select directory"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN); String result = dialog.open(); if (result != null && result.length() > 0) { // copyFileTable.removeAll(); TableItem item = new TableItem(copyFileTable, SWT.NONE); item.setText(result); } } }); b = new Button(copyParent, SWT.PUSH); b.setText("Copy"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { TableItem[] items = copyFileTable.getItems(); if (items.length > 0) { status.setText(""); String[] data = new String[items.length]; for (int i = 0; i < data.length; i++) { data[i] = items[i].getText(); } clipboard.setContents(new Object[] { data }, new Transfer[] { FileTransfer.getInstance() }); } else { status.setText("nothing to copy"); } } }); l = new Label(pasteParent, SWT.NONE); l.setText("FileTransfer:"); //$NON-NLS-1$ pasteFileTable = new Table(pasteParent, SWT.MULTI | SWT.BORDER); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = data.widthHint = SIZE; pasteFileTable.setLayoutData(data); b = new Button(pasteParent, SWT.PUSH); b.setText("Paste"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String[] data = (String[]) clipboard.getContents(FileTransfer.getInstance()); if (data != null && data.length > 0) { status.setText(""); pasteFileTable.removeAll(); for (int i = 0; i < data.length; i++) { TableItem item = new TableItem(pasteFileTable, SWT.NONE); item.setText(data[i]); } } else { status.setText("nothing to paste"); } } }); }
From source file:org.emftrace.quarc.ui.views.RatioView.java
/** * Show a PieChart for the priorities of the goals * @param builder a SelectedGoalsGraphBuilder *//* w w w . j ava 2 s . c o m*/ protected void showChart(SelectedGoalsGraphBuilder builder) { if ((!parentComposite.isDisposed() && (composite == null || composite.isDisposed()))) { composite = new Composite(parentComposite, SWT.NONE); composite.setLayout(new FillLayout()); final PieDataset dataset = createDataset(builder); JFreeChart chart = createChart(dataset); ChartComposite chartComposite = new ChartComposite(composite, SWT.NONE, chart, true); chartComposite.setVisible(true); composite.layout(); parentComposite.layout(); } }
From source file:GraphicsExample.java
void createToolBar(final Composite parent) { final Display display = parent.getDisplay(); toolBar = new ToolBar(parent, SWT.FLAT); Listener toolBarListener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.Selection: { if (event.widget == playItem) { animate = true;//from w w w .j a v a 2s . co m playItem.setEnabled(!animate); pauseItem.setEnabled(animate); } else if (event.widget == pauseItem) { animate = false; playItem.setEnabled(!animate); pauseItem.setEnabled(animate); } else if (event.widget == backItem) { final ToolItem toolItem = (ToolItem) event.widget; final ToolBar toolBar = toolItem.getParent(); Rectangle toolItemBounds = toolItem.getBounds(); Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y)); backMenu.setLocation(point.x, point.y + toolItemBounds.height); backMenu.setVisible(true); } } break; } } }; playItem = new ToolItem(toolBar, SWT.PUSH); playItem.setText(getResourceString("Play")); //$NON-NLS-1$ playItem.setImage(loadImage(display, "play.gif")); //$NON-NLS-1$ playItem.addListener(SWT.Selection, toolBarListener); pauseItem = new ToolItem(toolBar, SWT.PUSH); pauseItem.setText(getResourceString("Pause")); //$NON-NLS-1$ pauseItem.setImage(loadImage(display, "pause.gif")); //$NON-NLS-1$ pauseItem.addListener(SWT.Selection, toolBarListener); backItem = new ToolItem(toolBar, SWT.PUSH); backItem.setText(getResourceString("Background")); //$NON-NLS-1$ backItem.addListener(SWT.Selection, toolBarListener); String[] names = new String[] { getResourceString("White"), //$NON-NLS-1$ getResourceString("Black"), //$NON-NLS-1$ getResourceString("Red"), //$NON-NLS-1$ getResourceString("Green"), //$NON-NLS-1$ getResourceString("Blue"), //$NON-NLS-1$ getResourceString("CustomColor"), //$NON-NLS-1$ }; Color[] colors = new Color[] { display.getSystemColor(SWT.COLOR_WHITE), display.getSystemColor(SWT.COLOR_BLACK), display.getSystemColor(SWT.COLOR_RED), display.getSystemColor(SWT.COLOR_GREEN), display.getSystemColor(SWT.COLOR_BLUE), null, }; backMenu = new Menu(parent); Listener listener = new Listener() { public void handleEvent(Event event) { MenuItem item = (MenuItem) event.widget; if (customMI == item) { ColorDialog dialog = new ColorDialog(parent.getShell()); RGB rgb = dialog.open(); if (rgb == null) return; if (customColor != null) customColor.dispose(); customColor = new Color(display, rgb); if (customImage != null) customImage.dispose(); customImage = createImage(display, customColor); item.setData(new Object[] { customColor, customImage }); item.setImage(customImage); } tabBackground = (Object[]) item.getData(); backItem.setImage((Image) tabBackground[1]); canvas.redraw(); } }; for (int i = 0; i < names.length; i++) { MenuItem item = new MenuItem(backMenu, SWT.NONE); item.setText(names[i]); item.addListener(SWT.Selection, listener); Image image = null; if (colors[i] != null) { image = createImage(display, colors[i]); images.addElement(image); item.setImage(image); } else { // custom menu item customMI = item; } item.setData(new Object[] { colors[i], image }); if (tabBackground == null) { tabBackground = (Object[]) item.getData(); backItem.setImage((Image) tabBackground[1]); } } dbItem = new ToolItem(toolBar, SWT.CHECK); dbItem.setText(getResourceString("DoubleBuffer")); //$NON-NLS-1$ dbItem.setImage(loadImage(display, "db.gif")); //$NON-NLS-1$ ToolItem separator = new ToolItem(toolBar, SWT.SEPARATOR); Composite comp = new Composite(toolBar, SWT.NONE); GridData data; GridLayout layout = new GridLayout(1, false); layout.verticalSpacing = 0; layout.marginWidth = layout.marginHeight = 3; comp.setLayout(layout); timerSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP); data = new GridData(SWT.CENTER, SWT.CENTER, false, false); timerSpinner.setLayoutData(data); Label label = new Label(comp, SWT.NONE); label.setText(getResourceString("Animation")); //$NON-NLS-1$ data = new GridData(SWT.CENTER, SWT.CENTER, false, false); label.setLayoutData(data); timerSpinner.setMaximum(1000); timerSpinner.setSelection(TIMER); timerSpinner.setSelection(TIMER); separator.setControl(comp); separator.setWidth(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT).x); }
From source file:fr.inria.soctrace.framesoc.ui.histogram.view.HistogramView.java
@Override public void createFramesocPartControl(Composite parent) { statusLineManager = getViewSite().getActionBars().getStatusLineManager(); // parent layout GridLayout gl_parent = new GridLayout(1, false); gl_parent.verticalSpacing = 2;/* w w w . j a va2 s.c o m*/ gl_parent.marginWidth = 0; gl_parent.horizontalSpacing = 0; gl_parent.marginHeight = 0; parent.setLayout(gl_parent); // Sash SashForm sashForm = new SashForm(parent, SWT.NONE); sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // Chart Composite compositeChart = new Composite(sashForm, SWT.BORDER); FillLayout fl_compositeChart = new FillLayout(SWT.HORIZONTAL); compositeChart.setLayout(fl_compositeChart); compositeChart.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { int width = Math.max(compositeChart.getSize().x - 40, 1); numberOfTicks = Math.max(width / TIMESTAMP_MAX_SIZE, 1); refresh(false, false, true); } }); // Configuration Composite compositeConf = new Composite(sashForm, SWT.NONE); GridLayout gl_compositeConf = new GridLayout(1, false); gl_compositeConf.marginHeight = 1; gl_compositeConf.verticalSpacing = 0; gl_compositeConf.marginWidth = 0; compositeConf.setLayout(gl_compositeConf); compositeConf.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); // Tab folder TabFolder tabFolder = new TabFolder(compositeConf, SWT.NONE); tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); PatternFilter filter = new TreePatternFilter(); TreeContentProvider contentProvider = new TreeContentProvider(); ViewerComparator treeComparator = new ViewerComparator(); SelectionChangedListener selectionChangeListener = new SelectionChangedListener(); CheckStateListener checkStateListener = new CheckStateListener(); SquareIconLabelProvider p = null; // Tab item types TabItem tbtmEventTypes = new TabItem(tabFolder, SWT.NONE); tbtmEventTypes.setData(ConfigurationDimension.TYPE); tbtmEventTypes.setText(ConfigurationDimension.TYPE.getName()); filter.setIncludeLeadingWildcard(true); FilteredCheckboxTree typeTree = new FilteredCheckboxTree(tabFolder, SWT.BORDER, filter, true); configurationMap.get(ConfigurationDimension.TYPE).tree = typeTree; typeTree.getViewer().setContentProvider(contentProvider); p = new EventTypeTreeLabelProvider(); labelProviders.add(p); typeTree.getViewer().setLabelProvider(p); typeTree.getViewer().setComparator(treeComparator); typeTree.addCheckStateListener(checkStateListener); typeTree.getViewer().addSelectionChangedListener(selectionChangeListener); tbtmEventTypes.setControl(typeTree); // Tab item producers TabItem tbtmEventProducers = new TabItem(tabFolder, SWT.NONE); tbtmEventProducers.setData(ConfigurationDimension.PRODUCERS); tbtmEventProducers.setText(ConfigurationDimension.PRODUCERS.getName()); FilteredCheckboxTree prodTree = new FilteredCheckboxTree(tabFolder, SWT.BORDER, filter, true); configurationMap.get(ConfigurationDimension.PRODUCERS).tree = prodTree; prodTree.getViewer().setContentProvider(contentProvider); p = new EventProducerTreeLabelProvider(); labelProviders.add(p); prodTree.getViewer().setLabelProvider(p); prodTree.getViewer().setComparator(treeComparator); prodTree.addCheckStateListener(checkStateListener); prodTree.getViewer().addSelectionChangedListener(selectionChangeListener); tbtmEventProducers.setControl(prodTree); // sash weights sashForm.setWeights(new int[] { 80, 20 }); // tab switch tabFolder.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { currentDimension = (ConfigurationDimension) event.item.getData(); enableTreeButtons(); enableSubTreeButtons(); } }); // Buttons Composite compositeBtn = new Composite(compositeConf, SWT.BORDER); GridLayout gl_compositeBtn = new GridLayout(10, false); gl_compositeBtn.marginWidth = 1; gl_compositeBtn.horizontalSpacing = 1; compositeBtn.setLayout(gl_compositeBtn); compositeBtn.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1)); btnCheckall = new Button(compositeBtn, SWT.NONE); btnCheckall.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); btnCheckall.setToolTipText("Check all"); btnCheckall.setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, "icons/check_all.png")); btnCheckall.setEnabled(false); btnCheckall.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (configurationMap.get(currentDimension).roots != null) { FilteredCheckboxTree tree = configurationMap.get(currentDimension).tree; TreeContentProvider provider = (TreeContentProvider) tree.getViewer().getContentProvider(); Object[] roots = provider.getElements(tree.getViewer().getInput()); for (Object root : roots) { checkElementAndSubtree(root); } selectionChanged(); } } }); btnUncheckall = new Button(compositeBtn, SWT.NONE); btnUncheckall.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); btnUncheckall.setToolTipText("Uncheck all"); btnUncheckall.setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, "icons/uncheck_all.png")); btnUncheckall.setEnabled(false); btnUncheckall.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { configurationMap.get(currentDimension).tree.setCheckedElements(EMPTY_ARRAY); selectionChanged(); } }); Label separator = new Label(compositeBtn, SWT.SEPARATOR | SWT.VERTICAL); GridData gd_separator = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_separator.horizontalIndent = 2; gd_separator.widthHint = 5; gd_separator.heightHint = 20; separator.setLayoutData(gd_separator); btnCheckSubtree = new Button(compositeBtn, SWT.NONE); btnCheckSubtree.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); btnCheckSubtree.setToolTipText("Check subtree"); btnCheckSubtree.setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, "icons/check_subtree.png")); btnCheckSubtree.setEnabled(false); btnCheckSubtree.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (configurationMap.get(currentDimension).roots != null) { ITreeNode node = getCurrentSelection(configurationMap.get(currentDimension).tree); if (node == null) return; checkElementAndSubtree(node); selectionChanged(); } } }); btnUncheckSubtree = new Button(compositeBtn, SWT.NONE); btnUncheckSubtree.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); btnUncheckSubtree.setToolTipText("Uncheck subtree"); btnUncheckSubtree .setImage(ResourceManager.getPluginImage(Activator.PLUGIN_ID, "icons/uncheck_subtree.png")); btnUncheckSubtree.setEnabled(false); btnUncheckSubtree.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (configurationMap.get(currentDimension).roots != null) { ITreeNode node = getCurrentSelection(configurationMap.get(currentDimension).tree); if (node == null) return; uncheckElement(node); uncheckAncestors(node); selectionChanged(); } } }); // Time management bar Composite timeComposite = new Composite(parent, SWT.BORDER); timeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); GridLayout gl_timeComposite = new GridLayout(1, false); gl_timeComposite.horizontalSpacing = 0; timeComposite.setLayout(gl_timeComposite); // time manager timeBar = new TimeBar(timeComposite, SWT.NONE, true, true); timeBar.setEnabled(false); IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager(); timeBar.setStatusLineManager(statusLineManager); timeBar.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TimeInterval barInterval = timeBar.getSelection(); if (marker == null) { addNewMarker(barInterval.startTimestamp, barInterval.endTimestamp); } else { marker.setStartValue(barInterval.startTimestamp); marker.setEndValue(barInterval.endTimestamp); } selectedTs0 = barInterval.startTimestamp; selectedTs1 = barInterval.endTimestamp; timeChanged = !barInterval.equals(loadedInterval); } }); // button to synch the timebar, producers and type with the current loaded data timeBar.getSynchButton().setToolTipText("Reset Timebar, Types and Producers"); timeBar.getSynchButton().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (loadedInterval != null) { timeBar.setSelection(loadedInterval); if (marker != null && plot != null) { plot.removeDomainMarker(marker); marker = null; } } for (ConfigurationData data : configurationMap.values()) { data.tree.setCheckedElements(data.checked); } timeChanged = false; enableTreeButtons(); enableSubTreeButtons(); } }); // load button timeBar.getLoadButton().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (timeChanged || configurationChanged) { loadHistogram(currentShownTrace, timeBar.getSelection()); } } }); // build toolbar IActionBars actionBars = getViewSite().getActionBars(); IToolBarManager toolBar = actionBars.getToolBarManager(); TableTraceIntervalAction.add(toolBar, createTableAction()); GanttTraceIntervalAction.add(toolBar, createGanttAction()); PieTraceIntervalAction.add(toolBar, createPieAction()); enableActions(false); }
From source file:org.eclipse.swt.snippets.SnippetExplorer.java
/** Initialize the SnippetExplorer controls. * * @param shell parent shell/*from www . ja v a2 s . c o m*/ */ private void createControls(Shell shell) { shell.setLayout(new FormLayout()); if (listUpdater == null) { listUpdater = new ListUpdater(); listUpdater.start(); } final Composite leftContainer = new Composite(shell, SWT.NONE); leftContainer.setLayout(new GridLayout()); final Sash splitter = new Sash(shell, SWT.BORDER | SWT.VERTICAL); final int splitterWidth = 3; splitter.addListener(SWT.Selection, e -> splitter.setBounds(e.x, e.y, e.width, e.height)); final Composite rightContainer = new Composite(shell, SWT.NONE); rightContainer.setLayout(new GridLayout()); FormData formData = new FormData(); formData.left = new FormAttachment(0, 0); formData.right = new FormAttachment(splitter, 0); formData.top = new FormAttachment(0, 0); formData.bottom = new FormAttachment(100, 0); leftContainer.setLayoutData(formData); formData = new FormData(); formData.left = new FormAttachment(50, 0); formData.right = new FormAttachment(50, splitterWidth); formData.top = new FormAttachment(0, 0); formData.bottom = new FormAttachment(100, 0); splitter.setLayoutData(formData); splitter.addListener(SWT.Selection, event -> { final FormData splitterFormData = (FormData) splitter.getLayoutData(); splitterFormData.left = new FormAttachment(0, event.x); splitterFormData.right = new FormAttachment(0, event.x + splitterWidth); shell.layout(); }); formData = new FormData(); formData.left = new FormAttachment(splitter, 0); formData.right = new FormAttachment(100, 0); formData.top = new FormAttachment(0, 0); formData.bottom = new FormAttachment(100, 0); rightContainer.setLayoutData(formData); filterField = new Text(leftContainer, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); filterField.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); filterField.setMessage(FILTER_HINT); filterField.addListener(SWT.Modify, event -> { listUpdater.updateInMs(FILTER_DELAY_MS); }); snippetTable = new Table(leftContainer, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); snippetTable.setLinesVisible(true); snippetTable.setHeaderVisible(true); final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); data.heightHint = 500; snippetTable.setLayoutData(data); snippetTable.addListener(SWT.MouseDoubleClick, event -> { final Point clickPoint = new Point(event.x, event.y); launchSnippet(snippetTable.getItem(clickPoint)); }); snippetTable.addListener(SWT.KeyUp, event -> { if (event.keyCode == '\r' || event.keyCode == '\n') { launchSnippet(snippetTable.getSelection()); } }); final Composite buttonRow = new Composite(leftContainer, SWT.NONE); buttonRow.setLayout(new GridLayout(3, false)); buttonRow.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); startSelectedButton = new Button(buttonRow, SWT.LEAD); startSelectedButton.setText(" Start &selected Snippets"); snippetTable.addListener(SWT.Selection, event -> { startSelectedButton.setEnabled(snippetTable.getSelectionCount() > 0); updateInfoTab(snippetTable.getSelection()); }); startSelectedButton.setEnabled(snippetTable.getSelectionCount() > 0); startSelectedButton.addListener(SWT.Selection, event -> { launchSnippet(snippetTable.getSelection()); }); final Label runnerLabel = new Label(buttonRow, SWT.NONE); runnerLabel.setText("Snippet Runner:"); runnerLabel.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false)); runnerCombo = new Combo(buttonRow, SWT.TRAIL | SWT.DROP_DOWN | SWT.READ_ONLY); runnerMapping.clear(); if (multiDisplaySupport) { runnerCombo.add("Thread"); runnerMapping.add(THREAD_RUNNER); } if (javaCommand != null) { runnerCombo.add("Process"); runnerMapping.add(PROCESS_RUNNER); } runnerCombo.add("Serial"); runnerMapping.add(null); runnerCombo.setData(runnerMapping); runnerCombo.addListener(SWT.Modify, event -> { if (runnerMapping.size() > runnerCombo.getSelectionIndex()) { snippetRunner = runnerMapping.get(runnerCombo.getSelectionIndex()); } else { System.err.println("Unknown runner index " + runnerCombo.getSelectionIndex()); } }); runnerCombo.select(0); infoTabs = new TabFolder(rightContainer, SWT.TOP); infoTabs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); descriptionView = new StyledText(infoTabs, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL); sourceView = new StyledText(infoTabs, SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL); setMonospaceFont(sourceView); final ScrolledComposite previewContainer = new ScrolledComposite(infoTabs, SWT.V_SCROLL | SWT.H_SCROLL); previewImageLabel = new Label(previewContainer, SWT.NONE); previewContainer.setContent(previewImageLabel); final TabItem descriptionTab = new TabItem(infoTabs, SWT.NONE); descriptionTab.setText("Description"); descriptionTab.setControl(descriptionView); final TabItem sourceTab = new TabItem(infoTabs, SWT.NONE); sourceTab.setText("Source"); sourceTab.setControl(sourceView); final TabItem previewTab = new TabItem(infoTabs, SWT.NONE); previewTab.setText("Preview"); previewTab.setControl(previewContainer); updateInfoTab(null, true); updateInfoTab(snippetTable.getSelection()); }
From source file:com.android.ddmuilib.HeapPanel.java
/** * Create our control(s).//from w w w.ja va 2 s . c o m */ @Override protected Control createControl(Composite parent) { mDisplay = parent.getDisplay(); GridLayout gl; mTop = new Composite(parent, SWT.NONE); mTop.setLayout(new GridLayout(1, false)); mTop.setLayoutData(new GridData(GridData.FILL_BOTH)); mUpdateStatus = new Label(mTop, SWT.NONE); setUpdateStatus(NOT_SELECTED); Composite summarySection = new Composite(mTop, SWT.NONE); summarySection.setLayout(gl = new GridLayout(2, false)); gl.marginHeight = gl.marginWidth = 0; mHeapSummary = createSummaryTable(summarySection); mGcButton = new Button(summarySection, SWT.PUSH); mGcButton.setText("Cause GC"); mGcButton.setEnabled(false); mGcButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Client client = getCurrentClient(); if (client != null) { client.executeGarbageCollector(); } } }); Composite comboSection = new Composite(mTop, SWT.NONE); gl = new GridLayout(2, false); gl.marginHeight = gl.marginWidth = 0; comboSection.setLayout(gl); Label displayLabel = new Label(comboSection, SWT.NONE); displayLabel.setText("Display: "); mDisplayMode = new Combo(comboSection, SWT.READ_ONLY); mDisplayMode.setEnabled(false); mDisplayMode.add("Stats"); if (DISPLAY_HEAP_BITMAP) { mDisplayMode.add("Linear"); if (DISPLAY_HILBERT_BITMAP) { mDisplayMode.add("Hilbert"); } } // the base of the displays. mDisplayBase = new Composite(mTop, SWT.NONE); mDisplayBase.setLayoutData(new GridData(GridData.FILL_BOTH)); mDisplayStack = new StackLayout(); mDisplayBase.setLayout(mDisplayStack); // create the statistics display mStatisticsBase = new Composite(mDisplayBase, SWT.NONE); //mStatisticsBase.setLayoutData(new GridData(GridData.FILL_BOTH)); mStatisticsBase.setLayout(gl = new GridLayout(1, false)); gl.marginHeight = gl.marginWidth = 0; mDisplayStack.topControl = mStatisticsBase; mStatisticsTable = createDetailedTable(mStatisticsBase); mStatisticsTable.setLayoutData(new GridData(GridData.FILL_BOTH)); createChart(); //create the linear composite mLinearBase = new Composite(mDisplayBase, SWT.NONE); //mLinearBase.setLayoutData(new GridData()); gl = new GridLayout(1, false); gl.marginHeight = gl.marginWidth = 0; mLinearBase.setLayout(gl); { mLinearHeapImage = new Label(mLinearBase, SWT.NONE); mLinearHeapImage.setLayoutData(new GridData()); mLinearHeapImage.setImage(ImageLoader.createPlaceHolderArt(mDisplay, PLACEHOLDER_LINEAR_H_SIZE, PLACEHOLDER_LINEAR_V_SIZE, mDisplay.getSystemColor(SWT.COLOR_BLUE))); // create a composite to contain the bottom part (legend) Composite bottomSection = new Composite(mLinearBase, SWT.NONE); gl = new GridLayout(1, false); gl.marginHeight = gl.marginWidth = 0; bottomSection.setLayout(gl); createLegend(bottomSection); } /* mScrolledComposite = new ScrolledComposite(mTop, SWT.H_SCROLL | SWT.V_SCROLL); mScrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); mScrolledComposite.setExpandHorizontal(true); mScrolledComposite.setExpandVertical(true); mScrolledComposite.setContent(mDisplayBase); */ // create the hilbert display. mHilbertBase = new Composite(mDisplayBase, SWT.NONE); //mHilbertBase.setLayoutData(new GridData()); gl = new GridLayout(2, false); gl.marginHeight = gl.marginWidth = 0; mHilbertBase.setLayout(gl); if (DISPLAY_HILBERT_BITMAP) { mHilbertHeapImage = new Label(mHilbertBase, SWT.NONE); mHilbertHeapImage.setLayoutData(new GridData()); mHilbertHeapImage.setImage(ImageLoader.createPlaceHolderArt(mDisplay, PLACEHOLDER_HILBERT_SIZE, PLACEHOLDER_HILBERT_SIZE, mDisplay.getSystemColor(SWT.COLOR_BLUE))); // create a composite to contain the right part (legend + zoom) Composite rightSection = new Composite(mHilbertBase, SWT.NONE); gl = new GridLayout(1, false); gl.marginHeight = gl.marginWidth = 0; rightSection.setLayout(gl); Composite zoomComposite = new Composite(rightSection, SWT.NONE); gl = new GridLayout(2, false); zoomComposite.setLayout(gl); Label l = new Label(zoomComposite, SWT.NONE); l.setText("Zoom:"); mZoom = new Combo(zoomComposite, SWT.READ_ONLY); for (int z : ZOOMS) { mZoom.add(String.format("%1$d%%", z)); //$NON-NLS-1$ } mZoom.select(0); mZoom.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setLegendText(mZoom.getSelectionIndex()); Client client = getCurrentClient(); if (client != null) { renderHeapData(client.getClientData(), 1, true); mTop.pack(); } } }); createLegend(rightSection); } mHilbertBase.pack(); mLayout = new Composite[] { mStatisticsBase, mLinearBase, mHilbertBase }; mDisplayMode.select(0); mDisplayMode.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { int index = mDisplayMode.getSelectionIndex(); Client client = getCurrentClient(); if (client != null) { if (index == 0) { fillDetailedTable(client, true /* forceRedraw */); } else { renderHeapData(client.getClientData(), index - 1, true /* forceRedraw */); } } mDisplayStack.topControl = mLayout[index]; //mScrolledComposite.setMinSize(mDisplayStack.topControl.computeSize(SWT.DEFAULT, // SWT.DEFAULT)); mDisplayBase.layout(); //mScrolledComposite.redraw(); } }); //mScrolledComposite.setMinSize(mDisplayStack.topControl.computeSize(SWT.DEFAULT, // SWT.DEFAULT)); mDisplayBase.layout(); //mScrolledComposite.redraw(); return mTop; }
From source file:ImageAnalyzer.java
void createWidgets() { // Add the widgets to the shell in a grid layout. GridLayout layout = new GridLayout(); layout.marginHeight = 0;/* www. j a v a2s .c o m*/ layout.numColumns = 2; shell.setLayout(layout); // Separate the menu bar from the rest of the widgets. Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); GridData gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; separator.setLayoutData(gridData); // Add a composite to contain some control widgets across the top. Composite controls = new Composite(shell, SWT.NULL); RowLayout rowLayout = new RowLayout(); rowLayout.marginTop = 0; rowLayout.marginBottom = 5; rowLayout.spacing = 8; controls.setLayout(rowLayout); gridData = new GridData(); gridData.horizontalSpan = 2; controls.setLayoutData(gridData); // Combo to change the background. Group group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("Background"); backgroundCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); backgroundCombo.setItems(new String[] { "None", "White", "Black", "Red", "Green", "Blue" }); backgroundCombo.select(backgroundCombo.indexOf("White")); backgroundCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { changeBackground(); } }); // Combo to change the x scale. String[] values = { "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2", "3", "4", "5", "6", "7", "8", "9", "10", }; group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("X_scale"); scaleXCombo = new Combo(group, SWT.DROP_DOWN); for (int i = 0; i < values.length; i++) { scaleXCombo.add(values[i]); } scaleXCombo.select(scaleXCombo.indexOf("1")); scaleXCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scaleX(); } }); // Combo to change the y scale. group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("Y_scale"); scaleYCombo = new Combo(group, SWT.DROP_DOWN); for (int i = 0; i < values.length; i++) { scaleYCombo.add(values[i]); } scaleYCombo.select(scaleYCombo.indexOf("1")); scaleYCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scaleY(); } }); // Combo to change the alpha value. group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("Alpha_K"); alphaCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY); for (int i = 0; i <= 255; i += 5) { alphaCombo.add(String.valueOf(i)); } alphaCombo.select(alphaCombo.indexOf("255")); alphaCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { alpha(); } }); // Check box to request incremental display. group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("Display"); incrementalCheck = new Button(group, SWT.CHECK); incrementalCheck.setText("Incremental"); incrementalCheck.setSelection(incremental); incrementalCheck.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { incremental = ((Button) event.widget).getSelection(); } }); // Check box to request transparent display. transparentCheck = new Button(group, SWT.CHECK); transparentCheck.setText("Transparent"); transparentCheck.setSelection(transparent); transparentCheck.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { transparent = ((Button) event.widget).getSelection(); if (image != null) { imageCanvas.redraw(); } } }); // Check box to request mask display. maskCheck = new Button(group, SWT.CHECK); maskCheck.setText("Mask"); maskCheck.setSelection(showMask); maskCheck.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { showMask = ((Button) event.widget).getSelection(); if (image != null) { imageCanvas.redraw(); } } }); // Check box to request background display. backgroundCheck = new Button(group, SWT.CHECK); backgroundCheck.setText("Background"); backgroundCheck.setSelection(showBackground); backgroundCheck.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { showBackground = ((Button) event.widget).getSelection(); } }); // Group the animation buttons. group = new Group(controls, SWT.NULL); group.setLayout(new RowLayout()); group.setText("Animation"); // Push button to display the previous image in a multi-image file. previousButton = new Button(group, SWT.PUSH); previousButton.setText("Previous"); previousButton.setEnabled(false); previousButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { previous(); } }); // Push button to display the next image in a multi-image file. nextButton = new Button(group, SWT.PUSH); nextButton.setText("Next"); nextButton.setEnabled(false); nextButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { next(); } }); // Push button to toggle animation of a multi-image file. animateButton = new Button(group, SWT.PUSH); animateButton.setText("Animate"); animateButton.setEnabled(false); animateButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { animate(); } }); // Label to show the image file type. typeLabel = new Label(shell, SWT.NULL); typeLabel.setText("Type_initial"); typeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Canvas to show the image. imageCanvas = new Canvas(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.NO_REDRAW_RESIZE); imageCanvas.setBackground(whiteColor); imageCanvas.setCursor(crossCursor); gridData = new GridData(); gridData.verticalSpan = 15; gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; imageCanvas.setLayoutData(gridData); imageCanvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent event) { if (image != null) paintImage(event); } }); imageCanvas.addMouseMoveListener(new MouseMoveListener() { public void mouseMove(MouseEvent event) { if (image != null) { showColorAt(event.x, event.y); } } }); // Set up the image canvas scroll bars. ScrollBar horizontal = imageCanvas.getHorizontalBar(); horizontal.setVisible(true); horizontal.setMinimum(0); horizontal.setEnabled(false); horizontal.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scrollHorizontally((ScrollBar) event.widget); } }); ScrollBar vertical = imageCanvas.getVerticalBar(); vertical.setVisible(true); vertical.setMinimum(0); vertical.setEnabled(false); vertical.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scrollVertically((ScrollBar) event.widget); } }); // Label to show the image size. sizeLabel = new Label(shell, SWT.NULL); sizeLabel.setText("Size_initial"); sizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image depth. depthLabel = new Label(shell, SWT.NULL); depthLabel.setText("Depth_initial"); depthLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the transparent pixel. transparentPixelLabel = new Label(shell, SWT.NULL); transparentPixelLabel.setText("Transparent_pixel_initial"); transparentPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the time to load. timeToLoadLabel = new Label(shell, SWT.NULL); timeToLoadLabel.setText("Time_to_load_initial"); timeToLoadLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Separate the animation fields from the rest of the fields. separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the logical screen size for animation. screenSizeLabel = new Label(shell, SWT.NULL); screenSizeLabel.setText("Animation_size_initial"); screenSizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the background pixel. backgroundPixelLabel = new Label(shell, SWT.NULL); backgroundPixelLabel.setText("Background_pixel_initial"); backgroundPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image location (x, y). locationLabel = new Label(shell, SWT.NULL); locationLabel.setText("Image_location_initial"); locationLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image disposal method. disposalMethodLabel = new Label(shell, SWT.NULL); disposalMethodLabel.setText("Disposal_initial"); disposalMethodLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the image delay time. delayTimeLabel = new Label(shell, SWT.NULL); delayTimeLabel.setText("Delay_initial"); delayTimeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show the background pixel. repeatCountLabel = new Label(shell, SWT.NULL); repeatCountLabel.setText("Repeats_initial"); repeatCountLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Separate the animation fields from the palette. separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Label to show if the image has a direct or indexed palette. paletteLabel = new Label(shell, SWT.NULL); paletteLabel.setText("Palette_initial"); paletteLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); // Canvas to show the image's palette. paletteCanvas = new Canvas(shell, SWT.BORDER | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE); paletteCanvas.setFont(fixedWidthFont); paletteCanvas.getVerticalBar().setVisible(true); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; GC gc = new GC(paletteLabel); paletteWidth = gc.stringExtent("Max_length_string").x; gc.dispose(); gridData.widthHint = paletteWidth; gridData.heightHint = 16 * 11; // show at least 16 colors paletteCanvas.setLayoutData(gridData); paletteCanvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent event) { if (image != null) paintPalette(event); } }); // Set up the palette canvas scroll bar. vertical = paletteCanvas.getVerticalBar(); vertical.setVisible(true); vertical.setMinimum(0); vertical.setIncrement(10); vertical.setEnabled(false); vertical.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { scrollPalette((ScrollBar) event.widget); } }); // Sash to see more of image or image data. sash = new Sash(shell, SWT.HORIZONTAL); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; sash.setLayoutData(gridData); sash.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { if (event.detail != SWT.DRAG) { ((GridData) paletteCanvas.getLayoutData()).heightHint = SWT.DEFAULT; Rectangle paletteCanvasBounds = paletteCanvas.getBounds(); int minY = paletteCanvasBounds.y + 20; Rectangle dataLabelBounds = dataLabel.getBounds(); int maxY = statusLabel.getBounds().y - dataLabelBounds.height - 20; if (event.y > minY && event.y < maxY) { Rectangle oldSash = sash.getBounds(); sash.setBounds(event.x, event.y, event.width, event.height); int diff = event.y - oldSash.y; Rectangle bounds = imageCanvas.getBounds(); imageCanvas.setBounds(bounds.x, bounds.y, bounds.width, bounds.height + diff); bounds = paletteCanvasBounds; paletteCanvas.setBounds(bounds.x, bounds.y, bounds.width, bounds.height + diff); bounds = dataLabelBounds; dataLabel.setBounds(bounds.x, bounds.y + diff, bounds.width, bounds.height); bounds = dataText.getBounds(); dataText.setBounds(bounds.x, bounds.y + diff, bounds.width, bounds.height - diff); // shell.layout(true); } } } }); // Label to show data-specific fields. dataLabel = new Label(shell, SWT.NULL); dataLabel.setText("Pixel_data_initial"); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; dataLabel.setLayoutData(gridData); // Text to show a dump of the data. dataText = new StyledText(shell, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL); dataText.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); dataText.setFont(fixedWidthFont); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.heightHint = 128; gridData.grabExcessVerticalSpace = true; dataText.setLayoutData(gridData); dataText.addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent event) { if (image != null && event.button == 1) { showColorForData(); } } }); dataText.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { if (image != null) { showColorForData(); } } }); // Label to show status and cursor location in image. statusLabel = new Label(shell, SWT.NULL); statusLabel.setText(""); gridData = new GridData(); gridData.horizontalSpan = 2; gridData.horizontalAlignment = GridData.FILL; statusLabel.setLayoutData(gridData); }