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

The following examples show how to use org.eclipse.swt.widgets.ToolBar#setLayoutData() . 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: WebBrowserViewer.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void createNavigationBar(Composite parent)
{
	toolBarManager = new ToolBarManager(SWT.FLAT);
	toolBarManager.add(consoleAction);
	toolBarManager.add(backAction);
	toolBarManager.add(forwardAction);
	toolBarManager.add(stopAction);
	toolBarManager.add(refreshAction);
	ToolBar toolbar = toolBarManager.createControl(parent);
	toolbar.setLayoutData(GridDataFactory.fillDefaults().create());

	urlCombo = new Combo(parent, SWT.DROP_DOWN);
	urlCombo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
	urlCombo.addListener(SWT.DefaultSelection, new Listener() {
		
		@Override
		public void handleEvent(Event e) {
			setURL(urlCombo.getText());
		}
	});

	ToolBarManager toolBarManager2 = new ToolBarManager(SWT.FLAT);
	toolBarManager2.add(goAction);
	toolbar = toolBarManager2.createControl(parent);
	toolbar.setLayoutData(GridDataFactory.fillDefaults().create());
}
 
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: WebBrowserViewer4Mac.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void createNavigationBar(Composite parent) {
	toolBarManager = new ToolBarManager(SWT.FLAT);
	// toolBarManager.add(consoleAction);
	toolBarManager.add(backAction);
	toolBarManager.add(forwardAction);
	toolBarManager.add(stopAction);
	toolBarManager.add(refreshAction);
	ToolBar toolbar = toolBarManager.createControl(parent);
	toolbar.setLayoutData(GridDataFactory.fillDefaults().create());

	urlCombo = new Combo(parent, SWT.DROP_DOWN);
	urlCombo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false)
			.create());

	urlCombo.addListener(SWT.DefaultSelection, new Listener() {
		public void handleEvent(Event e) {
			setURL(urlCombo.getText());
		}
	});

	ToolBarManager toolBarManager2 = new ToolBarManager(SWT.FLAT);
	toolBarManager2.add(goAction);
	toolbar = toolBarManager2.createControl(parent);
	toolbar.setLayoutData(GridDataFactory.fillDefaults().create());
}
 
Example 4
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 5
Source File: CustomToolItem.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void createControl(Composite parent, CoolbarSize size) {
    if (contributionItem instanceof SeparatorCoolbarItem) {
        Label separator = new Label(parent, SWT.SEPARATOR);
        separator.setLayoutData(GridDataFactory.fillDefaults()
                .hint(SWT.DEFAULT, size == CoolbarSize.SMALL ? ICON_SIZE : SWT.DEFAULT).create());
    } else {
        Composite container = new Composite(parent, SWT.NONE);
        container.setLayoutData(GridDataFactory.swtDefaults().create());
        container.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 3)
                .extendedMargins(0, 0, 0, size != CoolbarSize.SMALL ? 5 : 0).create());
        ToolBar tb = new ToolBar(container, SWT.FLAT | SWT.HORIZONTAL);
        tb.setLayoutData(GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.FILL).grab(true, true).create());
        contributionItem.fill(tb, -1, size == CoolbarSize.SMALL ? ICON_SIZE : -1);
        toolItem = tb.getItem(0);
        if (size != CoolbarSize.SMALL) {
            text = new Label(container, SWT.CENTER);
            text.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
            text.setText(contributionItem.getText());
        }
        update();
    }
}
 
Example 6
Source File: GraphNodeViewer.java    From depan with Apache License 2.0 6 votes vote down vote up
private Composite setupOptions(Composite parent) {
  Composite result = new Composite(parent, SWT.NONE);
  GridLayout layout = Widgets.buildContainerLayout(1);

  Composite leftCmds = createCommands(result);
  if (null != leftCmds) {
    leftCmds.setLayoutData(Widgets.buildHorzFillData());
    layout.numColumns = 2;
  }
  result.setLayout(layout);

  ToolBar rightOptions = createToolBar(result);
  rightOptions.setLayoutData(Widgets.buildTrailFillData());

  return result;
}
 
