summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-06 05:11:40 (EDT)
committerEike Stepper2007-08-06 05:11:40 (EDT)
commit8874c8f47fd48aa896dedfc44b1638249b924b42 (patch)
tree3dd9ce2c8fc578966fe7ed96a3d05ec651820030
parente1ca00aca6525feb0ea2248bf3bf3d24d148538f (diff)
downloadcdo-8874c8f47fd48aa896dedfc44b1638249b924b42.zip
cdo-8874c8f47fd48aa896dedfc44b1638249b924b42.tar.gz
cdo-8874c8f47fd48aa896dedfc44b1638249b924b42.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterFilesystemPackagesAction.java79
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java92
3 files changed, 221 insertions, 30 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterFilesystemPackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterFilesystemPackagesAction.java
new file mode 100644
index 0000000..e134d9a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterFilesystemPackagesAction.java
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.internal.ui.dialogs.SelectPackageDialog;
+
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class RegisterFilesystemPackagesAction extends RegisterPackagesAction
+{
+ private static final String TITLE = "Register Generated Packages";
+
+ private EPackage.Registry registry = EPackage.Registry.INSTANCE;
+
+ public RegisterFilesystemPackagesAction(IWorkbenchPage page, CDOSession session)
+ {
+ super(page, TITLE, "Register native, legacy or converted packages", null, session);
+ }
+
+ @Override
+ protected List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session)
+ {
+ Shell shell = page.getWorkbenchWindow().getShell();
+ SelectPackageDialog dialog = new SelectPackageDialog(shell, "Generated Packages",
+ "Select one or more packages for registration with the CDO package registry", session.getPackageRegistry()
+ .keySet());
+
+ if (dialog.open() == SelectPackageDialog.OK)
+ {
+ Set<String> checkedURIs = dialog.getCheckedURIs();
+ List<EPackage> ePackages = new ArrayList(checkedURIs.size());
+ for (String uri : checkedURIs)
+ {
+ EPackage ePackage = registry.getEPackage(uri);
+ ePackages.add(ePackage);
+ }
+
+ return ePackages;
+ }
+
+ return null;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class EPackageFactoryValidator implements IInputValidator
+ {
+ public String isValid(String uri)
+ {
+ if (uri == null || uri.length() == 0)
+ {
+ return "";
+ }
+
+ return registry.containsKey(uri) ? null : "Package " + uri + " not found.";
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java
new file mode 100644
index 0000000..513876e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java
@@ -0,0 +1,80 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.internal.ui.dialogs.SelectPackageDialog;
+
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class RegisterWorkspacePackagesAction extends RegisterPackagesAction
+{
+ private static final String TITLE = "Register Generated Packages";
+
+ private EPackage.Registry registry = EPackage.Registry.INSTANCE;
+
+ public RegisterWorkspacePackagesAction(IWorkbenchPage page, CDOSession session)
+ {
+ super(page, TITLE, "Register native, legacy or converted packages", null, session);
+ }
+
+ @Override
+ protected List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session)
+ {
+ Shell shell = page.getWorkbenchWindow().getShell();
+
+ SelectPackageDialog dialog = new SelectPackageDialog(shell, "Generated Packages",
+ "Select one or more packages for registration with the CDO package registry", session.getPackageRegistry()
+ .keySet());
+
+ if (dialog.open() == SelectPackageDialog.OK)
+ {
+ Set<String> checkedURIs = dialog.getCheckedURIs();
+ List<EPackage> ePackages = new ArrayList(checkedURIs.size());
+ for (String uri : checkedURIs)
+ {
+ EPackage ePackage = registry.getEPackage(uri);
+ ePackages.add(ePackage);
+ }
+
+ return ePackages;
+ }
+
+ return null;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class EPackageFactoryValidator implements IInputValidator
+ {
+ public String isValid(String uri)
+ {
+ if (uri == null || uri.length() == 0)
+ {
+ return "";
+ }
+
+ return registry.containsKey(uri) ? null : "Package " + uri + " not found.";
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java
index 8d6dac9..c9299d3 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java
@@ -12,7 +12,9 @@ package org.eclipse.emf.cdo.internal.ui.dialogs;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.internal.ui.SharedIcons;
+import org.eclipse.emf.cdo.internal.ui.actions.RegisterFilesystemPackagesAction;
import org.eclipse.emf.cdo.internal.ui.actions.RegisterGeneratedPackagesAction;
+import org.eclipse.emf.cdo.internal.ui.actions.RegisterWorkspacePackagesAction;
import org.eclipse.emf.cdo.internal.ui.views.CDOItemProvider;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.util.CDOPackageType;
@@ -53,7 +55,11 @@ import java.util.Map.Entry;
*/
public class PackageManagerDialog extends TitleAreaDialog
{
- private static final int REGISTER_PACKAGE_ID = IDialogConstants.CLIENT_ID + 1;
+ private static final int REGISTER_GENERATED_PACKAGES_ID = IDialogConstants.CLIENT_ID + 1;
+
+ private static final int REGISTER_WORKSPACE_PACKAGES_ID = IDialogConstants.CLIENT_ID + 2;
+
+ private static final int REGISTER_FILESYSTEM_PACKAGES_ID = IDialogConstants.CLIENT_ID + 3;
private static final String TITLE = "CDO Package Manager";
@@ -106,45 +112,54 @@ public class PackageManagerDialog extends TitleAreaDialog
@Override
protected void createButtonsForButtonBar(Composite parent)
{
- createButton(parent, REGISTER_PACKAGE_ID, "Register Package", false);
+ createButton(parent, REGISTER_GENERATED_PACKAGES_ID, "Register Generated Packages", false);
+ createButton(parent, REGISTER_WORKSPACE_PACKAGES_ID, "Register Workspace Packages", false);
+ createButton(parent, REGISTER_FILESYSTEM_PACKAGES_ID, "Register Filesystem Packages", false);
createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false);
}
@Override
protected void buttonPressed(int buttonId)
{
- if (buttonId == REGISTER_PACKAGE_ID)
- {
- registerPackage();
- }
- else if (buttonId == IDialogConstants.CLOSE_ID)
+ switch (buttonId)
{
- close();
- }
- }
+ case REGISTER_GENERATED_PACKAGES_ID:
+ new RegisterGeneratedPackagesAction(page, session)
+ {
+ @Override
+ protected void postRegistration(List<EPackage> ePackages)
+ {
+ refreshViewer();
+ }
+ }.run();
+ break;
- protected void registerPackage()
- {
- new RegisterGeneratedPackagesAction(page, session)
- {
- @Override
- protected void postRegistration(List<EPackage> ePackages)
+ case REGISTER_WORKSPACE_PACKAGES_ID:
+ new RegisterWorkspacePackagesAction(page, session)
{
- page.getWorkbenchWindow().getShell().getDisplay().syncExec(new Runnable()
+ @Override
+ protected void postRegistration(List<EPackage> ePackages)
{
- public void run()
- {
- try
- {
- viewer.refresh();
- }
- catch (RuntimeException ignore)
- {
- }
- }
- });
- }
- }.run();
+ refreshViewer();
+ }
+ }.run();
+ break;
+
+ case REGISTER_FILESYSTEM_PACKAGES_ID:
+ new RegisterFilesystemPackagesAction(page, session)
+ {
+ @Override
+ protected void postRegistration(List<EPackage> ePackages)
+ {
+ refreshViewer();
+ }
+ }.run();
+ break;
+
+ case IDialogConstants.CLOSE_ID:
+ close();
+ break;
+ }
}
protected Image getContentIcon(Content content)
@@ -196,6 +211,23 @@ public class PackageManagerDialog extends TitleAreaDialog
column.setWidth(width);
}
+ protected void refreshViewer()
+ {
+ page.getWorkbenchWindow().getShell().getDisplay().syncExec(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ viewer.refresh();
+ }
+ catch (RuntimeException ignore)
+ {
+ }
+ }
+ });
+ }
+
/**
* @author Eike Stepper
*/