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

The following examples show how to use org.eclipse.swt.widgets.ToolBar#pack() . 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: HopGui.java    From hop with Apache License 2.0 6 votes vote down vote up
protected void addPerspectivesToolbar() {
  // We can't mix horizontal and vertical toolbars so we need to add a composite.
  //
  shell.setLayout( new FormLayout() );
  mainHopGuiComposite = new Composite( shell, SWT.NO_BACKGROUND );
  mainHopGuiComposite.setLayout( new FormLayout() );
  FormData formData = new FormData();
  formData.left = new FormAttachment( 0, 0 );
  formData.right = new FormAttachment( 100, 0 );
  formData.top = new FormAttachment( mainToolbar, 0 );
  formData.bottom = new FormAttachment( 100, 0 );
  mainHopGuiComposite.setLayoutData( formData );

  perspectivesToolbar = new ToolBar( mainHopGuiComposite, SWT.WRAP | SWT.RIGHT | SWT.VERTICAL );
  props.setLook( perspectivesToolbar, PropsUi.WIDGET_STYLE_TOOLBAR );
  FormData fdToolBar = new FormData();
  fdToolBar.left = new FormAttachment( 0, 0 );
  fdToolBar.top = new FormAttachment( 0, 0 );
  fdToolBar.bottom = new FormAttachment( 100, 0 );
  perspectivesToolbar.setLayoutData( fdToolBar );

  perspectivesToolbarWidgets = new GuiToolbarWidgets();
  perspectivesToolbarWidgets.registerGuiPluginObject( this );
  perspectivesToolbarWidgets.createToolbarWidgets( perspectivesToolbar, GUI_PLUGIN_PERSPECTIVES_PARENT_ID );
  perspectivesToolbar.pack();
}
 
Example 2
Source File: HopGuiPipelineGraph.java    From hop with Apache License 2.0 6 votes vote down vote up
private void addToolBar() {

    try {
      // Create a new toolbar at the top of the main composite...
      //
      toolBar = new ToolBar( this, SWT.WRAP | SWT.LEFT | SWT.HORIZONTAL );
      toolBarWidgets = new GuiToolbarWidgets();
      toolBarWidgets.registerGuiPluginObject( this );
      toolBarWidgets.createToolbarWidgets( toolBar, GUI_PLUGIN_TOOLBAR_PARENT_ID );
      FormData layoutData = new FormData();
      layoutData.left = new FormAttachment( 0, 0 );
      layoutData.top = new FormAttachment( 0, 0 );
      layoutData.right = new FormAttachment( 100, 0 );
      toolBar.setLayoutData( layoutData );
      toolBar.pack();

      // enable / disable the icons in the toolbar too.
      //
      updateGui();

    } catch ( Throwable t ) {
      log.logError( "Error setting up the navigation toolbar for HopUI", t );
      new ErrorDialog( hopShell(), "Error", "Error setting up the navigation toolbar for HopGUI", new Exception( t ) );
    }
  }
 
Example 3
Source File: HopGuiWorkflowGraph.java    From hop with Apache License 2.0 6 votes vote down vote up
private void addToolBar() {

    try {
      // Create a new toolbar at the top of the main composite...
      //
      toolBar = new ToolBar( this, SWT.WRAP | SWT.LEFT | SWT.HORIZONTAL );
      toolBarWidgets = new GuiToolbarWidgets();
      toolBarWidgets.registerGuiPluginObject( this );
      toolBarWidgets.createToolbarWidgets( toolBar, GUI_PLUGIN_TOOLBAR_PARENT_ID );
      FormData layoutData = new FormData();
      layoutData.left = new FormAttachment( 0, 0 );
      layoutData.top = new FormAttachment( 0, 0 );
      layoutData.right = new FormAttachment( 100, 0 );
      toolBar.setLayoutData( layoutData );
      toolBar.pack();

      // enable / disable the icons in the toolbar too.
      //
      updateGui();

    } catch ( Throwable t ) {
      log.logError( "Error setting up the navigation toolbar for HopUI", t );
      new ErrorDialog( hopShell(), "Error", "Error setting up the navigation toolbar for HopGUI", new Exception( t ) );
    }
  }
 
Example 4
Source File: MainToolBar.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param parent
 * @param controller
 */
public MainToolBar(final Shell parent, final Controller controller, List<MainMenuItem> items) {
    super(controller);
    toolbar = new ToolBar(parent, SWT.FLAT);
    toolbar.setLayoutData(SWTUtil.createFillHorizontallyGridData());

    // Create items
    this.createItems(toolbar, items, ""); //$NON-NLS-1$
    this.createLabels();

    // Pack
    toolbar.pack();
    
    // Initialize
    this.update(new ModelEvent(this, ModelPart.MODEL, null));
    
}
 
