Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2013-11-13 17:27:04 +0000
committerChristian W. Damus2013-11-13 17:29:17 +0000
commit278a9089c9176645ea256720c578e23a0c3f6068 (patch)
tree47b7296bb43211799336efd7fc010e3d12061fe2 /extraplugins
parent9c55419fd35945cd638230fa546948f712f638e0 (diff)
downloadorg.eclipse.papyrus-278a9089c9176645ea256720c578e23a0c3f6068.tar.gz
org.eclipse.papyrus-278a9089c9176645ea256720c578e23a0c3f6068.tar.xz
org.eclipse.papyrus-278a9089c9176645ea256720c578e23a0c3f6068.zip
[415375] [CDO] Model repository administration
https://bugs.eclipse.org/bugs/show_bug.cgi?id=415375 Add an action on admin repositories to open them in the Model Repositories view.
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/admin/PapyrusRepositoryAdminManager.java2
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.properties4
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.xml28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ConnectRepositoryAction.java2
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/OpenInModelRepositoriesViewHandler.java82
5 files changed, 115 insertions, 3 deletions
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
index bba2bb62421..f858b5b5d79 100644
--- 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
@@ -39,7 +39,7 @@ public class PapyrusRepositoryAdminManager extends ContainerEventAdapter<CDOAdmi
}
public void install(IContainer<? extends CDOAdminClient> container) {
- container.addListener(repositoryListener);
+ container.addListener(this);
for(CDOAdminClient next : container.getElements()) {
next.addListener(repositoryListener);
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.properties
index 759800eea8e..f6fa05b14af 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.properties
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.properties
@@ -28,4 +28,6 @@ resolveCommand.name = Resolve conflicts
importCommand.name = Import Models into Repository
exportCommand.name = Export Model to Workspace
navigatorDropContent.name = Papyrus Model Repository Content
-repoFiltersExtPt.name = Model Repository Item Provider Filters \ No newline at end of file
+repoFiltersExtPt.name = Model Repository Item Provider Filters
+openInModelRepositoriesCommand.label = Open in Model Repositories
+openInModelRepositoriesCommand.name = Open in Model Repositories View
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.xml b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.xml
index 8f74e64e722..9d1a0dcb6f9 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.xml
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.xml
@@ -169,6 +169,14 @@
checkEnabled="true">
</visibleWhen>
</command>
+ <command
+ commandId="org.eclipse.papyrus.cdo.ui.commands.openInModelRepositories"
+ label="%openInModelRepositoriesCommand.label"
+ icon="$nl$/icons/full/view16/model_repositories.gif">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.papyrus.cdo.ui.ModelRepositoriesView?after=additions">
@@ -203,6 +211,10 @@
id="org.eclipse.papyrus.cdo.ui.commands.exportModel"
name="%exportCommand.name">
</command>
+ <command
+ id="org.eclipse.papyrus.cdo.ui.commands.openInModelRepositories"
+ name="%openInModelRepositoriesCommand.name">
+ </command>
</extension>
<extension
point="org.eclipse.ui.handlers">
@@ -270,6 +282,22 @@
</iterate>
</enabledWhen>
</handler>
+ <handler
+ class="org.eclipse.papyrus.cdo.internal.ui.handlers.OpenInModelRepositoriesViewHandler"
+ commandId="org.eclipse.papyrus.cdo.ui.commands.openInModelRepositories">
+ <enabledWhen>
+ <with variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate operator="and">
+ <adapt
+ type="org.eclipse.emf.cdo.admin.CDOAdminClientRepository">
+ </adapt>
+ </iterate>
+ </with>
+ </enabledWhen>
+ </handler>
</extension>
<extension
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ConnectRepositoryAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ConnectRepositoryAction.java
index 2fa5916ed54..a33e102d8a6 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ConnectRepositoryAction.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ConnectRepositoryAction.java
@@ -39,7 +39,7 @@ public class ConnectRepositoryAction extends AbstractRepositoryAction {
}
@Override
- protected void run(final IPapyrusRepository repository) {
+ public void run(final IPapyrusRepository repository) {
try {
getPart().getSite().getWorkbenchWindow().run(true, false, new IRunnableWithProgress() {
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/OpenInModelRepositoriesViewHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/OpenInModelRepositoriesViewHandler.java
new file mode 100644
index 00000000000..720dc5b4b1a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/OpenInModelRepositoriesViewHandler.java
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * 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.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.cdo.admin.CDOAdminClient;
+import org.eclipse.emf.cdo.admin.CDOAdminClientRepository;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.net4j.util.ui.UIUtil;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.actions.ConnectRepositoryAction;
+import org.eclipse.papyrus.cdo.internal.ui.views.ModelRepositoriesView;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * This is the OpenInModelRepositoriesViewHandler type. Enjoy.
+ */
+public class OpenInModelRepositoriesViewHandler extends AbstractHandler {
+
+ private final IPapyrusRepositoryManager manager = PapyrusRepositoryManager.INSTANCE;
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ CDOAdminClientRepository adminRepository = UIUtil.adaptElement(selection, CDOAdminClientRepository.class);
+ if(adminRepository != null) {
+ CDOAdminClient client = adminRepository.getAdmin();
+ String url = String.format("%s?repositoryName=%s", client.getURL(), adminRepository.getName()); //$NON-NLS-1$
+
+ IPapyrusRepository repository = manager.getRepository(url);
+ if(repository == null) {
+ repository = manager.createRepository(url);
+ repository.setName(adminRepository.getName());
+ manager.saveRepositories();
+ }
+
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
+
+ if(window != null) {
+ selectReveal(window, repository);
+ }
+
+ if(!repository.isConnected()) {
+ new ConnectRepositoryAction(HandlerUtil.getActivePart(event)).run(repository);
+ }
+ }
+
+ return null;
+ }
+
+ protected void selectReveal(IWorkbenchWindow window, IPapyrusRepository repository) {
+ IWorkbenchPage page = window.getActivePage();
+ if(page != null) {
+ try {
+ IViewPart view = page.showView(ModelRepositoriesView.ID);
+ view.getSite().getSelectionProvider().setSelection(new StructuredSelection(repository));
+ } catch (PartInitException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+}

Back to the top