/** * Initialize the toolbar with icons and selection listeners in the appropriate part of the window */ public void initToolbar() { Device dev = shell.getDisplay(); try { exitImg = new Image(dev, "img/exit.png"); // openImg = new Image(dev, "img/open.png"); playImg = new Image(dev, "img/play.png"); // pauseImg = new Image(dev, "img/pause.png"); } catch (Exception e) { System.out.println("Cannot load images"); System.out.println(e.getMessage()); System.exit(1); } ToolBar toolBar = new ToolBar(shell, SWT.BORDER); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; toolBar.setLayoutData(gridData); ToolItem exit = new ToolItem(toolBar, SWT.PUSH); exit.setImage(exitImg); // ToolItem open = new ToolItem(toolBar, SWT.PUSH); // exit.setImage(openImg); ToolItem play = new ToolItem(toolBar, SWT.PUSH); play.setImage(playImg); // ToolItem pause = new ToolItem(toolBar, SWT.PUSH); // pause.setImage(pauseImg); toolBar.pack(); exit.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { System.exit(0); } }); // open.addSelectionListener(new SelectionAdapter() { // @Override // public void widgetSelected(SelectionEvent e) { // FileDialog dialog = new FileDialog(shell, SWT.NULL); // String path = dialog.open(); // } // }); play.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { controller.RunAnimation(); } }); }
/** * Add expand all and collapse all toolbar items to the given toolbar bound to the given tree * viewer * * @param toolbar * @param viewer * @return given toolbar */ public static ToolBar addExpansionItems(final ToolBar toolbar, final AbstractTreeViewer viewer) { ToolItem collapseItem = new ToolItem(toolbar, SWT.PUSH); Image collapseImage = UIIcons.COLLAPSEALL.createImage(); UIUtils.hookDisposal(collapseItem, collapseImage); collapseItem.setImage(collapseImage); collapseItem.setToolTipText(UIText.UIUtils_CollapseAll); collapseItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { viewer.collapseAll(); } }); ToolItem expandItem = new ToolItem(toolbar, SWT.PUSH); Image expandImage = UIIcons.EXPAND_ALL.createImage(); UIUtils.hookDisposal(expandItem, expandImage); expandItem.setImage(expandImage); expandItem.setToolTipText(UIText.UIUtils_ExpandAll); expandItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { viewer.expandAll(); } }); return toolbar; }
private ToolBar createConfigureToolBar(Composite parent) { final ToolBar tb = new ToolBar(parent, SWT.NONE); final ToolItem config = new ToolItem(tb, SWT.DROP_DOWN); config.setImage(imageCache.get(CONFIG_ICON)); config.setToolTipText("Options"); config.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final Rectangle r = config.getBounds(); final Point p = new Point(r.x, r.y + r.height); optionsMenu.setLocation(tb.getDisplay().map(tb, null, p)); optionsMenu.setVisible(true); } }); hideItem = new ToolItem(tb, SWT.PUSH); hideItem.setImage(imageCache.get(UP_ICON)); hideItem.setToolTipText("Hide Request Table"); hideItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { toggleHideState(); } }); tb.pack(); return tb; }
/** This method initializes main controls of the main window */ private void initControlsArea( final Composite controlsArea, final Combo feederSelectionCombo, final Button startStopButton, final StartStopScanningAction startStopScanningAction, final ToolsActions.Preferences preferencesListener, final ToolsActions.ChooseFetchers chooseFetchersListsner) { controlsArea.setLayoutData( LayoutHelper.formData( new FormAttachment(feederArea), new FormAttachment(100), new FormAttachment(0), new FormAttachment(feederArea, 0, SWT.BOTTOM))); controlsArea.setLayout(LayoutHelper.formLayout(7, 3, 3)); // steal the height from the second child of the FeederGUI - this must be the first edit box. // this results in better visual alignment with FeederGUIs Control secondControl = feederRegistry.current().getChildren()[1]; // initialize global standard button height buttonHeight = secondControl.getSize().y + 2; // feeder selection combobox this.feederSelectionCombo = feederSelectionCombo; feederSelectionCombo.pack(); IPFeederSelectionListener feederSelectionListener = new IPFeederSelectionListener(); feederSelectionCombo.addSelectionListener(feederSelectionListener); // initialize the selected feeder GUI feederSelectionCombo.select(guiConfig.activeFeeder); feederSelectionCombo.setToolTipText(Labels.getLabel("combobox.feeder.tooltip")); // start/stop button this.startStopButton = startStopButton; shell.setDefaultButton(startStopButton); startStopButton.addSelectionListener(startStopScanningAction); // traverse the button before the combo (and don't traverse other buttons at all) controlsArea.setTabList(new Control[] {startStopButton, feederSelectionCombo}); prefsButton = new ToolBar(controlsArea, SWT.FLAT); prefsButton.setCursor(prefsButton.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); ToolItem item = new ToolItem(prefsButton, SWT.PUSH); item.setImage(new Image(null, Labels.getInstance().getImageAsStream("button.preferences.img"))); item.setToolTipText(Labels.getLabel("title.preferences")); item.addListener(SWT.Selection, preferencesListener); fetchersButton = new ToolBar(controlsArea, SWT.FLAT); fetchersButton.setCursor(fetchersButton.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); item = new ToolItem(fetchersButton, SWT.PUSH); item.setImage(new Image(null, Labels.getInstance().getImageAsStream("button.fetchers.img"))); item.setToolTipText(Labels.getLabel("title.fetchers.select")); item.addListener(SWT.Selection, chooseFetchersListsner); feederSelectionListener.widgetSelected(null); }
private void toggleHideState() { if (hideState) { hideState = false; hideItem.setImage(imageCache.get(UP_ICON)); hideItem.setToolTipText("Hide Request Table"); parentForm.setMaximizedControl(null); } else { hideState = true; hideItem.setToolTipText("Show Request Table"); hideItem.setImage(imageCache.get(DOWN_ICON)); parentForm.setMaximizedControl(parentComposite); } }
private void createToolBar(Composite parent) { ToolBar toolBar = new ToolBar(parent, SWT.FLAT); modeButton = new ToolItem(toolBar, SWT.CHECK); modeButton.setImage(HierarchyView.INHERITED_IMAGE); modeButton.setToolTipText("Show Inherited Members"); modeButton.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { mode = !mode; getTreeViewer().refresh(); getTreeViewer().expandToLevel(getDefaultLevel()); } @Override public void widgetDefaultSelected(SelectionEvent e) {} }); sortButton = new ToolItem(toolBar, SWT.CHECK); sortButton.setImage(SORT); sortButton.setToolTipText("Sort by Name"); boolean sortChecker = getDialogSettings().getBoolean("sort"); sortButton.setSelection(sortChecker); sortButton.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { lexicalSortingAction.setChecked(sortButton.getSelection()); lexicalSortingAction.run(); } @Override public void widgetDefaultSelected(SelectionEvent e) {} }); hideButton = new ToolItem(toolBar, SWT.CHECK); hideButton.setImage(PUBLIC); hideButton.setToolTipText("Hide Unshared Declarations"); boolean hideChecked = getDialogSettings().getBoolean("hideNonShared"); hideButton.setSelection(hideChecked); hideButton.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { hideNonSharedAction.setChecked(hideButton.getSelection()); hideNonSharedAction.run(); } @Override public void widgetDefaultSelected(SelectionEvent e) {} }); }
@SuppressWarnings("unused") // SWT constructors have side effects, they are not unused private ToolBar createLintControls() { ToolBar toolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT | SWT.HORIZONTAL); // Separate from adjacent toolbar new ToolItem(toolBar, SWT.SEPARATOR); ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); mLintButton = new ToolItem(toolBar, SWT.PUSH); mLintButton.setToolTipText("Show Lint Warnings for this Layout"); mLintButton.setImage(sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK)); mLintButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { CommonXmlEditor editor = mEditor.getEditorDelegate().getEditor(); IFile file = editor.getInputFile(); if (file != null) { EclipseLintClient.showErrors(getShell(), file, editor); } } }); return toolBar; }
private ToolBar createHelpImageButton(Composite parent, Image image) { ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS); ((GridLayout) parent.getLayout()).numColumns++; toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); toolBar.setCursor(cursor); toolBar.addDisposeListener( new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { cursor.dispose(); } }); ToolItem item = new ToolItem(toolBar, SWT.NONE); item.setImage(image); item.setToolTipText(JFaceResources.getString("helpToolTip")); // $NON-NLS-1$ item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { helpPressed(); } }); return toolBar; }
private void addRadio(RuleAction.Choices choices) { List<URL> icons = choices.getIconUrls(); List<String> titles = choices.getTitles(); List<String> ids = choices.getIds(); String current = choices.getCurrent() != null ? choices.getCurrent() : ""; // $NON-NLS-1$ assert icons != null; assert icons.size() == titles.size(); for (int i = 0; i < icons.size(); i++) { URL iconUrl = icons.get(i); String title = titles.get(i); final String id = ids.get(i); final ToolItem item = new ToolItem(mLayoutToolBar, SWT.RADIO); item.setToolTipText(title); item.setImage(IconFactory.getInstance().getIcon(iconUrl)); item.setData(choices); item.setData(ATTR_ID, id); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (item.getSelection()) { RuleAction.Choices choices = (Choices) item.getData(); choices.getCallback().action(choices, getSelectedNodes(), id, null); updateSelection(); } } }); boolean selected = current.equals(id); if (selected) { item.setSelection(true); } } }
private void addPlainAction(RuleAction menuAction) { final ToolItem button = new ToolItem(mLayoutToolBar, SWT.PUSH); URL iconUrl = menuAction.getIconUrl(); String title = menuAction.getTitle(); if (iconUrl != null) { button.setImage(IconFactory.getInstance().getIcon(iconUrl)); button.setToolTipText(title); } else { button.setText(title); } button.setData(menuAction); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { RuleAction menuAction = (RuleAction) button.getData(); menuAction .getCallback() .action(menuAction, getSelectedNodes(), menuAction.getId(), false); updateSelection(); } }); }
private void addToggle(Toggle toggle) { final ToolItem button = new ToolItem(mLayoutToolBar, SWT.CHECK); URL iconUrl = toggle.getIconUrl(); String title = toggle.getTitle(); if (iconUrl != null) { button.setImage(IconFactory.getInstance().getIcon(iconUrl)); button.setToolTipText(title); } else { button.setText(title); } button.setData(toggle); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Toggle toggle = (Toggle) button.getData(); toggle .getCallback() .action(toggle, getSelectedNodes(), toggle.getId(), button.getSelection()); updateSelection(); } }); if (toggle.isChecked()) { button.setSelection(true); } }
public ExpandButton(Composite parent) { expandImage = SATC_Activator.getImageDescriptor(EXPAND_ICON).createImage(); collapseImage = SATC_Activator.getImageDescriptor(COLLAPSE_ICON).createImage(); toolBar = new ToolBar(parent, SWT.FLAT); toolItem = new ToolItem(toolBar, SWT.PUSH); toolItem.setImage(expandImage); toolItem.addSelectionListener( new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent arg0) { // } @Override public void widgetSelected(SelectionEvent event) { setSelection(!selected); if (listeners != null) { for (SelectionListener listener : listeners) { listener.widgetSelected(event); } } } }); }
private void updateToolBar() { if (toolbar != null) { ResourceManager parentResourceManager = JFaceResources.getResources(); LocalResourceManager localManager = new LocalResourceManager(parentResourceManager); for (int i = 0; i < toolbar.getItemCount(); i++) { ToolItem item = toolbar.getItem(i); IAction action = (IAction) actionMap.get(item); if (action != null) { ImageDescriptor image = null; if (action.isEnabled() && action.getImageDescriptor() != null) image = action.getImageDescriptor(); else if (action.isEnabled() && action.getImageDescriptor() != null) image = action.getDisabledImageDescriptor(); if (image != null) item.setImage(localManager.createImageWithDefault(image)); item.setToolTipText(action.getToolTipText()); if (IAction.AS_CHECK_BOX == action.getStyle()) { item.setSelection(action.isChecked()); } } } disposeOldImages(); imageManager = localManager; if (toolbar.isFocusControl()) toolbar.setFocus(); } }
/* * Overridden so that clicking in the title menu area closes the dialog. Also creates a close box menu in the title * area. */ protected Control createTitleMenuArea(Composite parent) { Composite titleComposite = (Composite) super.createTitleMenuArea(parent); titleComposite.addMouseListener(clickListener); ToolBar toolBar = new ToolBar(titleComposite, SWT.FLAT); ToolItem closeButton = new ToolItem(toolBar, SWT.PUSH, 0); GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(toolBar); closeButton.setImage( UIEplPlugin.getDefault().getImageRegistry().get((UIEplPlugin.IMG_TOOL_CLOSE))); closeButton.setHotImage( UIEplPlugin.getDefault().getImageRegistry().get((UIEplPlugin.IMG_TOOL_CLOSE_HOT))); closeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { close(); } }); toolBar.addMouseListener( new MouseAdapter() { public void mouseDown(MouseEvent e) { close(); } }); return titleComposite; }
private org.eclipse.swt.widgets.ToolItem addToolItem( final org.eclipse.swt.widgets.ToolBar toolbar, final org.eclipse.swt.examples.paint.Tool tool) { final java.lang.String id = tool.group + '.' + tool.name; org.eclipse.swt.widgets.ToolItem item = new org.eclipse.swt.widgets.ToolItem(toolbar, tool.type); item.setText(getResourceString(id + ".label")); item.setToolTipText(getResourceString(id + ".tooltip")); item.setImage(tool.image); item.addSelectionListener( new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { tool.action.run(); } }); final int childID = toolbar.indexOf(item); toolbar .getAccessible() .addAccessibleListener( new org.eclipse.swt.accessibility.AccessibleAdapter() { public void getName(org.eclipse.swt.accessibility.AccessibleEvent e) { if (e.childID == childID) { e.result = getResourceString(id + ".description"); } } }); return item; }
public ToolItem addButton(String toolTipText, Image image) { ToolItem toolButton = new ToolItem(toolBar, SWT.PUSH); toolButton.setToolTipText(toolTipText); toolButton.setImage(image); return toolButton; }
/* * Creates a button with a help image. This is only used if there * is an image available. */ private ToolBar createLocalizationImageButton(Composite parent, Image image) { ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS); ((GridLayout) parent.getLayout()).numColumns++; toolBar.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, false)); final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); toolBar.setCursor(cursor); toolBar.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { cursor.dispose(); } }); final ToolItem item = new ToolItem(toolBar, SWT.NONE); item.setImage(image); languageSet.associate( "localizationToolTip", //$NON-NLS-1$ new TranslatableTextInput( Activator.getLocalizableText( "LocalizableTrayDialog.localizationToolTip")) { //$NON-NLS-1$ @Override public void updateControl(String text) { item.setToolTipText(text); } }); item.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { localizationPressed(); } }); return toolBar; }
public void setSelection(boolean selected) { if (selected == this.selected) { return; } this.selected = selected; toolItem.setImage(selected ? collapseImage : expandImage); }
@Override protected Control createControl(Composite parent) { super.createControl(parent); ToolBar buttons = new ToolBar(parent, SWT.FLAT | SWT.WRAP); ToolItem changeImage = new ToolItem(buttons, SWT.PUSH); changeImage.setImage( JaspersoftStudioPlugin.getInstance().getImage("icons/resources/equalizer--arrow.png")); changeImage.setToolTipText("Set exporter properties"); changeImage.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { createPopupMenu(); if (popupMenu.isVisible()) { popupMenu.setVisible(false); } else { locatePopupMenu(popupMenu); popupMenu.setVisible(true); } } }); return buttons; }
private void updateIcons() { if (this.widget instanceof MenuItem) { final MenuItem item = (MenuItem) this.widget; final LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources()); try { item.setImage(this.icon == null ? null : m.createImage(this.icon)); } catch (final DeviceResourceException e) { this.icon = ImageDescriptor.getMissingImageDescriptor(); item.setImage(m.createImage(this.icon)); // as we replaced the failed icon, log the message once. StatusManager.getManager() .handle( new Status( IStatus.ERROR, SharedUIResources.PLUGIN_ID, "Failed to load image", e)); //$NON-NLS-1$ } disposeOldImages(); this.localResourceManager = m; } else if (this.widget instanceof ToolItem) { final ToolItem item = (ToolItem) this.widget; final LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources()); item.setDisabledImage(this.disabledIcon == null ? null : m.createImage(this.disabledIcon)); item.setHotImage(this.hoverIcon == null ? null : m.createImage(this.hoverIcon)); item.setImage(this.icon == null ? null : m.createImage(this.icon)); disposeOldImages(); this.localResourceManager = m; } }
/** 添加帮助按钮,备注,这里的配置与其他的不一样 robert 2012-09-06 */ protected Control createHelpToolItem(Composite parent) { // ROBERTHELP xml 转换器配置 String language = CommonFunction.getSystemLanguage(); final String helpUrl = MessageFormat.format( "/net.heartsome.cat.ts.ui.help/html/{0}/ch08.html#configure-xml-converter", language); Image helpImage = JFaceResources.getImage(DLG_IMG_HELP); ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS); toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); toolBar.setCursor(cursor); toolBar.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { cursor.dispose(); } }); ToolItem helpItem = new ToolItem(toolBar, SWT.NONE); helpItem.setImage(helpImage); helpItem.setToolTipText(JFaceResources.getString("helpToolTip")); // $NON-NLS-1$ helpItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl); } }); return toolBar; }
/** {@inheritDoc} */ @Override public void createPartControl(final Composite parent) { toolBar = new ToolBar(parent, SWT.NONE); objectSelection = new ToolItem(toolBar, SWT.RADIO | SWT.NONE); objectSelection.setImage(MoreDreadUI.getDefault().getImage("/icons/SelectionModeObject.png")); objectSelection.setSelection(true); objectSelection.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { MoreDreadUI.getDefault().getSceneHolder().setSelectionMode(SelectionMode.OBJECT); } }); faceSelection = new ToolItem(toolBar, SWT.RADIO | SWT.NONE); faceSelection.setImage(MoreDreadUI.getDefault().getImage("/icons/SelectionModeFace.png")); faceSelection.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { MoreDreadUI.getDefault().getSceneHolder().setSelectionMode(SelectionMode.FACE); } }); faceSelection.setEnabled(false); edgeSelection = new ToolItem(toolBar, SWT.RADIO | SWT.NONE); edgeSelection.setImage(MoreDreadUI.getDefault().getImage("/icons/SelectionModeEdge.png")); edgeSelection.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { MoreDreadUI.getDefault().getSceneHolder().setSelectionMode(SelectionMode.EDGE); } }); edgeSelection.setEnabled(false); vertexSelection = new ToolItem(toolBar, SWT.RADIO | SWT.NONE); vertexSelection.setImage(MoreDreadUI.getDefault().getImage("/icons/SelectionModeVertex.png")); vertexSelection.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { MoreDreadUI.getDefault().getSceneHolder().setSelectionMode(SelectionMode.VERTEX); } }); vertexSelection.setEnabled(false); MoreDreadUI.getDefault().getSceneHolder().addSceneSelectionModeListener(this); MoreDreadUI.getDefault().getSceneHolder().addSceneSelectionChangeListener(this); }
private void addDropdown(RuleAction.Choices choices) { final ToolItem combo = new ToolItem(mLayoutToolBar, SWT.DROP_DOWN); URL iconUrl = choices.getIconUrl(); if (iconUrl != null) { combo.setImage(IconFactory.getInstance().getIcon(iconUrl)); combo.setToolTipText(choices.getTitle()); } else { combo.setText(choices.getTitle()); } combo.setData(choices); Listener menuListener = new Listener() { @Override public void handleEvent(Event event) { Menu menu = new Menu(mLayoutToolBar.getShell(), SWT.POP_UP); RuleAction.Choices choices = (Choices) combo.getData(); List<URL> icons = choices.getIconUrls(); List<String> titles = choices.getTitles(); List<String> ids = choices.getIds(); String current = choices.getCurrent() != null ? choices.getCurrent() : ""; // $NON-NLS-1$ for (int i = 0; i < titles.size(); i++) { String title = titles.get(i); final String id = ids.get(i); URL itemIconUrl = icons != null && icons.size() > 0 ? icons.get(i) : null; MenuItem item = new MenuItem(menu, SWT.CHECK); item.setText(title); if (itemIconUrl != null) { Image itemIcon = IconFactory.getInstance().getIcon(itemIconUrl); item.setImage(itemIcon); } boolean selected = id.equals(current); if (selected) { item.setSelection(true); } item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { RuleAction.Choices choices = (Choices) combo.getData(); choices.getCallback().action(choices, getSelectedNodes(), id, null); updateSelection(); } }); } Rectangle bounds = combo.getBounds(); Point location = new Point(bounds.x, bounds.y + bounds.height); location = combo.getParent().toDisplay(location); menu.setLocation(location.x, location.y); menu.setVisible(true); } }; combo.addListener(SWT.Selection, menuListener); }
private static ToolItem createToolItem( ToolBar toolBar, String text, String toolTipText, Image image, int style) { ToolItem toolItem = new ToolItem(toolBar, style); toolItem.setText(text); toolItem.setToolTipText(toolTipText); toolItem.setImage(image); return toolItem; }
private void createFeedback() { dragShell = new Shell(SWT.NO_TRIM | SWT.NO_BACKGROUND); dragShell.setAlpha(175); ToolBar dragTB = new ToolBar(dragShell, SWT.RIGHT); ToolItem newTI = new ToolItem(dragTB, SWT.RADIO); newTI.setText(dragItem.getText()); newTI.setImage(dragItem.getImage()); dragTB.pack(); dragShell.pack(); dragShell.setVisible(true); }
/** * Creates toolbar * * @param ancestor the parent composite */ private void createToolBar(Composite ancestor) { Composite parent = new Composite(ancestor, SWT.NULL); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; layout.horizontalSpacing = 0; parent.setLayout(layout); GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); parent.setLayoutData(gridData); // to simulate a vertical toolbar (not possible), create a separate toolbar for each button ToolBar toolBar = new ToolBar(parent, SWT.FLAT); Image imageUp = DiagramUIPluginImages.DESC_UP_PATH.createImage(); moveUpToolItem = new ToolItem(toolBar, SWT.PUSH); moveUpToolItem.setEnabled(false); moveUpToolItem.setToolTipText(MOVE_UP_TOOL_TIP); moveUpToolItem.setImage(imageUp); moveUpToolItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { moveUpElements(); } }); ToolBar toolBarDown = new ToolBar(parent, SWT.FLAT); Image imageDown = DiagramUIPluginImages.DESC_DOWN_PATH.createImage(); moveDownToolItem = new ToolItem(toolBarDown, SWT.PUSH); moveDownToolItem.setEnabled(false); moveDownToolItem.setToolTipText(MOVE_DOWN_TOOL_TIP); moveDownToolItem.setImage(imageDown); moveDownToolItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { moveDownElements(); } }); }
public Control createControl(Composite parent, int style) { toolbar = new ToolBar(parent, style); btnAdd = new ToolItem(toolbar, SWT.PUSH); btnAdd.setImage( PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD)); btnAdd.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { for (AddRemoveListener l : listeners) { l.addSelected(); } } }); btnRemove = new ToolItem(toolbar, SWT.PUSH); btnRemove.setImage( PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE)); btnRemove.setDisabledImage( PlatformUI.getWorkbench() .getSharedImages() .getImage(ISharedImages.IMG_TOOL_DELETE_DISABLED)); btnRemove.setToolTipText("Remove"); btnRemove.setEnabled(false); btnRemove.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { for (AddRemoveListener l : listeners) { l.removeSelected(); } } }); return toolbar; }
protected ToolItem createAddItemTool(ToolBar toolbar) { ToolItem tool = new ToolItem(toolbar, SWT.PUSH); tool.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD)); tool.setToolTipText("Add Bundle"); tool.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doAdd(); } }); return tool; }
private ToolBar createLayoutToolBar(Composite parent) { ToolBar tb = new ToolBar(parent, SWT.NONE); ToolItem tabbed = new ToolItem(tb, SWT.RADIO); tabbed.setImage(imageCache.get(TABBED_ICON)); tabbed.setToolTipText("Tabbed Request/Response layout"); tabbed.setSelection(true); tabbed.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setTabbedMode(); } }); ToolItem horiz = new ToolItem(tb, SWT.RADIO); horiz.setImage(imageCache.get(HORIZONTAL_ICON)); horiz.setToolTipText("Horizontal Request/Response layout"); horiz.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setHorizontalSashMode(); } }); ToolItem vert = new ToolItem(tb, SWT.RADIO); vert.setImage(imageCache.get(VERTICAL_ICON)); vert.setToolTipText("Vertical Request/Response layout"); vert.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setVerticalSashMode(); } }); tb.pack(); return tb; }
/* (non-Javadoc) * @see org.eclipse.ui.IPresentationPreview#createControl(org.eclipse.swt.widgets.Composite, org.eclipse.ui.themes.ITheme) */ public void createControl(Composite parent, ITheme currentTheme) { this.theme = currentTheme; folder = new CTabFolder(parent, SWT.BORDER); folder.setUnselectedCloseVisible(false); folder.setEnabled(false); folder.setMaximizeVisible(true); folder.setMinimizeVisible(true); viewForm = new ViewForm(folder, SWT.NONE); viewForm.marginHeight = 0; viewForm.marginWidth = 0; viewForm.verticalSpacing = 0; viewForm.setBorderVisible(false); toolBar = new ToolBar(viewForm, SWT.FLAT | SWT.WRAP); ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH); Image hoverImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU); toolItem.setImage(hoverImage); viewForm.setTopRight(toolBar); viewMessage = new CLabel(viewForm, SWT.NONE); viewMessage.setText("Etu?"); // $NON-NLS-1$ viewForm.setTopLeft(viewMessage); CTabItem item = new CTabItem(folder, SWT.CLOSE); item.setText("Lorem"); // $NON-NLS-1$ Label text = new Label(viewForm, SWT.NONE); viewForm.setContent(text); text.setText("Lorem ipsum dolor sit amet"); // $NON-NLS-1$ text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); item = new CTabItem(folder, SWT.CLOSE); item.setText("Ipsum"); // $NON-NLS-1$ item.setControl(viewForm); item.setImage(WorkbenchImages.getImage(ISharedImages.IMG_TOOL_COPY)); folder.setSelection(item); item = new CTabItem(folder, SWT.CLOSE); item.setText("Dolor"); // $NON-NLS-1$ item = new CTabItem(folder, SWT.CLOSE); item.setText("Sit"); // $NON-NLS-1$ currentTheme.addPropertyChangeListener(fontAndColorListener); setColorsAndFonts(); setTabPosition(); setTabStyle(); }