summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-06 06:37:29 (EDT)
committerEike Stepper2007-08-06 06:37:29 (EDT)
commitf6eaab5dd93fd74f0e6d923d36defb2347ecf868 (patch)
treeae946614221e612488c2398c092f79694343593d
parent23f0951350c02ca680c6c01a5c421609f753a638 (diff)
downloadcdo-f6eaab5dd93fd74f0e6d923d36defb2347ecf868.zip
cdo-f6eaab5dd93fd74f0e6d923d36defb2347ecf868.tar.gz
cdo-f6eaab5dd93fd74f0e6d923d36defb2347ecf868.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterFilesystemPackagesAction.java67
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java4
2 files changed, 35 insertions, 36 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
index e134d9a..15a545b 100644
--- 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
@@ -11,69 +11,68 @@
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.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.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
+import java.io.File;
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 static final String TITLE = "Register Filesystem Packages";
- private EPackage.Registry registry = EPackage.Registry.INSTANCE;
+ private static final String[] FILTER_NAMES = { "Ecore models (*.ecore)", "XMI files (*.xmi)", "XML files (*.xml)",
+ "All files (*.*)" };
+
+ private static final String[] FILTER_EXTENSIONS = { "ecore", "xmi", "xml", null };
public RegisterFilesystemPackagesAction(IWorkbenchPage page, CDOSession session)
{
- super(page, TITLE, "Register native, legacy or converted packages", null, session);
+ super(page, TITLE, "Register dynamic packages from the filesystem", 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)
+ FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
+ dialog.setFileName("*.ecore");
+ dialog.setFilterNames(FILTER_NAMES);
+ dialog.setFilterExtensions(FILTER_EXTENSIONS);
+ if (dialog.open() != null)
{
- Set<String> checkedURIs = dialog.getCheckedURIs();
- List<EPackage> ePackages = new ArrayList(checkedURIs.size());
- for (String uri : checkedURIs)
+ String filterPath = dialog.getFilterPath();
+ String[] fileNames = dialog.getFileNames();
+ if (fileNames != null && fileNames.length != 0)
{
- EPackage ePackage = registry.getEPackage(uri);
- ePackages.add(ePackage);
- }
+ ResourceSet resourceSet = EMFUtil.newEcoreResourceSet();
+ List<EPackage> ePackages = new ArrayList(fileNames.length);
+ for (String fileName : fileNames)
+ {
+ String path = filterPath + File.separator + fileName;
+ URI uri = URI.createFileURI(path);
+ 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/actions/RegisterWorkspacePackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java
index 492de9d..9370999 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
@@ -31,11 +31,11 @@ import java.util.List;
*/
public class RegisterWorkspacePackagesAction extends RegisterPackagesAction
{
- private static final String TITLE = "Register Generated Packages";
+ private static final String TITLE = "Register Workspace Packages";
public RegisterWorkspacePackagesAction(IWorkbenchPage page, CDOSession session)
{
- super(page, TITLE, "Register native, legacy or converted packages", null, session);
+ super(page, TITLE, "Register dynamic packages from the workspace", null, session);
}
@Override