Example 7
Source File: DbTabContentConversion.java    From Rel with Apache License 2.0 5 votes vote down vote up
public DbTabContentConversion(DbTab parentTab, String message, String dbDir, Composite contentParent) {
	super(contentParent, SWT.None);
	setLayout(new FormLayout());

	ToolBar toolBar = new ToolBar(this, SWT.None);
	FormData fd_toolBar = new FormData();
	fd_toolBar.left = new FormAttachment(0);
	fd_toolBar.top = new FormAttachment(0);
	fd_toolBar.right = new FormAttachment(100);
	toolBar.setLayoutData(fd_toolBar);
	
	conversion = new ConversionPanel(this, parentTab, message, dbDir, SWT.None);
	FormData fd_composite = new FormData();
	fd_composite.left = new FormAttachment(0);
	fd_composite.top = new FormAttachment(toolBar);
	fd_composite.right = new FormAttachment(100);
	fd_composite.bottom = new FormAttachment(100);
	conversion.setLayoutData(fd_composite);
	
	setupIcons();
	
	preferenceChangeListener = new PreferenceChangeAdapter("DbTabContentConversion") {
		@Override
		public void preferenceChange(PreferenceChangeEvent evt) {
			setupIcons();
		}
	};		
	Preferences.addPreferenceChangeListener(PreferencePageGeneral.LARGE_ICONS, preferenceChangeListener);
}
 
Example 8
Source File: SearchAdvanced.java    From Rel with Apache License 2.0 5 votes vote down vote up
public SearchAdvanced(FilterSorter filterSorter, Composite contentPanel) {
	super(contentPanel, SWT.NONE);
	
	this.filterSorter = filterSorter;
	
	GridLayout layout = new GridLayout(2, false);
	layout.horizontalSpacing = 0;
	layout.verticalSpacing = 0;
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	setLayout(layout);

	filterSpec = new Label(this, SWT.NONE);
	filterSpec.setText(emptyFilterPrompt);
	filterSpec.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
	
	filterSpec.addListener(SWT.MouseUp, e -> popup());		
	
	ToolBar toolBar = new ToolBar(this, SWT.NONE);
	
	ToolItem clear = new ToolItem(toolBar, SWT.PUSH);
	clear.addListener(SWT.Selection, e -> {
		filterSpec.setText(emptyFilterPrompt);
		filterSorter.refresh();
	});
	clear.setText("Clear");
	
	toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	
	this.addListener(SWT.Show, e -> {
		if (filterSpec.getText().equals(emptyFilterPrompt))
			popup();
	});
	
	constructPopup();
}
 
Example 9
Source File: TreeCompoundTask.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the compound task's title area.
 * 
 * @param parent
 *            the SWT parent for the title area composite.
 * @return the created title area composite.
 */
protected Composite createTitleArea( Composite parent )
{
	Composite cmpTitle = new Composite( parent, SWT.NONE );
	GridLayout layout = new GridLayout( 2, false );
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	cmpTitle.setLayout( layout );

	GridData gridData = new GridData( GridData.FILL_BOTH );
	cmpTitle.setLayoutData( gridData );

	Label label = new Label( cmpTitle, SWT.NONE );
	{
		label.setFont( JFaceResources.getBannerFont( ) );
		label.setText( getTitleAreaString( ) );
	}

	if ( needHistory )
	{
		ToolBar historyBar = new ToolBar( cmpTitle, SWT.HORIZONTAL
				| SWT.FLAT );
		{
			GridData gd = new GridData( );
			gd.horizontalAlignment = SWT.END;
			historyBar.setLayoutData( gd );
			ToolBarManager historyManager = new ToolBarManager( historyBar );
			history.createHistoryControls( historyBar, historyManager );
			historyManager.update( false );
		}
	}
	else
	{
		new Label( cmpTitle, SWT.NONE );
	}
	return cmpTitle;
}
 
Example 10
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 11
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 12
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 13
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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());
    editControl = createEditToolItem(toolbar);
    if (withConnector) {
        createToolBarExtension(toolbar);
    }
    createEraseToolItem(toolbar);
    if (widgetFactory != null) {
        widgetFactory.adapt(toolbar, true, true);
    }
}
 
