Java Code Examples for org.eclipse.swt.widgets.ToolItem#addListener()

The following examples show how to use org.eclipse.swt.widgets.ToolItem#addListener() . 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 vote down vote up
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: QueryDetailsControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createToolbar(Composite parent) {
    ToolBar toolBar = new ToolBar(parent, SWT.HORIZONTAL | SWT.LEFT | SWT.NO_FOCUS | SWT.FLAT);
    formPage.getToolkit().adapt(toolBar);

    addParameterItem = new ToolItem(toolBar, SWT.PUSH);
    addParameterItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ADD_PARAM_BUTTON_ID);
    addParameterItem.setImage(BusinessObjectPlugin.getImage("/icons/add.png"));
    addParameterItem.setToolTipText(Messages.addParameterTooltip);
    addParameterItem.addListener(SWT.Selection, e -> addParameter());

    deleteParameterItem = new ToolItem(toolBar, SWT.PUSH);
    deleteParameterItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, REMOVE_PARAM_BUTTON_ID);
    deleteParameterItem.setImage(BusinessObjectPlugin.getImage("/icons/delete_icon.png"));
    deleteParameterItem.setToolTipText(Messages.deleteParameterTooltip);
    deleteParameterItem.addListener(SWT.Selection, e -> removeParameter());
}
 
Example 3
Source File: QueryEditionControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createToolbar(Composite parent) {
    ToolBar toolBar = new ToolBar(parent, SWT.HORIZONTAL | SWT.LEFT | SWT.NO_FOCUS | SWT.FLAT);
    formPage.getToolkit().adapt(toolBar);

    ToolItem addQueryItem = new ToolItem(toolBar, SWT.PUSH);
    addQueryItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ADD_QUERY_BUTTON_ID);
    addQueryItem.setImage(BusinessObjectPlugin.getImage("/icons/add.png"));
    addQueryItem.setToolTipText(Messages.addQueryTooltip);
    addQueryItem.addListener(SWT.Selection, e -> addQuery());

    deleteQueryItem = new ToolItem(toolBar, SWT.PUSH);
    deleteQueryItem.setImage(BusinessObjectPlugin.getImage("/icons/delete_icon.png"));
    deleteQueryItem.setToolTipText(Messages.deleteQueryTooltip);
    deleteQueryItem.addListener(SWT.Selection, e -> removeQuery());

    ToolItem expandItem = new ToolItem(toolBar, SWT.PUSH);
    expandItem.setImage(Pics.getImage(PicsConstants.expandAll));
    expandItem.setToolTipText(Messages.expandAll);
    expandItem.addListener(SWT.Selection, e -> viewer.expandAll());

    ToolItem collapseItem = new ToolItem(toolBar, SWT.PUSH);
    collapseItem.setImage(Pics.getImage(PicsConstants.collapseAll));
    collapseItem.setToolTipText(Messages.collapseAll);
    collapseItem.addListener(SWT.Selection, e -> viewer.collapseAll());
}
 
Example 4
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected ToolItem createEraseToolItem(final ToolBar tb) {
    eraseControl = new ToolItem(tb, SWT.PUSH | SWT.NO_FOCUS);
    eraseControl.setImage(Pics.getImage(PicsConstants.clear));
    eraseControl.setToolTipText(Messages.eraseExpression);

    /* For test purpose */
    eraseControl.setData(SWTBOT_WIDGET_ID_KEY, SWTBOT_ID_ERASEBUTTON);
    eraseControl.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            erase(getSelectedExpression());
        }

    });

    eraseControl.addDisposeListener(disposeListener);
    return eraseControl;
}
 
Example 5
Source File: IndexControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createToolbar(Composite parent) {
    ToolBar toolBar = new ToolBar(parent, SWT.HORIZONTAL | SWT.LEFT | SWT.NO_FOCUS | SWT.FLAT);
    formPage.getToolkit().adapt(toolBar);

    ToolItem addIndexItem = new ToolItem(toolBar, SWT.PUSH);
    addIndexItem.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ADD_INDEX_BUTTON_ID);
    addIndexItem.setImage(BusinessObjectPlugin.getImage("/icons/add.png"));
    addIndexItem.setToolTipText(Messages.addIndexTooltip);
    addIndexItem.addListener(SWT.Selection, e -> addIndex());

    deleteIndexItem = new ToolItem(toolBar, SWT.PUSH);
    deleteIndexItem.setImage(BusinessObjectPlugin.getImage("/icons/delete_icon.png"));
    deleteIndexItem.setToolTipText(Messages.deleteIndexTooltip);
    deleteIndexItem.addListener(SWT.Selection, e -> removeIndex());
}
 
