Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2013-10-21 21:39:51 +0000
committerChristian W. Damus2013-11-08 14:52:10 +0000
commitaafe5e09753190dd5a850e278efe84a9661af6cd (patch)
treea4c7ca356ff772a0ae8bfa55f28d5f5c5e2aeed9 /extraplugins
parent43486330f187ad2dc2526277dbd27af241e39fb3 (diff)
downloadorg.eclipse.papyrus-aafe5e09753190dd5a850e278efe84a9661af6cd.tar.gz
org.eclipse.papyrus-aafe5e09753190dd5a850e278efe84a9661af6cd.tar.xz
org.eclipse.papyrus-aafe5e09753190dd5a850e278efe84a9661af6cd.zip
[415375] [CDO] Model repository administration
https://bugs.eclipse.org/bugs/show_bug.cgi?id=415375 Integrate Change Password functionality into the Model Repositories view. Enable certain menu actions only on writable resources/folders.
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF4
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java11
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java2
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/META-INF/MANIFEST.MF2
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/wizban/Papyrus_CDO.pngbin0 -> 6696 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/wizban/Papyrus_CDO.pxmbin0 -> 194280 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/Activator.java4
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncAction.java4
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncEditAction.java51
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ChangePasswordAction.java58
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/CreateFolderAction.java3
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DeleteModelAction.java22
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/RenameModelAction.java3
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/RepositoryCredentialsDialog.java21
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/Messages.java4
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/l10n/messages.properties2
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/DialogCredentialsProviderFactory.java63
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoriesView.java16
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/handlers/NewModelHandler.java37
19 files changed, 253 insertions, 54 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 62db9d97ad9..5f2609a1713 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
@@ -22,7 +22,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport,
org.eclipse.emf.ecore.xmi;visibility:=reexport,
- org.eclipse.emf.cdo;bundle-version="[4.2.0,5.0.0)";visibility:=reexport,
+ org.eclipse.emf.cdo;bundle-version="[4.3.0,5.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.core;bundle-version="0.10.1";visibility:=reexport,
org.eclipse.papyrus.infra.core.log;bundle-version="0.10.1",
org.eclipse.papyrus.infra.services.resourceloading;bundle-version="0.10.1";visibility:=reexport,
@@ -40,7 +40,7 @@ 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.2.0,5.0.0)"
+ org.eclipse.net4j;bundle-version="[4.3.0,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/internal/core/CDOUtils.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java
index bd9aeefe624..3172f301cdf 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java
@@ -24,7 +24,6 @@ import org.eclipse.emf.cdo.CDOLock;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.dawn.spi.DawnState;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.util.CDOUtil;
@@ -76,6 +75,13 @@ public class CDOUtils {
result = type.cast(((IAdaptable)object).getAdapter(type));
}
+ if((result == null) && (type == CDOObject.class)) {
+ EObject eObject = adapt(object, EObject.class);
+ if(eObject != null) {
+ result = type.cast(getCDOObject(eObject));
+ }
+ }
+
if((result == null) && (object instanceof Notifier)) {
result = getFirst(filter(((Notifier)object).eAdapters(), type), null);
}
@@ -209,8 +215,7 @@ public class CDOUtils {
// or if the current user doesn't have permission to write it
if(!result) {
- CDORevision revision = object.cdoRevision();
- result = (revision != null) && !revision.getPermission().isWritable();
+ result = !object.cdoPermission().isWritable();
}
return result;
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java
index fd19e6edf68..3396655f7e7 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java
@@ -27,7 +27,6 @@ import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
import org.eclipse.emf.cdo.common.model.CDOPackageRegistryPopulator;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.common.util.NotAuthenticatedException;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.session.CDOSession;
@@ -58,6 +57,7 @@ import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.net4j.util.lifecycle.LifecycleException;
import org.eclipse.net4j.util.security.CredentialsProviderFactory;
import org.eclipse.net4j.util.security.ICredentialsProvider2;
+import org.eclipse.net4j.util.security.NotAuthenticatedException;
import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.cdo.core.CommitException;
import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryListener;
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 f966cd3efcc..34c70133ec8 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
@@ -5,7 +5,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.papyrus.infra.core.log;bundle-version="0.10.1",
org.eclipse.ui.workbench,
org.eclipse.papyrus.cdo.core;bundle-version="0.10.1";visibility:=reexport,
- org.eclipse.emf.cdo.ui;bundle-version="[4.2.0,5.0.0)";visibility:=reexport,
+ org.eclipse.emf.cdo.ui;bundle-version="[4.3.0,5.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.10.1",
org.eclipse.emf.cdo.dawn;bundle-version="[2.0.0,3.0.0)",
org.eclipse.emf.cdo.dawn.gmf;bundle-version="[2.1.0,3.0.0)",
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/wizban/Papyrus_CDO.png b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/wizban/Papyrus_CDO.png
new file mode 100644
index 00000000000..a14b170eede
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/wizban/Papyrus_CDO.png
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/wizban/Papyrus_CDO.pxm b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/wizban/Papyrus_CDO.pxm
new file mode 100644
index 00000000000..2f1dd77b7b1
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/wizban/Papyrus_CDO.pxm
Binary files differ
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 515876f5880..3c4dbba1282 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
@@ -51,6 +51,8 @@ public class Activator extends AbstractUIPlugin {
public static final String ICON_LINK_WITH_EDITOR = "link_editor"; //$NON-NLS-1$
+ public static final String ICON_PAPYRUS_CDO_WIZARD = "cdo_wizard"; //$NON-NLS-1$
+
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.papyrus.cdo.ui"; //$NON-NLS-1$
@@ -137,6 +139,8 @@ public class Activator extends AbstractUIPlugin {
reg.put(ICON_DEPENDENT_OVERLAY16, getImageDescriptor("full/ovr16/dependent.gif")); //$NON-NLS-1$
reg.put(ICON_LINK_WITH_EDITOR, getImageDescriptor("full/ctool16/link_editor.gif")); //$NON-NLS-1$
+
+ reg.put(ICON_PAPYRUS_CDO_WIZARD, getImageDescriptor("full/wizban/Papyrus_CDO.png")); //$NON-NLS-1$
}
public static ImageDescriptor getIcon(String key) {
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncAction.java
index 1e3957a5f8d..5679f0a191b 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncAction.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncAction.java
@@ -56,6 +56,10 @@ public abstract class AsyncAction<T> extends BaseSelectionListenerAction {
return (this.selection != null) && super.updateSelection(selection);
}
+ protected T getSelection() {
+ return selection;
+ }
+
protected T coerce(Object selection) {
T result = null;
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncEditAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncEditAction.java
new file mode 100644
index 00000000000..fb707481b1a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncEditAction.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * 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.actions;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+
+/**
+ * This is the AsyncEditAction type. Enjoy.
+ */
+public abstract class AsyncEditAction<T> extends AsyncTransactionAction<T> {
+
+ public AsyncEditAction(Class<? extends T> type, String text, String icon) {
+ super(type, text, icon);
+ }
+
+ public AsyncEditAction(Class<? extends T> type, String text, ImageDescriptor icon) {
+ super(type, text, icon);
+ }
+
+ @Override
+ protected boolean updateSelection(org.eclipse.jface.viewers.IStructuredSelection selection) {
+ boolean result = super.updateSelection(selection);
+
+ if(result) {
+ CDOObject cdoObject = getSelectedCDOObject();
+
+ if((cdoObject == null) || CDOUtils.isReadOnly(cdoObject)) {
+ result = false;
+ }
+ }
+
+ return result;
+ }
+
+ protected CDOObject getSelectedCDOObject() {
+ Object selection = getSelection();
+
+ return CDOUtils.adapt(selection, CDOObject.class);
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ChangePasswordAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ChangePasswordAction.java
new file mode 100644
index 00000000000..c0f072b7d2a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ChangePasswordAction.java
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST and others.
+ *
+ * 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.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.ui.l10n.Messages;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * The "change password" action.
+ */
+public final class ChangePasswordAction extends AsyncAction<IInternalPapyrusRepository> {
+
+ private static final String TITLE = Messages.ChangePasswordAction_0;
+
+ private static final String TOOL_TIP = Messages.ChangePasswordAction_1;
+
+ public ChangePasswordAction(IWorkbenchPart part) {
+ super(IInternalPapyrusRepository.class, TITLE, (ImageDescriptor)null);
+
+ setToolTipText(TOOL_TIP);
+ }
+
+ @Override
+ protected void doRun(IInternalPapyrusRepository selection, IProgressMonitor monitor) throws CoreException {
+ if(selection.isConnected()) {
+ CDOSession session = selection.getCDOSession();
+ if((session != null) && !session.isClosed()) {
+ session.changeCredentials();
+ }
+ }
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ boolean result = super.updateSelection(selection);
+
+ if(result) {
+ result = getSelection().isConnected();
+ }
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/CreateFolderAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/CreateFolderAction.java
index 39324b650cf..89fab965161 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/CreateFolderAction.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/CreateFolderAction.java
@@ -35,7 +35,7 @@ import com.google.common.collect.Iterables;
/**
* This is the CreateFolderAction type. Enjoy.
*/
-public class CreateFolderAction extends AsyncTransactionAction<CDOResourceNode> {
+public class CreateFolderAction extends AsyncEditAction<CDOResourceNode> {
private final IShellProvider shellProvider;
@@ -130,6 +130,7 @@ public class CreateFolderAction extends AsyncTransactionAction<CDOResourceNode>
return new IInputValidator() {
+ @Override
public String isValid(String newText) {
String result;
String name = (newText == null) ? "" //$NON-NLS-1$
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DeleteModelAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DeleteModelAction.java
index 837f3ddf858..5324d24826f 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DeleteModelAction.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DeleteModelAction.java
@@ -16,14 +16,18 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
import org.eclipse.papyrus.cdo.internal.ui.editors.PapyrusCDOEditorInput;
import org.eclipse.papyrus.cdo.internal.ui.l10n.Messages;
import org.eclipse.papyrus.cdo.internal.ui.views.DIModel;
@@ -38,7 +42,7 @@ import com.google.common.collect.Lists;
/**
* This is the DeleteModelAction type. Enjoy.
*/
-public class DeleteModelAction extends AsyncTransactionAction<DIModel> {
+public class DeleteModelAction extends AsyncEditAction<DIModel> {
private final IWorkbenchPart part;
@@ -100,4 +104,20 @@ public class DeleteModelAction extends AsyncTransactionAction<DIModel> {
}
}
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ boolean result = super.updateSelection(selection);
+
+ if(result) {
+ // must also be able to modify the containing folder/resource
+ CDOObject toDelete = getSelectedCDOObject();
+ EObject container = toDelete.eContainer();
+ if(container != null) {
+ CDOObject cdoContainer = CDOUtils.getCDOObject(container);
+ result = (cdoContainer == null) || cdoContainer.cdoPermission().isWritable();
+ }
+ }
+
+ return result;
+ }
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/RenameModelAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/RenameModelAction.java
index 099122623ac..08d7f095bf9 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/RenameModelAction.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/RenameModelAction.java
@@ -41,7 +41,7 @@ import com.google.common.collect.Lists;
/**
* This is the RenameModelAction type. Enjoy.
*/
-public class RenameModelAction extends AsyncTransactionAction<DIModel> {
+public class RenameModelAction extends AsyncEditAction<DIModel> {
private final IWorkbenchPart part;
@@ -135,6 +135,7 @@ public class RenameModelAction extends AsyncTransactionAction<DIModel> {
return new IInputValidator() {
+ @Override
public String isValid(String newText) {
String result = null;
newText = Strings.nullToEmpty(newText).trim();
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/RepositoryCredentialsDialog.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/RepositoryCredentialsDialog.java
index 61032b52ec9..94106483ab1 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/RepositoryCredentialsDialog.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/RepositoryCredentialsDialog.java
@@ -18,6 +18,8 @@ import org.eclipse.net4j.util.security.PasswordCredentials;
import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.SharedImages;
import org.eclipse.papyrus.cdo.internal.ui.l10n.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
@@ -31,8 +33,7 @@ import org.eclipse.swt.widgets.Text;
/**
* This is the AddRepositoryDialog type. Enjoy.
*/
-public class RepositoryCredentialsDialog
- extends TitleAreaDialog {
+public class RepositoryCredentialsDialog extends TitleAreaDialog {
private static final String TITLE = Messages.RepositoryCredentialsDialog_0;
@@ -50,8 +51,7 @@ public class RepositoryCredentialsDialog
private IPasswordCredentials credentials;
- public RepositoryCredentialsDialog(Shell parentShell,
- IPapyrusRepository repository) {
+ public RepositoryCredentialsDialog(Shell parentShell, IPapyrusRepository repository) {
super(parentShell);
setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.TITLE);
@@ -69,8 +69,9 @@ public class RepositoryCredentialsDialog
protected Control createDialogArea(Composite parent) {
setTitle(TITLE);
setMessage(message);
+ setTitleImage(SharedImages.getImage(Activator.ICON_PAPYRUS_CDO_WIZARD));
- Composite result = (Composite) super.createDialogArea(parent);
+ Composite result = (Composite)super.createDialogArea(parent);
Composite main = new Composite(result, SWT.NONE);
main.setLayout(new GridLayout(2, false));
@@ -78,21 +79,21 @@ public class RepositoryCredentialsDialog
new Label(main, SWT.NONE).setText(Messages.RepositoryCredentialsDialog_2);
usernameText = new Text(main, SWT.BORDER);
- GridDataFactory.fillDefaults().applyTo(usernameText);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(usernameText);
new Label(main, SWT.NONE).setText(Messages.RepositoryCredentialsDialog_3);
passwordText = new Text(main, SWT.BORDER | SWT.PASSWORD);
- GridDataFactory.fillDefaults().applyTo(passwordText);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(passwordText);
rememberCheckbox = new Button(main, SWT.CHECK);
rememberCheckbox.setText(Messages.RepositoryCredentialsDialog_4);
GridDataFactory.fillDefaults().span(2, 1).applyTo(rememberCheckbox);
- if (repository.getUsername() != null) {
+ if(repository.getUsername() != null) {
usernameText.setText(repository.getUsername());
}
- if (repository.getPassword() != null) {
+ if(repository.getPassword() != null) {
passwordText.setText(repository.getPassword());
}
@@ -115,7 +116,7 @@ public class RepositoryCredentialsDialog
String password = passwordText.getText().trim();
credentials = new PasswordCredentials(username, password.toCharArray());
- if (rememberCheckbox.getSelection()) {
+ if(rememberCheckbox.getSelection()) {
repository.setUsername(username);
repository.setPassword(password);
PapyrusRepositoryManager.INSTANCE.saveRepositories();
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 8612c22257c..59958d6784f 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
@@ -78,6 +78,10 @@ public class Messages extends NLS {
public static String CDOStateLabelDecorator_1;
+ public static String ChangePasswordAction_0;
+
+ public static String ChangePasswordAction_1;
+
public static String ConnectRepositoryAction_0;
public static String ConnectRepositoryAction_errorTitle;
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 ca53107946b..9c07b695c5e 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
@@ -38,6 +38,8 @@ CDOResLabels_pattern={0} {1} in repository "{2}"
CDOResLabels_txtKind=Text file
CDOResLabels_unknown=(unknown)
CDOStateLabelDecorator_1=Update CDO state label decorations
+ChangePasswordAction_0=Change Password...
+ChangePasswordAction_1=Change the connected user's login password
ConnectRepositoryAction_0=Connect
ConnectRepositoryAction_errorTitle=Connect to Repository
CreateCDOFragDlg_browseMessage=Choose the location and name of the new model unit.
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/DialogCredentialsProviderFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/DialogCredentialsProviderFactory.java
index 6fe7051256d..d8f83e6c9de 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/DialogCredentialsProviderFactory.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/DialogCredentialsProviderFactory.java
@@ -15,9 +15,13 @@ import java.util.concurrent.Callable;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
+import org.eclipse.net4j.util.security.CredentialsUpdateOperation;
import org.eclipse.net4j.util.security.IPasswordCredentials;
import org.eclipse.net4j.util.security.IPasswordCredentialsProvider2;
+import org.eclipse.net4j.util.security.IPasswordCredentialsUpdate;
+import org.eclipse.net4j.util.security.IPasswordCredentialsUpdateProvider;
import org.eclipse.net4j.util.security.PasswordCredentials;
+import org.eclipse.net4j.util.ui.security.InteractiveCredentialsProvider;
import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
import org.eclipse.papyrus.cdo.internal.core.ICredentialsProviderFactory;
import org.eclipse.papyrus.cdo.internal.core.IInteractiveCredentialsProvider;
@@ -35,8 +39,7 @@ import com.google.common.base.Strings;
/**
* This is the DialogCredentialsProviderFactory type. Enjoy.
*/
-public class DialogCredentialsProviderFactory
- implements ICredentialsProviderFactory {
+public class DialogCredentialsProviderFactory implements ICredentialsProviderFactory {
private volatile IWorkbenchWindow activeWindow;
@@ -45,20 +48,24 @@ public class DialogCredentialsProviderFactory
PlatformUI.getWorkbench().addWindowListener(new IWindowListener() {
+ @Override
public void windowActivated(IWorkbenchWindow window) {
activeWindow = window;
}
+ @Override
public void windowClosed(IWorkbenchWindow window) {
- if (activeWindow == window) {
+ if(activeWindow == window) {
activeWindow = null;
}
}
+ @Override
public void windowOpened(IWorkbenchWindow window) {
// pass
}
+ @Override
public void windowDeactivated(IWorkbenchWindow window) {
// pass
}
@@ -66,8 +73,8 @@ public class DialogCredentialsProviderFactory
});
}
- public IPasswordCredentialsProvider2 createCredentialsProvider(
- IPapyrusRepository repository) {
+ @Override
+ public IPasswordCredentialsProvider2 createCredentialsProvider(IPapyrusRepository repository) {
return new CredentialsProvider(repository);
}
@@ -76,8 +83,9 @@ public class DialogCredentialsProviderFactory
// Nested types
//
- private class CredentialsProvider
- implements IInteractiveCredentialsProvider {
+ private class CredentialsProvider implements IInteractiveCredentialsProvider, IPasswordCredentialsUpdateProvider {
+
+ private final IPasswordCredentialsUpdateProvider delegate = new InteractiveCredentialsProvider();
private IPapyrusRepository repository;
@@ -87,29 +95,31 @@ public class DialogCredentialsProviderFactory
this.repository = repository;
}
+ @Override
public boolean isInteractive() {
return true;
}
+ @Override
public IPasswordCredentials getCredentials() {
return getCredentials(null);
}
+ @Override
public IPasswordCredentials getCredentials(String realm) {
IPasswordCredentials result;
String username = repository.getUsername();
String password = repository.getPassword();
- if (!Strings.isNullOrEmpty(username)
- && !Strings.isNullOrEmpty(password)) {
+ if(!Strings.isNullOrEmpty(username) && !Strings.isNullOrEmpty(password)) {
// use stored creds
- result = new PasswordCredentials(username,
- password.toCharArray());
+ result = new PasswordCredentials(username, password.toCharArray());
} else {
// OK, prompt the user, then
result = call(new Callable<IPasswordCredentials>() {
+ @Override
public IPasswordCredentials call() {
return openDialog();
}
@@ -120,48 +130,57 @@ public class DialogCredentialsProviderFactory
}
private Shell getCurrentShell() {
- return (activeWindow != null)
- ? activeWindow.getShell()
- : Display.getDefault().getActiveShell();
+ return (activeWindow != null) ? activeWindow.getShell() : Display.getDefault().getActiveShell();
}
private IPasswordCredentials openDialog() {
IPasswordCredentials result = null;
- RepositoryCredentialsDialog dlg = new RepositoryCredentialsDialog(
- getCurrentShell(), repository);
- if (dlg.open() == Window.OK) {
+ RepositoryCredentialsDialog dlg = new RepositoryCredentialsDialog(getCurrentShell(), repository);
+ if(dlg.open() == Window.OK) {
result = dlg.getCredentials();
}
return result;
}
+ @Override
public void reportCredentialsFailure(final SecurityException e) {
call(new Callable<Void>() {
+ @Override
public Void call() {
- MessageDialog.openWarning(getCurrentShell(),
- Messages.DialogCredentialsProviderFactory_0, e.getLocalizedMessage());
+ MessageDialog.openWarning(getCurrentShell(), Messages.DialogCredentialsProviderFactory_0, e.getLocalizedMessage());
return null;
}
});
}
+ @Override
+ public IPasswordCredentialsUpdate getCredentialsUpdate(String userID, CredentialsUpdateOperation operation) {
+ return getCredentialsUpdate(null, userID, operation);
+ }
+
+ @Override
+ public IPasswordCredentialsUpdate getCredentialsUpdate(String realm, String userID, CredentialsUpdateOperation operation) {
+ return delegate.getCredentialsUpdate(realm, userID, operation);
+ }
+
private <T> T call(final Callable<T> callable) {
final Object[] result = new Object[1];
final Shell parentShell = getCurrentShell();
- if (parentShell.getDisplay() == Display.getCurrent()) {
+ if(parentShell.getDisplay() == Display.getCurrent()) {
try {
- result[0] = (T) callable.call();
+ result[0] = callable.call();
} catch (Exception e) {
Activator.log.error(e);
}
} else {
parentShell.getDisplay().syncExec(new Runnable() {
+ @Override
public void run() {
try {
result[0] = callable.call();
@@ -174,7 +193,7 @@ public class DialogCredentialsProviderFactory
// this is safe according to the 'callable' type
@SuppressWarnings("unchecked")
- T resultAsT = (T) result[0];
+ T resultAsT = (T)result[0];
return resultAsT;
}
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 e614e3ce962..f08c1e8f140 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
@@ -14,6 +14,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.eresource.CDOResourceLeaf;
+import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.ui.CDOEditorUtil;
import org.eclipse.emf.cdo.util.CommitException;
@@ -28,10 +29,12 @@ 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.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.actions.AbstractRepositoryAction;
import org.eclipse.papyrus.cdo.internal.ui.actions.AddRepositoryAction;
+import org.eclipse.papyrus.cdo.internal.ui.actions.ChangePasswordAction;
import org.eclipse.papyrus.cdo.internal.ui.actions.ConnectRepositoryAction;
import org.eclipse.papyrus.cdo.internal.ui.actions.CreateFolderAction;
import org.eclipse.papyrus.cdo.internal.ui.actions.DeleteModelAction;
@@ -61,6 +64,8 @@ import org.eclipse.ui.statushandlers.IStatusAdapterConstants;
import org.eclipse.ui.statushandlers.StatusAdapter;
import org.eclipse.ui.statushandlers.StatusManager;
+import com.google.common.base.Strings;
+
/**
* This is the ModelRepositoriesView type. Enjoy.
*/
@@ -82,6 +87,8 @@ public class ModelRepositoriesView extends ContainerView {
private AbstractRepositoryAction disconnectRepositoryAction;
+ private ChangePasswordAction changePasswordAction;
+
private RemoveRepositoryAction removeRepositoryAction;
private OpenPapyrusModelAction openModelAction;
@@ -166,6 +173,7 @@ public class ModelRepositoriesView extends ContainerView {
selectionProvider.addSelectionChangedListener(openModelAction);
selectionProvider.addSelectionChangedListener(connectRepositoryAction);
selectionProvider.addSelectionChangedListener(disconnectRepositoryAction);
+ selectionProvider.addSelectionChangedListener(changePasswordAction);
selectionProvider.addSelectionChangedListener(removeRepositoryAction);
selectionProvider.addSelectionChangedListener(createFolderAction);
selectionProvider.addSelectionChangedListener(renameModelAction);
@@ -181,6 +189,7 @@ public class ModelRepositoriesView extends ContainerView {
linkWithEditorAction = new LinkWithEditorAction(this);
connectRepositoryAction = new ConnectRepositoryAction(this);
disconnectRepositoryAction = new DisconnectRepositoryAction(this);
+ changePasswordAction = new ChangePasswordAction(this);
removeRepositoryAction = new RemoveRepositoryAction(this);
openModelAction = new OpenPapyrusModelAction(this);
createFolderAction = new CreateFolderAction(this.getSite());
@@ -222,6 +231,13 @@ public class ModelRepositoriesView extends ContainerView {
manager.add(connectRepositoryAction);
manager.add(disconnectRepositoryAction);
+ if(selected instanceof IInternalPapyrusRepository) {
+ CDOSession session = ((IInternalPapyrusRepository)selected).getCDOSession();
+ if((session != null) && !Strings.isNullOrEmpty(session.getUserID())) {
+ manager.add(changePasswordAction);
+ }
+ }
+
manager.add(removeRepositoryAction);
manager.add(propertyDialogAction);
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/handlers/NewModelHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/handlers/NewModelHandler.java
index 75b2ee6ecb4..e273f8994e9 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/handlers/NewModelHandler.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/handlers/NewModelHandler.java
@@ -14,38 +14,51 @@ package org.eclipse.papyrus.cdo.uml.diagram.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.CDOObject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.net4j.util.ui.UIUtil;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
import org.eclipse.papyrus.uml.diagram.wizards.InitModelWizard;
+import org.eclipse.ui.ISources;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* This is the NewModelHandler type. Enjoy.
*/
-public class NewModelHandler
- extends AbstractHandler {
+public class NewModelHandler extends AbstractHandler {
public NewModelHandler() {
super();
}
- public Object execute(ExecutionEvent event)
- throws ExecutionException {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ setEnabled(event.getApplicationContext());
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof IStructuredSelection) {
- InitModelWizard wizard = new InitModelWizard();
+ if(isEnabled()) {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if(selection instanceof IStructuredSelection) {
+ InitModelWizard wizard = new InitModelWizard();
- wizard.init(HandlerUtil.getActiveWorkbenchWindow(event)
- .getWorkbench(), (IStructuredSelection) selection);
+ wizard.init(HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench(), (IStructuredSelection)selection);
- WizardDialog dlg = new WizardDialog(
- HandlerUtil.getActiveShell(event), wizard);
- dlg.open();
+ WizardDialog dlg = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
+ dlg.open();
+ }
}
return null;
}
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ Object variable = HandlerUtil.getVariable(evaluationContext, ISources.ACTIVE_CURRENT_SELECTION_NAME);
+ ISelection selection = variable instanceof ISelection ? (ISelection)variable : StructuredSelection.EMPTY;
+ CDOObject cdoObject = CDOUtils.adapt(UIUtil.getElement(selection), CDOObject.class);
+
+ setBaseEnabled((cdoObject == null) || !CDOUtils.isReadOnly(cdoObject));
+ }
}

Back to the top