Java Code Examples for org.eclipse.swt.widgets.ToolItem#setEnabled()
The following examples show how to use
org.eclipse.swt.widgets.ToolItem#setEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PasteCoolbarItem.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void fill(final ToolBar toolbar, final int index, final int iconSize) { item = new ToolItem(toolbar, SWT.PUSH); item.setToolTipText(Messages.PasteButtonLabel); if (iconSize < 0) { item.setImage(Pics.getImage(PicsConstants.coolbar_paste_48)); item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_paste_disabled_48)); } else { item.setImage(Pics.getImage(PicsConstants.coolbar_paste_16)); item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_paste_disabled_16)); } item.setEnabled(false); item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final Command cmd = getCommand(); try { cmd.executeWithChecks(new ExecutionEvent()); } catch (final Exception ex) { BonitaStudioLog.error(ex); } } }); }
Example 2
Source File: MainToolBar.java From arx with Apache License 2.0 | 6 votes |
@Override protected void update(Model model) { // Check if (toolbar == null) return; // For each item for (final ToolItem item : toolbar.getItems()) { // Check group if (!(item.getData() instanceof MainMenuGroup)) { MainMenuItem mItem = (MainMenuItem) item.getData(); item.setEnabled(mItem == null || mItem.isEnabled(model)); } } }
Example 3
Source File: RunCoolbarItem.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void fill(final ToolBar toolbar, final int index, final int iconSize) { final ToolItem item = new ToolItem(toolbar, SWT.PUSH); item.setToolTipText(Messages.RunButtonLabel); if (iconSize < 0) { item.setImage(Pics.getImage(PicsConstants.coolbar_run_48)); item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_run_disabled_48)); } else { item.setImage(Pics.getImage(PicsConstants.coolbar_run_16)); item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_run_disabled_16)); } item.setEnabled(false); item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final Command cmd = getCommand(); try { cmd.executeWithChecks(new ExecutionEvent()); } catch (final Exception ex) { BonitaStudioLog.error(ex); } } }); }
Example 4
Source File: DeployCoolbarItem.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void fill(final ToolBar toolbar, final int index, final int iconSize) { item = new ToolItem(toolbar, SWT.PUSH); item.setToolTipText(Messages.DeployButtonLabel); item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_DEPLOY_TOOLITEM); if (iconSize < 0) { item.setImage(Pics.getImage("deploy48.png", ApplicationPlugin.getDefault())); } else { item.setImage(Pics.getImage("deploy24.png", ApplicationPlugin.getDefault())); } item.setEnabled(false); item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final Command cmd = getCommand(); try { cmd.executeWithChecks(new ExecutionEvent()); } catch (final Exception ex) { BonitaStudioLog.error(ex); } } }); }
Example 5
Source File: DataWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void createNewDocumentItem(final ToolBar tb) { newXMLButton = new ToolItem(tb, SWT.PUSH); newXMLButton.setImage(Pics.getImage("filenew.png", DataPlugin.getDefault())); newXMLButton.setToolTipText("New empty document"); newXMLButton.setEnabled(((XMLData) data).getType() != null && ((XMLData) data).getNamespace() != null); newXMLButton.addSelectionListener(new SelectionAdapter() { @SuppressWarnings({ "restriction" }) @Override public void widgetSelected(final SelectionEvent e) { final NewXMLGenerator generator = new NewXMLGenerator(); final XSDRepositoryStore store = RepositoryManager.getInstance() .getRepositoryStore(XSDRepositoryStore.class); if (data instanceof XMLData) { final XSDFileStore nameSpaceStore = store .findArtifactWithNamespace(((XMLData) data).getNamespace()); if (nameSpaceStore != null) { final String[] errors = new String[2]; final CMDocument createCMDocument = NewXMLGenerator .createCMDocument(nameSpaceStore.getResource().getLocation().toFile().toURI() .toString(), errors); generator.setCMDocument(createCMDocument); generator.setBuildPolicy(ContentBuilder.BUILD_ALL_CONTENT); generator.setRootElementName(((XMLData) data).getType()); try { final ByteArrayOutputStream stream = generator.createXMLDocument("xmlFileName", "UTF-8"); final String xmlContent = new String(stream.toByteArray(), "UTF-8"); defaultValueViewer.getTextControl().setText(xmlContent); } catch (final Exception e1) { BonitaStudioLog.error(e1); } } } } }); }
Example 6
Source File: XFindPanel.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
protected ToolItem createSearchHistoryMenu(final ToolBar bar) { bHistory = new ToolItem(bar, SWT.PUSH); bHistory.setImage(ImageUtils.getImage(ImageUtils.FIND_HISTORY)); bHistory.setToolTipText(Messages.XFindPanel_ShowHistory_tooltip); bHistory.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { showHistoryMenu(); } }); bHistory.setEnabled(!history.isEmpty()); return bHistory; }
Example 7
Source File: CreateAndEditFormContributionItem.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void fill(final ToolBar toolbar, final int style) { toolItem = new ToolItem(toolbar, SWT.LEFT | SWT.PUSH | SWT.NO_FOCUS); toolItem.setEnabled(false); toolItem.setToolTipText(Messages.newFormTooltipForPool); toolItem.setImage(Pics.getImage("new_form.png", UIDesignerPlugin.getDefault())); toolItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (shoudCreateNewForm()) { if (!isEditable()) { createNewForm(); } else { editForm(); } } } /** * @param canCreateOrEdit * @return */ protected boolean shoudCreateNewForm() { if (!isInternalForm()) { return MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), Messages.switchTypeOfFormQuestionTitle, Messages.bind(Messages.switchTypeOfFormQuestion, getFormMappingTypeName())); } return true; } }); }
Example 8
Source File: GamaToolbar2.java From gama with GNU General Public License v3.0 | 5 votes |
public ToolItem sep(final int n, final int side /* SWT.LEFT or SWT.RIGHT */) { final GamaIcon icon = GamaIcons.createSizer(getBackground(), n, height); final ToolItem item = create(icon.getCode(), null, null, null, SWT.NONE, false, null, side); item.setDisabledImage(icon.image()); if (!PlatformHelper.isLinux()) { item.setEnabled(false); } return item; }
Example 9
Source File: FileViewerWindow.java From AppleCommander with GNU General Public License v2.0 | 5 votes |
/** * Create the print tool item (button). */ protected ToolItem createPrintToolItem() { ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH); toolItem.setImage(imageManager.get(ImageManager.ICON_PRINT_FILE)); toolItem.setText(textBundle.get("PrintButton")); //$NON-NLS-1$ toolItem.setToolTipText(textBundle.get("FileViewerWindow.PrintTooltip")); //$NON-NLS-1$ toolItem.setEnabled(true); toolItem.addSelectionListener(new SelectionAdapter () { public void widgetSelected(SelectionEvent e) { getContentTypeAdapter().print(); } }); return toolItem; }
Example 10
Source File: TabbedPropertyTitle.java From birt with Eclipse Public License 1.0 | 5 votes |
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.getImageDescriptor( ) != null ) image = action.getImageDescriptor( ); if ( image != null ) item.setImage( localManager.createImageWithDefault( image ) ); item.setToolTipText( action.getToolTipText( ) ); if ( IAction.AS_CHECK_BOX == action.getStyle( ) ) { item.setSelection( action.isChecked( ) ); } item.setEnabled( action.isEnabled( ) ); } } disposeOldImages( ); imageManager = localManager; if ( toolbar.isFocusControl( ) ) toolbar.setFocus( ); } }
Example 11
Source File: SaveCoolbarItem.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void fill(final ToolBar toolbar, final int index, final int iconSize) { item = new ToolItem(toolbar, SWT.PUSH); item.setToolTipText(Messages.SaveProcessButtonLabel); item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_SAVE_EDITOR); if (iconSize < 0) { item.setImage(Pics.getImage(PicsConstants.coolbar_save_48)); item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_save_disabled_48)); } else { item.setImage(Pics.getImage(PicsConstants.coolbar_save_16)); item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_save_disabled_16)); } item.setEnabled(false); item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor(); if (editor != null) { if (editor instanceof DiagramEditor) { final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getService(IHandlerService.class); final Command command = getCommand(); final ExecutionEvent executionEvent = new ExecutionEvent(command, Collections.EMPTY_MAP, null, handlerService.getClass()); try { command.executeWithChecks(executionEvent); } catch (final Exception e1) { BonitaStudioLog.error(e1); } } else { editor.doSave(null); } } } }); }
Example 12
Source File: CleanDeployContributionItem.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void fill(ToolBar parent, int index) { item = new ToolItem(parent, SWT.PUSH); item.setImage(BusinessObjectPlugin.getImage("icons/cleanDeploy.png")); item.setText(Messages.cleanDeployTitle); item.setToolTipText(Messages.cleanDeployTitle); item.addListener(SWT.Selection, event -> deploy(true)); item.setEnabled(isEnabled()); }
Example 13
Source File: ValidateContributionItem.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void fill(ToolBar parent, int index) { item = new ToolItem(parent, SWT.PUSH); item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ID); item.setText(Messages.validate); item.setToolTipText(Messages.validateTooltip); item.setImage(BusinessObjectPlugin.getImage("icons/validate.png")); item.addListener(SWT.Selection, e -> validate()); item.setEnabled(true); }
Example 14
Source File: DeployContributionItem.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void fill(ToolBar parent, int index) { item = new ToolItem(parent, SWT.PUSH); item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ID); item.setText(Messages.deploy); item.setToolTipText(Messages.deploy); item.setImage(BusinessObjectPlugin.getImage("icons/deploy16.png")); item.addListener(SWT.Selection, event -> deploy(false)); item.setEnabled(isEnabled()); }
Example 15
Source File: ExploreBDMContributionItem.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void fill(ToolBar parent, int index) { item = new ToolItem(parent, SWT.PUSH); item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ID); item.setText(Messages.explore); item.setToolTipText(Messages.exploreTooltip); item.setImage(BusinessObjectPlugin.getImage("icons/wen.png")); item.addListener(SWT.Selection, event -> commandExecutor.executeCommand(EXPLORE_BDM_COMMAND, null)); item.setEnabled(isEnabled()); }
Example 16
Source File: FileViewerWindow.java From AppleCommander with GNU General Public License v2.0 | 5 votes |
/** * Create the copy tool item (button). */ protected ToolItem createCopyToolItem() { ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH); toolItem.setImage(imageManager.get(ImageManager.ICON_COPY)); toolItem.setText(textBundle.get("FileViewerWindow.CopyButton")); //$NON-NLS-1$ toolItem.setToolTipText(textBundle.get("FileViewerWindow.CopyTooltip")); //$NON-NLS-1$ toolItem.setEnabled(true); toolItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { getContentTypeAdapter().copy(); } }); return toolItem; }
Example 17
Source File: GuiToolbarWidgets.java From hop with Apache License 2.0 | 5 votes |
public void enableToolbarItem( String id, boolean enabled ) { ToolItem toolItem = toolItemMap.get( id ); if ( toolItem == null ) { return; } if ( enabled != toolItem.isEnabled() ) { toolItem.setEnabled( enabled ); } }
Example 18
Source File: SimpleToolBarEx.java From SWET with MIT License | 4 votes |
public void showEnabled(ToolItem element) { element.setEnabled(true); }
Example 19
Source File: ShowHelpDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void open() { Shell parent = getParent(); display = parent.getDisplay(); shell = createShell( parent ); shell.setImage( GUIResource.getInstance().getImageSpoon() ); props.setLook( shell ); FormLayout formLayout = new FormLayout(); shell.setLayout( formLayout ); shell.setText( dialogTitle ); //Set Images setImages(); // Canvas wBrowser = new Browser( shell, SWT.NONE ); props.setLook( wBrowser ); // Browser canvas FormData fdBrowser = new FormData(); fdBrowser.top = new FormAttachment( 0, TOOLBAR_HEIGHT ); fdBrowser.bottom = new FormAttachment( 100, 0 ); fdBrowser.right = new FormAttachment( 100, 0 ); fdBrowser.left = new FormAttachment( 0, 0 ); wBrowser.setLayoutData( fdBrowser ); wBrowser.setUrl( url ); // Left toolbar (back, forward, refresh, home) toolbarLeft = new ToolBar( shell, SWT.WRAP ); FormData fdToolbarLeft = new FormData(); fdToolbarLeft.top = new FormAttachment( 0, MARGIN ); toolbarLeft.setLayoutData( fdToolbarLeft ); toolbarLeft.setCursor( cursorEnabled ); toolbarLeft.setBackground( toolbarLeft.getParent().getBackground() ); tltmBack = new ToolItem( toolbarLeft, SWT.PUSH ); tltmBack.setImage( imageBackEnabled ); tltmBack.setDisabledImage( imageBackDisabled ); tltmBack.setToolTipText( BaseMessages.getString( PKG, "Spoon.Documentation.Tooltip.Back" ) ); tltmBack.setEnabled( false ); tltmForward = new ToolItem( toolbarLeft, SWT.PUSH ); tltmForward.setImage( imageForwardEnabled ); tltmForward.setDisabledImage( imageForwardDisabled ); tltmForward.setToolTipText( BaseMessages.getString( PKG, "Spoon.Documentation.Tooltip.Forward" ) ); tltmForward.setEnabled( false ); tltmRefresh = new ToolItem( toolbarLeft, SWT.PUSH ); tltmRefresh.setImage( imageRefreshEnabled ); tltmRefresh.setDisabledImage( imageRefreshDisabled ); tltmRefresh.setToolTipText( BaseMessages.getString( PKG, "Spoon.Documentation.Tooltip.Refresh" ) ); tltmRefresh.setEnabled( true ); tltmHome = new ToolItem( toolbarLeft, SWT.PUSH ); tltmHome.setImage( imageHomeEnabled ); tltmHome.setDisabledImage( imageHomeDisabled ); tltmHome.setToolTipText( BaseMessages.getString( PKG, "Spoon.Documentation.Tooltip.Home" ) ); tltmHome.setEnabled( true ); // Right toolbar (print) toolbarRight = new ToolBar( shell, SWT.WRAP ); FormData fdToolbarRight = new FormData(); fdToolbarRight.top = new FormAttachment( 0, MARGIN ); fdToolbarRight.right = new FormAttachment( 100, -1 * TOOL_ITEM_SPACING ); toolbarRight.setLayoutData( fdToolbarRight ); toolbarRight.setCursor( cursorEnabled ); toolbarRight.setBackground( toolbarRight.getParent().getBackground() ); // URL toolbar element textURL = new Text( shell, SWT.BORDER ); FormData fdText = new FormData(); fdText.top = new FormAttachment( 0, MARGIN ); fdText.right = new FormAttachment( toolbarRight, -1 * TOOL_ITEM_SPACING ); fdText.left = new FormAttachment( toolbarLeft, TOOL_ITEM_SPACING ); textURL.setLayoutData( fdText ); textURL.setForeground( new Color( display, 101, 101, 101 ) ); tltmPrint = new ToolItem( toolbarRight, SWT.PUSH ); tltmPrint.setImage( imagePrintEnabled ); tltmPrint.setDisabledImage( imagePrintDisabled ); tltmPrint.setToolTipText( BaseMessages.getString( PKG, "Spoon.Documentation.Tooltip.Print" ) ); tltmPrint.setEnabled( true ); setUpListeners(); // Specs are 760/530, but due to rendering differences, we need to adjust the actual hgt/wdt used BaseStepDialog.setSize( shell, 755, 538, true ); shell.setMinimumSize( 515, 408 ); shell.open(); while ( !shell.isDisposed() ) { if ( !display.readAndDispatch() ) { display.sleep(); } } }
Example 20
Source File: TreeToolbar.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public TreeToolbar( Composite composite, int i ) { super( composite, i ); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = 0; formLayout.marginHeight = 0; formLayout.marginTop = 0; formLayout.marginBottom = 0; this.setLayout( formLayout ); Label sep3 = new Label( this, SWT.SEPARATOR | SWT.HORIZONTAL ); sep3.setBackground( GUIResource.getInstance().getColorWhite() ); FormData fdSep3 = new FormData(); fdSep3.left = new FormAttachment( 0, 0 ); fdSep3.right = new FormAttachment( 100, 0 ); fdSep3.top = new FormAttachment( 0 ); sep3.setLayoutData( fdSep3 ); ToolBar treeTb = new ToolBar( this, SWT.HORIZONTAL | SWT.FLAT ); props.setLook( treeTb, Props.WIDGET_STYLE_TOOLBAR ); /* This contains a map with all the unnamed transformation (just a filename) */ expandAll = new ToolItem( treeTb, SWT.PUSH ); expandAll.setImage( GUIResource.getInstance().getImageExpandAll() ); collapseAll = new ToolItem( treeTb, SWT.PUSH ); collapseAll.setImage( GUIResource.getInstance().getImageCollapseAll() ); FormData fdTreeToolbar = new FormData(); if ( Const.isLinux() ) { fdTreeToolbar.top = new FormAttachment( sep3, 3 ); } else { fdTreeToolbar.top = new FormAttachment( sep3, 5 ); } fdTreeToolbar.right = new FormAttachment( 100, -10 ); treeTb.setLayoutData( fdTreeToolbar ); ToolBar selectionFilterTb = new ToolBar( this, SWT.HORIZONTAL | SWT.FLAT ); props.setLook( selectionFilterTb, Props.WIDGET_STYLE_TOOLBAR ); ToolItem clearSelectionFilter = new ToolItem( selectionFilterTb, SWT.PUSH ); clearSelectionFilter.setImage( GUIResource.getInstance().getImageClearText() ); clearSelectionFilter.setDisabledImage( GUIResource.getInstance().getImageClearTextDisabled() ); FormData fdSelectionFilterToolbar = new FormData(); if ( Const.isLinux() ) { fdSelectionFilterToolbar.top = new FormAttachment( sep3, 3 ); } else { fdSelectionFilterToolbar.top = new FormAttachment( sep3, 5 ); } fdSelectionFilterToolbar.right = new FormAttachment( treeTb, -20 ); selectionFilterTb.setLayoutData( fdSelectionFilterToolbar ); selectionFilter = new Text( this, SWT.SINGLE | SWT.BORDER | SWT.LEFT | SWT.SEARCH ); FormData fdSelectionFilter = new FormData(); int offset = -( GUIResource.getInstance().getImageClearTextDisabled().getBounds().height + 6 ); if ( Const.isLinux() ) { offset = -( GUIResource.getInstance().getImageClearTextDisabled().getBounds().height + 13 ); } fdSelectionFilter.top = new FormAttachment( selectionFilterTb, offset ); fdSelectionFilter.right = new FormAttachment( selectionFilterTb, 0 ); fdSelectionFilter.left = new FormAttachment( 0, 10 ); selectionFilter.setLayoutData( fdSelectionFilter ); clearSelectionFilter.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent event ) { selectionFilter.setText( "" ); } } ); clearSelectionFilter.setEnabled( !Utils.isEmpty( selectionFilter.getText() ) ); selectionFilter.addModifyListener( modifyEvent -> { clearSelectionFilter.setEnabled( !Utils.isEmpty( selectionFilter.getText() ) ); } ); Label sep4 = new Label( this, SWT.SEPARATOR | SWT.HORIZONTAL ); sep4.setBackground( GUIResource.getInstance().getColorWhite() ); FormData fdSep4 = new FormData(); fdSep4.left = new FormAttachment( 0, 0 ); fdSep4.right = new FormAttachment( 100, 0 ); fdSep4.top = new FormAttachment( treeTb, 5 ); sep4.setLayoutData( fdSep4 ); }