Search in sources :

Example 21 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project linuxtools by eclipse.

the class MetadataPage method createFormContent.

@Override
protected void createFormContent(IManagedForm managedForm) {
    // setting up the form page
    super.createFormContent(managedForm);
    GridLayout layout = new GridLayout();
    toolkit = managedForm.getToolkit();
    ScrolledForm form = managedForm.getForm();
    form.setText(Messages.MetadataPage_formHeaderText);
    form.setImage(Activator.getImageDescriptor(HEADER_ICON).createImage());
    ToolBarManager toolbarManager = (ToolBarManager) form.getToolBarManager();
    toolkit.decorateFormHeading(form.getForm());
    // add the menuContribution from MANIFEST.MF to the form
    IMenuService menuService = getSite().getService(IMenuService.class);
    menuService.populateContributionManager(toolbarManager, MENU_URI);
    toolbarManager.update(true);
    layout = new GridLayout();
    layout.marginWidth = 6;
    layout.marginHeight = 12;
    form.getBody().setLayout(layout);
    // --------------------------------- REVISION SECTION START ----------
    // Section and its client area to manage updating revision info
    Section revSection = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    layout = new GridLayout();
    GridData data = new GridData();
    data.verticalAlignment = GridData.FILL;
    data.horizontalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    revSection.setText(Messages.MetadataPage_sectionTitleRevision);
    revSection.setDescription(Messages.MetadataPage_sectionInstructionRevision);
    revSection.setLayoutData(data);
    // the client area containing the editing fields
    Composite sectionClient = toolkit.createComposite(revSection);
    layout = new GridLayout(2, false);
    layout.marginWidth = 1;
    layout.marginHeight = 7;
    sectionClient.setLayout(layout);
    Text revisionTxt = createTextFieldWithLabel(sectionClient, Messages.MetadataPage_labelRevision);
    String prefRevisionTxt = eclipsePreferences.get(CreaterepoPreferenceConstants.PREF_REVISION, ICreaterepoConstants.EMPTY_STRING);
    if (!prefRevisionTxt.isEmpty()) {
        revisionTxt.setText(prefRevisionTxt);
    }
    revisionTxt.addSelectionListener(SelectionListener.widgetDefaultSelectedAdapter(e -> {
        String revisionText = revisionTxt.getText().trim();
        savePreferences(CreaterepoPreferenceConstants.PREF_REVISION, revisionText);
    }));
    revSection.setClient(sectionClient);
    // ---------- REVISION SECTION END
    // --------------------------------- TAGS SECTION START ----------
    // Section and its client area to manage tags
    Section tagSection = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    layout = new GridLayout();
    tagSection.setText(Messages.MetadataPage_sectionTitleTags);
    tagSection.setDescription(Messages.MetadataPage_sectionInstructionTags);
    tagSection.setLayoutData(expandComposite());
    // the client area containing the tags
    Composite sectionClientTags = toolkit.createComposite(tagSection);
    layout = new GridLayout(2, false);
    layout.marginWidth = 1;
    layout.marginHeight = 7;
    sectionClientTags.setLayout(layout);
    tagTxt = createTextFieldWithLabel(sectionClientTags, Messages.MetadataPage_labelTags);
    tagTxt.addSelectionListener(new AddTagButtonListener());
    tagsTreeViewer = new TreeViewer(sectionClientTags, SWT.BORDER | SWT.SINGLE | SWT.HORIZONTAL | SWT.VERTICAL | SWT.LEFT_TO_RIGHT | SWT.SMOOTH);
    tagsTreeViewer.setContentProvider(new CreaterepoTreeContentProvider());
    tagsTreeViewer.setLabelProvider(new CreaterepoTreeLabelProvider());
    CreaterepoCategoryModel model = new CreaterepoCategoryModel(project);
    tagsTreeViewer.setInput(model);
    // change the tag text field on change (make editing tag easier)
    tagsTreeViewer.addSelectionChangedListener(event -> {
        if (tagsTree.getSelectionCount() == 1) {
            TreeItem treeItem = tagsTree.getSelection()[0];
            if (!(treeItem.getData() instanceof CreaterepoTreeCategory)) {
                String tag = (String) treeItem.getData();
                tagTxt.setText(tag);
            } else {
                tagTxt.setText(ICreaterepoConstants.EMPTY_STRING);
            }
        }
    });
    // expand or shrink a category
    tagsTreeViewer.addDoubleClickListener(event -> {
        IStructuredSelection selection = (IStructuredSelection) tagsTreeViewer.getSelection();
        if (selection.getFirstElement() instanceof CreaterepoTreeCategory) {
            CreaterepoTreeCategory category = (CreaterepoTreeCategory) selection.getFirstElement();
            tagsTreeViewer.setExpandedState(category, !tagsTreeViewer.getExpandedState(category));
        }
    });
    tagsTree = tagsTreeViewer.getTree();
    tagsTree.setLayoutData(expandComposite());
    // everything to do with the buttons
    Composite buttonList = toolkit.createComposite(sectionClientTags);
    layout = new GridLayout();
    data = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    buttonList.setLayout(layout);
    buttonList.setLayoutData(data);
    createPushButton(buttonList, Messages.MetadataPage_buttonAddTag, toolkit).addSelectionListener(new AddTagButtonListener());
    createPushButton(buttonList, Messages.MetadataPage_buttonEditTag, toolkit).addSelectionListener(new EditTagButtonListener());
    createPushButton(buttonList, Messages.MetadataPage_buttonRemoveTag, toolkit).addSelectionListener(new RemoveTagButtonListener());
    tagSection.setClient(sectionClientTags);
    // ---------- TAGS SECTION END
    refreshTree();
    managedForm.refresh();
}
Also used : IMenuService(org.eclipse.ui.menus.IMenuService) CreaterepoProject(org.eclipse.linuxtools.internal.rpm.createrepo.CreaterepoProject) ICreaterepoConstants(org.eclipse.linuxtools.internal.rpm.createrepo.ICreaterepoConstants) BackingStoreException(org.osgi.service.prefs.BackingStoreException) CreaterepoPreferenceConstants(org.eclipse.linuxtools.internal.rpm.createrepo.CreaterepoPreferenceConstants) Composite(org.eclipse.swt.widgets.Composite) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) CreaterepoTreeContentProvider(org.eclipse.linuxtools.internal.rpm.createrepo.tree.CreaterepoTreeContentProvider) GridData(org.eclipse.swt.layout.GridData) Activator(org.eclipse.linuxtools.internal.rpm.createrepo.Activator) Section(org.eclipse.ui.forms.widgets.Section) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) CreaterepoTreeLabelProvider(org.eclipse.linuxtools.internal.rpm.createrepo.tree.CreaterepoTreeLabelProvider) Button(org.eclipse.swt.widgets.Button) CreaterepoCategoryModel(org.eclipse.linuxtools.internal.rpm.createrepo.tree.CreaterepoCategoryModel) FormEditor(org.eclipse.ui.forms.editor.FormEditor) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) IManagedForm(org.eclipse.ui.forms.IManagedForm) TreeItem(org.eclipse.swt.widgets.TreeItem) Messages(org.eclipse.linuxtools.internal.rpm.createrepo.Messages) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) Tree(org.eclipse.swt.widgets.Tree) SWT(org.eclipse.swt.SWT) ToolBarManager(org.eclipse.jface.action.ToolBarManager) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CreaterepoTreeCategory(org.eclipse.linuxtools.internal.rpm.createrepo.tree.CreaterepoTreeCategory) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Label(org.eclipse.swt.widgets.Label) FormPage(org.eclipse.ui.forms.editor.FormPage) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) CreaterepoTreeContentProvider(org.eclipse.linuxtools.internal.rpm.createrepo.tree.CreaterepoTreeContentProvider) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CreaterepoTreeLabelProvider(org.eclipse.linuxtools.internal.rpm.createrepo.tree.CreaterepoTreeLabelProvider) Text(org.eclipse.swt.widgets.Text) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Section(org.eclipse.ui.forms.widgets.Section) ToolBarManager(org.eclipse.jface.action.ToolBarManager) CreaterepoTreeCategory(org.eclipse.linuxtools.internal.rpm.createrepo.tree.CreaterepoTreeCategory) GridLayout(org.eclipse.swt.layout.GridLayout) IMenuService(org.eclipse.ui.menus.IMenuService) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) GridData(org.eclipse.swt.layout.GridData) CreaterepoCategoryModel(org.eclipse.linuxtools.internal.rpm.createrepo.tree.CreaterepoCategoryModel)

