Java Code Examples for org.eclipse.swt.widgets.ToolItem#setText()
The following examples show how to use
org.eclipse.swt.widgets.ToolItem#setText() .
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: FooterArea.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void createFooterActions() { for (FooterAction action : footerActions) { final ToolItem item = new ToolItem(toolbar, SWT.NONE); item.setText(action.getLabel()); item.addListener(SWT.Selection, e -> action.getAction().accept(parent)); if (action.getActive().isPresent()) { item.setImage(action.getActive().get()); } if (action.getInactive().isPresent()) { item.setDisabledImage(action.getInactive().get()); } if (action.getHot().isPresent()) { item.setHotImage(action.getHot().get()); } } }
Example 2
Source File: GamaToolbar2.java From gama with GNU General Public License v3.0 | 6 votes |
private ToolItem create(final String image, final String text, final String tip, final SelectionListener listener, final int style, final boolean forceText, final Control control, final int side /* SWT.LEFT or SWT.RIGHT */) { final GamaToolbarSimple tb = getToolbar(side); final ToolItem button = new ToolItem(tb, style); if (text != null && forceText) { button.setText(text); } if (tip != null) { button.setToolTipText(tip); } if (image != null) { final Image im = GamaIcons.create(image).image(); button.setImage(im); } if (listener != null) { button.addSelectionListener(listener); } if (control != null) { button.setControl(control); } normalizeToolbars(); return button; }
Example 3
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 4
Source File: ImportBDMContributionItem.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.setText(Messages.importActionName); item.setToolTipText(Messages.smartImportDesc); item.setImage(BusinessObjectPlugin.getImage("icons/import-bdm.png")); item.addListener(SWT.Selection, e -> onClick()); }
Example 5
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 6
Source File: AbstractExportContributionItem.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.setText(Messages.export); item.setToolTipText(Messages.exportTooltips); item.setImage(UIPlugin.getImage("icons/export_16.png")); item.addListener(SWT.Selection, event -> onClick(parent.getShell())); }
Example 7
Source File: AnalysisToolComposite.java From ice with Eclipse Public License 1.0 | 5 votes |
/** * Creates the Menu that stores each of the available IAnalysisViews for * each of the data sources. */ private void createViewMenu() { // Instantiate viewMenu. POP_UP menus are used for context menus and // drop-downs from ToolItems. Menu menu = new Menu(this.getShell(), SWT.POP_UP); // Create the top-level of the view menu with a button for each possible // data source. for (DataSource dataSource : DataSource.values()) { // Create a disabled MenuItem with dataSource as its text. MenuItem item = new MenuItem(menu, SWT.CASCADE); item.setText(dataSource.toString()); item.setEnabled(false); // Create the sub-menu that will show the view types for this data // source. Menu subMenu = new Menu(menu); item.setMenu(subMenu); // Put the MenuItem into a Map for quick access (it will need to be // enabled/disabled depending on whether or not there are views // available for the data source. dataSourceItems.put(dataSource, item); } // Add the view ToolItem that should make the view menu appear. final ToolItem viewItem = new ToolItem(rightToolBar, SWT.DROP_DOWN); viewItem.setText("Views"); viewItem.setToolTipText("Select the view displayed below."); // We also need to add a listener to make viewMenu appear. viewItem.addListener(SWT.Selection, new ToolItemMenuListener(viewItem, menu)); return; }
Example 8
Source File: RepositoryConnectMenu.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void renderConnectButton() { connectButton = new ToolItem( toolBar, toolBar.getItems().length ); connectButton.setText( BaseMessages.getString( PKG, "RepositoryConnectMenu.Connect" ) ); connectButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent selectionEvent ) { new RepositoryDialog( spoon.getShell(), repoConnectController ).openCreation(); renderAndUpdate(); } } ); }
Example 9
Source File: SearchAdvanced.java From Rel with Apache License 2.0 | 5 votes |
public SearchAdvanced(FilterSorter filterSorter, Composite contentPanel) { super(contentPanel, SWT.NONE); this.filterSorter = filterSorter; GridLayout layout = new GridLayout(2, false); layout.horizontalSpacing = 0; layout.verticalSpacing = 0; layout.marginWidth = 0; layout.marginHeight = 0; setLayout(layout); filterSpec = new Label(this, SWT.NONE); filterSpec.setText(emptyFilterPrompt); filterSpec.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1)); filterSpec.addListener(SWT.MouseUp, e -> popup()); ToolBar toolBar = new ToolBar(this, SWT.NONE); ToolItem clear = new ToolItem(toolBar, SWT.PUSH); clear.addListener(SWT.Selection, e -> { filterSpec.setText(emptyFilterPrompt); filterSorter.refresh(); }); clear.setText("Clear"); toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); this.addListener(SWT.Show, e -> { if (filterSpec.getText().equals(emptyFilterPrompt)) popup(); }); constructPopup(); }
Example 10
Source File: Sorter.java From Rel with Apache License 2.0 | 5 votes |
public Sorter(FilterSorter filterSorter, Composite contentPanel) { super(contentPanel, SWT.NONE); this.filterSorter = filterSorter; GridLayout layout = new GridLayout(2, false); layout.horizontalSpacing = 0; layout.verticalSpacing = 0; layout.marginWidth = 0; layout.marginHeight = 0; setLayout(layout); sortSpec = new Label(this, SWT.NONE); sortSpec.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1)); sortSpec.addListener(SWT.MouseUp, e -> popup()); sortSpec.setText(emptySortPrompt); ToolBar toolBar = new ToolBar(this, SWT.NONE); ToolItem clear = new ToolItem(toolBar, SWT.PUSH); clear.addListener(SWT.Selection, e -> { sortSpec.setText(emptySortPrompt); filterSorter.refresh(); }); clear.setText("Clear"); toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); this.addListener(SWT.Show, e -> { if (sortSpec.getText().equals(emptySortPrompt)) popup(); }); createPopup(); }
Example 11
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 12
Source File: LogAnalysis.java From AndroidRobot with Apache License 2.0 | 5 votes |
private void createStatusBar() { coolBar1 = new CoolBar(shell, SWT.NONE); FormData formData1 = new FormData(); formData1.left = new FormAttachment(0, 0); formData1.right = new FormAttachment(100, 0); formData1.top = new FormAttachment(100, -24); formData1.bottom = new FormAttachment(100, 0); coolBar1.setLayoutData(formData1); CoolItem coolItem1 = new CoolItem(coolBar1, SWT.NONE); toolBar1 = new ToolBar(coolBar1, SWT.NONE); ToolItem tiStatusBarTotal = new ToolItem(toolBar1, SWT.NONE); ToolItem tiStatusBarPass = new ToolItem(toolBar1, SWT.NONE); ToolItem tiStatusBarFail = new ToolItem(toolBar1, SWT.NONE); ToolItem tiStatusBarRate = new ToolItem(toolBar1, SWT.NONE); tiStatusBarPass.setText("通过:0"); tiStatusBarFail.setText("失败:0"); tiStatusBarRate.setText("通过率:0%"); tiStatusBarTotal.setText("总用例数:0"); coolItem1.setControl(toolBar1); Control control = coolItem1.getControl(); Point pt = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); pt = coolItem1.computeSize(pt.x, pt.y); coolItem1.setSize(pt); coolBar1.pack(); }
Example 13
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 14
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 15
Source File: BarManager.java From pmTrans with GNU Lesser General Public License v3.0 | 5 votes |
private ToolItem addItemToToolBar(ToolBar bar, String text, String toolTip, int type) { ToolItem cit = new ToolItem(bar, type); if (text != null) cit.setText(text); if (toolTip != null) cit.setToolTipText(toolTip); return cit; }
Example 16
Source File: SearchQuick.java From Rel with Apache License 2.0 | 4 votes |
public SearchQuick(FilterSorter filterSorter, Composite contentPanel) { super(contentPanel, SWT.NONE); this.filterSorter = filterSorter; GridLayout layout = new GridLayout(2, false); layout.horizontalSpacing = 0; layout.verticalSpacing = 0; layout.marginWidth = 0; layout.marginHeight = 0; setLayout(layout); findText = new StyledText(this, SWT.BORDER | SWT.SINGLE); findText.addListener(SWT.Traverse, event -> { if (event.detail == SWT.TRAVERSE_RETURN) { fireUpdate(); } }); findText.addListener(SWT.Modify, event -> { if (findText.getText().trim().length() > 0) { findText.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED)); findText.setBackground(SWTResourceManager.getColor(255, 225, 225)); } }); findText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); ToolBar toolBar = new ToolBar(this, SWT.NONE); ToolItem wholeWord = new ToolItem(toolBar, SWT.PUSH); wholeWord.addListener(SWT.Selection, e -> { wholeWordSearch = !wholeWordSearch; wholeWord.setText(wholeWordSearch ? "Whole word" : "Any match"); layout(); fireUpdateIfSearch(); }); wholeWord.setText("Any match"); ToolItem caseSensitive = new ToolItem(toolBar, SWT.PUSH); caseSensitive.addListener(SWT.Selection, e -> { caseSensitiveSearch = !caseSensitiveSearch; caseSensitive.setText(caseSensitiveSearch ? "Case sensitive" : "Case insensitive"); layout(); fireUpdateIfSearch(); }); caseSensitive.setText("Case insensitive"); ToolItem regex = new ToolItem(toolBar, SWT.CHECK); regex.addListener(SWT.Selection, e -> { regexSearch = regex.getSelection(); wholeWord.setEnabled(!regexSearch); caseSensitive.setEnabled(!regexSearch); fireUpdateIfSearch(); }); regex.setText("Regex"); ToolItem clear = new ToolItem(toolBar, SWT.PUSH); clear.addListener(SWT.Selection, e -> { if (findText.getText().trim().length() == 0) return; findText.setText(""); fireUpdate(); }); clear.setText("Clear"); toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); }
Example 17
Source File: TextEditor.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Creates tool item given a HTMLTag to display information in the tool bar. * * @param parent * Container tool bar. * @param tag * The given HTMLTag contain information of the tag to display. */ protected void createToolItemWithHTMLTag( ToolBar parent, final HTMLTag tag ) { tagItem = new ToolItem( parent, SWT.NONE ); tagItem.setText( tag.getName( ) ); tagItem.setToolTipText( tag.getToolTip( ) ); tagItem.addSelectionListener( new SelectionAdapter( ) { public void widgetSelected( SelectionEvent e ) { String frontTag = tag.getName( ); String backTag = tag.getName( ).replaceFirst( "<", "</" ); //$NON-NLS-1$ //$NON-NLS-2$ // if tag.attributes is not empty, then adds its attributes // following the front tag. if ( !tag.getAttributes( ).isEmpty( ) ) { //String text = " "; //$NON-NLS-1$ StringBuffer buffer = new StringBuffer( ); for ( Iterator<String> iter = tag.getAttributes( ) .iterator( ); iter.hasNext( ); ) { //text = text + iter.next( ) + "=\"\" "; //$NON-NLS-1$ buffer.append( " " + iter.next( ) + "=\"\"" );//$NON-NLS-1$ //$NON-NLS-2$ } frontTag = tag.getName( ) .replaceFirst( ">", buffer.toString( ) + ">" ); //$NON-NLS-1$ //$NON-NLS-2$ } // start: the start offset of selected text. Point point = textEditor.getSelection( ); int start = point.x < point.y ? point.x : point.y; String selectedText = textEditor.getSelectionText( ); if ( tag.isPair( ) ) { String text; if ( selectedText.length( ) == 0 ) { text = frontTag + textEditor.getLineDelimiter( ) + textEditor.getLineDelimiter( ) + backTag; } else { text = frontTag + selectedText + backTag; } textEditor.insert( text ); } else { textEditor.insert( frontTag + selectedText ); } // if the tag takes some attributes, then set the // cursor to the first attribute. if ( !tag.getAttributes( ).isEmpty( ) ) { textEditor.setCaretOffset( start + tag.getName( ).length( ) + tag.getAttributes( ).get( 0 ).length( ) + 2 ); } else { int offset = start + frontTag.length( ); if ( tag.isPair( ) && selectedText.length( ) == 0 ) { // a new line break is needed, set cursor to the new // line. offset = textEditor.getOffsetAtLine( textEditor.getLineAtOffset( start ) + 1 ); } textEditor.setCaretOffset( offset ); } } } ); }
Example 18
Source File: AbstractDefinitionWizardDialog.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected void createToolbar(final Composite parent) { toolbar = new ToolBar(parent, SWT.FLAT); toolbar.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).grab(true, false).create()); loadItem = new ToolItem(toolbar, SWT.NO_FOCUS | SWT.FLAT); loadItem.setImage(Pics.getImage("load_conf.png")); loadItem.setText(Messages.loadConfiguration); loadItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final IWizardPage page = getCurrentPage(); if (page instanceof AbstractConnectorConfigurationWizardPage) { final AbstractConnectorConfigurationWizardPage connectorConfPage = (AbstractConnectorConfigurationWizardPage) page; final ConnectorConfiguration connectorConfigurationToLoad = connectorConfPage.getConfiguration(); final SelectConnectorConfigurationWizard wizard = new SelectConnectorConfigurationWizard(connectorConfigurationToLoad, configurationStore, definitionRepositoryStore); final WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard); if (dialog.open() == Dialog.OK) { final IConnectorDefinitionContainer connectorWizard = (IConnectorDefinitionContainer) getWizard(); final ConnectorDefinition def = connectorWizard.getDefinition(); final IWizardPage namePage = getWizard().getPage(SelectNameAndDescWizardPage.class.getName()); if (namePage != null) { final IWizardPage previousNamePage = namePage.getPreviousPage(); showPage(namePage); namePage.setPreviousPage(previousNamePage); connectorWizard.recreateConnectorConfigurationPages(def, false); } else { final IWizardPage[] wizardPages = getWizard().getPages(); if (wizardPages.length > 1) { final IWizardPage firstPage = wizardPages[0]; showPage(firstPage.getNextPage()); } } updateButtons(); } } } }); saveItem = new ToolItem(toolbar, SWT.NO_FOCUS | SWT.FLAT); saveItem.setImage(Pics.getImage("save_conf.png")); saveItem.setText(Messages.saveConfiguration); final ITestConfigurationListener listener = getTestListener(null, (IWizard) null); if (implStore != null && listener != null) { testItem = new ToolItem(toolbar, SWT.NO_FOCUS | SWT.FLAT); testItem.setImage(Pics.getImage("test.png")); testItem.setText(Messages.testConfiguration); testItem.setEnabled(false); } }
Example 19
Source File: FontAwesomeSnippet2.java From nebula with Eclipse Public License 2.0 | 4 votes |
public static void main(final String[] args) throws IllegalArgumentException, IllegalAccessException { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("FontAwesome Snippet"); shell.setSize(600, 600); shell.setLayout(new GridLayout(1, false)); // Label new Label(shell, SWT.NONE).setText("In Label"); Label text = new Label(shell, SWT.NONE); text.setFont(FontAwesome.getFont(22)); text.setText(FontAwesome.code); // Button new Label(shell, SWT.NONE).setText("In Button"); Composite comp1 = new Composite(shell, SWT.NONE); comp1.setLayout(new RowLayout()); Button button1 = new Button(comp1, SWT.NONE); button1.setFont(FontAwesome.getFont(10)); button1.setText(FontAwesome.plus + " plus"); Button button2 = new Button(comp1, SWT.NONE); button2.setFont(FontAwesome.getFont(10)); button2.setText(FontAwesome.minus + " minus"); // Toolbar new Label(shell, SWT.NONE).setText("In ToolBar"); ToolBar toolbar = new ToolBar(shell, SWT.NONE); toolbar.setFont(FontAwesome.getFont(15)); ToolItem item1 = new ToolItem(toolbar, SWT.NONE); item1.setText(FontAwesome.align_left); ToolItem item2 = new ToolItem(toolbar, SWT.NONE); item2.setText(FontAwesome.align_center); ToolItem item3 = new ToolItem(toolbar, SWT.NONE); item3.setText(FontAwesome.align_right); new ToolItem(toolbar, SWT.SEPARATOR); ToolItem item4 = new ToolItem(toolbar, SWT.NONE); item4.setText(FontAwesome.quote_left); new ToolItem(toolbar, SWT.SEPARATOR); ToolItem item5 = new ToolItem(toolbar, SWT.NONE); item5.setText(FontAwesome.question); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
Example 20
Source File: FooterArea.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * Create the details section * * @param numberOfColumns */ private void createDetails(final int numberOfColumns) { final ToolItem detailsItem = new ToolItem(toolbar, SWT.NONE); detailsItem.setImage(isExpanded() ? getFewerDetailsImage() : getMoreDetailsImage()); detailsItem.setText(isExpanded() ? expandedLabelText : collapsedLabelText); final int numberOfColumnsParam = numberOfColumns; final Listener listener = new Listener() { @Override public void handleEvent(final Event event) { if (FooterArea.this.parent.getMessageArea().getException() != null) { if (detailsItem.getText().equals(expandedLabelText)) { detailsItem.setText(collapsedLabelText); detailsItem.setImage(FooterArea.this.getMoreDetailsImage()); FooterArea.this.parent.getMessageArea().hideException(); } else { detailsItem.setText(expandedLabelText); detailsItem.setImage(FooterArea.this.getFewerDetailsImage()); FooterArea.this.parent.getMessageArea().showException(); } } else { if (detailsItem.getText().equals(expandedLabelText)) { detailsItem.setText(collapsedLabelText); detailsItem.setImage(FooterArea.this.getMoreDetailsImage()); expandedPanel.dispose(); FooterArea.this.parent.pack(); } else { detailsItem.setText(expandedLabelText); detailsItem.setImage(FooterArea.this.getFewerDetailsImage()); FooterArea.this.createExpandedPanel(numberOfColumnsParam); FooterArea.this.parent.pack(); } } } }; detailsItem.addListener(SWT.Selection, listener); }