Java 类org.eclipse.swt.widgets.ToolBar 实例源码

项目:neoscada    文件:ToolBarNavigator.java   
public ToolBarNavigator ( final Composite parent, final int style, final ViewManager viewManager )
{
    this.viewManager = viewManager;
    this.toolbar = new ToolBar ( parent, style );
    this.resourceManager = new LocalResourceManager ( JFaceResources.getResources ( parent.getDisplay () ) );

    this.toolbar.addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            handleDispose ();
        }
    } );

    viewManager.addViewManagerListener ( this );
}
项目:Hydrograph    文件:InputFieldsComposite.java   
private void deleteToolItem(ToolBar toolBar) {
    ToolItem tltmDelete = new ToolItem(toolBar, SWT.NONE);
    tltmDelete.setWidth(5);
    tltmDelete.setImage(ImagePathConstant.DELETE_BUTTON.getImageFromRegistry());
    tltmDelete.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            for (TableItem tableItem : inputFieldTable.getSelection()) {
                inputFields.remove(String.valueOf(tableItem.getData()));
            }
            inputFieldTableViewer.refresh();
            dialog.refreshErrorLogs();
            addCusrsorToLastRow();
        }
    });
}
项目:pgsqlblocks    文件:ProcessesView.java   
private void createContent() {
    toolBar = new ToolBar(this, SWT.HORIZONTAL);
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    SashForm sashForm = new SashForm(this, SWT.HORIZONTAL);
    sashForm.SASH_WIDTH = 2;
    sashForm.setLayoutData(layoutData);
    sashForm.setLayout(layout);

    createLeftPanel(sashForm);
    createRightPanel(sashForm);

    sashForm.setSashWidth(2);
    sashForm.setWeights(new int[] {15, 85});
}
项目:pgsqlblocks    文件:DBProcessInfoView.java   
private void createContent() {
    toolBar = new ToolBar(this, SWT.HORIZONTAL);
    toolBar.setEnabled(false);
    GridLayout layout = new GridLayout();
    GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
    toolBar.setLayout(layout);
    toolBar.setLayoutData(layoutData);

    ToolItem cancelProcessToolItem = new ToolItem(toolBar, SWT.PUSH);
    cancelProcessToolItem.setText(resourceBundle.getString("cancel_process"));
    cancelProcessToolItem.addListener(SWT.Selection, event -> {
        listeners.forEach(DBProcessInfoViewListener::dbProcessInfoViewCancelProcessToolItemClicked);
    });

    ToolItem terminateProcessToolItem = new ToolItem(toolBar, SWT.PUSH);
    terminateProcessToolItem.setText(resourceBundle.getString("kill_process"));
    terminateProcessToolItem.addListener(SWT.Selection, event -> {
        listeners.forEach(DBProcessInfoViewListener::dbProcessInfoViewTerminateProcessToolItemClicked);
    });

    processInfoText = new Text(this, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
    GridData textLayoutData = new GridData(SWT.FILL, SWT.BOTTOM, true, false);
    textLayoutData.heightHint = 200;
    processInfoText.setLayoutData(textLayoutData);
}
项目:peten    文件:TagListSelected.java   
/**
 * Creates the actual GUI widgets.
 */
private static Composite createTagComposite(Composite parent, TagVM tagVm, TagToolItemConfigurator configurator) {
    Composite tagContainer = new Composite(parent, SWT.BORDER);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    tagContainer.setLayout(layout);

    Label tagLabel = new Label(tagContainer, SWT.NONE);
    tagLabel.setText(tagVm.getName());
    GridData gdl = new GridData();
    gdl.verticalAlignment = GridData.CENTER;
    tagLabel.setLayoutData(gdl);

    ToolBar toolBar = new ToolBar(tagContainer, SWT.FLAT);
    Rectangle clientArea = tagContainer.getClientArea();
    toolBar.setLocation(clientArea.x, clientArea.y);
    configurator.setupToolbar(toolBar, tagVm);

    toolBar.pack();
    return tagContainer;
}
项目:JSmooth    文件:JSmoothPage.java   
public ToolItem createToolItem(final ToolBar toolbar) {
    configureResources();
    item = new ToolItem(toolbar, SWT.RADIO);
    item.setImage(getImage());
    item.setToolTipText(getToolTip());
    item.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            js.showPage(JSmoothPage.this);
            ToolItem[] items = toolbar.getItems();
            for (int i = 0; i < items.length; i++) {
                if (items[i] != item) items[i].setSelection(false);
            }
        }
    });
    return item;
}
项目:TuxGuitar-1.3.1-fork    文件:TGSettingsEditor.java   
private void createComposites(Composite parent) {
    ToolBar toolBar = new ToolBar(parent, SWT.VERTICAL | SWT.FLAT | SWT.WRAP);
    toolBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true , true));

    Composite option = new Composite(parent,SWT.NONE);
    option.setLayout(new FormLayout());

    initOptions(toolBar,option);

    Point optionSize = computeOptionsSize(0 , toolBar.computeSize(SWT.DEFAULT,SWT.DEFAULT).y );
    option.setLayoutData(new GridData(optionSize.x,optionSize.y));

    if( this.options.size() > 0 ){
        select((Option)this.options.get(0));
    }
}
项目:TranskribusSwtGui    文件:ToolBarVertical.java   
public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    ToolBar bar = new ToolBar(shell, SWT.BORDER|SWT.VERTICAL);
    for (int i = 0; i < 4; i++) {
      ToolItem item = new ToolItem(bar, 0);
//      item.setText("Item " + i);
      item.setImage(Images.APPLICATION);
    }
    bar.pack();

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    display.dispose();
  }
