Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Cortell2012-02-15 16:44:29 -0500
committerJohn Cortell2012-02-15 16:44:29 -0500
commit7ce1c8fa8b0a12bcb2555164f4d39699afb0b89d (patch)
treeea7e4836960616936696ad7a7ed3fc9ecd807191 /build/org.eclipse.cdt.managedbuilder.ui
parent12f2b8f8d57806cbbfbfdcc496e1931fa433a97e (diff)
downloadorg.eclipse.cdt-7ce1c8fa8b0a12bcb2555164f4d39699afb0b89d.tar.gz
org.eclipse.cdt-7ce1c8fa8b0a12bcb2555164f4d39699afb0b89d.tar.xz
org.eclipse.cdt-7ce1c8fa8b0a12bcb2555164f4d39699afb0b89d.zip
Bug 326105 - MakeFile Project with Existing Code wizard got issues
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.ui')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/plugin.xml2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExisting.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExistingPage.java108
5 files changed, 90 insertions, 26 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
index 9a6cb9b787..9dd588b939 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
@@ -28,7 +28,7 @@
category="org.eclipse.cdt.ui.newCWizards"
class="org.eclipse.cdt.managedbuilder.ui.wizards.NewMakeProjFromExisting"
finalPerspective="org.eclipse.cdt.ui.CPerspective"
- icon="icons/obj16/convert-normal.gif"
+ icon="icons/elcl16/newmngcc_app.gif"
id="org.eclipse.cdt.ui.wizards.NewMakeFromExisting"
name="%NewMakeFromExisting.name"
project="true">
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java
index 9a53359c5c..50e2a377f8 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.java
@@ -161,7 +161,7 @@ public class Messages extends NLS {
public static String NewConfiguration_label_group;
public static String NewConfiguration_label_name;
public static String NewConfiguration_label_warning;
- public static String NewMakeProjFromExisting_0;
+ public static String NewMakeProjFromExisting_wizard_title;
public static String NewMakeProjFromExisting_1;
public static String NewMakeProjFromExistingPage_0;
public static String NewMakeProjFromExistingPage_1;
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties
index 6501855af3..5c6d90caaf 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties
@@ -137,7 +137,7 @@ MBSWizardHandler_0=At least one toolchain should be selected
CMainWizardPage_1=Show project types and toolchains only if they are supported on the platform
AbstractCWizard_0=Empty Project
-NewMakeProjFromExisting_0=Import Existing Code
+NewMakeProjFromExisting_wizard_title=New Project
NewMakeProjFromExisting_1=Importing Existing Code
NewMakeProjFromExistingPage_0=Import Existing Code
NewMakeProjFromExistingPage_1=Import Existing Code
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExisting.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExisting.java
index 6fb3743574..706f0c6373 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExisting.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExisting.java
@@ -54,7 +54,7 @@ public class NewMakeProjFromExisting extends Wizard implements IImportWizard, IN
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
- setWindowTitle(Messages.NewMakeProjFromExisting_0);
+ setWindowTitle(Messages.NewMakeProjFromExisting_wizard_title);
}
@Override
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExistingPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExistingPage.java
index fa5d314ee1..479a242b44 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExistingPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewMakeProjFromExistingPage.java
@@ -20,10 +20,14 @@ import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
@@ -51,6 +55,14 @@ public class NewMakeProjFromExistingPage extends WizardPage {
IWorkspaceRoot root;
List tcList;
Map<String, IToolChain> tcMap = new HashMap<String, IToolChain>();
+
+
+ /**
+ * True if the user entered a non-empty string in the project name field. In that state, we avoid
+ * automatically filling the project name field with the directory name (last segment of the location) he
+ * has entered.
+ */
+ boolean projectNameSetByUser;
protected NewMakeProjFromExistingPage() {
super(Messages.NewMakeProjFromExistingPage_0);
@@ -88,18 +100,77 @@ public class NewMakeProjFromExistingPage extends WizardPage {
projectName.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
- validateProjectName();
+ validatePage();
+ if (getProjectName().isEmpty()) {
+ projectNameSetByUser = false;
+ }
+ }
+ });
+
+ // Note that the modify listener gets called not only when the user enters text but also when we
+ // programatically set the field. This listener only gets called when the user modifies the field
+ projectName.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ projectNameSetByUser = true;
}
});
}
+
+ /**
+ * Validates the contents of the page, setting the page error message and Finish button state accordingly
+ *
+ * @since 8.1
+ */
+ protected void validatePage() {
+ // Don't generate an error if project name or location is empty, but do disable Finish button.
+ String msg = null;
+ boolean complete = true; // ultimately treated as false if msg != null
+
+ String name = getProjectName();
+ if (name.isEmpty()) {
+ complete = false;
+ }
+ else {
+ IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.PROJECT);
+ if (!status.isOK()) {
+ msg = status.getMessage();
+ }
+ else {
+ IProject project = root.getProject(name);
+ if (project.exists()) {
+ msg = Messages.NewMakeProjFromExistingPage_4;
+ }
+ }
+ }
+ if (msg == null) {
+ String loc = getLocation();
+ if (loc.isEmpty()) {
+ complete = false;
+ }
+ else {
+ final File file= new File(loc);
+ if (file.isDirectory()) {
+ // Set the project name to the directory name but not if the user has supplied a name
+ // (bugzilla 368987)
+ if (!projectNameSetByUser && !name.equals(file.getName())) {
+ projectName.setText(file.getName());
+ }
+ } else {
+ msg = Messages.NewMakeProjFromExistingPage_8;
+ }
+ }
+ }
+
+ setErrorMessage(msg);
+ setPageComplete((msg == null) && complete);
+ }
+
+ /** @deprecated Replaced by {@link #validatePage()} */
+ @Deprecated
public void validateProjectName() {
- String name = projectName.getText();
- IProject project = root.getProject(name);
- if (project.exists())
- setErrorMessage(Messages.NewMakeProjFromExistingPage_4);
- else
- setErrorMessage(null);
+ validatePage();
}
public void addSourceSelector(Composite parent) {
@@ -115,10 +186,10 @@ public class NewMakeProjFromExistingPage extends WizardPage {
location.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
- validateSource();
+ validatePage();
}
});
- validateSource();
+ validatePage();
Button browse = new Button(group, SWT.NONE);
browse.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
@@ -139,17 +210,10 @@ public class NewMakeProjFromExistingPage extends WizardPage {
});
}
+ /** @deprecated Replaced by {@link #validatePage()} */
+ @Deprecated
void validateSource() {
- File file= new File(location.getText());
- if (file.isDirectory()) {
- setErrorMessage(null);
- // Set the project name to the directory name but not if a
- // name has already been specified (bugzilla 368987)
- if (projectName.getText().isEmpty()) {
- projectName.setText(file.getName());
- }
- } else
- setErrorMessage(Messages.NewMakeProjFromExistingPage_8);
+ validatePage();
}
public void addLanguageSelector(Composite parent) {
@@ -177,7 +241,7 @@ public class NewMakeProjFromExistingPage extends WizardPage {
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
group.setText(Messages.NewMakeProjFromExistingPage_10);
- tcList = new List(group, SWT.SINGLE);
+ tcList = new List(group, SWT.SINGLE | SWT.BORDER);
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
tcList.add(Messages.NewMakeProjFromExistingPage_11);
@@ -197,11 +261,11 @@ public class NewMakeProjFromExistingPage extends WizardPage {
}
public String getProjectName() {
- return projectName.getText();
+ return projectName.getText().trim();
}
public String getLocation() {
- return location.getText();
+ return location.getText().trim();
}
public boolean isC() {

Back to the top