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

The following examples show how to use org.eclipse.swt.widgets.ToolItem#addSelectionListener() . 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: BonitaPreferenceDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected ToolItem createTool(final Composite composite, final Color backgroundColor, final Image image,
        final Image disableImage, final String preferencePageId) {
    final ToolBar toolBar = new ToolBar(composite, SWT.FLAT);
    final GridData gd_toolBar = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    gd_toolBar.verticalIndent = 5;
    toolBar.setLayoutData(gd_toolBar);
    toolBar.setBackground(backgroundColor);

    final ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH | SWT.CENTER);
    toolItem.setImage(image);
    toolItem.setDisabledImage(disableImage);
    if (preferencePageId != null) {
        toolItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
                openPreferencePage(preferencePageId);
            }
        });
    }
    return toolItem;
}
 
Example 2
Source File: JavaPropertiesViewerDialog.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
private void createToolBar(Composite tparent) {
	Composite toolBarCmp = new Composite(tparent, SWT.NONE);
	GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(toolBarCmp);
	GridLayoutFactory.fillDefaults().numColumns(1).applyTo(toolBarCmp);

	ToolBar toolBar = new ToolBar(toolBarCmp, SWT.NO_FOCUS | SWT.FLAT);
	ToolItem openItem = new ToolItem(toolBar, SWT.PUSH);
	openItem.setToolTipText(Messages.getString("dialog.JavaPropertiesViewerDialog.toolBar"));
	openItem.setImage(new Image(Display.getDefault(), openFilePath));

	openItem.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			openFile();
		}
	});

}
 
Example 3
Source File: ConfigureCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void fill(final ToolBar toolbar, final int index, final int iconSize) {
    final ToolItem item = new ToolItem(toolbar, SWT.PUSH);
    item.setToolTipText(Messages.ConfigureButtonLabel);
    item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_CONFIGURE_TOOLITEM);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_configure_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_configure_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_configure_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_configure_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: OpenPortalCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void fill(final ToolBar toolbar, final int index, final int iconSize) {
    final ToolItem item = new ToolItem(toolbar, SWT.PUSH);
    item.setToolTipText(Messages.OpenUserXPButtonLabel);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_portal_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_portal_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_portal_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_portal_16));
    }
    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: DefaultNavigatorContributionItem.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void fill(final ToolBar parent, int index)
{
	toolItem = new ToolItem(parent, SWT.DROP_DOWN);
	toolItem.setImage(actionProvider.getImage());
	// toolItem.setDisabledImage(actionProvider.getDisabledImage());
	// toolItem.setHotImage(actionProvider.getHotImage());
	toolItem.setToolTipText(actionProvider.getToolTip());

	toolItem.addSelectionListener(new SelectionAdapter()
	{

		@Override
		public void widgetSelected(SelectionEvent selectionEvent)
		{
			actionProvider.run(parent);
		}
	});
}
 
Example 6
Source File: SWTUtil.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a help button in the given folder.
 *
 * @param controller
 * @param folder
 * @param id
 * @param helpids
 */
public static void createHelpButton(final Controller controller,
                                    final CTabFolder folder,
                                    final String id,
                                    final Map<Composite, String> helpids) {
    ToolBar toolbar = new ToolBar(folder, SWT.FLAT);
    folder.setTopRight( toolbar, SWT.RIGHT );
    ToolItem item = new ToolItem( toolbar, SWT.PUSH );
    item.setImage(controller.getResources().getManagedImage("help.png"));  //$NON-NLS-1$
    item.setToolTipText(Resources.getMessage("General.0")); //$NON-NLS-1$
    createDisabledImage(item);
    int height = toolbar.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    folder.setTabHeight(Math.max(height, folder.getTabHeight()));
    item.addSelectionListener(new SelectionAdapter(){
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            if (helpids != null && folder.getSelectionIndex() >= 0 &&
                helpids.get(folder.getItem(folder.getSelectionIndex()).getControl()) != null) {
                controller.actionShowHelpDialog(helpids.get(folder.getItem(folder.getSelectionIndex()).getControl()));
            } else {
                controller.actionShowHelpDialog(id);
            }
        }
    });
}
 
Example 7
Source File: OpenUIDesignerCoolBarItem.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void fill(final ToolBar toolbar, final int index, final int iconSize) {
    final ToolItem item = new ToolItem(toolbar, SWT.PUSH);
    item.setToolTipText(Messages.openUIDesigner);
    configureItemImage(item, iconSize < 0 ? "ui_designer_48x48.png" : "ui_designer_24x24.png");
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            openInformationDialogOnUiDesigner();
            try {
                getHandler().execute();
            } catch (final ExecutionException ex) {
                BonitaStudioLog.error("Failed to open ui designer", ex);
            }
        }

    });
}
 