项目:TranskribusSwtGui    文件:SWTCoolBarTestDemo.java   
protected Control createContents(Composite parent) {
  // --- Create the window title. ---

  getShell().setText("CoolBar Test");

  String asCoolItemSection[] = { "File", "Formatting", "Search" };
  CoolBar composite = new CoolBar(parent, SWT.NONE);
  for (int idxCoolItem = 0; idxCoolItem < 3; ++idxCoolItem) {
    CoolItem item = new CoolItem(composite, SWT.NONE);
    ToolBar tb = new ToolBar(composite, SWT.FLAT);
    for (int idxItem = 0; idxItem < 3; ++idxItem) {
      ToolItem ti = new ToolItem(tb, SWT.NONE);
      ti
          .setText(asCoolItemSection[idxCoolItem] + " Item #"
              + idxItem);
    }
    Point p = tb.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    tb.setSize(p);
    Point p2 = item.computeSize(p.x, p.y);
    item.setControl(tb);
    item.setSize(p2);
  }
  return composite;
}
项目:TranskribusSwtGui    文件:CanvasToolBarNew.java   
public CanvasToolBarNew(CanvasWidget parent, ToolBar mainTb, ToolBar viewTb, ToolBar editTb, int style) {
        Assert.assertNotNull("mainTb must be given!", mainTb);
//      Assert.assertNotNull("viewTb must be given!", viewTb);
        Assert.assertNotNull("editTb must be given!", editTb);

        this.mainTb = mainTb;
        this.viewTb = viewTb;
        this.editTb = editTb;

        this.canvasWidget = parent;

//      initMainTb(mainTb);
        createViewItems(mainTb);
        createEditItems(editTb);

        addListeners();
        updateButtonVisibility();
    }
项目:TranskribusSwtGui    文件:CanvasWidget.java   
public void toggleToolbarVisiblity(ToolBar tb, boolean show) {
    if (tb != bar1 && tb != bar2)
        return;

    if (!show) {
        tb.setParent(SWTUtil.dummyShell);
    } else {
        tb.setParent(this);
    }

    if (tb == bar1) {
        tb.moveAbove(null);
    } else {
        tb.moveAbove(canvas);
    }

    pack();
}
项目:mytourbook    文件:PicDirImages.java   
/**
 * fill gallery actionbar
 * 
 * @param galleryActionBarContainer
 */