Example 22 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project knime-core by knime.

the class KNIMEApplicationActionBarAdvisor method fillCoolBar.

/**
 * {@inheritDoc}
 */
@Override
protected void fillCoolBar(final ICoolBarManager coolBar) {
    // create a toolbar and add it to the coolbar :)
    IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
    Stream.of(coolBar.getItems()).forEach(item -> toolbar.remove(item));
    coolBar.add(new ToolBarContributionItem(toolbar, "main"));
    // add tools to the toolbar
    toolbar.add(m_newWizardDropdownAction);
    toolbar.add(m_saveAction);
    toolbar.add(m_saveAsAction);
    toolbar.add(m_saveAllAction);
}
Also used : ToolBarContributionItem(org.eclipse.jface.action.ToolBarContributionItem) IToolBarManager(org.eclipse.jface.action.IToolBarManager) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 23 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project yamcs-studio by yamcs.

the class ScriptsInputDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    final Composite parent_Composite = (Composite) super.createDialogArea(parent);
    // Parent composite has GridLayout with 1 columns.
    // Create embedded composite w/ 2 columns
    final Composite mainComposite = new Composite(parent_Composite, SWT.None);
    mainComposite.setLayout(new GridLayout(2, false));
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.heightHint = 250;
    mainComposite.setLayoutData(gridData);
    // Left Panel: List of scripts
    final Composite leftComposite = new Composite(mainComposite, SWT.NONE);
    leftComposite.setLayout(new GridLayout(1, false));
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 350;
    leftComposite.setLayoutData(gd);
    createLabel(leftComposite, "Scripts");
    Composite toolBarComposite = new Composite(leftComposite, SWT.BORDER);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridLayout.marginBottom = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    toolBarComposite.setLayout(gridLayout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    toolBarComposite.setLayoutData(gd);
    ToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolBar = toolbarManager.createControl(toolBarComposite);
    GridData grid = new GridData();
    grid.horizontalAlignment = GridData.FILL;
    grid.verticalAlignment = GridData.BEGINNING;
    toolBar.setLayoutData(grid);
    createActions();
    toolbarManager.add(addAction);
    toolbarManager.add(editAction);
    toolbarManager.add(removeAction);
    toolbarManager.add(moveUpAction);
    toolbarManager.add(moveDownAction);
    toolbarManager.add(convertToEmbedAction);
    toolbarManager.update(true);
    scriptsViewer = createScriptsTableViewer(toolBarComposite);
    scriptsViewer.setInput(scriptDataList);
    // Right panel: Input PVs for selected script
    final Composite rightComposite = new Composite(mainComposite, SWT.NONE);
    gridLayout = new GridLayout(1, false);
    rightComposite.setLayout(gridLayout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    // Account for the StringTableEditor's minimum size
    gd.minimumWidth = 250;
    rightComposite.setLayoutData(gd);
    this.createLabel(rightComposite, "");
    TabFolder tabFolder = new TabFolder(rightComposite, SWT.None);
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    TabItem pvTab = new TabItem(tabFolder, SWT.NONE);
    pvTab.setText("Input PVs");
    TabItem optionTab = new TabItem(tabFolder, SWT.NONE);
    optionTab.setText("Options");
    pvsEditor = new PVTupleTableEditor(tabFolder, new ArrayList<PVTuple>(), SWT.NONE);
    pvsEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    pvsEditor.setEnabled(false);
    pvTab.setControl(pvsEditor);
    final Composite optionTabComposite = new Composite(tabFolder, SWT.None);
    optionTabComposite.setLayout(new GridLayout(1, false));
    optionTab.setControl(optionTabComposite);
    skipFirstExecutionButton = new Button(optionTabComposite, SWT.CHECK | SWT.WRAP);
    skipFirstExecutionButton.setText("Skip executions triggered by PVs' first value.");
    skipFirstExecutionButton.setToolTipText("Skip the script executions triggered by PVs' first connections during OPI startup.\n" + "This is useful if you want to trigger a script from user inputs only.");
    skipFirstExecutionButton.setSelection(false);
    skipFirstExecutionButton.setEnabled(false);
    skipFirstExecutionButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) scriptsViewer.getSelection();
            if (!selection.isEmpty()) {
                ((ScriptData) selection.getFirstElement()).setSkipPVsFirstConnection(skipFirstExecutionButton.getSelection());
            }
        }
    });
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    Point preferredSize = skipFirstExecutionButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    gd.widthHint = preferredSize.x;
    gd.minimumHeight = preferredSize.y;
    skipFirstExecutionButton.setLayoutData(gd);
    checkConnectivityButton = new Button(optionTabComposite, SWT.CHECK | SWT.WRAP);
    checkConnectivityButton.setSelection(false);
    checkConnectivityButton.setText("Execute anyway even if some PVs are disconnected.");
    checkConnectivityButton.setToolTipText("This is only useful if you want to handle PVs' disconnection in script.\nOtherwise, please keep it unchecked.");
    checkConnectivityButton.setEnabled(false);
    checkConnectivityButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) scriptsViewer.getSelection();
            if (!selection.isEmpty()) {
                ((ScriptData) selection.getFirstElement()).setCheckConnectivity(!checkConnectivityButton.getSelection());
            }
            if (checkConnectivityButton.getSelection()) {
                MessageDialog.openWarning(getShell(), "Warning", "If this option is checked, " + "the script itself is responsible for checking PV's connectivity before using that PV in the script.\n" + "Otherwise, you will probably get an error message with java.lang.NullPointerException. \n" + "PV's connectivity can be checked via this method: pvArray[#].isConnected()");
            }
        }
    });
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    preferredSize = checkConnectivityButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    gd.widthHint = preferredSize.x;
    gd.minimumHeight = preferredSize.y;
    checkConnectivityButton.setLayoutData(gd);
    stopExecuteOnErrorButton = new Button(optionTabComposite, SWT.CHECK | SWT.WRAP);
    stopExecuteOnErrorButton.setSelection(false);
    stopExecuteOnErrorButton.setText("Do not execute the script if error was detected.");
    stopExecuteOnErrorButton.setToolTipText("If this option is selected, the script will not be executed \n" + "on next trigger if error was detected in the script.");
    stopExecuteOnErrorButton.setEnabled(false);
    stopExecuteOnErrorButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) scriptsViewer.getSelection();
            if (!selection.isEmpty()) {
                ((ScriptData) selection.getFirstElement()).setStopExecuteOnError(stopExecuteOnErrorButton.getSelection());
            }
        }
    });
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    preferredSize = stopExecuteOnErrorButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    gd.widthHint = preferredSize.x;
    gd.minimumHeight = preferredSize.y;
    stopExecuteOnErrorButton.setLayoutData(gd);
    if (scriptDataList.size() > 0) {
        setScriptsViewerSelection(scriptDataList.get(0));
        checkConnectivityButton.setSelection(!scriptDataList.get(0).isCheckConnectivity());
        skipFirstExecutionButton.setSelection(scriptDataList.get(0).isSkipPVsFirstConnection());
        stopExecuteOnErrorButton.setSelection(scriptDataList.get(0).isStopExecuteOnError());
    }
    return parent_Composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TabFolder(org.eclipse.swt.widgets.TabFolder) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Point(org.eclipse.swt.graphics.Point) ToolBarManager(org.eclipse.jface.action.ToolBarManager) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 24 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project yamcs-studio by yamcs.

