Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2013-11-12 19:34:15 +0000
committerChristian W. Damus2013-11-12 21:18:39 +0000
commitfc7dc3df6477972fec22cbc8e4a0953a7e4648ec (patch)
tree49cefb8000e1645f962e63b3c2eddc36ae2f6057 /extraplugins
parent83bea6eb06573d5f890e1052c9963257388443b6 (diff)
downloadorg.eclipse.papyrus-fc7dc3df6477972fec22cbc8e4a0953a7e4648ec.tar.gz
org.eclipse.papyrus-fc7dc3df6477972fec22cbc8e4a0953a7e4648ec.tar.xz
org.eclipse.papyrus-fc7dc3df6477972fec22cbc8e4a0953a7e4648ec.zip
[415375] [CDO] Model repository administration
https://bugs.eclipse.org/bugs/show_bug.cgi?id=415375 Prompt the user to add/remove repositories in the Model Repositories view when they are added/removed in the CDO Administration view.
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF16
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/IPapyrusRepositoryAdminListener.java25
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/PapyrusRepositoryAdminEvent.java58
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/PapyrusRepositoryAdminManager.java122
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/META-INF/MANIFEST.MF11
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/Activator.java6
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/admin/RepositoryAdminListener.java93
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/Messages.java10
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/messages.properties5
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoriesView.java34
10 files changed, 375 insertions, 5 deletions
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF
index 5f2609a1713..7a50f869445 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF
@@ -1,10 +1,21 @@
Manifest-Version: 1.0
Export-Package: org.eclipse.papyrus.cdo.core,
+ org.eclipse.papyrus.cdo.core.admin,
org.eclipse.papyrus.cdo.core.exporter,
org.eclipse.papyrus.cdo.core.importer,
org.eclipse.papyrus.cdo.core.resource,
org.eclipse.papyrus.cdo.core.util,
- org.eclipse.papyrus.cdo.internal.core;x-friends:="org.eclipse.papyrus.cdo.core.tests, org.eclipse.papyrus.cdo.ui, org.eclipse.papyrus.cdo.ui.tests, org.eclipse.papyrus.cdo.uml.diagram.ui, org.eclipse.papyrus.cdo.uml.ui, org.eclipse.papyrus.cdo.ui.customization.properties, org.eclipse.papyrus.cdo.uml.ui.tests, org.eclipse.papyrus.cdo.uml.search.ui, org.eclipse.papyrus.cdo.uml.search.ui.tests, org.eclipse.papyrus.cdo.ui.hyperlink",
+ org.eclipse.papyrus.cdo.internal.core;
+ x-friends:="org.eclipse.papyrus.cdo.core.tests,
+ org.eclipse.papyrus.cdo.ui,
+ org.eclipse.papyrus.cdo.ui.tests,
+ org.eclipse.papyrus.cdo.uml.diagram.ui,
+ org.eclipse.papyrus.cdo.uml.ui,
+ org.eclipse.papyrus.cdo.ui.customization.properties,
+ org.eclipse.papyrus.cdo.uml.ui.tests,
+ org.eclipse.papyrus.cdo.uml.search.ui,
+ org.eclipse.papyrus.cdo.uml.search.ui.tests,
+ org.eclipse.papyrus.cdo.ui.hyperlink",
org.eclipse.papyrus.cdo.internal.core.controlmode;x-friends:="org.eclipse.papyrus.cdo.ui,org.eclipse.papyrus.cdo.core.tests",
org.eclipse.papyrus.cdo.internal.core.exporter;x-friends:="org.eclipse.papyrus.cdo.core.tests,org.eclipse.papyrus.cdo.ui",
org.eclipse.papyrus.cdo.internal.core.expressions;x-friends:="org.eclipse.papyrus.cdo.core.tests,org.eclipse.papyrus.cdo.ui",
@@ -40,7 +51,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.gmf.runtime.emf.commands.core;bundle-version="[1.7.0,2.0.0)",
org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.7.0,2.0.0)",
org.eclipse.papyrus.infra.services.localizer;bundle-version="0.10.1",
- org.eclipse.net4j;bundle-version="[4.3.0,5.0.0)"
+ org.eclipse.net4j;bundle-version="[4.3.0,5.0.0)",
+ org.eclipse.emf.cdo.admin;bundle-version="[4.1.200,5.0.0)"
Bundle-Vendor: %providerName
Bundle-Version: 0.10.1.qualifier
Bundle-ManifestVersion: 2
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/IPapyrusRepositoryAdminListener.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/IPapyrusRepositoryAdminListener.java
new file mode 100644
index 00000000000..982d631519f
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/IPapyrusRepositoryAdminListener.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.admin;
+
+import java.util.EventListener;
+
+
+/**
+ * This is the IPapyrusRepositoryAdminListener type. Enjoy.
+ */
+public interface IPapyrusRepositoryAdminListener extends EventListener {
+
+ void repositoryAdded(PapyrusRepositoryAdminEvent event);
+
+ void repositoryRemoved(PapyrusRepositoryAdminEvent event);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/PapyrusRepositoryAdminEvent.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/PapyrusRepositoryAdminEvent.java
new file mode 100644
index 00000000000..8ee374930fa
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/PapyrusRepositoryAdminEvent.java
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.admin;
+
+import java.util.EventObject;
+
+
+/**
+ * This is the PapyrusRepositoryAdminEvent type. Enjoy.
+ */
+public class PapyrusRepositoryAdminEvent extends EventObject {
+
+ public static final int REPOSITORY_ADDED = 0;
+
+ public static final int REPOSITORY_REMOVED = 1;
+
+ private static final long serialVersionUID = 1L;
+
+ private final int eventType;
+
+ private final String url;
+
+ private final String name;
+
+ public PapyrusRepositoryAdminEvent(PapyrusRepositoryAdminManager source, int eventType, String url, String name) {
+ super(source);
+
+ this.eventType = eventType;
+ this.url = url;
+ this.name = name;
+ }
+
+ @Override
+ public PapyrusRepositoryAdminManager getSource() {
+ return (PapyrusRepositoryAdminManager)super.getSource();
+ }
+
+ public int getEventType() {
+ return eventType;
+ }
+
+ public String getRepositoryURL() {
+ return url;
+ }
+
+ public String getRepositoryName() {
+ return name;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/PapyrusRepositoryAdminManager.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/PapyrusRepositoryAdminManager.java
new file mode 100644
index 00000000000..bba2bb62421
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/PapyrusRepositoryAdminManager.java
@@ -0,0 +1,122 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.admin;
+
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.eclipse.emf.cdo.admin.CDOAdminClient;
+import org.eclipse.emf.cdo.common.admin.CDOAdminRepository;
+import org.eclipse.net4j.util.container.ContainerEventAdapter;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.papyrus.cdo.internal.core.Activator;
+
+import com.google.common.collect.Maps;
+
+
+/**
+ * This is the PapyrusRepositoryAdminManager type. Enjoy.
+ */
+public class PapyrusRepositoryAdminManager extends ContainerEventAdapter<CDOAdminClient> {
+
+ private final RepositoryListener repositoryListener = new RepositoryListener();
+
+ private final CopyOnWriteArrayList<IPapyrusRepositoryAdminListener> listeners = new CopyOnWriteArrayList<IPapyrusRepositoryAdminListener>();
+
+ private final Map<CDOAdminRepository, String> repositories = Maps.newConcurrentMap();
+
+ public PapyrusRepositoryAdminManager() {
+ super(true);
+ }
+
+ public void install(IContainer<? extends CDOAdminClient> container) {
+ container.addListener(repositoryListener);
+
+ for(CDOAdminClient next : container.getElements()) {
+ next.addListener(repositoryListener);
+ }
+ }
+
+ @Override
+ protected void onAdded(IContainer<CDOAdminClient> container, CDOAdminClient element) {
+ element.addListener(repositoryListener);
+ }
+
+ @Override
+ protected void onRemoved(IContainer<CDOAdminClient> container, CDOAdminClient element) {
+ element.removeListener(repositoryListener);
+ }
+
+ public void addRepositoryAdminListener(IPapyrusRepositoryAdminListener listener) {
+ listeners.addIfAbsent(listener);
+ }
+
+ public void removeRepositoryAdminListener(IPapyrusRepositoryAdminListener listener) {
+ listeners.remove(listener);
+ }
+
+ protected void fireRepositoryAdminEvent(int eventType, String url, String name) {
+ if(!listeners.isEmpty()) {
+ PapyrusRepositoryAdminEvent event = new PapyrusRepositoryAdminEvent(this, eventType, url, name);
+ for(IPapyrusRepositoryAdminListener next : listeners) {
+ try {
+ switch(eventType) {
+ case PapyrusRepositoryAdminEvent.REPOSITORY_ADDED:
+ next.repositoryAdded(event);
+ break;
+ case PapyrusRepositoryAdminEvent.REPOSITORY_REMOVED:
+ next.repositoryRemoved(event);
+ break;
+ }
+ } catch (Exception e) {
+ Activator.log.error("Uncaught exception in repository admin listener.", e); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ //
+ // Nested types
+ //
+
+ private class RepositoryListener extends ContainerEventAdapter<CDOAdminRepository> {
+
+ @Override
+ protected void onAdded(IContainer<CDOAdminRepository> container, CDOAdminRepository element) {
+ if(container instanceof CDOAdminClient) {
+ CDOAdminClient client = (CDOAdminClient)container;
+ String url = String.format("%s?repositoryName=%s", client.getURL(), element.getName()); //$NON-NLS-1$
+ repositories.put(element, url);
+
+ if(client.isConnected()) {
+ // Only notify for repositories added while connected, which ensures that we don't
+ // get a cascade of events on initial connection and discovery of existing repositories
+ fireRepositoryAdminEvent(PapyrusRepositoryAdminEvent.REPOSITORY_ADDED, url, element.getName());
+ }
+ }
+ }
+
+ @Override
+ protected void onRemoved(IContainer<CDOAdminRepository> container, CDOAdminRepository element) {
+ if(container instanceof CDOAdminClient) {
+ CDOAdminClient client = (CDOAdminClient)container;
+ String url = repositories.remove(element);
+
+ if((url != null) && client.isConnected()) {
+ // Only notify for repositories removed while connected, which ensures that we don't
+ // get a cascade of events on disconnection from the server
+ fireRepositoryAdminEvent(PapyrusRepositoryAdminEvent.REPOSITORY_REMOVED, url, element.getName());
+ }
+ }
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/META-INF/MANIFEST.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/META-INF/MANIFEST.MF
index 34c70133ec8..71da782344c 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/META-INF/MANIFEST.MF
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/META-INF/MANIFEST.MF
@@ -21,10 +21,12 @@ Require-Bundle: org.eclipse.core.runtime,
com.google.guava;bundle-version="[11.0.0,12.0.0)",
org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.1",
org.eclipse.papyrus.infra.services.controlmode;bundle-version="0.10.1",
- org.eclipse.ui.navigator;bundle-version="3.5.300"
+ org.eclipse.ui.navigator;bundle-version="3.5.300",
+ org.eclipse.emf.cdo.ui.admin;bundle-version="[4.1.200,5.0.0)"
Export-Package: org.eclipse.papyrus.cdo.internal.ui;x-friends:="org.eclipse.papyrus.cdo.ui.tests,org.eclipse.papyrus.cdo.uml.ui",
org.eclipse.papyrus.cdo.internal.ui.actions;x-friends:="org.eclipse.papyrus.cdo.ui.tests",
org.eclipse.papyrus.cdo.internal.ui.adapters;x-friends:="org.eclipse.papyrus.cdo.ui.tests",
+ org.eclipse.papyrus.cdo.internal.ui.admin;x-internal:=true,
org.eclipse.papyrus.cdo.internal.ui.decorators;x-friends:="org.eclipse.papyrus.cdo.ui.tests",
org.eclipse.papyrus.cdo.internal.ui.dialogs;x-friends:="org.eclipse.papyrus.cdo.ui.tests,org.eclipse.papyrus.cdo.ui.customization.properties,org.eclipse.papyrus.cdo.ui.hyperlink",
org.eclipse.papyrus.cdo.internal.ui.dnd;x-friends:="org.eclipse.papyrus.cdo.ui.hyperlink,org.eclipse.papyrus.cdo.ui.tests",
@@ -36,7 +38,12 @@ Export-Package: org.eclipse.papyrus.cdo.internal.ui;x-friends:="org.eclipse.papy
org.eclipse.papyrus.cdo.internal.ui.properties;x-friends:="org.eclipse.papyrus.cdo.ui.tests",
org.eclipse.papyrus.cdo.internal.ui.providers;x-friends:="org.eclipse.papyrus.cdo.ui.tests",
org.eclipse.papyrus.cdo.internal.ui.util;x-friends:="org.eclipse.papyrus.cdo.ui.tests",
- org.eclipse.papyrus.cdo.internal.ui.views;x-friends:="org.eclipse.papyrus.cdo.ui.tests,org.eclipse.papyrus.cdo.uml.diagram.ui,org.eclipse.papyrus.cdo.uml.ui,org.eclipse.papyrus.cdo.uml.ui.tests,org.eclipse.papyrus.cdo.ui.hyperlink",
+ org.eclipse.papyrus.cdo.internal.ui.views;
+ x-friends:="org.eclipse.papyrus.cdo.ui.tests,
+ org.eclipse.papyrus.cdo.uml.diagram.ui,
+ org.eclipse.papyrus.cdo.uml.ui,
+ org.eclipse.papyrus.cdo.uml.ui.tests,
+ org.eclipse.papyrus.cdo.ui.hyperlink",
org.eclipse.papyrus.cdo.internal.ui.widgets;x-internal:=true,
org.eclipse.papyrus.cdo.internal.ui.wizards;x-friends:="org.eclipse.papyrus.cdo.ui.tests,org.eclipse.papyrus.cdo.uml.diagram.ui,org.eclipse.papyrus.cdo.ui.customization.properties"
Bundle-Vendor: %providerName
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/Activator.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/Activator.java
index 3c4dbba1282..a808651e446 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/Activator.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/Activator.java
@@ -2,6 +2,7 @@ package org.eclipse.papyrus.cdo.internal.ui;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.cdo.admin.CDOAdminClientManager;
import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -167,4 +168,9 @@ public class Activator extends AbstractUIPlugin {
public static IStatus error(String message, Throwable exception) {
return new Status(IStatus.ERROR, PLUGIN_ID, message, exception);
}
+
+ @SuppressWarnings("restriction")
+ public static CDOAdminClientManager getCDOAdminClientManager() {
+ return org.eclipse.emf.cdo.ui.internal.admin.bundle.OM.getAdminManager();
+ }
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/admin/RepositoryAdminListener.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/admin/RepositoryAdminListener.java
new file mode 100644
index 00000000000..b3df356a8ed
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/admin/RepositoryAdminListener.java
@@ -0,0 +1,93 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.admin;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.net4j.util.ui.UIUtil;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.core.admin.IPapyrusRepositoryAdminListener;
+import org.eclipse.papyrus.cdo.core.admin.PapyrusRepositoryAdminEvent;
+import org.eclipse.papyrus.cdo.internal.ui.l10n.Messages;
+
+
+/**
+ * This is the RepositoryAdminListener type. Enjoy.
+ */
+public class RepositoryAdminListener implements IPapyrusRepositoryAdminListener {
+
+ private final IPapyrusRepositoryManager repositoryManager;
+
+ public RepositoryAdminListener(IPapyrusRepositoryManager repositoryManager) {
+ super();
+
+ this.repositoryManager = repositoryManager;
+ }
+
+ @Override
+ public void repositoryAdded(PapyrusRepositoryAdminEvent event) {
+ final String url = event.getRepositoryURL();
+
+ IPapyrusRepository existing = repositoryManager.getRepository(url);
+ if(existing == null) {
+ final String name = event.getRepositoryName();
+ UIUtil.getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ if(MessageDialog.openQuestion(UIUtil.getActiveWorkbenchWindow().getShell(), Messages.RepositoryAdminListener_0, NLS.bind(Messages.RepositoryAdminListener_1, name))) {
+ repositoryManager.createRepository(url).setName(uniqueName(name));
+ repositoryManager.saveRepositories();
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ public void repositoryRemoved(PapyrusRepositoryAdminEvent event) {
+ final IPapyrusRepository existing = repositoryManager.getRepository(event.getRepositoryURL());
+ if(existing != null) {
+ final String name = existing.getName();
+ UIUtil.getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ if(MessageDialog.openQuestion(UIUtil.getActiveWorkbenchWindow().getShell(), Messages.RepositoryAdminListener_2, NLS.bind(Messages.RepositoryAdminListener_3, name))) {
+ repositoryManager.removeRepository(existing);
+ repositoryManager.saveRepositories();
+ }
+ }
+ });
+ }
+ }
+
+ protected String uniqueName(String preferredName) {
+ String result = preferredName;
+ int counter = 1;
+ boolean again;
+
+ do {
+ again = false;
+ for(IPapyrusRepository next : repositoryManager.getRepositories()) {
+ if(result.equals(next.getName())) {
+ result = NLS.bind(Messages.RepositoryAdminListener_4, preferredName, counter++);
+ again = true;
+ break;
+ }
+ }
+ } while(again);
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/Messages.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/Messages.java
index 59958d6784f..a1a0ed51721 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/Messages.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/Messages.java
@@ -222,6 +222,16 @@ public class Messages extends NLS {
public static String RenameModelAction_8;
+ public static String RepositoryAdminListener_0;
+
+ public static String RepositoryAdminListener_1;
+
+ public static String RepositoryAdminListener_2;
+
+ public static String RepositoryAdminListener_3;
+
+ public static String RepositoryAdminListener_4;
+
public static String RepositoryCredentialsDialog_0;
public static String RepositoryCredentialsDialog_1;
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/messages.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/messages.properties
index 9c07b695c5e..81b2d8a6525 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/messages.properties
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/messages.properties
@@ -110,6 +110,11 @@ RenameModelAction_10=A resource named "{0}" already exists.
RenameModelAction_2=Enter a new name for the model:
RenameModelAction_7=A name is required.
RenameModelAction_8=Model name may not contain a path separator.
+RepositoryAdminListener_0=Repository Added
+RepositoryAdminListener_1=A repository named "{0}" has been added to the server. Would you like to add it to the Model Repositories view?
+RepositoryAdminListener_2=Repository Removed
+RepositoryAdminListener_3=The repository "{0}" has been removed from the server. Would you like to remove it from the Model Repositories view?
+RepositoryAdminListener_4={0} ({1})
RepositoryCredentialsDialog_0=Repository Login
RepositoryCredentialsDialog_1=Enter your credentials for the repository "{0}".
RepositoryCredentialsDialog_2=User name:
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoriesView.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoriesView.java
index f08c1e8f140..d589d619f1e 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoriesView.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoriesView.java
@@ -13,6 +13,7 @@ package org.eclipse.papyrus.cdo.internal.ui.views;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.cdo.admin.CDOAdminClientManager;
import org.eclipse.emf.cdo.eresource.CDOResourceLeaf;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
@@ -28,10 +29,12 @@ import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
import org.eclipse.net4j.util.ui.views.ContainerView;
import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
-import org.eclipse.papyrus.cdo.internal.core.Activator;
+import org.eclipse.papyrus.cdo.core.admin.IPapyrusRepositoryAdminListener;
+import org.eclipse.papyrus.cdo.core.admin.PapyrusRepositoryAdminManager;
import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepository;
import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepositoryManager;
import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
import org.eclipse.papyrus.cdo.internal.ui.actions.AbstractRepositoryAction;
import org.eclipse.papyrus.cdo.internal.ui.actions.AddRepositoryAction;
import org.eclipse.papyrus.cdo.internal.ui.actions.ChangePasswordAction;
@@ -43,6 +46,7 @@ import org.eclipse.papyrus.cdo.internal.ui.actions.LinkWithEditorAction;
import org.eclipse.papyrus.cdo.internal.ui.actions.OpenPapyrusModelAction;
import org.eclipse.papyrus.cdo.internal.ui.actions.RemoveRepositoryAction;
import org.eclipse.papyrus.cdo.internal.ui.actions.RenameModelAction;
+import org.eclipse.papyrus.cdo.internal.ui.admin.RepositoryAdminListener;
import org.eclipse.papyrus.cdo.internal.ui.dnd.ResourceDragAdapter;
import org.eclipse.papyrus.cdo.internal.ui.dnd.ResourceDropAdapter;
import org.eclipse.papyrus.cdo.internal.ui.l10n.Messages;
@@ -79,6 +83,12 @@ public class ModelRepositoriesView extends ContainerView {
private final IInternalPapyrusRepositoryManager repositoryManager;
+ private final PapyrusRepositoryAdminManager adminManager;
+
+ private CDOAdminClientManager clientManager;
+
+ private IPapyrusRepositoryAdminListener adminListener;
+
private AddRepositoryAction addRepositoryAction;
private LinkWithEditorAction linkWithEditorAction;
@@ -109,6 +119,7 @@ public class ModelRepositoriesView extends ContainerView {
super();
repositoryManager = PapyrusRepositoryManager.INSTANCE;
+ adminManager = new PapyrusRepositoryAdminManager();
}
@Override
@@ -124,6 +135,27 @@ public class ModelRepositoriesView extends ContainerView {
// link by default
Boolean linking = (memento == null) ? Boolean.TRUE : memento.getBoolean(STATE_LINKING);
setLinkWithEditor(!Boolean.FALSE.equals(linking));
+
+ // attach the admin manager
+ clientManager = Activator.getCDOAdminClientManager();
+ if(clientManager != null) {
+ adminManager.install(clientManager);
+ adminListener = new RepositoryAdminListener(repositoryManager);
+ adminManager.addRepositoryAdminListener(adminListener);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ try {
+ if(clientManager != null) {
+ adminManager.removeRepositoryAdminListener(adminListener);
+ clientManager.removeListener(adminManager);
+ clientManager = null;
+ }
+ } finally {
+ super.dispose();
+ }
}
@Override

Back to the top