Example 14
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 15
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 16
Source File: MakrosComposite.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create the composite.
 * 
 * @param parent
 * @param style
 */
public MakrosComposite(Composite parent, int style){
	super(parent, style);
	setLayout(new GridLayout(1, false));
	
	CLabel lblHeader = new CLabel(this, SWT.NONE);
	lblHeader.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
	lblHeader.setText("Makros des Anwender " + CoreHub.getLoggedInContact().getLabel());

	
	SashForm sash = new SashForm(this, SWT.HORIZONTAL);
	sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	
	Composite selectionComposite = new Composite(sash, SWT.NONE);
	selectionComposite.setLayout(new GridLayout(1, true));
	ToolBarManager toolbar = new ToolBarManager();
	ToolBar toolbarControl = toolbar.createControl(selectionComposite);
	toolbarControl.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
	
	viewer = new TableViewer(selectionComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
	viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	viewer.setContentProvider(new ArrayContentProvider());
	viewer.setLabelProvider(new DefaultLabelProvider());
	viewer.setInput(getUserMakros(CoreHub.getLoggedInContact()));
	viewer.addSelectionChangedListener(new ISelectionChangedListener() {
		@Override
		public void selectionChanged(SelectionChangedEvent event){
			StructuredSelection selection = (StructuredSelection) viewer.getSelection();
			if (selection != null && !selection.isEmpty()) {
				detailComposite.setMakro((MakroDTO) selection.getFirstElement());
			} else {
				detailComposite.setMakro(null);
			}
		}
	});
	viewer.setComparator(new ViewerComparator());
	
	MenuManager menuManager = new MenuManager();
	menuManager.add(new RemoveMakroAction(viewer));
	MenuManager subMenu = new MenuManager("Marko zu Anwender kopieren");
	subMenu.setRemoveAllWhenShown(true);
	subMenu.addMenuListener(new IMenuListener() {
		@Override
		public void menuAboutToShow(IMenuManager manager){
			addCopyToUserActions(manager);
		}
	});
	menuManager.add(subMenu);
	
	Menu menu = menuManager.createContextMenu(viewer.getTable());
	viewer.getTable().setMenu(menu);
	
	toolbar.add(new AddMakroAction(viewer));
	toolbar.add(new RemoveMakroAction(viewer));
	toolbar.add(new RefreshMakrosAction(viewer));
	toolbar.update(true);
	
	detailComposite = new MakroDetailComposite(sash, SWT.NONE);
	
	// can only be set after child components are available
	sash.setWeights(new int[] {
		1, 4
	});
}
 
Example 17
Source File: BreadcrumbItemDropDown.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public BreadcrumbItemDropDown(BreadcrumbItem parent, Composite composite) {
	fParent= parent;
	fParentComposite= composite;
	fMenuIsShown= false;
	fEnabled= true;

	fToolBar= new ToolBar(composite, SWT.FLAT);
	fToolBar.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
	SWTUtil.setAccessibilityText(fToolBar, BreadcrumbMessages.BreadcrumbItemDropDown_showDropDownMenu_action_toolTip);
	ToolBarManager manager= new ToolBarManager(fToolBar);

	final Action showDropDownMenuAction= new Action(null, SWT.NONE) {
		@Override
		public void run() {
			Shell shell= fParent.getDropDownShell();
			if (shell != null)
				return;

			shell= fParent.getViewer().getDropDownShell();
			if (shell != null)
				shell.close();

			showMenu();

			fShell.setFocus();
		}
	};

	showDropDownMenuAction.setImageDescriptor(new AccessibelArrowImage(isLTR()));
	showDropDownMenuAction.setToolTipText(BreadcrumbMessages.BreadcrumbItemDropDown_showDropDownMenu_action_toolTip);
	manager.add(showDropDownMenuAction);

	manager.update(true);
	if (IS_MAC_WORKAROUND) {
		manager.getControl().addMouseListener(new MouseAdapter() {
			// see also BreadcrumbItemDetails#addElementListener(Control)
			@Override
			public void mouseDown(MouseEvent e) {
				showDropDownMenuAction.run();
			}
		});
	}
}
 
Example 18
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 19
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 20
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);
    }
}