Example 8
Source File: IterationPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected ComboViewer createComboViewer(final TabbedPropertySheetWidgetFactory widgetFactory,
        final Composite composite, final ObservableListContentProviderWithProposalListeners contentProvider) {
    final ComboViewer comboViewer = new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY);

    comboViewer.setContentProvider(contentProvider);
    final IObservableSet knownElements = contentProvider.getKnownElements();
    final IObservableMap[] labelMaps = EMFObservables.observeMaps(knownElements,
            new EStructuralFeature[] { ProcessPackage.Literals.ELEMENT__NAME,
                    ProcessPackage.Literals.DATA__DATA_TYPE, ProcessPackage.Literals.DATA__MULTIPLE });
    comboViewer.setLabelProvider(new DataLabelProvider(labelMaps));

    final ToolBar toolBar = new ToolBar(composite, SWT.FLAT);
    widgetFactory.adapt(toolBar);
    final ToolItem toolItem = new ToolItem(toolBar, SWT.FLAT);
    toolItem.setImage(Pics.getImage(PicsConstants.clear));
    toolItem.setToolTipText(Messages.clearSelection);
    toolItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            comboViewer.setSelection(new StructuredSelection());
        }
    });

    return comboViewer;
}
 
Example 9
Source File: WelcomeCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void fill(final ToolBar toolbar, final int index, final int iconSize) {
    final ToolItem item = new ToolItem(toolbar, SWT.PUSH | SWT.RIGHT);
    item.setToolTipText(Messages.WelcomeButtonLabel);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_welcome_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_welcome_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_welcome_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_welcome_disabled_16));
    }
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            try {
                handler.execute(new ExecutionEvent());
            } catch (final ExecutionException e1) {
                BonitaStudioLog.error(e1);
            }
        }
    });

}
 
Example 10
Source File: ExpressionBuilder.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private ToolItem createToolItem( ToolBar toolBar, final int operationType )
{
	final ToolItem item = new ToolItem( toolBar, SWT.NONE );
	toolItemType.put( item, operationType );
	item.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent e )
		{
			sourceViewer.doOperation( operationType );
			updateToolItems( );
		}
	} );
	return item;
}
 
Example 11
Source File: FindBarOption.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ToolItem createToolItem(ToolBar optionsToolBar)
{
	if (!canCreateItem())
	{
		return null;
	}
	ToolItem item = isCheckable() ? new ToolItem(optionsToolBar, SWT.CHECK)
			: new ToolItem(optionsToolBar, SWT.PUSH);

	item.setImage(FindBarPlugin.getImage(this.image));
	if (imageDisabled != null)
	{
		item.setDisabledImage(FindBarPlugin.getImage(this.imageDisabled));
	}
	item.setToolTipText(this.initialText);
	if (preferencesKey != null)
	{
		IPreferenceStore preferenceStore = FindBarPlugin.getDefault().getPreferenceStore();
		item.setSelection(preferenceStore.getBoolean(preferencesKey));
	}
	item.addSelectionListener(this);
	if (!this.initiallyEnabled)
	{
		item.setEnabled(false);
	}
	setToolItemInDecorator(item);
	return item;
}
 
Example 12
Source File: GamaToolbarSimple.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private ToolItem create(final String i, final String text, final String tip, final SelectionListener listener,
		final int style) {
	final ToolItem button = new ToolItem(this, style, getItems().length);
	if (tip != null) {
		button.setToolTipText(tip);
	}
	if (i != null) {
		final Image image = GamaIcons.create(i).image();
		button.setImage(image);
	}
	if (listener != null) {
		button.addSelectionListener(listener);
	}
	return button;
}
 
Example 13
Source File: SaveCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@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 14
Source File: DataWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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 15
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, SelectionAdapter listener, Image icon) {
	ToolItem item = addItemToToolBar(bar, text, toolTip, type);

	if (listener != null)
		item.addSelectionListener(listener);
	if (icon != null)
		item.setImage(icon);

	return item;
}
 
Example 16
Source File: AbstractDefinitionWizardDialog.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
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 17
Source File: TreeToolbar.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
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 );
}
 
