Example usage for org.eclipse.jface.action ToolBarManager update

List of usage examples for org.eclipse.jface.action ToolBarManager update

Introduction

In this page you can find the example usage for org.eclipse.jface.action ToolBarManager update.

Prototype

@Override
    public void update(boolean force) 

Source Link

Usage

From source file:ar.com.fluxit.jqa.wizard.page.LayersDefinitionWizardPage.java

License:Open Source License

private void createLayersGroup(SashForm sash) {
    final Group layersGroup = new Group(sash, SWT.NONE);
    final GridLayout layersGroupGridLayout = new GridLayout();
    layersGroupGridLayout.verticalSpacing = -1;
    layersGroup.setLayout(layersGroupGridLayout);
    layersGroup.setText("Layers");
    ViewForm viewForm = new ViewForm(layersGroup, SWT.FLAT | SWT.BORDER);
    viewForm.setLayout(layersGroupGridLayout);
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolBar = toolBarManager.createControl(viewForm);
    toolBar.setBackground(layersGroup.getBackground());
    viewForm.setTopLeft(toolBar);//w w  w.j a va2  s  . com
    viewForm.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    TableViewer layersTable = new TableViewer(layersGroup,
            SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    layersTable.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
    layersTable.setContentProvider(ArrayContentProvider.getInstance());
    layersTable.setInput(getWizard().getLayers());
    layersTable.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            Layer layer = (Layer) element;
            String result = layer.getName();
            if (!layer.getPackages().isEmpty()) {
                result += " (" + layer.getPackages().size() + ")";
            }
            return result;
        }
    });
    layersTable.setCellEditors(new CellEditor[] { new TextCellEditor(layersTable.getTable()) });
    layersTable.setCellModifier(new LayerCellModifier(layersTable));
    layersTable.setColumnProperties(new String[] { "layer" });
    toolBarManager.add(new NewLayerAction(getWizard().getLayers(), layersTable));
    final EditLayerAction editLayerAction = new EditLayerAction(layersTable);
    editLayerAction.setEnabled(false);
    toolBarManager.add(editLayerAction);
    final RemoveLayerAction removeLayerAction = new RemoveLayerAction(getWizard().getLayers(), layersTable,
            targetPackagesTable, getContainer());
    removeLayerAction.setEnabled(false);
    toolBarManager.add(removeLayerAction);
    toolBarManager.update(true);
    layersTable.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent paramSelectionChangedEvent) {
            layerSelectionChanged(paramSelectionChangedEvent.getSelection(), editLayerAction,
                    removeLayerAction);
        }
    });
    layersTable.addDropSupport(DND.DROP_MOVE, getTransferTypes(), new LayersListTableDropListener(layersTable,
            targetPackagesTable, getDragViewerHolder(), getDragInputHolder(), getContainer()));
}

From source file:at.medevit.elexis.inbox.ui.part.InboxView.java

License:Open Source License

private void addFilterActions(ToolBarManager menuManager) {
    InboxElementUiExtension extension = new InboxElementUiExtension();
    List<IInboxElementUiProvider> providers = extension.getProviders();
    for (IInboxElementUiProvider iInboxElementUiProvider : providers) {
        ViewerFilter extensionFilter = iInboxElementUiProvider.getFilter();
        if (extensionFilter != null) {
            InboxFilterAction action = new InboxFilterAction(viewer, extensionFilter,
                    iInboxElementUiProvider.getFilterImage());
            menuManager.add(action);/*from  ww w.  ja v a  2 s.  c  o  m*/
        }
    }
    menuManager.update(true);
}

From source file:ca.uvic.cs.tagsea.ui.views.cloudsee.CloudSeeView.java

License:Open Source License

private void makeToolBar(GridData gridData) {
    ToolBar toolBar = new ToolBar(composite, SWT.HORIZONTAL);
    toolBar.setLayoutData(gridData);/*w w w.j  a va 2  s.co m*/

    ToolBarManager toolBarManager = new ToolBarManager(toolBar);
    toolBarManager.add(refreshAction);
    toolBarManager.add(backAction);
    toolBarManager.add(forwardAction);
    toolBarManager.update(true);

    forwardAction.setEnabled(false);
    backAction.setEnabled(false);
}

From source file:ca.uvic.cs.tagsea.ui.views.FilterComposite.java

License:Open Source License

/**
 * Creates the textbox and clear button which is tied to the given
 * TreeViewer.  Also adds listeners to the textbox so that when the 
 * enter or down arrow key is pressed the tree view gets focus.
 * The tree filter is also added to the tree viewer.
 * @param treeViewer//from  www  .j  a  v a 2  s.c o m
 */
