Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Moffatt2012-02-07 14:04:08 -0500
committerEric Moffatt2012-02-07 14:04:08 -0500
commitc68d805b69bd6c2cc50ce2f3ac75b49c4ac91db7 (patch)
treeb5164018489b5012493185e838162dd0960be9df
parent44274d98d794400a776a801de6e18cbe856b2384 (diff)
downloadorg.eclipse.e4.tools-integration.tar.gz
org.eclipse.e4.tools-integration.tar.xz
org.eclipse.e4.tools-integration.zip
project name
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizard.java28
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/NewApplicationWizardPage.java19
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/PluginContentPage.java26
3 files changed, 54 insertions, 19 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 ea336265..24c84c3d 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 Soyatec(http://www.soyatec.com) and others.
+ * Copyright (c) 2006, 2012 Soyatec(http://www.soyatec.com) 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Soyatec - initial API and implementation
+ * IBM Corporation - ongoing enhancements
*******************************************************************************/
package org.eclipse.e4.internal.tools.wizards.project;
@@ -129,7 +130,7 @@ public class E4NewProjectWizard extends NewPluginProjectWizard {
fContentPage = new PluginContentPage(
"page2", fProjectProvider, fMainPage, fPluginData); //$NON-NLS-1$
- fApplicationPage = new NewApplicationWizardPage(fProjectProvider);
+ fApplicationPage = new NewApplicationWizardPage(fProjectProvider, fPluginData);
addPage(fContentPage);
addPage(fApplicationPage);
@@ -347,7 +348,8 @@ public class E4NewProjectWizard extends NewPluginProjectWizard {
|| map.get(NewApplicationWizardPage.PRODUCT_NAME) == null)
return;
- String projectName = map.get(NewApplicationWizardPage.PRODUCT_NAME);
+ // If the project has invalid characters, the plug-in name would replace them with underscores, product name does the same
+ String pluginName = map.get(NewApplicationWizardPage.PRODUCT_NAME);
String xmiPath = map
.get(NewApplicationWizardPage.APPLICATION_XMI_PROPERTY);
@@ -451,23 +453,23 @@ public class E4NewProjectWizard extends NewPluginProjectWizard {
// Create Quit command
MCommand quitCommand = createCommand("quitCommand", "QuitHandler",
- "Ctrl+Q", projectName, fragment, application);
+ "Ctrl+Q", pluginName, fragment, application);
MCommand openCommand = createCommand("openCommand", "OpenHandler",
- "Ctrl+O", projectName, fragment, application);
+ "Ctrl+O", pluginName, fragment, application);
MCommand saveCommand = createCommand("saveCommand", "SaveHandler",
- "Ctrl+S", projectName, fragment, application);
+ "Ctrl+S", pluginName, fragment, application);
MCommand aboutCommand = createCommand("aboutCommand",
- "AboutHandler", "Ctrl+A", projectName, fragment,
+ "AboutHandler", "Ctrl+A", pluginName, fragment,
application);
MTrimmedWindow mainWindow = MBasicFactory.INSTANCE
.createTrimmedWindow();
application.getChildren().add(mainWindow);
{
- mainWindow.setLabel(projectName);
+ mainWindow.setLabel(pluginName);
mainWindow.setWidth(500);
mainWindow.setHeight(400);
@@ -486,7 +488,7 @@ public class E4NewProjectWizard extends NewPluginProjectWizard {
fileMenuItem.getChildren().add(menuItemOpen);
menuItemOpen.setLabel("Open");
menuItemOpen.setIconURI("platform:/plugin/"
- + project.getName() + "/icons/sample.gif");
+ + pluginName + "/icons/sample.gif");
menuItemOpen.setCommand(openCommand);
MHandledMenuItem menuItemSave = MMenuFactory.INSTANCE
@@ -494,7 +496,7 @@ public class E4NewProjectWizard extends NewPluginProjectWizard {
fileMenuItem.getChildren().add(menuItemSave);
menuItemSave.setLabel("Save");
menuItemSave.setIconURI("platform:/plugin/"
- + project.getName() + "/icons/save_edit.gif");
+ + pluginName + "/icons/save_edit.gif");
menuItemSave.setCommand(saveCommand);
MHandledMenuItem menuItemQuit = MMenuFactory.INSTANCE
@@ -555,14 +557,14 @@ public class E4NewProjectWizard extends NewPluginProjectWizard {
.createHandledToolItem();
toolBar.getChildren().add(toolItemOpen);
toolItemOpen.setIconURI("platform:/plugin/"
- + project.getName() + "/icons/sample.gif");
+ + pluginName + "/icons/sample.gif");
toolItemOpen.setCommand(openCommand);
MHandledToolItem toolItemSave = MMenuFactory.INSTANCE
.createHandledToolItem();
toolBar.getChildren().add(toolItemSave);
toolItemSave.setIconURI("platform:/plugin/"
- + project.getName() + "/icons/save_edit.gif");
+ + pluginName + "/icons/save_edit.gif");
toolItemSave.setCommand(saveCommand);
}
}
@@ -616,7 +618,7 @@ public class E4NewProjectWizard extends NewPluginProjectWizard {
binaryExtentions.add(".png");
Map<String, String> keys = new HashMap<String, String>();
- keys.put("projectName", projectName);
+ keys.put("projectName", pluginName);
keys.put("packageName", fragment.getElementName() + ".handlers");
try {
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 14bc00b9..8573dac1 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) and others.
+ * Copyright (c) 2006, 2012 Soyatec (http://www.soyatec.com) 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Soyatec - initial API and implementation
+ * IBM Corporation - ongoing enhancements
*******************************************************************************/
package org.eclipse.e4.internal.tools.wizards.project;
@@ -19,6 +20,7 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
+import org.eclipse.pde.internal.ui.wizards.plugin.AbstractFieldData;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -58,12 +60,14 @@ public class NewApplicationWizardPage extends WizardPage {
private Text proNameText;
private Text proApplicationText;
private Group propertyGroup;
+ private AbstractFieldData pluginData;
private PropertyData[] PROPERTIES;
- protected NewApplicationWizardPage(IProjectProvider projectProvider) {
+ protected NewApplicationWizardPage(IProjectProvider projectProvider, AbstractFieldData pluginData) {
super("New e4 Application Wizard Page");
this.projectProvider = projectProvider;
+ this.pluginData = pluginData;
data = new HashMap<String, String>();
setTitle("e4 Application");
setMessage("Configure application with special values.");
@@ -386,7 +390,9 @@ public class NewApplicationWizardPage extends WizardPage {
@Override
public void setVisible(boolean visible) {
if (visible && PROPERTIES == null) {
- proNameText.setText(projectProvider.getProjectName());
+
+ // Use the plug-in name for the product name (not project name which can contain illegal characters)
+ proNameText.setText(pluginData.getId());
proApplicationText.setText(E4_APPLICATION);
@@ -406,8 +412,11 @@ public class NewApplicationWizardPage extends WizardPage {
for (PropertyData property : getPropertyData()) {
data.put(property.getName(), property.getValue());
}
-
- data.put(PRODUCT_NAME, projectProvider.getProjectName());
+
+ // Use the plug-in name for the product name (not project name which can contain illegal characters)
+ String productName = pluginData.getId();
+
+ data.put(PRODUCT_NAME, productName);
data.put(APPLICATION, E4_APPLICATION);
}
Map<String, String> map = new HashMap<String, String>();
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/PluginContentPage.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/PluginContentPage.java
index 8f0c5ae0..74d65d95 100644
--- a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/PluginContentPage.java
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/PluginContentPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -50,6 +50,7 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.osgi.framework.Version;
/**
* Content wizard page for the New Plugin Project wizard (page 2)
@@ -360,4 +361,27 @@ public class PluginContentPage extends ContentPage {
}
return super.canFlipToNextPage();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.internal.ui.wizards.plugin.ContentPage#computeId()
+ */
+ protected String computeId() {
+ String id = super.computeId();
+ // In addition to removed illegal characters, the xmi model does not recognize plug-in uris if they end in a version number
+ // See PlatformURLPluginConnection.parse()
+ int underScore = id.lastIndexOf('_');
+ Version version;
+ while (underScore >= 0) {
+ try {
+ version = Version.parseVersion(id.substring(underScore + 1));
+ // name cannot end with a valid version, remove it
+ id = id.substring(0, underScore);
+ } catch (IllegalArgumentException iae) {
+ // valid name so far, continue to next underscore
+ }
+ underScore = id.lastIndexOf('_', underScore - 1);
+
+ }
+ return id;
+ }
}

Back to the top