summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-24 13:54:30 (EDT)
committerEike Stepper2007-07-24 13:54:30 (EDT)
commit1dc36a799ded0baf523c4feeb76a583683d8bf4b (patch)
tree62835e7e0f6a19b3ff5720e501b71d81e6528736
parentb75b9f81b7b134c9662c92004768a1306815b4cc (diff)
downloadcdo-1dc36a799ded0baf523c4feeb76a583683d8bf4b.zip
cdo-1dc36a799ded0baf523c4feeb76a583683d8bf4b.tar.gz
cdo-1dc36a799ded0baf523c4feeb76a583683d8bf4b.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java38
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java7
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java5
3 files changed, 29 insertions, 21 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java
index 3f556de..a2fb54f 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java
@@ -19,8 +19,8 @@ import org.eclipse.net4j.util.collection.IHistory;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
@@ -33,6 +33,8 @@ public class RegisterCDOPackageAction extends RegisterPackageAction
private static final String TITLE = "Register CDO Package";
+ private EPackage.Registry registry = EPackage.Registry.INSTANCE;
+
public RegisterCDOPackageAction(IWorkbenchPage page, CDOSession session)
{
super(page, TITLE, "Register a package generated for CDO", null, session);
@@ -42,26 +44,26 @@ public class RegisterCDOPackageAction extends RegisterPackageAction
protected EPackage getEPackage(IWorkbenchPage page, CDOSession session)
{
Shell shell = page.getWorkbenchWindow().getShell();
- for (;;)
+ IInputValidator validator = new EPackageFactoryValidator();
+ InputDialog dialog = new HistoryInputDialog(shell, TITLE, "Enter a package URI:", HISTORY, validator);
+ if (dialog.open() == InputDialog.OK)
{
- InputDialog dialog = new HistoryInputDialog(shell, TITLE, "Enter a package URI:", HISTORY, null);
- if (dialog.open() != InputDialog.OK)
- {
- return null;
- }
-
String uri = dialog.getValue();
- EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(uri);
- if (ePackage != null)
- {
- HISTORY.add(uri);
- return ePackage;
- }
+ HISTORY.add(uri);
+ return registry.getEPackage(uri);
+ }
- if (!MessageDialog.openQuestion(shell, TITLE, "Package " + uri + " not found.\nTry again?"))
- {
- return null;
- }
+ return null;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class EPackageFactoryValidator implements IInputValidator
+ {
+ public String isValid(String uri)
+ {
+ return registry.containsKey(uri) ? null : "Package " + uri + " not found.";
}
}
}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java
index fa85e8f..c692218 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java
@@ -98,14 +98,15 @@ public class HistoryInputDialog extends InputDialog
@Override
protected void buttonPressed(int buttonId)
{
- super.buttonPressed(buttonId);
- if (buttonId == IDialogConstants.OK_ID)
+ if (IDialogConstants.OK_ID == buttonId)
{
value = historyText.getText();
+ okPressed();
}
- else
+ else if (IDialogConstants.CANCEL_ID == buttonId)
{
value = null;
+ cancelPressed();
}
}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java
index 2df43f8..bc30f73 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java
@@ -215,6 +215,11 @@ public class HistoryText extends Composite
protected void historyChanged()
{
+ if (isDisposed())
+ {
+ return;
+ }
+
combo.removeAll();
for (IHistoryElement<String> element : history)
{