Java Code Examples for org.eclipse.swt.widgets.ToolBar#setBackground()

The following examples show how to use org.eclipse.swt.widgets.ToolBar#setBackground() . 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: CellExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void createToolbar(final int style, final TabbedPropertySheetWidgetFactory widgetFactory) {
    toolbar = new ToolBar(control, SWT.FLAT | SWT.NO_FOCUS);
    toolbar.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).create());
    toolbar.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    final ToolItem editControl = new ToolItem(toolbar, SWT.FLAT);
    editControl.setImage(Pics.getImage(PicsConstants.edit));
    editControl.setData(SWTBOT_WIDGET_ID_KEY, SWTBOT_ID_EDITBUTTON);
    editControl.addDisposeListener(disposeListener);
    editControl.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            editDialog = CellExpressionViewer.this.createEditDialog();
            openEditDialog(editDialog);
        }
    });
}
 
Example 2
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 3
Source File: PShelfStackPresentation.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/** 
 * {@inheritDoc}
 */
@Override
public void addPart(final IPresentablePart newPart, Object cookie)
{
    ignoreSelection = true;
    final PShelfItem item = new PShelfItem(shelf,SWT.NONE);
    ignoreSelection = false;
    item.setData(DATAKEY_PART,newPart);
    
    item.getBody().setLayout(null);        
    item.getBody().addListener(SWT.Paint, new Listener()
    {        
        public void handleEvent(Event e)
        {
            Integer separatorY = (Integer)item.getBody().getData(DATAKEY_SEPHEIGHT);
            if (separatorY == null) return;
            e.gc.setForeground(border);
            e.gc.drawLine(0,separatorY.intValue(),item.getBody().getSize().x,separatorY.intValue());
        }        
    });
    
    CLabel descLabel = new CLabel(item.getBody(),SWT.WRAP);
    item.setData(DATAKEY_DESCLABEL,descLabel);
    
    descLabel.setBackground(toolbarBackground);
    
    ToolBar tb = new ToolBar(item.getBody(),SWT.NONE);
    item.setData(DATAKEY_MENUTOOL,tb);
    
    tb.setBackground(toolbarBackground);
    
    updateItem(newPart);
    
    newPart.addPropertyListener(new IPropertyListener()
    {        
        public void propertyChanged(Object source, int propId)
        {
            updateItem(newPart);
        }        
    });
}
 
Example 4
Source File: MOOSEFormEditor.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates the content used for the plant view.
 * 
 * @param section
 *            The {@code Section} that should contain the plant view.
 * @param toolkit
 *            The {@code FormToolkit} used to decorate widgets as necessary.
 */
private void populatePlantViewSection(Section section,
		FormToolkit toolkit) {
	// Get the background color to use later.
	Color background = section.getBackground();

	// Create an analysis composite to contain a ToolBar and an
	// analysis-based view.
	Composite analysisComposite = new Composite(section, SWT.NONE);
	analysisComposite.setBackground(background);
	analysisComposite.setLayout(new GridLayout(1, false));
	// Set the overall client of the plant view's Section.
	section.setClient(analysisComposite);

	// Create a ToolBarManager so we can add JFace Actions to it.
	ToolBarManager toolBarManager = new ToolBarManager(SWT.RIGHT);
	// Fill the ToolBar with customized controls.
	fillPlantViewToolBar(toolBarManager);
	toolBarManager.update(true);
	// Add it to the view.
	ToolBar toolBar = toolBarManager.createControl(analysisComposite);
	toolBar.setBackground(background);
	toolBar.setLayoutData(
			new GridData(SWT.FILL, SWT.BEGINNING, true, false));

	// Create the plant composite.
	TreeComposite components = findComponentBlock();
	factory.setTree(components);
	PlantComposite plant = factory.getPlant();
	
	//Get the factory and create a plant view from the composite
	ViewFactory viewFactory = new ViewFactory();
	viewFactory.setVizServiceFactory((BasicVizServiceFactory) VizServiceFactoryHolder.getFactory());
	plantView = viewFactory.createPlantView(plant);

	// Render the plant view in the analysis Composite.
	Composite plantComposite = plantView.createComposite(analysisComposite);
	plantComposite.setBackground(background);
	plantComposite
			.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	// Make sure the factory/plant is reset when the plant view is disposed.
	plantComposite.addDisposeListener(new DisposeListener() {
		@Override
		public void widgetDisposed(DisposeEvent e) {
			factory.setTree(new TreeComposite());
		}
	});

	return;
}
 
Example 5
Source File: JobGraph.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void addToolBar() {

    try {
      toolbar = (XulToolbar) getXulDomContainer().getDocumentRoot().getElementById( "nav-toolbar" );

      ToolBar swtToolbar = (ToolBar) toolbar.getManagedObject();
      swtToolbar.setBackground( GUIResource.getInstance().getColorDemoGray() );
      swtToolbar.pack();

      // Added 1/11/2016 to implement dropdown option for "Run"
      ToolItem runItem = new ToolItem( swtToolbar, SWT.DROP_DOWN, 0 );

      runItem.setImage( GUIResource.getInstance().getImage( "ui/images/run.svg" ) );
      runItem.setToolTipText( BaseMessages.getString( PKG, "Spoon.Tooltip.RunTranformation" ) );
      runItem.addSelectionListener( new SelectionAdapter() {

        @Override
        public void widgetSelected( SelectionEvent e ) {
          if ( e.detail == SWT.DROP_DOWN ) {
            Menu menu = new Menu( shell, SWT.POP_UP );

            MenuItem item1 = new MenuItem( menu, SWT.PUSH );
            item1.setText( BaseMessages.getString( PKG, "Spoon.Run.Run" ) );
            item1.setAccelerator( SWT.F9 );
            item1.addSelectionListener( new SelectionAdapter() {
              @Override
              public void widgetSelected( SelectionEvent e1 ) {
                runJob();
              }
            } );
            MenuItem item2 = new MenuItem( menu, SWT.PUSH );
            item2.setText( BaseMessages.getString( PKG, "Spoon.Run.RunOptions" ) );
            item2.setAccelerator( SWT.F8 );
            item2.addSelectionListener( new SelectionAdapter() {
              @Override
              public void widgetSelected( SelectionEvent e2 ) {
                runOptionsJob();
              }
            } );

            menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) );
            menu.setVisible( true );
          } else {
            runJob();
          }
        }
      } );

      // Hack alert : more XUL limitations...
      //
      ToolItem sep = new ToolItem( swtToolbar, SWT.SEPARATOR );

      zoomLabel = new Combo( swtToolbar, SWT.DROP_DOWN );
      zoomLabel.setItems( TransPainter.magnificationDescriptions );
      zoomLabel.addSelectionListener( new SelectionAdapter() {
        public void widgetSelected( SelectionEvent arg0 ) {
          readMagnification();
        }
      } );

      zoomLabel.addKeyListener( new KeyAdapter() {
        public void keyPressed( KeyEvent event ) {
          if ( event.character == SWT.CR ) {
            readMagnification();
          }
        }
      } );

      setZoomLabel();
      zoomLabel.pack();

      sep.setWidth( 80 );
      sep.setControl( zoomLabel );
      swtToolbar.pack();
    } catch ( Throwable t ) {
      log.logError( Const.getStackTracker( t ) );
      new ErrorDialog( shell,
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Title" ),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_JOB_GRAPH ),
        new Exception( t ) );
    }
  }
 
Example 6
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();
    }
  }
}