summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-25 04:53:27 (EDT)
committerEike Stepper2007-07-25 04:53:27 (EDT)
commit236ede4eb55fcabec8604950cd64f469355eacb9 (patch)
treec9c5352f56636f02214980e944e1184e5050109c
parent13235c74afe23fa978ccd61ce5b0d8c60b01c69d (diff)
downloadcdo-236ede4eb55fcabec8604950cd64f469355eacb9.zip
cdo-236ede4eb55fcabec8604950cd64f469355eacb9.tar.gz
cdo-236ede4eb55fcabec8604950cd64f469355eacb9.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackageAction.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/IPackageProvider.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java375
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RegisterPackageDialog.java102
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java27
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java31
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java2
10 files changed, 546 insertions, 36 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 66f91e9..477c4f0 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
@@ -63,6 +63,11 @@ public class RegisterCDOPackageAction extends RegisterPackageAction
{
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/RegisterPackageAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackageAction.java
index dc47dac..e39abea 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackageAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackageAction.java
@@ -37,6 +37,11 @@ public abstract class RegisterPackageAction extends SessionAction
{
CDOPackageRegistry packageRegistry = getSession().getPackageRegistry();
packageRegistry.putEPackage(ePackage);
+ postRegistration(ePackage);
+ }
+
+ protected void postRegistration(EPackage ePackage)
+ {
}
protected abstract EPackage getEPackage(IWorkbenchPage page, CDOSession session);
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
index 7ed1083..b7d04d6 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
@@ -36,8 +36,8 @@ public abstract class OM
public static final OMPreferences PREFS = BUNDLE.preferences();
- public static final OMPreference<String[]> PREF_HISTORY_REGISTER_CDO_PACKAGE = PREFS
- .initArray("history.register.cdo.package");
+ public static final OMPreference<String[]> PREF_HISTORY_REGISTER_PACKAGE = PREFS
+ .initArray("history.register.package");
static void start() throws Exception
{
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/IPackageProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/IPackageProvider.java
new file mode 100644
index 0000000..0a45af2
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/IPackageProvider.java
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * 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.dialogs;
+
+import org.eclipse.emf.cdo.CDOSession;
+
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.swt.events.SelectionEvent;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IPackageProvider
+{
+ public String getTitle();
+
+ public EPackage getPackage(CDOSession session, SelectionEvent event);
+}
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
new file mode 100644
index 0000000..eadae2b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java
@@ -0,0 +1,375 @@
+/***************************************************************************
+ * 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.dialogs;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.internal.ui.SharedIcons;
+import org.eclipse.emf.cdo.internal.ui.actions.RegisterCDOPackageAction;
+import org.eclipse.emf.cdo.protocol.model.CDOPackage;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IWorkbenchPage;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+/**
+ * @author Eike Stepper
+ */
+public class PackageManagerDialog extends TitleAreaDialog
+{
+ private static final int REGISTER_PACKAGE_ID = IDialogConstants.CLIENT_ID + 1;
+
+ private static final String TITLE = "CDO Package Manager";
+
+ private static final String EMPTY = "";
+
+ private final Set<String> persistentPackageURIs = CDOUtil.getPersistentPackageURIs();
+
+ private IWorkbenchPage page;
+
+ private CDOSession session;
+
+ private TableViewer viewer;
+
+ public PackageManagerDialog(IWorkbenchPage page, CDOSession session)
+ {
+ super(new Shell(page.getWorkbenchWindow().getShell()));
+ this.page = page;
+ this.session = session;
+ setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.MAX | SWT.TITLE | SWT.RESIZE);
+ }
+
+ @Override
+ protected void configureShell(Shell newShell)
+ {
+ super.configureShell(newShell);
+ newShell.setText(TITLE);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ Composite composite = (Composite)super.createDialogArea(parent);
+ setTitle(TITLE);
+ setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_PACKAGE_MANAGER));
+
+ viewer = new TableViewer(composite, SWT.NONE);
+ Table table = viewer.getTable();
+
+ table.setHeaderVisible(true);
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ addColumn(table, "Package", 400, SWT.LEFT);
+ addColumn(table, "Registry", 80, SWT.CENTER);
+ addColumn(table, "Repository", 80, SWT.CENTER);
+
+ viewer.setContentProvider(new ContentProvider());
+ viewer.setLabelProvider(new LabelProvider());
+ viewer.setInput(session);
+
+ return composite;
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ createButton(parent, REGISTER_PACKAGE_ID, "Register Package", 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)
+ {
+ close();
+ }
+ }
+
+ protected void registerPackage()
+ {
+ new RegisterCDOPackageAction(page, session)
+ {
+ @Override
+ protected void postRegistration(EPackage package1)
+ {
+ viewer.refresh();
+ }
+ }.run();
+ }
+
+ protected Image getContentIcon(Content content)
+ {
+ return null;
+ }
+
+ protected String getEPackageText(Object ePackage)
+ {
+ if (ePackage instanceof EPackage.Descriptor)
+ {
+ return "proxy";
+ }
+
+ if (ePackage.getClass() == EPackageImpl.class)
+ {
+ return "dynamic";
+ }
+
+ if (ePackage == EcorePackage.eINSTANCE)
+ {
+ return "Ecore";
+ }
+
+ return persistentPackageURIs.contains(((EPackage)ePackage).getNsURI()) ? "CDO" : "EMF";
+ }
+
+ protected String getCDOPackageText(CDOPackage cdoPackage)
+ {
+ if (cdoPackage.isSystem())
+ {
+ return "SYSTEM";
+ }
+
+ if (!cdoPackage.isPersistent())
+ {
+ return "TRANSIENT";
+ }
+
+ return cdoPackage.isDynamic() ? "DYNAMIC" : "STATIC";
+ }
+
+ private void addColumn(Table table, String title, int width, int alignment)
+ {
+ TableColumn column = new TableColumn(table, alignment);
+ column.setText(title);
+ column.setWidth(width);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public class LabelProvider extends BaseLabelProvider implements ITableLabelProvider
+ {
+ public LabelProvider()
+ {
+ }
+
+ public String getColumnText(Object element, int columnIndex)
+ {
+ if (element instanceof Content)
+ {
+ Content content = (Content)element;
+ switch (columnIndex)
+ {
+ case 0:
+ return content.getPackageURI();
+ case 1:
+ return content.getEPackage() == null ? EMPTY : getEPackageText(content.getEPackage());
+ case 2:
+ return content.getCDOPackage() == null ? EMPTY : getCDOPackageText(content.getCDOPackage());
+ }
+ }
+
+ return element.toString();
+ }
+
+ public Image getColumnImage(Object element, int columnIndex)
+ {
+ if (element instanceof Content)
+ {
+ Content content = (Content)element;
+ if (columnIndex == 0)
+ {
+ return getContentIcon(content);
+ }
+ }
+
+ return null;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class ContentProvider implements IStructuredContentProvider
+ {
+ private static final Object[] NO_ELEMENTS = {};
+
+ private CDOSession session;
+
+ private Content[] elements;
+
+ public ContentProvider()
+ {
+ }
+
+ public void dispose()
+ {
+ elements = null;
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ if (newInput instanceof CDOSession)
+ {
+ if (!ObjectUtil.equals(session, newInput))
+ {
+ session = (CDOSession)newInput;
+ elements = null;
+ }
+ }
+ }
+
+ public Object[] getElements(Object inputElement)
+ {
+ if (inputElement == session)
+ {
+ if (elements == null)
+ {
+ elements = createContent();
+ }
+
+ return elements;
+ }
+
+ return NO_ELEMENTS;
+ }
+
+ private Content[] createContent()
+ {
+ Map<String, Content> map = new HashMap();
+ for (Entry<String, Object> entry : session.getPackageRegistry().entrySet())
+ {
+ String packageURI = entry.getKey();
+ Content content = new Content(packageURI);
+ map.put(packageURI, content);
+ content.setEPackage(entry.getValue());
+ }
+
+ for (CDOPackage cdoPackage : session.getPackageManager().getPackages())
+ {
+ String packageURI = cdoPackage.getPackageURI();
+ Content content = map.get(packageURI);
+ if (content == null)
+ {
+ content = new Content(packageURI);
+ map.put(packageURI, content);
+ }
+
+ content.setCDOPackage(cdoPackage);
+ }
+
+ ArrayList<Content> list = new ArrayList(map.values());
+ Collections.sort(list);
+ return list.toArray(new Content[list.size()]);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Content implements Comparable
+ {
+ private String packageURI;
+
+ private Object ePackage;
+
+ private CDOPackage cdoPackage;
+
+ public Content(String packageURI)
+ {
+ this.packageURI = packageURI;
+ }
+
+ public String getPackageURI()
+ {
+ return packageURI;
+ }
+
+ public Object getEPackage()
+ {
+ return ePackage;
+ }
+
+ public void setEPackage(Object ePackage)
+ {
+ this.ePackage = ePackage;
+ }
+
+ public CDOPackage getCDOPackage()
+ {
+ return cdoPackage;
+ }
+
+ public void setCDOPackage(CDOPackage cdoPackage)
+ {
+ this.cdoPackage = cdoPackage;
+ }
+
+ public int compareTo(Object obj)
+ {
+ return packageURI.compareTo(((Content)obj).packageURI);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof Content)
+ {
+ Content that = (Content)obj;
+ return ObjectUtil.equals(this.packageURI, that.packageURI);
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return ObjectUtil.hashCode(packageURI);
+ }
+
+ @Override
+ public String toString()
+ {
+ return packageURI;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RegisterPackageDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RegisterPackageDialog.java
new file mode 100644
index 0000000..b30cd35
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RegisterPackageDialog.java
@@ -0,0 +1,102 @@
+/***************************************************************************
+ * 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.dialogs;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.internal.ui.bundle.OM;
+
+import org.eclipse.net4j.internal.util.collection.PreferenceHistory;
+import org.eclipse.net4j.util.collection.IHistory;
+
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author Eike Stepper
+ */
+public class RegisterPackageDialog extends TitleAreaDialog
+{
+ public static final IHistory<String> HISTORY = new PreferenceHistory(OM.PREF_HISTORY_REGISTER_PACKAGE);
+
+ private static final String TITLE = "Register Package";
+
+ private CDOSession session;
+
+ public RegisterPackageDialog(Shell parentShell, CDOSession session)
+ {
+ super(parentShell);
+ this.session = session;
+ setShellStyle(getShellStyle() | SWT.TITLE | SWT.RESIZE);
+ }
+
+ @Override
+ protected void configureShell(Shell newShell)
+ {
+ super.configureShell(newShell);
+ newShell.setText(TITLE);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ Composite composite = (Composite)super.createDialogArea(parent);
+ setTitle(TITLE);
+
+ IPackageProvider[] packageProviders = getPackageProviders();
+ Composite packageProviderArea = new Composite(composite, SWT.NONE);
+ packageProviderArea.setLayout(new GridLayout(packageProviders.length, false));
+ packageProviderArea.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ for (final IPackageProvider packageProvider : packageProviders)
+ {
+ Button button = new Button(packageProviderArea, SWT.PUSH);
+ button.setText(packageProvider.getTitle());
+ button.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ EPackage ePackage = packageProvider.getPackage(session, e);
+ if (ePackage != null)
+ {
+ session.getPackageRegistry().putEPackage(ePackage);
+ }
+ }
+ });
+ }
+
+ Composite grid = new Composite(composite, SWT.NONE);
+ grid.setLayout(new GridLayout(2, false));
+
+ return composite;
+ }
+
+ protected IPackageProvider[] getPackageProviders()
+ {
+ return new IPackageProvider[0];
+ }
+
+ protected void registerPackage()
+ {
+ // RegisterCDOPackageAction action = new RegisterCDOPackageAction(page,
+ // session);
+ // action.run();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
index 2edaaee..8878917 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
@@ -22,11 +22,11 @@ import org.eclipse.emf.cdo.internal.ui.actions.CloseSessionAction;
import org.eclipse.emf.cdo.internal.ui.actions.CloseViewAction;
import org.eclipse.emf.cdo.internal.ui.actions.CreateResourceAction;
import org.eclipse.emf.cdo.internal.ui.actions.LoadResourceAction;
+import org.eclipse.emf.cdo.internal.ui.actions.ManagePackagesAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenAuditAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenTransactionAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenViewAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenViewEditorAction;
-import org.eclipse.emf.cdo.internal.ui.actions.RegisterCDOPackageAction;
import org.eclipse.emf.cdo.internal.ui.views.CDOViewHistory.Entry;
import org.eclipse.net4j.IConnector;
@@ -263,7 +263,7 @@ public class CDOItemProvider extends ContainerItemProvider
manager.add(new OpenViewAction(page, session));
manager.add(new OpenAuditAction(page, session));
manager.add(new Separator());
- manager.add(new RegisterCDOPackageAction(page, session));
+ manager.add(new ManagePackagesAction(page, session));
manager.add(new Separator());
manager.add(new CloseSessionAction(page, session));
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
index cdd63e8..a724470 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.net4j.ConnectorException;
import org.eclipse.net4j.IConnector;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.emf.common.notify.Adapter;
@@ -36,19 +37,45 @@ import org.eclipse.emf.ecore.resource.Resource.Factory.Registry;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
import org.eclipse.emf.internal.cdo.CDOSessionImpl;
+import org.eclipse.emf.internal.cdo.bundle.OM;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* @author Eike Stepper
*/
public final class CDOUtil
{
+ public static final String EXT_POINT_NAME = "persistent_package";
+
private CDOUtil()
{
}
+ public static Set<String> getPersistentPackageURIs()
+ {
+ Set<String> result = new HashSet();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] elements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, EXT_POINT_NAME);
+ for (IConfigurationElement element : elements)
+ {
+ String uri = element.getAttribute("uri");
+ if (!StringUtil.isEmpty(uri))
+ {
+ result.add(uri);
+ }
+ }
+
+ return result;
+ }
+
public static CDOSession openSession(IConnector connector, String repositoryName, EPackage.Registry delegate)
throws ConnectorException
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java
index a6f8033..3b053f6 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java
@@ -28,8 +28,7 @@ public final class Activator extends EMFPlugin
return plugin;
}
- public static class Implementation extends EclipsePlugin // implements
- // IRegistryChangeListener
+ public static class Implementation extends EclipsePlugin
{
public Implementation()
{
@@ -41,42 +40,14 @@ public final class Activator extends EMFPlugin
{
super.start(context);
OM.BUNDLE.setBundleContext(context);
- // EMFUtil.addModelInfos(EMFUtil.PACKAGE_MANAGER);
- // IExtensionRegistry registry = Platform.getExtensionRegistry();
- // IConfigurationElement[] elements =
- // registry.getConfigurationElementsFor(CDO.BUNDLE_ID,
- // CDO.PERSISTENT_PACKAGE_EXT_POINT);
- // for (IConfigurationElement element : elements)
- // {
- // String uri = element.getAttribute("uri");
- // // TODO Don't load EPackages eagerly
- // EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(uri);
- // if (ePackage != null)
- // {
- // EMFUtil.getCDOPackage(ePackage, EMFUtil.PACKAGE_MANAGER);
- // }
- // else
- // {
- // CDO.LOG.warn("Ecore package not found: " + uri);
- // }
- // }
- //
- // registry.addRegistryChangeListener(this, CDO.BUNDLE_ID);
}
@Override
public void stop(BundleContext context) throws Exception
{
- // IExtensionRegistry registry = Platform.getExtensionRegistry();
- // registry.removeRegistryChangeListener(this);
- // EMFUtil.removeModelInfos(EMFUtil.PACKAGE_MANAGER);
plugin = null;
OM.BUNDLE.setBundleContext(null);
super.stop(context);
}
-
- // public void registryChanged(IRegistryChangeEvent event)
- // {
- // }
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java
index a11da14..c943a4a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java
@@ -47,6 +47,4 @@ public abstract class OM
public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$
public static final OMLogger LOG = BUNDLE.logger();
-
- public static final String PERSISTENT_PACKAGE_EXT_POINT = "persistent_package";
}