Example 6
Source File: CleanDeployContributionItem.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@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 7
Source File: ExploreBDMContributionItem.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@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 8
Source File: ValidateContributionItem.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@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 9
Source File: EditExpressionDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Control createHelpControl(final Composite parent) {
    helpControl = super.createHelpControl(parent);
    final ToolItem item = ((ToolBar) helpControl).getItem(0);
    final Listener[] listeners = item.getListeners(SWT.Selection);
    if (listeners.length > 0) {
        for (final Listener l : listeners) {
            item.removeListener(SWT.Selection, l);
        }
    }
    item.addListener(SWT.Selection, openTrayListener);
    helpControl.setVisible(currentExpressionEditor == null);
    return helpControl;
}
 
Example 10
Source File: BusinessDataViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void createToolItems(ToolBar toolBar) {
    ToolItem defineBdmToolItem = new ToolItem(toolBar, SWT.PUSH);
    defineBdmToolItem.setImage(BusinessObjectPlugin.getImage("/icons/manage-bdm.png"));
    defineBdmToolItem.setText(org.bonitasoft.studio.businessobject.i18n.Messages.manageBusinessDataModelTitle);
    defineBdmToolItem.addListener(SWT.Selection, e -> commandExecutor.executeCommand(DEFINE_BDM_COMMAND, null));
}
 
Example 11
Source File: SelectArtifactToDeployPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createToolbarComposite(DataBindingContext ctx, Composite parent) {
    Composite composite = new Composite(parent, SWT.INHERIT_FORCE);
    composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).extendedMargins(0, 0, 8, 0).create());
    composite.setLayoutData(
            GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).grab(true, false).create());

    Button onlyLatestProcessVersionButton = new Button(composite, SWT.CHECK);
    onlyLatestProcessVersionButton.setText(Messages.selectLatestVersion);

    ctx.bindValue(WidgetProperties.selection().observe(onlyLatestProcessVersionButton),
            PojoProperties.value("latestVersionOnly").observe(this));

    ToolBar toolBar = new ToolBar(composite, SWT.HORIZONTAL | SWT.RIGHT | SWT.NO_FOCUS | SWT.FLAT);

    new ToolItem(toolBar, SWT.SEPARATOR | SWT.VERTICAL);

    ToolItem expandAll = new ToolItem(toolBar, SWT.PUSH);
    expandAll.setImage(Pics.getImage(PicsConstants.expandAll));
    expandAll.setToolTipText(Messages.expandAll);
    expandAll.addListener(SWT.Selection, e -> fileStoreViewer.expandAll());

    ToolItem collapseAll = new ToolItem(toolBar, SWT.PUSH);
    collapseAll.setImage(Pics.getImage(PicsConstants.collapseAll));
    collapseAll.setToolTipText(Messages.collapseAll);
    collapseAll.addListener(SWT.Selection, e -> fileStoreViewer.collapseAll());
}
 
Example 12
Source File: AbstractExportContributionItem.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@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 13
Source File: AnalysisToolComposite.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 14
Source File: SearchAdvanced.java    From Rel with Apache License 2.0 5 votes vote down vote up
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 15
Source File: Sorter.java    From Rel with Apache License 2.0 5 votes vote down vote up
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 16
Source File: BarManager.java    From pmTrans with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ToolItem addItemToToolBar(ToolBar bar, String text, String toolTip,
		int type, Listener listener, Image icon) {
	ToolItem item = addItemToToolBar(bar, text, toolTip, type);

	if (listener != null)
		item.addListener(SWT.Selection, listener);
	if (icon != null)
		item.setImage(icon);

	return item;
}
 