Example 5
Source File: HopGui.java    From hop with Apache License 2.0 5 votes vote down vote up
protected void addMainToolbar() {
  mainToolbar = new ToolBar( shell, SWT.WRAP | SWT.LEFT | SWT.HORIZONTAL );
  FormData fdToolBar = new FormData();
  fdToolBar.left = new FormAttachment( 0, 0 );
  fdToolBar.top = new FormAttachment( 0, 0 );
  fdToolBar.right = new FormAttachment( 100, 0 );
  mainToolbar.setLayoutData( fdToolBar );
  props.setLook( mainToolbar, Props.WIDGET_STYLE_TOOLBAR );

  mainToolbarWidgets = new GuiToolbarWidgets();
  mainToolbarWidgets.registerGuiPluginObject( this );
  mainToolbarWidgets.createToolbarWidgets( mainToolbar, ID_MAIN_TOOLBAR );
  mainToolbar.pack();
}
 
Example 6
Source File: HopGuiPipelineLogDelegate.java    From hop with Apache License 2.0 5 votes vote down vote up
private void addToolBar() {
  toolbar = new ToolBar( pipelineLogComposite, SWT.BORDER | SWT.WRAP | SWT.SHADOW_OUT | SWT.LEFT | SWT.HORIZONTAL );
  FormData fdToolBar = new FormData();
  fdToolBar.left = new FormAttachment( 0, 0 );
  fdToolBar.top = new FormAttachment( 0, 0 );
  fdToolBar.right = new FormAttachment( 100, 0 );
  toolbar.setLayoutData( fdToolBar );
  hopGui.getProps().setLook( toolbar, Props.WIDGET_STYLE_TOOLBAR );

  toolBarWidgets = new GuiToolbarWidgets();
  toolBarWidgets.registerGuiPluginObject( this );
  toolBarWidgets.createToolbarWidgets( toolbar, GUI_PLUGIN_TOOLBAR_PARENT_ID );
  toolbar.pack();
}
 
Example 7
Source File: HopGuiPipelineGridDelegate.java    From hop with Apache License 2.0 5 votes vote down vote up
private void addToolBar() {

    toolbar = new ToolBar( pipelineGridComposite, SWT.BORDER | SWT.WRAP | SWT.SHADOW_OUT | SWT.LEFT | SWT.HORIZONTAL );
    FormData fdToolBar = new FormData();
    fdToolBar.left = new FormAttachment( 0, 0 );
    fdToolBar.top = new FormAttachment( 0, 0 );
    fdToolBar.right = new FormAttachment( 100, 0 );
    toolbar.setLayoutData( fdToolBar );
    hopGui.getProps().setLook( toolbar, Props.WIDGET_STYLE_TOOLBAR );

    toolbarWidget = new GuiToolbarWidgets();
    toolbarWidget.registerGuiPluginObject( this );
    toolbarWidget.createToolbarWidgets( toolbar, GUI_PLUGIN_TOOLBAR_PARENT_ID );
    toolbar.pack();
  }
 
Example 8
Source File: HopGuiWorkflowLogDelegate.java    From hop with Apache License 2.0 5 votes vote down vote up
private void addToolBar() {
  toolbar = new ToolBar( jobLogComposite, SWT.BORDER | SWT.WRAP | SWT.SHADOW_OUT | SWT.LEFT | SWT.HORIZONTAL );
  FormData fdToolBar = new FormData();
  fdToolBar.left = new FormAttachment( 0, 0 );
  fdToolBar.top = new FormAttachment( 0, 0 );
  fdToolBar.right = new FormAttachment( 100, 0 );
  toolbar.setLayoutData( fdToolBar );
  hopGui.getProps().setLook( toolbar, Props.WIDGET_STYLE_TOOLBAR );

  toolBarWidgets = new GuiToolbarWidgets();
  toolBarWidgets.registerGuiPluginObject( this );
  toolBarWidgets.createToolbarWidgets( toolbar, GUI_PLUGIN_TOOLBAR_PARENT_ID );
  toolbar.pack();
}
 
Example 9
Source File: FileViewerWindow.java    From AppleCommander with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the toolbar.
 */
