summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-06 06:09:15 (EDT)
committerEike Stepper2007-08-06 06:09:15 (EDT)
commit23f0951350c02ca680c6c01a5c421609f753a638 (patch)
treeeb6bee5b35ecce26262b8307eaba8ea160852aa9
parent8874c8f47fd48aa896dedfc44b1638249b924b42 (diff)
downloadcdo-23f0951350c02ca680c6c01a5c421609f753a638.zip
cdo-23f0951350c02ca680c6c01a5c421609f753a638.tar.gz
cdo-23f0951350c02ca680c6c01a5c421609f753a638.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java41
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java59
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenResourcesDialog.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java6
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/Logger.java8
5 files changed, 91 insertions, 39 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java
index 161ed27..530ca7b 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java
@@ -1,12 +1,17 @@
package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.internal.ui.bundle.OM;
import org.eclipse.emf.cdo.util.CDOPackageRegistry;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import java.util.List;
@@ -18,6 +23,8 @@ public abstract class RegisterPackagesAction extends SessionAction
{
private List<EPackage> ePackages;
+ private int errors;
+
public RegisterPackagesAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image,
CDOSession session)
{
@@ -37,13 +44,45 @@ public abstract class RegisterPackagesAction extends SessionAction
@Override
protected void doRun(IProgressMonitor monitor) throws Exception
{
+ errors = 0;
CDOPackageRegistry packageRegistry = getSession().getPackageRegistry();
for (EPackage ePackage : ePackages)
{
- packageRegistry.putEPackage(ePackage);
+ Resource resource = ePackage.eResource();
+ URI uri = resource == null ? null : resource.getURI();
+
+ try
+ {
+ packageRegistry.putEPackage(ePackage);
+ }
+ catch (RuntimeException ex)
+ {
+ ++errors;
+ if (uri == null)
+ {
+ OM.LOG.error(ex);
+ }
+ else
+ {
+ OM.LOG.error("Failed to register package " + uri, ex);
+ }
+ }
}
postRegistration(ePackages);
+ if (errors != 0)
+ {
+ final String label = String.valueOf(errors) + (errors == 1 ? " package has" : " packages have");
+ final Shell shell = getShell();
+ shell.getDisplay().asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ MessageDialog.openError(shell, getText(), label
+ + " not been registered due to errors.\nSee the log for details.");
+ }
+ });
+ }
}
protected void postRegistration(List<EPackage> ePackages)
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
index 513876e..492de9d 100644
--- 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
@@ -11,17 +11,20 @@
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.cdo.internal.ui.dialogs.OpenResourcesDialog;
+import org.eclipse.emf.cdo.util.EMFUtil;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.core.resources.IFile;
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
@@ -30,8 +33,6 @@ 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);
@@ -41,40 +42,30 @@ public class RegisterWorkspacePackagesAction extends RegisterPackagesAction
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)
+ OpenResourcesDialog dialog = new OpenResourcesDialog(shell);
+ if (dialog.open() == OpenResourcesDialog.OK)
{
- Set<String> checkedURIs = dialog.getCheckedURIs();
- List<EPackage> ePackages = new ArrayList(checkedURIs.size());
- for (String uri : checkedURIs)
+ Object[] result = dialog.getResult();
+ if (result != null && result.length != 0)
{
- EPackage ePackage = registry.getEPackage(uri);
- ePackages.add(ePackage);
- }
+ ResourceSet resourceSet = EMFUtil.newEcoreResourceSet();
+ List<EPackage> ePackages = new ArrayList(result.length);
+ for (Object object : result)
+ {
+ if (object instanceof IFile)
+ {
+ IFile file = (IFile)object;
+ URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
+ Resource resource = resourceSet.getResource(uri, true);
+ EPackage ePackage = (EPackage)resource.getContents().get(0);
+ ePackages.add(ePackage);
+ }
+ }
- return ePackages;
+ 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/OpenResourcesDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenResourcesDialog.java
new file mode 100644
index 0000000..52389f1
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenResourcesDialog.java
@@ -0,0 +1,16 @@
+package org.eclipse.emf.cdo.internal.ui.dialogs;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
+
+public class OpenResourcesDialog extends FilteredResourcesSelectionDialog
+{
+ public OpenResourcesDialog(Shell parentShell)
+ {
+ super(parentShell, true, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
+ setTitle("Open Resources");
+ setInitialPattern("*.ecore");
+ }
+}
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 c9299d3..f03f969 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
@@ -112,9 +112,9 @@ public class PackageManagerDialog extends TitleAreaDialog
@Override
protected void createButtonsForButtonBar(Composite parent)
{
- 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, REGISTER_GENERATED_PACKAGES_ID, "Generated...", false);
+ createButton(parent, REGISTER_WORKSPACE_PACKAGES_ID, "Workspace...", false);
+ createButton(parent, REGISTER_FILESYSTEM_PACKAGES_ID, "Filesystem...", false);
createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false);
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/Logger.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/Logger.java
index 9acfaf1..ac2fb6b 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/Logger.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/Logger.java
@@ -83,7 +83,13 @@ public class Logger implements OMLogger
public void log(Level level, Throwable t)
{
- log(level, t.getLocalizedMessage(), t);
+ String msg = t.getMessage();
+ if (msg == null)
+ {
+ msg = t.getClass().getSimpleName();
+ }
+
+ log(level, msg, t);
}
public void error(Throwable t)