Search in sources :

Example 11 with IManagedForm

use of org.eclipse.ui.forms.IManagedForm 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 12 with IManagedForm

use of org.eclipse.ui.forms.IManagedForm in project eclipse-integration-commons by spring-projects.

the class DashboardMainPage method createHeader.

private void createHeader() {
    IManagedForm headerForm = dashboardEditor.getHeaderForm();
    Form topForm = headerForm.getForm().getForm();
    final IToolBarManager toolBarManager = topForm.getToolBarManager();
    toolBarManager.removeAll();
    toolBarManager.update(true);
    toolBarManager.add(new ControlContribution("springSource_search") {

        @Override
        protected Control createControl(Composite parent) {
            Composite composite = new Composite(parent, SWT.NONE);
            composite.setBackground(null);
            GridLayout layout = new GridLayout(2, false);
            layout.marginRight = 0;
            layout.marginHeight = 0;
            layout.marginTop = 5;
            layout.verticalSpacing = 1;
            composite.setLayout(layout);
            GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BOTTOM).grab(false, true).applyTo(composite);
            createSearchBox(composite);
            return composite;
        }
    });
    toolBarManager.add(new ControlContribution("subscribe") {

        @Override
        protected Control createControl(Composite parent) {
            Composite composite = new Composite(parent, SWT.NONE);
            composite.setBackground(null);
            GridLayout layout = new GridLayout(2, false);
            layout.marginRight = 2;
            layout.marginLeft = 0;
            layout.marginHeight = 0;
            layout.marginTop = 12;
            layout.verticalSpacing = 1;
            composite.setLayout(layout);
            GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BOTTOM).grab(false, true).applyTo(composite);
            Button subscribeButton = new Button(composite, SWT.PUSH);
            subscribeButton.setText("Subscribe");
            subscribeButton.setImage(IdeUiPlugin.getImageDescriptor(SUBSCRIBE_SPRINGSOURCE).createImage());
            subscribeButton.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
            subscribeButton.addSelectionListener(new SelectionListener() {

                public void widgetSelected(SelectionEvent e) {
                    TasksUiUtil.openUrl(ResourceProvider.getUrl(RESOURCE_DASHBOARD_SUBSCRIBE));
                }

                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });
            return composite;
        }
    });
    toolBarManager.add(new Action("Spring", IdeUiPlugin.getImageDescriptor(LOGO_SPRINGSOURCE)) {

        @Override
        public void run() {
            TasksUiUtil.openUrl(ResourceProvider.getUrl(RESOURCE_DASHBOARD_LOGO));
        }
    });
    toolBarManager.update(true);
}
Also used : TextSearchControl(org.eclipse.mylyn.commons.workbench.search.TextSearchControl) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) NewWizardAction(org.eclipse.ui.actions.NewWizardAction) Action(org.eclipse.jface.action.Action) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) Form(org.eclipse.ui.forms.widgets.Form) IManagedForm(org.eclipse.ui.forms.IManagedForm) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) IToolBarManager(org.eclipse.jface.action.IToolBarManager) Button(org.eclipse.swt.widgets.Button) IManagedForm(org.eclipse.ui.forms.IManagedForm) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlContribution(org.eclipse.jface.action.ControlContribution) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 13 with IManagedForm

use of org.eclipse.ui.forms.IManagedForm in project liferay-ide by liferay.

the class IDEFormPage method getFocusControl.

protected Control getFocusControl() {
    IManagedForm form = getManagedForm();
    if (form == null) {
        return null;
    }
    Control control = form.getForm();
    if ((control == null) || control.isDisposed()) {
        return null;
    }
    Display display = control.getDisplay();
    Control focusControl = display.getFocusControl();
    if ((focusControl == null) || focusControl.isDisposed()) {
        return null;
    }
    return focusControl;
}
Also used : Control(org.eclipse.swt.widgets.Control) IManagedForm(org.eclipse.ui.forms.IManagedForm) Display(org.eclipse.swt.widgets.Display)

Example 14 with IManagedForm

use of org.eclipse.ui.forms.IManagedForm in project bndtools by bndtools.

the class ProjectBuildPage method reportProblemsInHeader.