public void createTextFilterControl(TreeViewer treeViewer) {
    this.treeViewer = treeViewer;

    treeViewer.addFilter(treeFilter);
    this.text = new Text(this, SWT.SINGLE | SWT.BORDER);
    text.setText(INITIAL_TEXT);
    text.setToolTipText("Tags Filter");
    GridData data = new GridData(SWT.LEFT, SWT.FILL, false, false);
    data.widthHint = 80;
    text.setLayoutData(data);
    text.pack();
    originalTextColor = text.getForeground();

    // create the clear text button
    this.clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {
        public void run() {
            text.setText("");
            text.setFocus();
        }
    };
    clearTextAction.setToolTipText("Clear the filter text");
    final ImageDescriptor clearDescriptor = TagSEAPlugin.getDefault().getTagseaImages()
            .getDescriptor(ITagseaImages.IMG_CLEAR);
    final ImageDescriptor clearDescriptorDisabled = TagSEAPlugin.getDefault().getTagseaImages()
            .getDescriptor(ITagseaImages.IMG_CLEAR_DISABLED);
    clearTextAction.setImageDescriptor(clearDescriptor);
    clearTextAction.setDisabledImageDescriptor(clearDescriptorDisabled);
    ToolBar toolBar = new ToolBar(this, SWT.FLAT | SWT.HORIZONTAL);
    ToolBarManager manager = new ToolBarManager(toolBar);
    manager.add(clearTextAction);
    manager.update(false);

    Label spacer = new Label(this, SWT.NONE);
    data = new GridData(SWT.LEFT, SWT.FILL, false, false);
    data.widthHint = 8;
    spacer.setLayoutData(data);

    // add the textbox listeners
    text.addModifyListener(this);
    text.addKeyListener(this);
    text.addFocusListener(this);
}

From source file:ca.uvic.cs.tagsea.ui.views.TagsComposite.java

License:Open Source License

private void createScanToolBar(Composite parent) {
    ToolBar toolbar = new ToolBar(parent, SWT.FLAT | SWT.LEFT);
    GridData data = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
    toolbar.setLayoutData(data);/*w w  w .j av a  2  s.c  om*/

    ToolBarManager manager = new ToolBarManager(toolbar);

    scanForTagsAction = new Action("Refresh tag database...",
            TagSEAPlugin.getImageDescriptor("/icons/synch.gif")) {
        public void run() {
            new RefreshTagsAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()).run();
        }
    };

    manager.add(scanForTagsAction);
    manager.update(false);
    toolbar.setToolTipText("Refresh tag database...");
}

From source file:ch.hsr.ifs.cutelauncher.ui.CuteCompareResultDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    ViewForm pane = new ViewForm(composite, SWT.BORDER | SWT.FLAT);
    Control control = createCompareViewer(pane);
    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    data.widthHint = convertWidthInCharsToPixels(120);
    data.heightHint = convertHeightInCharsToPixels(13);
    pane.setLayoutData(data);/*  w w  w. j a  v  a  2 s . c om*/
    ToolBar tb = new ToolBar(pane, SWT.BORDER | SWT.FLAT);
    ToolBarManager tbm = new ToolBarManager(tb);
    ShowWhiteSpaceAction action = new ShowWhiteSpaceAction(compareViewer);
    tbm.add(action);
    tbm.update(true);
    ;
    pane.setTopRight(tb);

    pane.setContent(control);
    GridData gd = new GridData(GridData.FILL_BOTH);
    control.setLayoutData(gd);
    return composite;
}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.editor.ApplicationMasterPart.java

License:Open Source License