Example 17
Source File: SearchQuick.java    From Rel with Apache License 2.0 4 votes vote down vote up
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 18
Source File: MyXViewerTest.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void createTaskActionBar(Composite parent) {

      Composite actionComp = new Composite(parent, SWT.NONE);
      actionComp.setLayout(new GridLayout());
      actionComp.setLayoutData(new GridData(GridData.END));

      ToolBar toolBar = new ToolBar(actionComp, SWT.FLAT | SWT.RIGHT);
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      toolBar.setLayoutData(gd);

      ToolItem refreshItem = new ToolItem(toolBar, SWT.PUSH);
      refreshItem.setImage(MyImageCache.getImage("refresh.gif"));
      refreshItem.setToolTipText("Refresh");
		refreshItem.addListener(SWT.Selection, e -> {
			List<Object> tasks = new ArrayList<>();
			for (int x = 0; x < 1; x++) {
				tasks.addAll(getTestTasks());
			}
			/**
			 * Note: setInputXViewer must be called instead of setInput for XViewer to
			 * operate properly
			 */
			myXviewer.setInputXViewer(tasks);
		});

      Action dropDownAction = myXviewer.getCustomizeAction();
      new ActionContributionItem(dropDownAction).fill(toolBar, 0);

      ToolItem descriptionItem = new ToolItem(toolBar, SWT.PUSH);
      descriptionItem.setImage(MyImageCache.getImage("descriptionView.gif"));
      descriptionItem.setToolTipText("Show Description View");
		descriptionItem.addListener(SWT.Selection, e -> {
			myXviewer.getCustomizeMgr().loadCustomization(MyDefaultCustomizations.getDescriptionCustomization());
			myXviewer.refresh();
		});

      ToolItem completeItem = new ToolItem(toolBar, SWT.PUSH);
      completeItem.setImage(MyImageCache.getImage("completionView.gif"));
      completeItem.setToolTipText("Show Completion View");
		completeItem.addListener(SWT.Selection, e -> {
			myXviewer.getCustomizeMgr().loadCustomization(MyDefaultCustomizations.getCompletionCustomization());
			myXviewer.refresh();
		});

      ToolItem refreshSingleColumn = new ToolItem(toolBar, SWT.PUSH);
      refreshSingleColumn.setImage(MyImageCache.getImage("columnRefresh.gif"));
      refreshSingleColumn.setToolTipText("Example of Refreshing a Single Column");
      refreshSingleColumn.addListener(SWT.Selection, e -> {
            @SuppressWarnings("unchecked")
            List<Object> items = (List<Object>) myXviewer.getInput();
            for (Object item : items) {
               SomeTask task = (SomeTask) item;
               task.setTaskType(TaskType.Refreshed);
            }

            String columnId = MyXViewerFactory.Task_Type.getId();
            myXviewer.refreshColumn(columnId);
      });

   }
 
Example 19
Source File: FooterArea.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 20
Source File: QuickLinksView.java    From BiglyBT with GNU General Public License v2.0 2 votes vote down vote up
private static void
addItem(
	BaseMDI					mdi,
	ToolBar					toolBar,
	QuickLinkItem			qli )
{
	String tt_id = qli.tt_id;
	
	ToolItem item = new ToolItem( toolBar, SWT.PUSH );
	
	if ( MessageText.keyExists( tt_id )){
	
		Messages.setLanguageTooltip( item, tt_id );
		
	}else{
		
		Utils.setTT( item,  tt_id );
	}
	
	ImageLoader imageLoader = ImageLoader.getInstance();
	
	Image image = imageLoader.getImage( qli.image_id );
	
	Image resized = imageLoader.resizeImageIfLarger(image, new Point( 15, 15 ));
	
	if ( resized == null ){
	
		item.setImage( image);
		
	}else{
		
		item.setImage( resized );
		
		item.addListener( SWT.Dispose, (ev)->{
			
			resized.dispose();
		});
	}
		
	item.addListener( SWT.Selection, ev->{
		
		if ( qli.ds_map == null ){
			
			mdi.showEntryByID( qli.mdi_id );
				
		}else{
				
			Object ds = DataSourceResolver.importDataSource( qli.ds_map );
				
			mdi.showEntryByID(	qli.mdi_id, ds );
		}
	});
	
	item.setData( "qli", qli );
}