Search in sources :

Example 1 with NewWizardAction

use of org.eclipse.ui.actions.NewWizardAction in project eclipse-integration-commons by spring-projects.

the class DashboardMainPage method createNewProjectsSection.

private void createNewProjectsSection(Composite parent) {
    Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
    section.setText("Create");
    GridDataFactory.fillDefaults().grab(false, false).applyTo(section);
    section.setLayout(new GridLayout());
    final 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);
    section.setTextClient(headerComposite);
    toolBarManager.add(new NewWizardAction(getSite().getWorkbenchWindow()));
    toolBarManager.update(true);
    Composite container = toolkit.createComposite(section);
    container.setLayout(new GridLayout(2, false));
    GridDataFactory.fillDefaults().grab(true, false).applyTo(container);
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_ID_NEW_WIZARD);
    IExtension[] extensions = extensionPoint.getExtensions();
    IConfigurationElement[] foundElements = new IConfigurationElement[6];
    String[] ids = new String[] { JAVA_WIZARD_ID, SPRING_WIZARD_ID, ROO_WIZARD_ID, GROOVY_WIZARD_ID, GRAILS_WIZARD_ID };
    for (IExtension extension : extensions) {
        IConfigurationElement[] elements = extension.getConfigurationElements();
        for (IConfigurationElement element : elements) {
            String id = element.getAttribute("id");
            for (int i = 0; i < ids.length; i++) {
                if (ids[i].equals(id) && element.getAttribute(ELEMENT_CLASS) != null && element.getAttribute(ELEMENT_NAME) != null && element.getAttribute(ELEMENT_ICON) != null) {
                    foundElements[i] = element;
                }
            }
        }
    }
    for (IConfigurationElement element : foundElements) {
        createNewProjectFromExtension(container, element);
    }
    section.setClient(container);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) NewWizardAction(org.eclipse.ui.actions.NewWizardAction) Section(org.eclipse.ui.forms.widgets.Section) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) GridLayout(org.eclipse.swt.layout.GridLayout) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) RowLayout(org.eclipse.swt.layout.RowLayout) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtension (org.eclipse.core.runtime.IExtension)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1 IToolBarManager (org.eclipse.jface.action.IToolBarManager)1 ToolBarManager (org.eclipse.jface.action.ToolBarManager)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 NewWizardAction (org.eclipse.ui.actions.NewWizardAction)1 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)1 Section (org.eclipse.ui.forms.widgets.Section)1