private void createApplicationsSection() {
    Section section = getSection();/*from  w  w w  .java  2s.co  m*/
    section.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(section);
    section.setText(Messages.COMMONTXT_APPLICATIONS);
    section.setDescription(Messages.ApplicationMasterPart_TEXT_APP_DESCRIP);

    Composite client = toolkit.createComposite(section);
    client.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(client);
    section.setClient(client);

    Composite headerComposite = toolkit.createComposite(section, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginTop = 0;
    rowLayout.marginBottom = 0;
    headerComposite.setLayout(rowLayout);
    headerComposite.setBackground(null);

    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    toolBarManager.createControl(headerComposite);

    applicationsViewer = new TableViewer(toolkit.createTable(client, SWT.NONE));
    applicationsViewer.setContentProvider(new TreeContentProvider());
    applicationsViewer.setLabelProvider(new ServerLabelProvider() {
        @Override
        public Image getImage(Object element) {
            Image image = super.getImage(element);

            if (element instanceof IModule) {
                IModule module = (IModule) element;
                DockerFoundryApplicationModule appModule = editorPage.getCloudServer()
                        .getExistingCloudModule(module);
                if (appModule != null && appModule.getErrorMessage() != null) {
                    return DockerFoundryImages.getImage(new DecorationOverlayIcon(image,
                            DockerFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT));
                }
            }

            return image;
        }

        @Override
        public String getText(Object element) {
            // This is the WTP module name (usually, it's the workspace
            // project name)
            String moduleName = super.getText(element);

            // However, the user has the option to specify a different name
            // when pushing an app, which is used as the cf app name. If
            // they are different, and the
            // corresponding workspace project is accessible, show both.
            // Otherwise, show the cf app name.

            if (element instanceof IModule) {

                IModule module = (IModule) element;

                // Find the corresponding Cloud Foundry-aware application
                // Module.
                DockerFoundryApplicationModule appModule = cloudServer
                        .getExistingCloudModule((IModule) element);

                if (appModule != null) {
                    String cfAppName = appModule.getDeployedApplicationName();

                    if (cfAppName != null) {

                        // Be sure not to show a null WTP module name,
                        // although
                        // that should not be encountered
                        if (moduleName != null && !cfAppName.equals(moduleName)
                                && DockerFoundryProperties.isModuleProjectAccessible
                                        .testProperty(new IModule[] { module }, cloudServer)) {
                            moduleName = cfAppName + " (" + moduleName + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                        } else {
                            moduleName = cfAppName;
                        }
                    }
                }
            }

            return moduleName;
        }

    });
    applicationsViewer.setInput(new CloudApplication[0]);
    applicationsViewer.setSorter(new DockerFoundryViewerSorter());

    applicationsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            IModule module = (IModule) selection.getFirstElement();

            if (currentModule != module) {
                currentModule = module;
                getManagedForm().fireSelectionChanged(ApplicationMasterPart.this, selection);
            }
        }
    });
    GridDataFactory.fillDefaults().grab(true, true).hint(250, SWT.DEFAULT)
            .applyTo(applicationsViewer.getControl());

    int ops = DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;
    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
    ApplicationViewersDropAdapter listener = new ApplicationViewersDropAdapter(applicationsViewer);
    applicationsViewer.addDropSupport(ops, transfers, listener);

    // create context menu
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            fillApplicationsContextMenu(manager);
        }
    });

    Menu menu = menuManager.createContextMenu(applicationsViewer.getControl());
    applicationsViewer.getControl().setMenu(menu);
    editorPage.getSite().registerContextMenu(menuManager, applicationsViewer);

    Action addRemoveApplicationAction = new Action(Messages.ApplicationMasterPart_TEXT_ADD_REMOVE,
            ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_MODIFY_MODULES)) {
        @Override
        public void run() {
            ModifyModulesWizard wizard = new ModifyModulesWizard(cloudServer.getServerOriginal());
            WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
            dialog.open();
        }
    };
    toolBarManager.add(addRemoveApplicationAction);

    // Fix for STS-2996. Moved from CloudFoundryApplicationsEditorPage
    toolBarManager.add(RefreshEditorAction.getRefreshAction(editorPage, null));
    toolBarManager.update(true);
    section.setTextClient(headerComposite);

    getManagedForm().getToolkit().paintBordersFor(client);
}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.wizards.DockerFoundryApplicationServicesWizardPage.java

License:Open Source License