void reportProblemsInHeader() {
    IManagedForm mform = getManagedForm();
    if (mform == null)
        return;
    if (mform.getForm().isDisposed())
        // We were called asynchronously after dialog was closed
        return;
    IMessageManager manager = mform.getMessageManager();
    manager.removeMessages();
    for (Entry<String, Integer> entry : messageSeverityMap.entrySet()) {
        // severities in IMessageProvider are 1 higher than in IMarker
        int mappedSeverity = entry.getValue() + 1;
        // may be null
        IAction[] fixes = messageFixesMap.get(entry.getKey());
        manager.addMessage(entry.getKey(), entry.getKey(), fixes, mappedSeverity);
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) IManagedForm(org.eclipse.ui.forms.IManagedForm) IMessageManager(org.eclipse.ui.forms.IMessageManager)

Example 15 with IManagedForm

use of org.eclipse.ui.forms.IManagedForm in project bndtools by bndtools.

the class BundleDescriptionPage method createFormContent.

@Override
protected void createFormContent(IManagedForm managedForm) {
    FormToolkit toolkit = managedForm.getToolkit();
    managedForm.setInput(model);
    ScrolledForm scrolledForm = managedForm.getForm();
    scrolledForm.setText("Bundle Description");
    Form form = scrolledForm.getForm();
    toolkit.decorateFormHeading(form);
    form.addMessageHyperlinkListener(new MessageHyperlinkAdapter(getEditor()));
    Composite body = form.getBody();
    greyTitleBarColour = new Color(body.getDisplay(), 210, 245, 210);
    // Create controls
    MDSashForm sashForm = new MDSashForm(body, SWT.HORIZONTAL, managedForm);
    sashForm.setSashWidth(2);
    toolkit.adapt(sashForm, false, false);
    Composite leftPanel = toolkit.createComposite(sashForm);
    DescriptionBundlePart infoPart = new DescriptionBundlePart(leftPanel, toolkit, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
    managedForm.addPart(infoPart);
    DescriptionRightsPart rightsPart = new DescriptionRightsPart(leftPanel, toolkit, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
    managedForm.addPart(rightsPart);
    DescriptionVendorPart vendorPart = new DescriptionVendorPart(leftPanel, toolkit, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
    managedForm.addPart(vendorPart);
    DescriptionDeveloperPart developerPart = new DescriptionDeveloperPart(leftPanel, toolkit, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
    managedForm.addPart(developerPart);
    // LAYOUT
    GridData gd;
    GridLayout layout;
    layout = new GridLayout(1, false);
    leftPanel.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    infoPart.getSection().setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    rightsPart.getSection().setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    vendorPart.getSection().setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    developerPart.getSection().setLayoutData(gd);
    sashForm.hookResizeListener();
    // Layout
    body.setLayout(new FillLayout());
}
Also used : DescriptionDeveloperPart(bndtools.editor.contents.DescriptionDeveloperPart) MessageHyperlinkAdapter(bndtools.utils.MessageHyperlinkAdapter) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) MDSashForm(bndtools.editor.common.MDSashForm) DescriptionBundlePart(bndtools.editor.contents.DescriptionBundlePart) IManagedForm(org.eclipse.ui.forms.IManagedForm) Form(org.eclipse.ui.forms.widgets.Form) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) MDSashForm(bndtools.editor.common.MDSashForm) Color(org.eclipse.swt.graphics.Color) FillLayout(org.eclipse.swt.layout.FillLayout) DescriptionRightsPart(bndtools.editor.contents.DescriptionRightsPart) GridLayout(org.eclipse.swt.layout.GridLayout) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) DescriptionVendorPart(bndtools.editor.contents.DescriptionVendorPart) GridData(org.eclipse.swt.layout.GridData)

Aggregations

IManagedForm (org.eclipse.ui.forms.IManagedForm)15 Composite (org.eclipse.swt.widgets.Composite)6 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)5 GridData (org.eclipse.swt.layout.GridData)4 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)4 GridLayout (org.eclipse.swt.layout.GridLayout)3 ScrolledForm (org.eclipse.ui.forms.widgets.ScrolledForm)3 MDSashForm (bndtools.editor.common.MDSashForm)2 MessageHyperlinkAdapter (bndtools.utils.MessageHyperlinkAdapter)2 IFile (org.eclipse.core.resources.IFile)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 Button (org.eclipse.swt.widgets.Button)2 Control (org.eclipse.swt.widgets.Control)2 PartInitException (org.eclipse.ui.PartInitException)2 IFormPage (org.eclipse.ui.forms.editor.IFormPage)2 Form (org.eclipse.ui.forms.widgets.Form)2 Section (org.eclipse.ui.forms.widgets.Section)2