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

The following examples show how to use org.eclipse.swt.widgets.ToolItem#setDisabledImage() . 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: ExportBarCoolbarItem.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.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_EXPORT_TOOLITEM);
    item.setToolTipText(Messages.ExportButtonLabel);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_export_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_export_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_export_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_export_disabled_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 2
Source File: PasteCoolbarItem.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) {
    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 3
Source File: CopyCoolbarItem.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) {
    item = new ToolItem(toolbar, SWT.PUSH);
    item.setToolTipText(Messages.CopyButtonLabel);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_copy_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_copy_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_copy_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_copy_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: HelpCoolbarItem.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.HelpButtonLabel);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_help_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_help_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_help_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_help_disabled_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: PreferenceCoolbarItem.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.PreferencesButtonLabel);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_preferences_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_preferences_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_preferences_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_preferences_disabled_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 6
Source File: ImportBarCoolbarItem.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.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_IMPORT_TOOLITEM);
    item.setToolTipText(Messages.ImportProcessButtonLabel);
    if (iconSize < 0) {
        item.setImage(Pics.getImage(PicsConstants.coolbar_import_48));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_import_disabled_48));
    } else {
        item.setImage(Pics.getImage(PicsConstants.coolbar_import_16));
        item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_import_disabled_16));
    }
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
                ECommandService eCommandService = PlatformUI.getWorkbench().getService(ECommandService.class);
                EHandlerService eHandlerService = PlatformUI.getWorkbench().getService(EHandlerService.class);
                ParameterizedCommand importCommand = ParameterizedCommand.generateCommand(
                        eCommandService.getCommand("org.bonitasoft.studio.importer.bos.command"), null);
                eHandlerService.executeHandler(importCommand);
        }
    });

}
 
Example 7
Source File: RunCoolbarItem.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.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 8
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 9
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 10
Source File: TypeSelectionComponent.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createViewMenu(Composite parent) {
	fToolBar= new ToolBar(parent, SWT.FLAT);
	fToolItem= new ToolItem(fToolBar, SWT.PUSH, 0);

	GridData data= new GridData();
	data.horizontalAlignment= GridData.END;
	fToolBar.setLayoutData(data);

	fToolItem.setImage(JavaPluginImages.get(JavaPluginImages.IMG_ELCL_VIEW_MENU));
	fToolItem.setDisabledImage(JavaPluginImages.get(JavaPluginImages.IMG_DLCL_VIEW_MENU));
	fToolItem.setToolTipText(JavaUIMessages.TypeSelectionComponent_menu);
	fToolItem.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			showViewMenu();
		}
	});
	
	fMenuManager= new MenuManager();
	fillViewMenu(fMenuManager);

	// ICommandService commandService= (ICommandService)PlatformUI.getWorkbench().getAdapter(ICommandService.class);
	// IHandlerService handlerService= (IHandlerService)PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
}
 
Example 11
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 12
Source File: GamaToolbar2.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
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 13
Source File: XFindPanel.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
protected ToolItem createSettingsMenu(final ToolBar bar) {
    bSettings = new ToolItem(bar, SWT.PUSH);
    bSettings.setImage(JFaceResources.getImage(PopupDialog.POPUP_IMG_MENU));
    bSettings.setDisabledImage(JFaceResources.getImage(PopupDialog.POPUP_IMG_MENU_DISABLED));
    bSettings.setToolTipText(Messages.XFindPanel_ShowSettings_tooltip); //$NON-NLS-1$
    bSettings.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            showSettings();
        }
    });
    return bSettings;
}
 
Example 14
Source File: ParamsAttachManager.java    From http4e with Apache License 2.0 5 votes vote down vote up
ParamsAttachManager( final ItemModel model, final StyledText styledText, final ToolBar toolbar) {
   // this.swtText = swtText;
   this.toolBar = toolbar;

   ParamsOpen open = new ParamsOpen(this, model, styledText);

   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);
}
 
Example 15
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 16
Source File: ShowHelpDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
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 17
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 );
}
 
Example 18
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 19
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 20
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);
//               }
//            }
//         }
//      });
   }