public void createControl(Composite parent) {

    setDescription(DESCRIPTION);/*  www.  j  av a 2s  . c o  m*/
    ImageDescriptor banner = DockerFoundryImages.getWizardBanner(serverTypeId);
    if (banner != null) {
        setImageDescriptor(banner);
    }

    Composite tableArea = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(tableArea);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tableArea);

    Composite toolBarArea = new Composite(tableArea, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(toolBarArea);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(toolBarArea);

    Label label = new Label(toolBarArea, SWT.NONE);
    GridDataFactory.fillDefaults().grab(false, false).align(SWT.BEGINNING, SWT.CENTER).applyTo(label);
    label.setText(Messages.DockerFoundryApplicationServicesWizardPage_LABEL_SELECT_SERVICE);

    Table table = new Table(tableArea, SWT.BORDER | SWT.SINGLE | SWT.CHECK);

    GridDataFactory.fillDefaults().grab(true, true).applyTo(table);

    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    ToolBar bar = toolBarManager.createControl(toolBarArea);
    GridDataFactory.fillDefaults().align(SWT.END, SWT.BEGINNING).grab(true, false).applyTo(bar);

    servicesViewer = new CheckboxTableViewer(table);

    servicesViewer.setContentProvider(new TreeContentProvider());
    servicesViewer.setLabelProvider(new ServicesTreeLabelProvider(servicesViewer) {

        protected Image getColumnImage(DockerApplicationService service, ServiceViewColumn column) {

            return null;
        }

    });
    servicesViewer.setSorter(new ServiceViewerSorter(servicesViewer) {

        @Override
        protected int compare(DockerApplicationService service1, DockerApplicationService service2,
                ServiceViewColumn sortColumn) {

            return super.compare(service1, service2, sortColumn);
        }

    });

    new ServiceViewerConfigurator().enableAutomaticViewerResizing().configureViewer(servicesViewer);

    servicesViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            Object[] services = servicesViewer.getCheckedElements();
            if (services != null) {
                selectedServicesToBind.clear();
                for (Object obj : services) {
                    DockerApplicationService service = (DockerApplicationService) obj;
                    selectedServicesToBind.add(service.getName());
                }
                setServicesToBindInDescriptor();
            }
        }
    });

    Action addServiceAction = new Action(Messages.COMMONTXT_ADD_SERVICE, DockerFoundryImages.NEW_SERVICE) {

        public void run() {
            // Do not create the service right away.
            boolean deferAdditionOfService = true;

            DockerFoundryServiceWizard wizard = new DockerFoundryServiceWizard(cloudServer,
                    deferAdditionOfService);
            WizardDialog dialog = new WizardDialog(getShell(), wizard);
            wizard.setParent(dialog);
            dialog.setPageSize(900, 600);
            dialog.setBlockOnOpen(true);

            if (dialog.open() == Window.OK) {
                // This cloud service does not yet exist. It will be created
                // outside of the wizard
                List<List<ServiceInstance>> addedService = wizard.getServices();
                if (addedService != null) {
                    List<DockerApplicationService> _addedServiceList = new ArrayList<DockerApplicationService>();
                    for (List<ServiceInstance> list : addedService) {
                        for (ServiceInstance serviceInstance : list) {
                            DockerApplicationService e = new DockerApplicationService();
                            e.setName(serviceInstance.getName());
                            e.setLinkName(serviceInstance.getUserDefinedName());
                            _addedServiceList.add(e);
                        }
                    }
                    addServices(_addedServiceList);
                }
            }
        }

        public String getToolTipText() {
            return Messages.DockerFoundryApplicationServicesWizardPage_TEXT_TOOLTIP;
        }
    };
    toolBarManager.add(addServiceAction);

    toolBarManager.update(true);

    setControl(tableArea);
    setInput();
}

From source file:com.amazonaws.eclipse.ec2.ui.launchwizard.AmiSelectionWizardPage.java

License:Apache License

public void createControl(Composite parent) {
    Composite control = new Composite(parent, SWT.NONE);
    control.setLayout(new GridLayout(1, false));
    control.setLayoutData(new GridData(GridData.FILL_BOTH));

    ToolBarManager manager = new ToolBarManager(SWT.None);
    amiSelectionComposite = new FilteredAmiSelectionTable(control, manager, 3);
    amiSelectionComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    amiSelectionComposite.addSelectionListener(new SelectionAdapter() {
        @Override// w ww .  ja  v a2 s. c  o  m
        public void widgetSelected(SelectionEvent e) {
            updateErrorMessages();
            getContainer().updateButtons();
        }
    });

    manager.add(amiSelectionComposite.getAmiSelectionTable().getRefreshAction());
    manager.add(amiSelectionComposite.getAmiSelectionTable().getAmiFilterDropDownAction());
    manager.add(amiSelectionComposite.getAmiSelectionTable().getPlatformFilterDropDownAction());
    manager.update(true);

    updateErrorMessages();
    this.setControl(control);
}

From source file:com.android.ide.eclipse.adt.internal.editors.ui.tree.UiTreeBlock.java

License:Open Source License

private void createSectionActions(Section section, FormToolkit toolkit) {
    ToolBarManager manager = new ToolBarManager(SWT.FLAT);
    manager.removeAll();//  ww  w . j  ava2 s .  co  m

    ToolBar toolbar = manager.createControl(section);
    section.setTextClient(toolbar);

    ElementDescriptor[] descs = mDescriptorFilters;
    if (descs == null && mUiRootNode != null) {
        descs = mUiRootNode.getDescriptor().getChildren();
    }

    if (descs != null && descs.length > 1) {
        for (ElementDescriptor desc : descs) {
            manager.add(new DescriptorFilterAction(desc));
        }
    }

    manager.add(new TreeSortAction());

    manager.update(true /*force*/);
}