private void createToolBar(Composite composite, Object layoutData) {
	toolBar = new ToolBar(composite, SWT.FLAT);
	toolBar.addListener(SWT.KeyUp, createToolbarCommandHandler());
	if (layoutData != null) toolBar.setLayoutData(layoutData);
	
	if (nativeFilter != null) {
		nativeFilterAdapter = (FilterAdapter) nativeFilterAdapterMap.get(nativeFilter.getClass());
		if (nativeFilterAdapter != null) {
			nativeToolItem = nativeFilterAdapter.create(toolBar);
			nativeToolItem.setSelection(true);
		} 
	}
	hexDumpToolItem = createHexDumpToolItem();
	if (nativeFilterAdapter == null) {
		// Default button changes for these instances.
		hexDumpToolItem.setSelection(true);
		// Prevent NullPointerExceptions if the nativeFilterAdapter does not apply.
		nativeFilterAdapter = hexFilterAdapter;
	}
	rawDumpToolItem = createRawDumpToolItem();
	new ToolItem(toolBar, SWT.SEPARATOR);
	copyToolItem = createCopyToolItem();
	new ToolItem(toolBar, SWT.SEPARATOR);
	createPrintToolItem();
	toolBar.pack();
}
 
Example 10
Source File: EigenartikelDetailDisplay.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @wbp.parser.entryPoint
 */
@Override
public Composite createDisplay(Composite parent, IViewSite site){
	this.site = site;
	
	container = new Composite(parent, SWT.NONE);
	// 		parent.setLayoutData(new GridData(GridData.FILL_BOTH));
		layout = new StackLayout();
		container.setLayout(layout);
	
	compProduct = new Composite(container, SWT.None);		
	compProduct.setLayout(new GridLayout(1, false));
	
	ToolBar toolBar = new ToolBar(compProduct, SWT.BORDER | SWT.FLAT | SWT.RIGHT);
	toolBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	final ToolBarManager manager = new ToolBarManager(toolBar);
	manager.add(createAction);
	if (LocalLockServiceHolder.get().getStatus() != Status.STANDALONE) {
		manager.add(toggleLockAction);
	}
	manager.add(deleteAction);
	manager.update(true);
	toolBar.pack();
	
	epc = new EigenartikelProductComposite(compProduct, SWT.None);
	epc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	epc.setUnlocked(LocalLockServiceHolder.get().getStatus() == Status.STANDALONE);
	
	compArticle = new Composite(container, SWT.None);		
	compArticle.setLayout(new GridLayout(1, false));
	
	ec = new EigenartikelComposite(compArticle, SWT.None, false, null);
	ec.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	ec.setUnlocked(LocalLockServiceHolder.get().getStatus() == Status.STANDALONE);
	
	layout.topControl = compProduct;
	container.layout();
	
	return container;
}
 
Example 11
Source File: SearchText.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createActionMenu(Composite composite) {
	ToolBar toolBar = new ToolBar(composite, SWT.NONE);
	ToolBarManager manager = new ToolBarManager(toolBar);
	action = new DropDownAction();
	manager.add(action);
	manager.update(true);
	toolBar.pack();
}
 
Example 12
Source File: TransPreviewDelegate.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void addToolBar() {

    try {
      XulLoader loader = new KettleXulLoader();
      loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
      ResourceBundle bundle = GlobalMessages.getBundle( "org/pentaho/di/ui/spoon/messages/messages" );
      XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_TRANS_PREVIEW_TOOLBAR, bundle );
      xulDomContainer.addEventHandler( this );
      toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "nav-toolbar" );
      ToolBar swtToolBar = (ToolBar) toolbar.getManagedObject();
      spoon.props.setLook( swtToolBar, Props.WIDGET_STYLE_TOOLBAR );
      swtToolBar.layout( true, true );
      swtToolBar.pack();

      firstRadio = (SwtRadio) xulDomContainer.getDocumentRoot().getElementById( "preview-first" );
      lastRadio = (SwtRadio) xulDomContainer.getDocumentRoot().getElementById( "preview-last" );
      offRadio = (SwtRadio) xulDomContainer.getDocumentRoot().getElementById( "preview-off" );

      PropsUI.getInstance().setLook( (Control) firstRadio.getManagedObject(), Props.WIDGET_STYLE_TOOLBAR );
      PropsUI.getInstance().setLook( (Control) lastRadio.getManagedObject(), Props.WIDGET_STYLE_TOOLBAR );
      PropsUI.getInstance().setLook( (Control) offRadio.getManagedObject(), Props.WIDGET_STYLE_TOOLBAR );

    } catch ( Throwable t ) {
      log.logError( toString(), Const.getStackTracker( t ) );
      new ErrorDialog( transPreviewComposite.getShell(),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Title" ),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_TRANS_PREVIEW_TOOLBAR ),
        new Exception( t ) );
    }
  }
 
Example 13
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 ) );
    }
  }