Example 18
Source File: NewCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void fill(final ToolBar toolbar, final int index, final int iconSize) {
    final ToolItem item = new ToolItem(toolbar, SWT.DROP_DOWN);
    item.setToolTipText(Messages.NewButtonTooltip);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_new_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_new_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_new_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_new_disabled_16));
    }
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (isEnabled()) {
                final DropdownSelectionListener listener = new DropdownSelectionListener(item);
                listener.add("org.bonitasoft.studio.organization.manage", Messages.organization);
                listener.addSeparator();

                boolean hasNewBDM = RepositoryManager.getInstance()
                        .getRepositoryStore(BusinessObjectModelRepositoryStore.class)
                        .getChild(BusinessObjectModelFileStore.BOM_FILENAME, true) == null;
                if (hasNewBDM) {
                    hasNewBDM = listener.add("org.bonitasoft.studio.businessobject.define",
                            Messages.businessDataModel);
                }
                boolean hasNewBDMAccess = RepositoryManager.getInstance()
                        .getRepositoryStore(BusinessObjectModelRepositoryStore.class)
                        .getChild("bdm_access_control.xml", true) == null;
                if (hasNewBDMAccess) {
                    hasNewBDMAccess = listener.add(
                            "org.bonitasoft.studio.bdm.access.control.command.definebdmaccesscontrol",
                            Messages.bdmAccessControl);
                }
                if (hasNewBDM || hasNewBDMAccess) {
                    listener.addSeparator();
                }
                if (listener.add("org.bonitasoft.studio.customProfile.newFile.command", Messages.profile)) {
                    listener.addSeparator();
                }
                listener.add("org.bonitasoft.studio.la.new.command", Messages.applicationDescriptor);
                listener.addSeparator();
                listener.add(NEW_DIAGRAM_CMD_ID, null);
                listener.addSeparator();
                listener.add("org.bonitasoft.studio.designer.command.create.page", Messages.applicationPage);
                listener.add("org.bonitasoft.studio.designer.command.create.layout", Messages.layout);
                listener.add("org.bonitasoft.studio.designer.command.create.widget", Messages.customWidget);
                listener.add("org.bonitasoft.studio.application.ex.command.createFragment", Messages.fragment);
                listener.addSeparator();
                if (listener.add("org.bonitasoft.studio.rest.api.extension.newCommand", Messages.restAPIExtension)) {
                    listener.addSeparator();
                }
                if (listener.add("org.bonitasoft.studio.theme.newCommand", Messages.theme)) {
                    listener.addSeparator();
                }
                listener.add("org.bonitasoft.studio.connectors.newDefinition", Messages.connectorDef);
                listener.add("org.bonitasoft.studio.connectors.newImplementation", Messages.connectorImpl);
                listener.addSeparator();
                listener.add("org.bonitasoft.studio.actors.newFilterDef", Messages.actorFilterDef);
                listener.add("org.bonitasoft.studio.actors.newFilterImpl", Messages.actorFilterImpl);
                listener.addSeparator();
                listener.add("org.bonitasoft.studio.groovy.ui.newScript", Messages.newGroovy);
                listener.widgetSelected(e);
            }
        }

    });

}
 
Example 19
Source File: AttachManager.java    From http4e with Apache License 2.0 4 votes vote down vote up
AttachManager( final ItemModel model, final StyledText swtText, final ToolBar toolbar) {
//      this.swtText = swtText;
      this.toolBar = toolbar;

      Open open = new Open(model, swtText);
      
      i_open = new ToolItem(toolBar, SWT.PUSH);
      i_open.setImage(ResourceUtils.getImage(CoreConstants.PLUGIN_CORE, CoreImages.FILE_OPEN));
      i_open.setDisabledImage(ResourceUtils.getImage(CoreConstants.PLUGIN_CORE, CoreImages.FILE_OPEN_DIS));
      i_open.setToolTipText("Add File");
      i_open.addSelectionListener(open);
//      i_open.addSelectionListener(new SelectionAdapter() {
//         public void widgetSelected( SelectionEvent e){
//         }
//      });
      
//      // Menu(bar)
//      menu = new Menu(toolBar.getShell(), SWT.POP_UP);
//
//      MenuItem m_addBody = new MenuItem(menu, SWT.PUSH);
//      m_addBody.setText("Add File");
//      m_addBody.addSelectionListener(open);
//      m_attachPart = new MenuItem(menu, SWT.PUSH);
//      m_attachPart.setText("Attach File");
//      m_attachPart.addSelectionListener(open);
//
//      addBody = new ToolItem(toolBar, SWT.DROP_DOWN);
//      addBody.setImage(ResourceUtils.getImage(CoreImages.ATTACH));
//      addBody.setToolTipText("Add Body");
//      addBody.addListener(SWT.Selection, new Listener() {
//         public void handleEvent( Event event){
//            if (event.detail == SWT.ARROW) {
//               Rectangle rect = addBody.getBounds();
//               menu.setLocation(toolBar.toDisplay(rect.x, rect.y + rect.height));
//               menu.setVisible(true);
//            } else {
//               FileDialog fd = new FileDialog(toolBar.getShell(), SWT.OPEN);
//               fd.setText("Open");
//               // fd.setFilterPath("C:/");
//               fd.setFilterExtensions(CoreConstants.FILE_FILTER_EXT);
//               String file = fd.open();
//               if (file != null) {
//                  fileReadAction(file);
//               }
//            }
//         }
//      });
   }
 
Example 20
Source File: TreeToolbar.java    From hop with Apache License 2.0 4 votes vote down vote up
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 pipeline (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 );
}