diff options
author | Sopot Cela | 2012-09-25 21:15:42 +0000 |
---|---|---|
committer | Sopot Cela | 2012-09-25 21:15:42 +0000 |
commit | c42a098e3c3cde22f2e5a1e97eb9be1b10863ab1 (patch) | |
tree | 3db7c87378ce205d5c297efd33944e867b80e9d8 | |
parent | dfade6eda878ddb16127b9f795f8e8b0967268a3 (diff) | |
download | org.eclipse.e4.tools-c42a098e3c3cde22f2e5a1e97eb9be1b10863ab1.tar.gz org.eclipse.e4.tools-c42a098e3c3cde22f2e5a1e97eb9be1b10863ab1.tar.xz org.eclipse.e4.tools-c42a098e3c3cde22f2e5a1e97eb9be1b10863ab1.zip |
bug 388774: Templates - More options to create Eclipse 4 RCPI20120927-2200I20120927-1300I20120927-1018
applications
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388774
3 files changed, 105 insertions, 81 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 e4ad8906..d9673692 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 @@ -8,6 +8,7 @@ * Contributors: * Soyatec - initial API and implementation * IBM Corporation - ongoing enhancements + * Sopot Cela - ongoing enhancements *******************************************************************************/ package org.eclipse.e4.internal.tools.wizards.project; @@ -332,6 +333,7 @@ public class E4NewProjectWizard extends NewPluginProjectWizard { public void createApplicationResources(IProject project, IProgressMonitor monitor) { Map<String, String> map = fApplicationPage.getData(); + boolean isMinimalist = !map.get(NewApplicationWizardPage.richSample).equalsIgnoreCase("TRUE"); if (map == null || map.get(NewApplicationWizardPage.PRODUCT_NAME) == null) return; @@ -417,24 +419,28 @@ public class E4NewProjectWizard extends NewPluginProjectWizard { try { URL corePath = ResourceLocator.getProjectTemplateFiles(template_id); IRunnableWithProgress op = new TemplateOperation(corePath, project, - keys, binaryExtentions); + keys, binaryExtentions,isMinimalist); getContainer().run(false, true, op); } catch (Exception e) { PDEPlugin.logException(e); } - + if (!isMinimalist) + { try { URL corePath = ResourceLocator.getProjectTemplateFiles("src"); IRunnableWithProgress op = new TemplateOperation(corePath, - (IContainer) fragment.getResource(), keys, binaryExtentions); + (IContainer) fragment.getResource(), keys, binaryExtentions, isMinimalist); getContainer().run(false, true, op); } catch (Exception e) { PDEPlugin.logException(e); } + } } private void createApplicationModel(IProject project, String pluginName, IPackageFragment fragment) { + Map<String, String> map = fApplicationPage.getData(); + boolean isMinimalist = !map.get(NewApplicationWizardPage.richSample).equalsIgnoreCase("TRUE"); if (APPLICATION_MODEL != null && APPLICATION_MODEL.trim().length() > 0) { // Create a resource set // @@ -483,56 +489,53 @@ public class E4NewProjectWizard extends NewPluginProjectWizard { addon.setElementId("org.eclipse.e4.ui.workbench.bindings.model"); addon.setContributionURI("bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon"); application.getAddons().add(addon); + MTrimmedWindow mainWindow = MBasicFactory.INSTANCE + .createTrimmedWindow(); + application.getChildren().add(mainWindow); + mainWindow.setLabel(pluginName); + mainWindow.setWidth(500); + mainWindow.setHeight(400); + resource.getContents().add((EObject) application); + if (!isMinimalist){ + MBindingContext rootContext = MCommandsFactory.INSTANCE + .createBindingContext(); + rootContext.setElementId("org.eclipse.ui.contexts.dialogAndWindow"); + rootContext.setName("In Dialog and Windows"); - MBindingContext rootContext = MCommandsFactory.INSTANCE - .createBindingContext(); - rootContext.setElementId("org.eclipse.ui.contexts.dialogAndWindow"); - rootContext.setName("In Dialog and Windows"); + MBindingContext childContext = MCommandsFactory.INSTANCE + .createBindingContext(); + childContext.setElementId("org.eclipse.ui.contexts.window"); + childContext.setName("In Windows"); + rootContext.getChildren().add(childContext); - MBindingContext childContext = MCommandsFactory.INSTANCE - .createBindingContext(); - childContext.setElementId("org.eclipse.ui.contexts.window"); - childContext.setName("In Windows"); - rootContext.getChildren().add(childContext); + childContext = MCommandsFactory.INSTANCE.createBindingContext(); + childContext.setElementId("org.eclipse.ui.contexts.dialog"); + childContext.setName("In Dialogs"); + rootContext.getChildren().add(childContext); - childContext = MCommandsFactory.INSTANCE.createBindingContext(); - childContext.setElementId("org.eclipse.ui.contexts.dialog"); - childContext.setName("In Dialogs"); - rootContext.getChildren().add(childContext); + application.getRootContext().add(rootContext); + application.getBindingContexts().add(rootContext); - application.getRootContext().add(rootContext); - application.getBindingContexts().add(rootContext); - resource.getContents().add((EObject) application); - // Create Quit command - MCommand quitCommand = createCommand("org.eclipse.ui.file.exit", - "quitCommand", "QuitHandler", - "M1+Q", pluginName, fragment, application); + // Create Quit command + MCommand quitCommand = createCommand("org.eclipse.ui.file.exit", + "quitCommand", "QuitHandler", + "M1+Q", pluginName, fragment, application); - MCommand openCommand = createCommand(pluginName + ".open", - "openCommand", "OpenHandler", - "M1+O", pluginName, fragment, application); + MCommand openCommand = createCommand(pluginName + ".open", + "openCommand", "OpenHandler", + "M1+O", pluginName, fragment, application); - MCommand saveCommand = createCommand("org.eclipse.ui.file.save", - "saveCommand", "SaveHandler", - "M1+S", pluginName, fragment, application); + MCommand saveCommand = createCommand("org.eclipse.ui.file.save", + "saveCommand", "SaveHandler", + "M1+S", pluginName, fragment, application); - MCommand aboutCommand = createCommand( - "org.eclipse.ui.help.aboutAction", "aboutCommand", - "AboutHandler", "M1+A", pluginName, fragment, - application); + MCommand aboutCommand = createCommand( + "org.eclipse.ui.help.aboutAction", "aboutCommand", + "AboutHandler", "M1+A", pluginName, fragment, + application); - MTrimmedWindow mainWindow = MBasicFactory.INSTANCE - .createTrimmedWindow(); - application.getChildren().add(mainWindow); - { - mainWindow.setLabel(pluginName); - mainWindow.setWidth(500); - mainWindow.setHeight(400); - - // Menu - { MMenu menu = MMenuFactory.INSTANCE.createMenu(); mainWindow.setMainMenu(menu); menu.setElementId("menu:org.eclipse.ui.main.menu"); @@ -573,10 +576,8 @@ public class E4NewProjectWizard extends NewPluginProjectWizard { menuItemAbout.setLabel("About"); menuItemAbout.setCommand(aboutCommand); } - } - // PerspectiveStack - { + // PerspectiveStack MPerspectiveStack perspectiveStack = MAdvancedFactory.INSTANCE .createPerspectiveStack(); mainWindow.getChildren().add(perspectiveStack); @@ -593,47 +594,45 @@ public class E4NewProjectWizard extends NewPluginProjectWizard { MPartStack partStack = MBasicFactory.INSTANCE .createPartStack(); partSashContainer.getChildren().add(partStack); - - MPart part = MBasicFactory.INSTANCE.createPart(); - partStack.getChildren().add(part); - part.setLabel("Sample Part"); - part.setContributionURI("bundleclass://"+pluginName+"/"+fragment.getElementName()+".parts"+".SamplePart"); - - } - // WindowTrim - { - MTrimBar trimBar = MBasicFactory.INSTANCE - .createTrimBar(); - mainWindow.getTrimBars().add(trimBar); - - MToolBar toolBar = MMenuFactory.INSTANCE - .createToolBar(); - toolBar.setElementId("toolbar:org.eclipse.ui.main.toolbar"); - trimBar.getChildren().add(toolBar); - - MHandledToolItem toolItemOpen = MMenuFactory.INSTANCE - .createHandledToolItem(); - toolBar.getChildren().add(toolItemOpen); - toolItemOpen.setIconURI("platform:/plugin/" - + pluginName + "/icons/sample.gif"); - toolItemOpen.setCommand(openCommand); + MPart part = MBasicFactory.INSTANCE.createPart(); + partStack.getChildren().add(part); + part.setLabel("Sample Part"); + part.setContributionURI("bundleclass://"+pluginName+"/"+fragment.getElementName()+".parts"+".SamplePart"); - MHandledToolItem toolItemSave = MMenuFactory.INSTANCE - .createHandledToolItem(); - toolBar.getChildren().add(toolItemSave); - toolItemSave.setIconURI("platform:/plugin/" - + pluginName + "/icons/save_edit.gif"); - toolItemSave.setCommand(saveCommand); } + + // WindowTrim + MTrimBar trimBar = MBasicFactory.INSTANCE + .createTrimBar(); + mainWindow.getTrimBars().add(trimBar); + + MToolBar toolBar = MMenuFactory.INSTANCE + .createToolBar(); + toolBar.setElementId("toolbar:org.eclipse.ui.main.toolbar"); + trimBar.getChildren().add(toolBar); + + MHandledToolItem toolItemOpen = MMenuFactory.INSTANCE + .createHandledToolItem(); + toolBar.getChildren().add(toolItemOpen); + toolItemOpen.setIconURI("platform:/plugin/" + + pluginName + "/icons/sample.gif"); + toolItemOpen.setCommand(openCommand); + + MHandledToolItem toolItemSave = MMenuFactory.INSTANCE + .createHandledToolItem(); + toolBar.getChildren().add(toolItemSave); + toolItemSave.setIconURI("platform:/plugin/" + + pluginName + "/icons/save_edit.gif"); + toolItemSave.setCommand(saveCommand); } - } Map<Object, Object> options = new HashMap<Object, Object>(); options.put(XMLResource.OPTION_ENCODING, "UTF-8"); try { resource.save(options); } catch (IOException e) { PDEPlugin.logException(e); + } } } diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/NewApplicationWizardPage.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/NewApplicationWizardPage.java index 0ff88fe6..ff94d0c9 100644 --- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/NewApplicationWizardPage.java +++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/NewApplicationWizardPage.java @@ -9,6 +9,7 @@ * Soyatec - initial API and implementation * IBM Corporation - ongoing enhancements * Lars Vogel, vogella GmbH - ongoing enhancements + * Sopot Cela - ongoing enhancements *******************************************************************************/ package org.eclipse.e4.internal.tools.wizards.project; @@ -54,7 +55,7 @@ public class NewApplicationWizardPage extends WizardPage { public static final String APPLICATION = "application"; public static final String CLEAR_PERSISTED_STATE = "clearPersistedState"; public static final String EOL = System.getProperty("line.separator"); - + public static final String richSample = "RICH_SAMPLE"; private final Map<String, String> data; private IProject project; @@ -64,12 +65,14 @@ public class NewApplicationWizardPage extends WizardPage { private AbstractFieldData pluginData; private PropertyData[] PROPERTIES; - + private Button richSampleCheckbox; + protected NewApplicationWizardPage(IProjectProvider projectProvider, AbstractFieldData pluginData) { super("New Eclipse 4 Application Wizard Page"); this.projectProvider = projectProvider; this.pluginData = pluginData; data = new HashMap<String, String>(); + data.put(richSample, "FALSE");//minimalist by default setTitle("Eclipse 4 Application"); setMessage("Configure application with special values."); } @@ -386,7 +389,23 @@ public class NewApplicationWizardPage extends WizardPage { handleTextEvent(PRODUCT_NAME, proNameText); } }); - + Label label = new Label(proGroup,SWT.NONE); + label.setText("Rich sample (with parts, menu etc.)"); + richSampleCheckbox = new Button(proGroup, SWT.CHECK); + richSampleCheckbox.setSelection(false); + richSampleCheckbox.addSelectionListener(new SelectionListener() { + + public void widgetSelected(SelectionEvent e) { + data.put(richSample, richSampleCheckbox.getSelection()?"TRUE":"FALSE"); + + } + + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e) + ; + + } + }); return proGroup; } diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/TemplateOperation.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/TemplateOperation.java index 3546db57..ce2c7f49 100644 --- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/TemplateOperation.java +++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/TemplateOperation.java @@ -7,6 +7,7 @@ * * Contributors: * Soyatec - initial API and implementation + * Sopot Cela - ongoing enhancements *******************************************************************************/ package org.eclipse.e4.internal.tools.wizards.project; @@ -47,13 +48,15 @@ public class TemplateOperation extends WorkspaceModifyOperation implements private final IContainer target; private final Map<String, String> keys; private final Set<String> binaryExtentions; + private boolean isMinimalist; public TemplateOperation(URL source, IContainer target, - Map<String, String> keys, Set<String> binaryExtentions) { + Map<String, String> keys, Set<String> binaryExtentions, boolean justProduct) { templateDirectory = source; this.binaryExtentions = binaryExtentions; this.target = target; this.keys = keys; + this.isMinimalist = justProduct; } @Override @@ -102,6 +105,8 @@ public class TemplateOperation extends WorkspaceModifyOperation implements private void generateFiles(File src, IContainer dst, boolean firstLevel, IProgressMonitor monitor) throws CoreException { + if ((!firstLevel)&&(isMinimalist)) + return; File[] members = src.listFiles(); for (int i = 0; i < members.length; i++) { @@ -118,6 +123,7 @@ public class TemplateOperation extends WorkspaceModifyOperation implements } if (dstContainer != null && !dstContainer.exists()) ((IFolder) dstContainer).create(true, true, monitor); + generateFiles(member, dstContainer, false, monitor); } else { InputStream in = null; |