the class ActionsInputDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    final Composite parent_Composite = (Composite) super.createDialogArea(parent);
    final Composite mainComposite = new Composite(parent_Composite, SWT.None);
    mainComposite.setLayout(new GridLayout(2, false));
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.heightHint = 250;
    mainComposite.setLayoutData(gridData);
    final Composite leftComposite = new Composite(mainComposite, SWT.None);
    leftComposite.setLayout(new GridLayout(1, false));
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 250;
    leftComposite.setLayoutData(gd);
    createLabel(leftComposite, "Actions:");
    Composite toolBarComposite = new Composite(leftComposite, SWT.BORDER);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridLayout.marginBottom = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    toolBarComposite.setLayout(gridLayout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    toolBarComposite.setLayoutData(gd);
    ToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolBar = toolbarManager.createControl(toolBarComposite);
    GridData grid = new GridData();
    grid.horizontalAlignment = GridData.FILL;
    grid.verticalAlignment = GridData.BEGINNING;
    toolBar.setLayoutData(grid);
    createActions();
    toolbarManager.add(addAction);
    toolbarManager.add(copyAction);
    toolbarManager.add(removeAction);
    toolbarManager.add(moveUpAction);
    toolbarManager.add(moveDownAction);
    toolbarManager.update(true);
    actionsViewer = createActionsTableViewer(toolBarComposite);
    actionsViewer.setInput(actionsList);
    Composite rightComposite = new Composite(mainComposite, SWT.NONE);
    rightComposite.setLayout(new GridLayout(1, false));
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 350;
    rightComposite.setLayoutData(gd);
    this.createLabel(rightComposite, "Properties:");
    propertiesViewer = createPropertiesViewer(rightComposite);
    Composite bottomComposite = new Composite(mainComposite, SWT.NONE);
    bottomComposite.setLayout(new GridLayout(1, false));
    bottomComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
    if (showHookOption) {
        hookFirstCheckBox = new Button(bottomComposite, SWT.CHECK);
        hookFirstCheckBox.setSelection(hookedUpFirstActionToWidget);
        hookFirstCheckBox.setText("Hook the first action to the mouse click event on widget.");
        hookFirstCheckBox.setEnabled(!hookedUpAllActionsToWidget);
        hookFirstCheckBox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                hookedUpFirstActionToWidget = hookFirstCheckBox.getSelection();
            }
        });
    }
    final Button hookAllCheckBox = new Button(bottomComposite, SWT.CHECK);
    hookAllCheckBox.setSelection(hookedUpAllActionsToWidget);
    hookAllCheckBox.setText("Hook all actions to the mouse click event on widget.");
    hookAllCheckBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            hookedUpAllActionsToWidget = hookAllCheckBox.getSelection();
            if (hookFirstCheckBox != null)
                hookFirstCheckBox.setEnabled(!hookedUpAllActionsToWidget);
        }
    });
    if (actionsList.size() > 0) {
        refreshActionsViewer(actionsList.get(0));
    }
    return parent_Composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 25 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project yamcs-studio by yamcs.

