diff options
author | Sopot Cela | 2012-09-04 11:17:38 +0000 |
---|---|---|
committer | Sopot Cela | 2012-09-04 11:17:38 +0000 |
commit | dd901c12b4080861e1097d5b870399c1af9d42c3 (patch) | |
tree | b9333677eda82132a842da680e1d3f0dd9ed221f /bundles | |
parent | b467c9969d2bd1964497057c4b8e4e6f62b0dcff (diff) | |
download | org.eclipse.e4.tools-dd901c12b4080861e1097d5b870399c1af9d42c3.tar.gz org.eclipse.e4.tools-dd901c12b4080861e1097d5b870399c1af9d42c3.tar.xz org.eclipse.e4.tools-dd901c12b4080861e1097d5b870399c1af9d42c3.zip |
Bug 387018 - [Tooling] Adding a Part in the Eclipse 4 Application Wizard
Diffstat (limited to 'bundles')
-rw-r--r-- | bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizard.java | 17 | ||||
-rw-r--r-- | bundles/org.eclipse.e4.tools/templates/src/parts/SamplePart.java | 47 |
2 files changed, 57 insertions, 7 deletions
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizard.java index 65e60d2a..8cecd72c 100644 --- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizard.java +++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizard.java @@ -45,6 +45,7 @@ import org.eclipse.e4.ui.model.application.ui.advanced.MAdvancedFactory; import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective; import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack; import org.eclipse.e4.ui.model.application.ui.basic.MBasicFactory; +import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer; import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar; @@ -171,6 +172,7 @@ public class E4NewProjectWizard extends NewPluginProjectWizard { "org.eclipse.e4.ui.workbench", "org.eclipse.e4.core.services", "org.eclipse.e4.core.di", + "org.eclipse.e4.ui.di", "org.eclipse.e4.core.contexts", "org.eclipse.e4.ui.workbench.swt", "org.eclipse.core.databinding.property", @@ -410,7 +412,7 @@ public class E4NewProjectWizard extends NewPluginProjectWizard { keys.put("projectName", pluginName); String elementName = fragment.getElementName(); keys.put("packageName", (elementName.equals("")?"": elementName + ".")+"handlers"); - + keys.put("packageName2", (elementName.equals("")?"": elementName + ".")+"parts"); try { URL corePath = ResourceLocator.getProjectTemplateFiles(template_id); IRunnableWithProgress op = new TemplateOperation(corePath, project, @@ -419,7 +421,7 @@ public class E4NewProjectWizard extends NewPluginProjectWizard { } catch (Exception e) { PDEPlugin.logException(e); } - + try { URL corePath = ResourceLocator.getProjectTemplateFiles("src"); IRunnableWithProgress op = new TemplateOperation(corePath, @@ -590,11 +592,12 @@ public class E4NewProjectWizard extends NewPluginProjectWizard { MPartStack partStack = MBasicFactory.INSTANCE .createPartStack(); partSashContainer.getChildren().add(partStack); - // - // MPart part = - // MApplicationFactory.eINSTANCE.createPart(); - // partStack.getChildren().add(part); - // part.setLabel("Main"); + + MPart part = MBasicFactory.INSTANCE.createPart(); + partStack.getChildren().add(part); + part.setLabel("Sample Part"); + part.setContributionURI("bundleclass://"+pluginName+"/"+fragment.getElementName()+".parts"+".SamplePart"); + } // WindowTrim diff --git a/bundles/org.eclipse.e4.tools/templates/src/parts/SamplePart.java b/bundles/org.eclipse.e4.tools/templates/src/parts/SamplePart.java new file mode 100644 index 00000000..0d637480 --- /dev/null +++ b/bundles/org.eclipse.e4.tools/templates/src/parts/SamplePart.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package @@packageName2@@; + +import javax.annotation.PostConstruct; +import org.eclipse.e4.ui.di.Focus; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +public class SamplePart { + + private Label label; + private TableViewer tableViewer; + + @PostConstruct + public void createComposite(Composite parent) { + parent.setLayout(new GridLayout()); + + label = new Label(parent, SWT.NONE); + label.setText("Sample table"); + + tableViewer = new TableViewer(parent); + tableViewer.add("Sample item 1"); + tableViewer.add("Sample item 2"); + tableViewer.add("Sample item 3"); + tableViewer.add("Sample item 4"); + tableViewer.add("Sample item 5"); + tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); + } + + @Focus + public void setFocus() { + tableViewer.getTable().setFocus(); + } +} |