private void createUI_20_GalleryToolbars(final Composite galleryActionBarContainer) {

    /*
     * toolbar actions
     */
    _galleryToolbar = new ToolBar(galleryActionBarContainer, SWT.FLAT);
    GridDataFactory.fillDefaults()//
            .align(SWT.BEGINNING, SWT.CENTER)
            .applyTo(_galleryToolbar);

    final ToolBarManager tbm = new ToolBarManager(_galleryToolbar);

    tbm.add(_actionToggleFolderGallery);
    tbm.add(_actionNavigateBackward);
    tbm.add(_actionNavigateForward);

    tbm.update(true);
}
项目:cft    文件:ApplicationActionMenuControl.java   
protected void showViewMenu(MenuManager manager, ToolBar toolBar) {
    // don't show if the debug button is disabled.
    if (!isVisible()) {
        return;
    }

    Menu menu = manager.createContextMenu(applicationActionButton);
    applicationActionButton.setMenu(menu);

    Rectangle bounds = toolBar.getBounds();
    // Position the menu near the toolitem
    Point topRight = new Point(bounds.x + bounds.x / 10, bounds.height);
    topRight = applicationActionButton.toDisplay(topRight);
    menu.setLocation(topRight.x, topRight.y);

    menu.setVisible(true);

}
项目:bpm-beans    文件:DataMappingComposite.java   
public DataMappingComposite(Composite parent, int style)
{
  super(parent, style);

  GridLayout layout = new GridLayout(2, false);
  layout.horizontalSpacing = 0;
  layout.verticalSpacing = 0;
  layout.marginWidth = 0;
  layout.marginHeight = 0;
  this.setLayout(layout);

  text = new StyledText(this, SWT.BORDER);
  text.setBackground(getGrey());
  text.setEnabled(false);
  text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
  text.setTopMargin(2);

  ToolBar toolBar = new ToolBar(this, SWT.HORIZONTAL);
  toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1));
  btnAttributeBrowser = new ToolItem(toolBar, SWT.NONE);
  btnAttributeBrowser.setImage(IconFactory.get(parent.getDisplay()).getAttribute16());
}
项目:APICloud-Studio    文件:DefaultNavigatorContributionItem.java   
@Override
public void fill(final ToolBar parent, int index)
{
    toolItem = new ToolItem(parent, SWT.DROP_DOWN);
    toolItem.setImage(actionProvider.getImage());
    // toolItem.setDisabledImage(actionProvider.getDisabledImage());
    // toolItem.setHotImage(actionProvider.getHotImage());
    toolItem.setToolTipText(actionProvider.getToolTip());

    toolItem.addSelectionListener(new SelectionAdapter()
    {

        @Override
        public void widgetSelected(SelectionEvent selectionEvent)
        {
            actionProvider.run(parent);
        }
    });
}
项目:bpm-beans    文件:DecisionTableComposite.java   
private void createDownButton(ToolBar actionBar)
{
  downBtn = new ToolItem(actionBar, SWT.PUSH);
  downBtn.setImage(IconFactory.get(actionBar).getArrowDownBlue(Size.SIZE_16));
  downBtn.setToolTipText("move row down");
  downBtn.addSelectionListener(new SelectionAdapter()
  {
    @Override
    public void widgetSelected(SelectionEvent e)
    {
      int selectionIndex = viewer.getTable().getSelectionIndex();
      model.rows.add(selectionIndex, model.rows.remove(selectionIndex+1));
      viewer.refresh();
      tableCursor.setEditCell(new Cell(selectionIndex+1, 0));
    }
  });
}
项目:mytourbook    文件:SlideoutTourBlogMarker.java   
public SlideoutTourBlogMarker(  final Control ownerControl,
                                final ToolBar toolBar,
                                final IDialogSettings state,
                                final TourBlogView tourBlogView) {

    super(ownerControl);

    _tourBlogView = tourBlogView;

    addListener(ownerControl, toolBar);

    setToolTipCreateStyle(AnimatedToolTipShell.TOOLTIP_STYLE_KEEP_CONTENT);
    setBehaviourOnMouseOver(AnimatedToolTipShell.MOUSE_OVER_BEHAVIOUR_IGNORE_OWNER);
    setIsKeepShellOpenWhenMoved(false);
    setFadeInSteps(1);
    setFadeOutSteps(10);
    setFadeOutDelaySteps(1);
}
项目:APICloud-Studio    文件:FindBarDecorator.java   
private ToolItem createHistoryToolItem(ToolBar toolbar, final String preferenceName)
{
    ToolItem historyToolItem = new ToolItem(toolbar, SWT.DROP_DOWN);
    historyToolItem.setImage(FindBarPlugin.getImage(FindBarPlugin.ICON_SEARCH_HISTORY));
    historyToolItem.setToolTipText(Messages.FindBarDecorator_TOOLTIP_History);

    historyToolItem.addSelectionListener(new SelectionAdapter()
    {
        Menu menu = null;

        /*
         * (non-Javadoc)
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e)
        {
            ToolItem toolItem = (ToolItem) e.widget;
            menu = createHistoryMenu(toolItem, preferenceName, menu);
        }

    });

    return historyToolItem;
}
项目:mytourbook    文件:DialogSelectMap3Color.java   
public DialogSelectMap3Color(   final Control ownerControl,
                                final ToolBar toolBar,
                                final Map3View map3View,
                                final MapGraphId graphId) {

    super(ownerControl);

    _graphId = graphId;
    _map3View = map3View;

    addListener(ownerControl, toolBar);

    setToolTipCreateStyle(AnimatedToolTipShell.TOOLTIP_STYLE_KEEP_CONTENT);
    setBehaviourOnMouseOver(AnimatedToolTipShell.MOUSE_OVER_BEHAVIOUR_IGNORE_OWNER);
    setIsKeepShellOpenWhenMoved(false);
    setFadeInSteps(1);
    setFadeOutSteps(10);
    setFadeOutDelaySteps(1);
}
项目:depan    文件:GraphNodeViewer.java   
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;
}
项目:PDFReporter-Studio    文件:SPToolBarEnum.java   
protected void createComponent(Composite parent) {
    toolBar = new ToolBar(parent, SWT.FLAT | SWT.WRAP | SWT.RIGHT);

    final JSSEnumPropertyDescriptor pd = (JSSEnumPropertyDescriptor) pDescriptor;
    toolItems = new ToolItem[pd.getJrEnums().length];
    for (int i = 0; i < pd.getJrEnums().length; i++) {
        final int index = i;
        toolItems[i] = new ToolItem(toolBar, SWT.CHECK);
        toolItems[i].setText(pd.getJrEnums()[i].getName());
        toolItems[i].setToolTipText(pd.getJrEnums()[i].getName());
        toolItems[i].addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                int val = index;
                if (pd.getType() != NullEnum.NOTNULL)
                    val++;
                propertyChange(section, pd.getId(), toolItems[index].getSelection() ? val : null);
            }
        });
        // bindToHelp(pd, toolItems[i].getControl());
    }
}
项目:PDFReporter-Studio    文件:DataAdapterAction.java   
public void setSelected(DataAdapterDescriptor d) {
    selectedDA = d;
    // set current
    String name = d.getName();
    if (name.length() > 17)
        name = name.substring(0, 17) + "..."; //$NON-NLS-1$
    setText(name);
    setDescription(d.getDescription());
    setToolTipText(d.getName());

    if (parent != null) {
        ToolBar toolBar = (ToolBar) parent;
        toolBar.pack(true);
        toolBar.getParent().getParent().layout(true);
    }
}
项目:PDFReporter-Studio    文件:TextStyleWizardPage.java   
private ToolItem createColorButton(ToolBar toolBar){
    final ToolItem button = new ToolItem(toolBar, SWT.PUSH);
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            ColorDialog cd = new ColorDialog(button.getParent().getShell());
            cd.setText(Messages.TextStyleWizardPage_colorLabel);
            AlfaRGB rgb = (AlfaRGB) button.getData();
            cd.setRGB(rgb == null ? null : rgb);
            AlfaRGB newColor = cd.openAlfaRGB();
            if (newColor != null) {
                button.setData(newColor);
                button.setImage(colorLabelProvider.getImage(newColor));
                updateStyle();
                refreshPreview();
            }
        }
    }); 
    return button;
}
项目:PDFReporter-Studio    文件:ExporterContributionItem.java   
@Override
protected Control createControl(Composite parent) {
    super.createControl(parent);
    ToolBar buttons = new ToolBar(parent, SWT.FLAT | SWT.WRAP);

    ToolItem changeImage = new ToolItem(buttons, SWT.PUSH);
    changeImage.setImage(JaspersoftStudioPlugin.getInstance().getImage("icons/resources/equalizer--arrow.png"));
    changeImage.setToolTipText("Set exporter properties");
    changeImage.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
             createPopupMenu();
             if (popupMenu.isVisible()) {
             popupMenu.setVisible(false);
         } else {
             locatePopupMenu(popupMenu);
           popupMenu.setVisible(true);
         }
        }
    });

    return buttons;
}
项目:PDFReporter-Studio    文件:CreationContributionItem.java   
@Override
protected Control createControl(Composite parent) {
    super.createControl(parent);
    ToolBar buttons = new ToolBar(parent, SWT.FLAT | SWT.WRAP);

    ToolItem createPin = new ToolItem(buttons, SWT.PUSH);
    createPin.setImage(JaspersoftStudioPlugin.getInstance().getImage("icons/pin-16.png"));
    createPin.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            List<Object> selection = getSelectionForType(MCallout.class);
            if (selection.size() == 1){
                Command cmd = CreatePinAction.getCreationCommand((MCallout)selection.get(0));
                if (cmd != null){
                    getCommandStack().execute(cmd);;
                }
            }
        }
    });

    return buttons;
}
项目:PDFReporter-Studio    文件:SizeContributionItem.java   
@Override
protected Control createControl(Composite parent) {
    super.createControl(parent);
    ToolBar buttons = new ToolBar(parent, SWT.FLAT | SWT.WRAP);

    ToolItem sizeButton = new ToolItem(buttons, SWT.PUSH);
    sizeButton.setImage(JaspersoftStudioPlugin.getInstance().getImage("icons/eclipseapps/size_to_control_width.gif"));
    sizeButton.setData(Size2BorderAction.WIDTH);
    sizeButton.setToolTipText(Messages.Size2BorderAction_fit_width_tool_tip);
    sizeButton.addSelectionListener(pushButtonPressed);

    sizeButton = new ToolItem(buttons, SWT.PUSH);
    sizeButton.setImage(JaspersoftStudioPlugin.getInstance().getImage("icons/eclipseapps/size_to_control_height.gif"));
    sizeButton.setData(Size2BorderAction.HEIGHT);
    sizeButton.setToolTipText(Messages.Size2BorderAction_fit_height_tool_tip);
    sizeButton.addSelectionListener(pushButtonPressed);

    sizeButton = new ToolItem(buttons, SWT.PUSH);
    sizeButton.setImage(JaspersoftStudioPlugin.getInstance().getImage("icons/eclipseapps/size_to_control.gif"));
    sizeButton.setData(Size2BorderAction.BOTH);
    sizeButton.setToolTipText(Messages.Size2BorderAction_fit_both_tool_tip);
    sizeButton.addSelectionListener(pushButtonPressed);

    return buttons;
}
项目:PDFReporter-Studio    文件:MoveBandContributionItem.java   
@Override
protected Control createControl(Composite parent) {
    super.createControl(parent);
    ToolBar buttons = new ToolBar(parent, SWT.FLAT | SWT.WRAP);

    moveDown = new ToolItem(buttons, SWT.PUSH);
    moveDown.setImage(ResourceManager.getImage(moveDetailDownAction.getImageDescriptor()));
    moveDown.setToolTipText(moveDetailDownAction.getToolTipText());
    moveDown.addSelectionListener(pushButtonPressed);

    moveUp = new ToolItem(buttons, SWT.PUSH);
    moveUp.setImage(ResourceManager.getImage(moveDetailUpAction.getImageDescriptor()));
    moveUp.setToolTipText(moveDetailUpAction.getToolTipText());
    moveUp.addSelectionListener(pushButtonPressed);

    setEnablement();
    return buttons;
}
项目:gama    文件:GamlReferenceMenu.java   
protected void open(final Decorations parent, final SelectionEvent trigger) {
    // final boolean asMenu = trigger.detail == SWT.ARROW;
    final boolean init = mainMenu == null;
    // if (!asMenu) {
    // openView();
    // } else {
    final ToolItem target = (ToolItem) trigger.widget;
    final ToolBar toolBar = target.getParent();

    if (init) {
        mainMenu = new Menu(parent, SWT.POP_UP);
        // AD: again. In the first call, the mainMenu was perhaps not
        // yet initialized
        fillMenu();
        // mainMenu.addMenuListener(tooltipListener);
    }

    final Point point = toolBar.toDisplay(new Point(trigger.x, trigger.y));
    mainMenu.setLocation(point.x, point.y);
    mainMenu.setVisible(true);
    // }
}
项目:mytourbook    文件:PrefPageMap3Color.java   
private void createUI_10_Title(final Composite parent) {

        final Composite container = new Composite(parent, SWT.NONE);
        GridDataFactory.fillDefaults().grab(true, false).applyTo(container);
        GridLayoutFactory.fillDefaults().numColumns(2).applyTo(container);
//      container.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
        {
            // label: title
            final Label label = new Label(container, SWT.WRAP);
            label.setText(Messages.Pref_Map3Color_Label_Title);
            GridDataFactory.fillDefaults()//
                    .grab(true, true)
                    .align(SWT.FILL, SWT.CENTER)
                    .applyTo(label);

            // toolbar
            _toolBar = new ToolBar(container, SWT.FLAT);
        }

        // spacer
        new Label(parent, SWT.NONE);
    }
项目:mytourbook    文件:SlideoutTourMarkerFilter.java   
public SlideoutTourMarkerFilter(final Control ownerControl,
                                final ToolBar toolBar,
                                final IDialogSettings state,
                                final TourMarkerAllView tourMarkerAllView) {

    super(ownerControl);

    _tourMarkerAllView = tourMarkerAllView;

    addListener(ownerControl, toolBar);

    setToolTipCreateStyle(AnimatedToolTipShell.TOOLTIP_STYLE_KEEP_CONTENT);
    setBehaviourOnMouseOver(AnimatedToolTipShell.MOUSE_OVER_BEHAVIOUR_IGNORE_OWNER);
    setIsKeepShellOpenWhenMoved(false);
    setFadeInSteps(1);
    setFadeOutSteps(10);
    setFadeOutDelaySteps(1);
}
项目:gama    文件:OpenGLToolbarMenu.java   
/**
 * @param tb
 * @param view
 */
public void createItem(final GamaToolbar2 tb, final OpenGLDisplayView view) {

    tb.menu("display.presentation2", "Presentation", "OpenGL options", trigger -> {
        final boolean asMenu = trigger.detail == SWT.ARROW;
        if (!asMenu) { return; }
        final ToolItem target = (ToolItem) trigger.widget;
        final ToolBar toolBar = target.getParent();
        if (menu != null) {
            menu.dispose();
        }
        menu = new Menu(toolBar.getShell(), SWT.POP_UP);
        fillMenu(menu, view);
        final Point point = toolBar.toDisplay(new Point(trigger.x, trigger.y));
        menu.setLocation(point.x, point.y);
        menu.setVisible(true);

    }, SWT.LEFT);

}
项目:APICloud-Studio    文件:WebBrowserViewer4Mac.java   
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());
}
项目:ecle    文件:PortMonitor.java   
public void createUI(Composite parent) {
    ToolBar tbMonitor = new ToolBar(parent, SWT.FLAT | SWT.RIGHT | SWT.VERTICAL);
    tbMonitor.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1));

    fClearOnStart = createButton(tbMonitor, Action.CLEARONSTART, "Clear on session start (port opened or RTS pin twitched)", "terminal-clear");
    createButton(tbMonitor, Action.CLEAR, "Clear", "eraser");

    // ToolItem save = createButton(tbMonitor, Action.SAVE,
    // "Save content to file...", "disk");
    // save.setEnabled(false);

    createButton(tbMonitor, Action.HOME, "Scroll to home", "atop");
    ToolItem se = createButton(tbMonitor, Action.END, "Scroll to end", "abottom");

    eMonitor = new StyledText(parent, SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    eMonitor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    eMonitor.setRightMargin(3);
    eMonitor.setBottomMargin(3);
    eMonitor.setTopMargin(3);
    eMonitor.setLeftMargin(3);
    eMonitor.setText("Embed plugin serial terminal\r\n");

    se.setSelection(true);
    doMonitorAction(Action.END, true);
}
项目:ecle    文件:PortMonitor.java   
private ToolItem createButton(ToolBar tb, final Action action, String tip, String ico) {
    int style = SWT.NONE;

    switch (action) {
    case CLEARONSTART:
    case END:
        style = SWT.CHECK;
        break;
    }

    final ToolItem tbItem = new ToolItem(tb, style);

    tbItem.setToolTipText(tip);
    tbItem.setImage(Icons.ico(ico));
    tbItem.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            doMonitorAction(action, tbItem.getSelection());
        }
    });

    return tbItem;
}
项目:n4js    文件:DashboardComposite.java   
private void createToolbarActions(ToolBar bar) {
    createAction(bar, SWT.PUSH,
            "Snapshot",
            "Take a data snapshot.",
            Activator.getInstance().ICON_SNAPSHOT,
            this::takeSnapshot);
    createAction(bar, SWT.PUSH,
            "Delete",
            "Delete selected snapshots from history.",
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE),
            this::deleteCurrentSelection);
}
项目:android-uiautomatorviewer    文件:UiAutomatorViewer.java   
@Override
protected Control createContents(Composite parent) {
  Composite c = new Composite(parent, SWT.BORDER);

  GridLayout gridLayout = new GridLayout(1, false);
  gridLayout.marginWidth = 0;
  gridLayout.marginHeight = 0;
  gridLayout.horizontalSpacing = 0;
  gridLayout.verticalSpacing = 0;
  c.setLayout(gridLayout);

  GridData gd = new GridData(GridData.FILL_HORIZONTAL);
  c.setLayoutData(gd);

  ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
  toolBarManager.add(new OpenFilesAction(this));
  toolBarManager.add(new ScreenshotAction(this, false));
  toolBarManager.add(new ScreenshotAction(this, true));
  toolBarManager.add(new SaveScreenShotAction(this));
  ToolBar tb = toolBarManager.createControl(c);
  tb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

  mUiAutomatorView = new UiAutomatorView(c, SWT.BORDER);
  mUiAutomatorView.setLayoutData(new GridData(GridData.FILL_BOTH));

  return parent;
}
项目:pmTrans    文件:BarManager.java   
private ToolItem addItemToToolBar(ToolBar bar, String text, String toolTip,
        int type) {
    ToolItem cit = new ToolItem(bar, type);
    if (text != null)
        cit.setText(text);
    if (toolTip != null)
        cit.setToolTipText(toolTip);

    return cit;
}
项目:pmTrans    文件:BarManager.java   
private ToolItem addItemToToolBar(ToolBar bar, String text, String toolTip,
        int type, Listener listener, Image icon) {
    ToolItem item = addItemToToolBar(bar, text, toolTip, type);

    if (listener != null)
        item.addListener(SWT.Selection, listener);
    if (icon != null)
        item.setImage(icon);

    return item;
}
项目:pmTrans    文件:BarManager.java   
private ToolItem addItemToToolBar(ToolBar bar, String text, String toolTip,
        int type, SelectionAdapter listener, Image icon) {
    ToolItem item = addItemToToolBar(bar, text, toolTip, type);

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

    return item;
}
项目:AppleCommander    文件:FileViewerWindow.java   
/**
 * 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();
}