the class RulesInputDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    final Composite parent_Composite = (Composite) super.createDialogArea(parent);
    // Parent composite has GridLayout with 1 columns.
    // Create embedded composite w/ 2 columns
    final Composite mainComposite = new Composite(parent_Composite, SWT.None);
    mainComposite.setLayout(new GridLayout(1, false));
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.heightHint = 200;
    mainComposite.setLayoutData(gridData);
    createLabel(mainComposite, "Rules");
    Composite toolBarComposite = new Composite(mainComposite, SWT.BORDER);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridLayout.marginBottom = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    toolBarComposite.setLayout(gridLayout);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    toolBarComposite.setLayoutData(gridData);
    ToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolBar = toolbarManager.createControl(toolBarComposite);
    GridData grid = new GridData();
    grid.horizontalAlignment = GridData.FILL;
    grid.verticalAlignment = GridData.BEGINNING;
    toolBar.setLayoutData(grid);
    createActions();
    toolbarManager.add(addAction);
    toolbarManager.add(editAction);
    toolbarManager.add(copyAction);
    toolbarManager.add(removeAction);
    toolbarManager.add(moveUpAction);
    toolbarManager.add(moveDownAction);
    toolbarManager.update(true);
    rulesViewer = createRulsListViewer(toolBarComposite);
    rulesViewer.setInput(ruleDataList);
    rulesViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            refreshToolbarOnSelection();
        }
    });
    return parent_Composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Aggregations

ToolBarManager (org.eclipse.jface.action.ToolBarManager)25 GridData (org.eclipse.swt.layout.GridData)15 GridLayout (org.eclipse.swt.layout.GridLayout)13 ToolBar (org.eclipse.swt.widgets.ToolBar)12 Composite (org.eclipse.swt.widgets.Composite)11 IToolBarManager (org.eclipse.jface.action.IToolBarManager)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 Button (org.eclipse.swt.widgets.Button)6 ToolBarContributionItem (org.eclipse.jface.action.ToolBarContributionItem)4 Label (org.eclipse.swt.widgets.Label)4 Action (org.eclipse.jface.action.Action)3 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 DisposeEvent (org.eclipse.swt.events.DisposeEvent)3 DisposeListener (org.eclipse.swt.events.DisposeListener)3 ArrayList (java.util.ArrayList)2 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)2 IAction (org.eclipse.jface.action.IAction)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2