diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui')
26 files changed, 2143 insertions, 2143 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/CommonNavigatorUtils.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/CommonNavigatorUtils.java index 7ce294b383..369869b752 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/CommonNavigatorUtils.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/CommonNavigatorUtils.java @@ -1,125 +1,125 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.ide;
-
-import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM;
-
-import org.eclipse.net4j.util.ui.UIUtil;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.PartInitException;
-
-/**
- * Miscellaneous functionality associated with visualization on the Common Navigator Framework.
- *
- * @author Victor Roldan Betancort
- */
-public final class CommonNavigatorUtils
-{
- private CommonNavigatorUtils()
- {
- }
-
- /**
- * Creates a fake {@link org.eclipse.core.runtime.IAdaptable adaptable} object whose sole purpose is to show a message
- * in the common navigator.
- */
- public static Object createMessageProvider(final String message, final MessageType type)
- {
- return new IAdaptable()
- {
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter)
- {
- if (adapter.equals(ILabelProvider.class))
- {
- return new LabelProvider()
- {
- @Override
- public String getText(Object element)
- {
- return message;
- }
-
- @Override
- public Image getImage(Object element)
- {
- switch (type)
- {
- case ERROR:
- return OM.getImageDescriptor(OM.ERROR_ICON).createImage();
- case WARNING:
- return OM.getImageDescriptor(OM.WARNING_ICON).createImage();
- case INFO:
- return OM.getImageDescriptor(OM.INFO_ICON).createImage();
- }
-
- return super.getImage(element);
- }
- };
- }
-
- if (adapter.equals(Runnable.class))
- {
- return new Runnable()
- {
- public void run()
- {
- try
- {
- UIUtil.getActiveWorkbenchPage().showView(UIUtil.ERROR_LOG_ID);
- }
- catch (PartInitException ex)
- {
- OM.LOG.error(ex);
- }
- }
- };
- }
-
- return null;
- }
-
- /*
- * In case is not adapted, at least the message is shown through toString()
- */
- @Override
- public String toString()
- {
- return message;
- }
- };
- }
-
- /**
- * Same as {@link #createMessageProvider(String, MessageType)}, but returning the object as an <code>Object</code>
- * array
- */
- public static Object[] createMessageProviderChild(final String message, final MessageType type)
- {
- Object[] result = { createMessageProvider(message, type) };
- return result;
- }
-
- /**
- * Defines message decoration to be shown in the Common Navigator through {@link CommonNavigatorUtils}
- *
- * @author Victor Roldan Betancort
- */
- public static enum MessageType
- {
- ERROR, WARNING, INFO
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.ide; + +import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM; + +import org.eclipse.net4j.util.ui.UIUtil; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.PartInitException; + +/** + * Miscellaneous functionality associated with visualization on the Common Navigator Framework. + * + * @author Victor Roldan Betancort + */ +public final class CommonNavigatorUtils +{ + private CommonNavigatorUtils() + { + } + + /** + * Creates a fake {@link org.eclipse.core.runtime.IAdaptable adaptable} object whose sole purpose is to show a message + * in the common navigator. + */ + public static Object createMessageProvider(final String message, final MessageType type) + { + return new IAdaptable() + { + @SuppressWarnings("rawtypes") + public Object getAdapter(Class adapter) + { + if (adapter.equals(ILabelProvider.class)) + { + return new LabelProvider() + { + @Override + public String getText(Object element) + { + return message; + } + + @Override + public Image getImage(Object element) + { + switch (type) + { + case ERROR: + return OM.getImageDescriptor(OM.ERROR_ICON).createImage(); + case WARNING: + return OM.getImageDescriptor(OM.WARNING_ICON).createImage(); + case INFO: + return OM.getImageDescriptor(OM.INFO_ICON).createImage(); + } + + return super.getImage(element); + } + }; + } + + if (adapter.equals(Runnable.class)) + { + return new Runnable() + { + public void run() + { + try + { + UIUtil.getActiveWorkbenchPage().showView(UIUtil.ERROR_LOG_ID); + } + catch (PartInitException ex) + { + OM.LOG.error(ex); + } + } + }; + } + + return null; + } + + /* + * In case is not adapted, at least the message is shown through toString() + */ + @Override + public String toString() + { + return message; + } + }; + } + + /** + * Same as {@link #createMessageProvider(String, MessageType)}, but returning the object as an <code>Object</code> + * array + */ + public static Object[] createMessageProviderChild(final String message, final MessageType type) + { + Object[] result = { createMessageProvider(message, type) }; + return result; + } + + /** + * Defines message decoration to be shown in the Common Navigator through {@link CommonNavigatorUtils} + * + * @author Victor Roldan Betancort + */ + public static enum MessageType + { + ERROR, WARNING, INFO + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/Node.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/Node.java index 9f0a1178d7..38e3bd3bfe 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/Node.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/Node.java @@ -1,291 +1,291 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.ui.ide;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.team.IRepositoryProject;
-import org.eclipse.emf.cdo.ui.ide.CommonNavigatorUtils.MessageType;
-import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-
-import org.eclipse.core.runtime.PlatformObject;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * {@link org.eclipse.core.runtime.IAdaptable Adaptable} abstraction for an UI representation of basic CDO concepts.
- *
- * @author Eike Stepper
- */
-public abstract class Node extends PlatformObject
-{
- private static final Object[] EMPTY = {};
-
- private IRepositoryProject repositoryProject;
-
- public Node(IRepositoryProject repositoryProject)
- {
- this.repositoryProject = repositoryProject;
- }
-
- public IRepositoryProject getRepositoryProject()
- {
- return repositoryProject;
- }
-
- public abstract String getText();
-
- public abstract String getImageKey();
-
- public Object[] getChildren()
- {
- return EMPTY;
- }
-
- public Object getParent()
- {
- return repositoryProject.getProject();
- }
-
- public abstract Type getType();
-
- /**
- * Differentiates kinds of {@link org.eclipse.emf.cdo.ui.ide.Node nodes}
- *
- * @author Eike Stepper
- */
- public static enum Type
- {
- BRANCH, PACKAGES, RESOURCES, SESSIONS
- }
-
- /**
- * Convenience UI object to represent a {@link org.eclipse.emf.cdo.common.branch.CDOBranch branch}
- *
- * @author Victor Roldan Betancort
- */
- public static final class BranchNode extends Node
- {
- private CDOBranch branch;
-
- public BranchNode(IRepositoryProject repositoryProject, CDOBranch branch)
- {
- super(repositoryProject);
- this.branch = branch;
- }
-
- public CDOBranch getBranch()
- {
- return branch;
- }
-
- @Override
- public Type getType()
- {
- return Type.BRANCH;
- }
-
- @Override
- public String getText()
- {
- return branch.getName();
- }
-
- @Override
- public String getImageKey()
- {
- return OM.BRANCH_ICON;
- }
-
- @Override
- public Object[] getChildren()
- {
- if (!getRepositoryProject().getView().getSession().getRepositoryInfo().isSupportingBranches())
- {
- return CommonNavigatorUtils.createMessageProviderChild(Messages.getString("Node.1"), //$NON-NLS-1$
- MessageType.INFO);
- }
-
- CDOBranch[] branches = branch.getBranches();
- BranchNode[] nodes = new BranchNode[branches.length];
- for (int i = 0; i < branches.length; i++)
- {
- nodes[i] = new BranchNode(getRepositoryProject(), branches[i]);
- }
-
- return nodes;
- }
-
- @Override
- public Object getParent()
- {
- if (branch.isMainBranch())
- {
- return getRepositoryProject();
- }
-
- return branch.getBase().getBranch();
- }
- }
-
- /**
- * Convenience UI object to represent the {@link org.eclipse.emf.cdo.common.model.CDOPackageRegistry
- * CDOPackageRegistry}
- *
- * @author Eike Stepper
- */
- public static final class PackagesNode extends Node
- {
- public PackagesNode(IRepositoryProject repositoryProject)
- {
- super(repositoryProject);
- }
-
- @Override
- public Type getType()
- {
- return Type.PACKAGES;
- }
-
- @Override
- public String getText()
- {
- return Messages.getString("Node.2"); //$NON-NLS-1$
- }
-
- @Override
- public String getImageKey()
- {
- return "icons/full/obj16/Packages.gif"; //$NON-NLS-1$
- }
-
- @Override
- public EPackage[] getChildren()
- {
- CDOPackageRegistry packageRegistry = getRepositoryProject().getView().getSession().getPackageRegistry();
- List<EPackage> children = new ArrayList<EPackage>();
- for (String nsURI : packageRegistry.keySet())
- {
- try
- {
- EPackage ePackage = packageRegistry.getEPackage(nsURI);
- children.add(ePackage);
- }
- catch (org.eclipse.emf.cdo.common.util.CDOException ex)
- {
- // Generated packages could not be locally available
- OM.LOG.error(ex);
- }
- }
-
- return children.toArray(new EPackage[children.size()]);
- }
- }
-
- /**
- * Convenience UI object to represent the {@link org.eclipse.emf.cdo.eresource.CDOResourceNode CDOResourceNode}
- *
- * @author Eike Stepper
- */
- public static final class ResourcesNode extends Node
- {
- public ResourcesNode(IRepositoryProject repositoryProject)
- {
- super(repositoryProject);
- }
-
- @Override
- public Type getType()
- {
- return Type.RESOURCES;
- }
-
- @Override
- public String getText()
- {
- return Messages.getString("Node.4"); //$NON-NLS-1$
- }
-
- @Override
- public String getImageKey()
- {
- return "icons/full/obj16/Resources.gif"; //$NON-NLS-1$
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter)
- {
- if (adapter.equals(CDOObject.class))
- {
- return getRepositoryProject().getView().getRootResource();
- }
-
- return super.getAdapter(adapter);
- }
-
- @Override
- public CDOResourceNode[] getChildren()
- {
- CDOView view = getRepositoryProject().getView();
- List<CDOResourceNode> children = new ArrayList<CDOResourceNode>();
- for (EObject resourceNode : view.getRootResource().getContents())
- {
- if (resourceNode instanceof CDOResourceNode)
- {
- children.add((CDOResourceNode)resourceNode);
- }
- }
-
- return children.toArray(new CDOResourceNode[children.size()]);
- }
- }
-
- /**
- * Convenience UI object to represent the {@link org.eclipse.emf.cdo.session.CDOSession CDOSession}
- *
- * @author Eike Stepper
- */
- public static final class SessionsNode extends Node
- {
- public SessionsNode(IRepositoryProject repositoryProject)
- {
- super(repositoryProject);
- }
-
- @Override
- public Type getType()
- {
- return Type.SESSIONS;
- }
-
- @Override
- public String getText()
- {
- return Messages.getString("Node.0"); //$NON-NLS-1$
- }
-
- @Override
- public String getImageKey()
- {
- return "icons/full/obj16/Sessions.gif"; //$NON-NLS-1$
- }
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.ui.ide; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.team.IRepositoryProject; +import org.eclipse.emf.cdo.ui.ide.CommonNavigatorUtils.MessageType; +import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.core.runtime.PlatformObject; + +import java.util.ArrayList; +import java.util.List; + +/** + * {@link org.eclipse.core.runtime.IAdaptable Adaptable} abstraction for an UI representation of basic CDO concepts. + * + * @author Eike Stepper + */ +public abstract class Node extends PlatformObject +{ + private static final Object[] EMPTY = {}; + + private IRepositoryProject repositoryProject; + + public Node(IRepositoryProject repositoryProject) + { + this.repositoryProject = repositoryProject; + } + + public IRepositoryProject getRepositoryProject() + { + return repositoryProject; + } + + public abstract String getText(); + + public abstract String getImageKey(); + + public Object[] getChildren() + { + return EMPTY; + } + + public Object getParent() + { + return repositoryProject.getProject(); + } + + public abstract Type getType(); + + /** + * Differentiates kinds of {@link org.eclipse.emf.cdo.ui.ide.Node nodes} + * + * @author Eike Stepper + */ + public static enum Type + { + BRANCH, PACKAGES, RESOURCES, SESSIONS + } + + /** + * Convenience UI object to represent a {@link org.eclipse.emf.cdo.common.branch.CDOBranch branch} + * + * @author Victor Roldan Betancort + */ + public static final class BranchNode extends Node + { + private CDOBranch branch; + + public BranchNode(IRepositoryProject repositoryProject, CDOBranch branch) + { + super(repositoryProject); + this.branch = branch; + } + + public CDOBranch getBranch() + { + return branch; + } + + @Override + public Type getType() + { + return Type.BRANCH; + } + + @Override + public String getText() + { + return branch.getName(); + } + + @Override + public String getImageKey() + { + return OM.BRANCH_ICON; + } + + @Override + public Object[] getChildren() + { + if (!getRepositoryProject().getView().getSession().getRepositoryInfo().isSupportingBranches()) + { + return CommonNavigatorUtils.createMessageProviderChild(Messages.getString("Node.1"), //$NON-NLS-1$ + MessageType.INFO); + } + + CDOBranch[] branches = branch.getBranches(); + BranchNode[] nodes = new BranchNode[branches.length]; + for (int i = 0; i < branches.length; i++) + { + nodes[i] = new BranchNode(getRepositoryProject(), branches[i]); + } + + return nodes; + } + + @Override + public Object getParent() + { + if (branch.isMainBranch()) + { + return getRepositoryProject(); + } + + return branch.getBase().getBranch(); + } + } + + /** + * Convenience UI object to represent the {@link org.eclipse.emf.cdo.common.model.CDOPackageRegistry + * CDOPackageRegistry} + * + * @author Eike Stepper + */ + public static final class PackagesNode extends Node + { + public PackagesNode(IRepositoryProject repositoryProject) + { + super(repositoryProject); + } + + @Override + public Type getType() + { + return Type.PACKAGES; + } + + @Override + public String getText() + { + return Messages.getString("Node.2"); //$NON-NLS-1$ + } + + @Override + public String getImageKey() + { + return "icons/full/obj16/Packages.gif"; //$NON-NLS-1$ + } + + @Override + public EPackage[] getChildren() + { + CDOPackageRegistry packageRegistry = getRepositoryProject().getView().getSession().getPackageRegistry(); + List<EPackage> children = new ArrayList<EPackage>(); + for (String nsURI : packageRegistry.keySet()) + { + try + { + EPackage ePackage = packageRegistry.getEPackage(nsURI); + children.add(ePackage); + } + catch (org.eclipse.emf.cdo.common.util.CDOException ex) + { + // Generated packages could not be locally available + OM.LOG.error(ex); + } + } + + return children.toArray(new EPackage[children.size()]); + } + } + + /** + * Convenience UI object to represent the {@link org.eclipse.emf.cdo.eresource.CDOResourceNode CDOResourceNode} + * + * @author Eike Stepper + */ + public static final class ResourcesNode extends Node + { + public ResourcesNode(IRepositoryProject repositoryProject) + { + super(repositoryProject); + } + + @Override + public Type getType() + { + return Type.RESOURCES; + } + + @Override + public String getText() + { + return Messages.getString("Node.4"); //$NON-NLS-1$ + } + + @Override + public String getImageKey() + { + return "icons/full/obj16/Resources.gif"; //$NON-NLS-1$ + } + + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Class adapter) + { + if (adapter.equals(CDOObject.class)) + { + return getRepositoryProject().getView().getRootResource(); + } + + return super.getAdapter(adapter); + } + + @Override + public CDOResourceNode[] getChildren() + { + CDOView view = getRepositoryProject().getView(); + List<CDOResourceNode> children = new ArrayList<CDOResourceNode>(); + for (EObject resourceNode : view.getRootResource().getContents()) + { + if (resourceNode instanceof CDOResourceNode) + { + children.add((CDOResourceNode)resourceNode); + } + } + + return children.toArray(new CDOResourceNode[children.size()]); + } + } + + /** + * Convenience UI object to represent the {@link org.eclipse.emf.cdo.session.CDOSession CDOSession} + * + * @author Eike Stepper + */ + public static final class SessionsNode extends Node + { + public SessionsNode(IRepositoryProject repositoryProject) + { + super(repositoryProject); + } + + @Override + public Type getType() + { + return Type.SESSIONS; + } + + @Override + public String getText() + { + return Messages.getString("Node.0"); //$NON-NLS-1$ + } + + @Override + public String getImageKey() + { + return "icons/full/obj16/Sessions.gif"; //$NON-NLS-1$ + } + } + +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/RepositoryLabelProvider.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/RepositoryLabelProvider.java index 64204653ba..9b52333ce7 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/RepositoryLabelProvider.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/RepositoryLabelProvider.java @@ -1,118 +1,118 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.ui.ide;
-
-import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.provider.IItemLabelProvider;
-import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * {@link org.eclipse.jface.viewers.ILabelProvider ILabelProvider} implementation for the CDO Team integration. Capable
- * of providing text and image information for {@link org.eclipse.emf.cdo.ui.ide.Node nodes}
- *
- * @author Eike Stepper
- */
-public class RepositoryLabelProvider extends LabelProvider
-{
- private ComposedAdapterFactory adapterFactory;
-
- public RepositoryLabelProvider()
- {
- adapterFactory = RepositoryContentProvider.createAdapterFactory();
- }
-
- @Override
- public void dispose()
- {
- adapterFactory.dispose();
- super.dispose();
- }
-
- @Override
- public String getText(Object element)
- {
- if (element instanceof Node)
- {
- Node node = (Node)element;
- return node.getText();
- }
-
- if (element instanceof CDOResourceNode)
- {
- CDOResourceNode resourceNode = (CDOResourceNode)element;
- return resourceNode.getName();
- }
-
- if (element instanceof Notifier)
- {
- Notifier notifier = (Notifier)element;
- IItemLabelProvider adapter = (IItemLabelProvider)adapterFactory.adapt(notifier, IItemLabelProvider.class);
- if (adapter != null)
- {
- return adapter.getText(notifier);
- }
- }
-
- if (element instanceof IAdaptable)
- {
- Object adapter = ((IAdaptable)element).getAdapter(ILabelProvider.class);
- if (adapter != null)
- {
- return ((ILabelProvider)adapter).getText(element);
- }
- }
-
- return super.getText(element);
- }
-
- @Override
- public Image getImage(Object element)
- {
- if (element instanceof Node)
- {
- Node node = (Node)element;
- String imageKey = node.getImageKey();
- ImageDescriptor imageDescriptor = OM.Activator.imageDescriptorFromPlugin(OM.BUNDLE_ID, imageKey);
- return imageDescriptor.createImage();
- }
-
- if (element instanceof Notifier)
- {
- Notifier notifier = (Notifier)element;
- IItemLabelProvider adapter = (IItemLabelProvider)adapterFactory.adapt(notifier, IItemLabelProvider.class);
- if (adapter != null)
- {
- return ExtendedImageRegistry.getInstance().getImage(adapter.getImage(notifier));
- }
- }
-
- if (element instanceof IAdaptable)
- {
- Object adapter = ((IAdaptable)element).getAdapter(ILabelProvider.class);
- if (adapter != null)
- {
- return ((ILabelProvider)adapter).getImage(element);
- }
- }
-
- return super.getImage(element);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.ui.ide; + +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM; + +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + +/** + * {@link org.eclipse.jface.viewers.ILabelProvider ILabelProvider} implementation for the CDO Team integration. Capable + * of providing text and image information for {@link org.eclipse.emf.cdo.ui.ide.Node nodes} + * + * @author Eike Stepper + */ +public class RepositoryLabelProvider extends LabelProvider +{ + private ComposedAdapterFactory adapterFactory; + + public RepositoryLabelProvider() + { + adapterFactory = RepositoryContentProvider.createAdapterFactory(); + } + + @Override + public void dispose() + { + adapterFactory.dispose(); + super.dispose(); + } + + @Override + public String getText(Object element) + { + if (element instanceof Node) + { + Node node = (Node)element; + return node.getText(); + } + + if (element instanceof CDOResourceNode) + { + CDOResourceNode resourceNode = (CDOResourceNode)element; + return resourceNode.getName(); + } + + if (element instanceof Notifier) + { + Notifier notifier = (Notifier)element; + IItemLabelProvider adapter = (IItemLabelProvider)adapterFactory.adapt(notifier, IItemLabelProvider.class); + if (adapter != null) + { + return adapter.getText(notifier); + } + } + + if (element instanceof IAdaptable) + { + Object adapter = ((IAdaptable)element).getAdapter(ILabelProvider.class); + if (adapter != null) + { + return ((ILabelProvider)adapter).getText(element); + } + } + + return super.getText(element); + } + + @Override + public Image getImage(Object element) + { + if (element instanceof Node) + { + Node node = (Node)element; + String imageKey = node.getImageKey(); + ImageDescriptor imageDescriptor = OM.Activator.imageDescriptorFromPlugin(OM.BUNDLE_ID, imageKey); + return imageDescriptor.createImage(); + } + + if (element instanceof Notifier) + { + Notifier notifier = (Notifier)element; + IItemLabelProvider adapter = (IItemLabelProvider)adapterFactory.adapt(notifier, IItemLabelProvider.class); + if (adapter != null) + { + return ExtendedImageRegistry.getInstance().getImage(adapter.getImage(notifier)); + } + } + + if (element instanceof IAdaptable) + { + Object adapter = ((IAdaptable)element).getAdapter(ILabelProvider.class); + if (adapter != null) + { + return ((ILabelProvider)adapter).getImage(element); + } + } + + return super.getImage(element); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/package-info.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/package-info.java index 7b17d3fce8..000a411d33 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/package-info.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/ide/package-info.java @@ -1,15 +1,15 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-
-/**
- * Reusable UI IDE components specific to the CDO Model Repository.
- */
-package org.eclipse.emf.cdo.ui.ide;
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ + +/** + * Reusable UI IDE components specific to the CDO Model Repository. + */ +package org.eclipse.emf.cdo.ui.ide; diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ChangeViewTargetActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ChangeViewTargetActionDelegate.java index 338afac35f..af09b5abb5 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ChangeViewTargetActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ChangeViewTargetActionDelegate.java @@ -1,38 +1,38 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.internal.ui.actions.SwitchTargetAction;
-
-import org.eclipse.jface.action.IAction;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class ChangeViewTargetActionDelegate extends ViewAwareActionDelegate
-{
- private IAction action;
-
- public ChangeViewTargetActionDelegate()
- {
- }
-
- @Override
- protected void safeRun() throws Exception
- {
- if (action == null)
- {
- action = new SwitchTargetAction(getPage(), getView());
- }
- action.run();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.internal.ui.actions.SwitchTargetAction; + +import org.eclipse.jface.action.IAction; + +/** + * @author Victor Roldan Betancort + */ +public class ChangeViewTargetActionDelegate extends ViewAwareActionDelegate +{ + private IAction action; + + public ChangeViewTargetActionDelegate() + { + } + + @Override + protected void safeRun() throws Exception + { + if (action == null) + { + action = new SwitchTargetAction(getPage(), getView()); + } + action.run(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/CreateBranchActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/CreateBranchActionDelegate.java index c3e6ed7f31..532384e7f4 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/CreateBranchActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/CreateBranchActionDelegate.java @@ -1,89 +1,89 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.ui.ide.Node.BranchNode;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-
-import org.eclipse.net4j.util.StringUtil;
-import org.eclipse.net4j.util.ui.UIUtil;
-import org.eclipse.net4j.util.ui.actions.LongRunningActionDelegate;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class CreateBranchActionDelegate extends LongRunningActionDelegate
-{
- private String name;
-
- public CreateBranchActionDelegate()
- {
- }
-
- @Override
- protected void preRun() throws Exception
- {
- InputDialog dialog = new InputDialog(new Shell(), Messages.getString("CreateBranchActionDelegate_0"), //$NON-NLS-1$
- Messages.getString("CreateBranchActionDelegate_1"), "", new BranchNameInputValidator()); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (dialog.open() == Dialog.OK)
- {
- name = dialog.getValue();
- }
- else
- {
- cancel();
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- BranchNode branchNode = UIUtil.getElement(getSelection(), BranchNode.class);
- branchNode.getBranch().createBranch(name);
- }
-
- /**
- * @author Victor Roldan Betancort
- */
- private final class BranchNameInputValidator implements IInputValidator
- {
- public String isValid(String newText)
- {
- if (StringUtil.isEmpty(newText))
- {
- return Messages.getString("CreateBranchActionDelegate_3"); //$NON-NLS-1$
- }
-
- if (newText.contains(CDOBranch.PATH_SEPARATOR))
- {
- return Messages.getString("CreateBranchActionDelegate_4"); //$NON-NLS-1$
- }
-
- BranchNode branchNode = UIUtil.getElement(getSelection(), BranchNode.class);
- CDOBranch branch = branchNode.getBranch();
- if (branch.getBranch(newText) != null)
- {
- return Messages.getString("CreateBranchActionDelegate_5"); //$NON-NLS-1$
- }
-
- return null;
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.ui.ide.Node.BranchNode; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; + +import org.eclipse.net4j.util.StringUtil; +import org.eclipse.net4j.util.ui.UIUtil; +import org.eclipse.net4j.util.ui.actions.LongRunningActionDelegate; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IInputValidator; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.swt.widgets.Shell; + +/** + * @author Victor Roldan Betancort + */ +public class CreateBranchActionDelegate extends LongRunningActionDelegate +{ + private String name; + + public CreateBranchActionDelegate() + { + } + + @Override + protected void preRun() throws Exception + { + InputDialog dialog = new InputDialog(new Shell(), Messages.getString("CreateBranchActionDelegate_0"), //$NON-NLS-1$ + Messages.getString("CreateBranchActionDelegate_1"), "", new BranchNameInputValidator()); //$NON-NLS-1$ //$NON-NLS-2$ + + if (dialog.open() == Dialog.OK) + { + name = dialog.getValue(); + } + else + { + cancel(); + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + BranchNode branchNode = UIUtil.getElement(getSelection(), BranchNode.class); + branchNode.getBranch().createBranch(name); + } + + /** + * @author Victor Roldan Betancort + */ + private final class BranchNameInputValidator implements IInputValidator + { + public String isValid(String newText) + { + if (StringUtil.isEmpty(newText)) + { + return Messages.getString("CreateBranchActionDelegate_3"); //$NON-NLS-1$ + } + + if (newText.contains(CDOBranch.PATH_SEPARATOR)) + { + return Messages.getString("CreateBranchActionDelegate_4"); //$NON-NLS-1$ + } + + BranchNode branchNode = UIUtil.getElement(getSelection(), BranchNode.class); + CDOBranch branch = branchNode.getBranch(); + if (branch.getBranch(newText) != null) + { + return Messages.getString("CreateBranchActionDelegate_5"); //$NON-NLS-1$ + } + + return null; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/DisconnectActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/DisconnectActionDelegate.java index b115fa9162..12cc55a156 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/DisconnectActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/DisconnectActionDelegate.java @@ -1,58 +1,58 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.internal.team.RepositoryManager;
-import org.eclipse.emf.cdo.internal.team.RepositoryTeamProvider;
-import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM;
-
-import org.eclipse.net4j.util.ui.UIUtil;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * @author Eike Stepper
- */
-public class DisconnectActionDelegate implements IObjectActionDelegate
-{
- private IProject project;
-
- public DisconnectActionDelegate()
- {
- }
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart)
- {
- }
-
- public void selectionChanged(IAction action, ISelection selection)
- {
- project = UIUtil.getElement(selection, IProject.class);
- }
-
- public void run(IAction action)
- {
- try
- {
- RepositoryManager.INSTANCE.removeElement(project);
- RepositoryTeamProvider.unmapProject(project);
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.internal.team.RepositoryManager; +import org.eclipse.emf.cdo.internal.team.RepositoryTeamProvider; +import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM; + +import org.eclipse.net4j.util.ui.UIUtil; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; + +/** + * @author Eike Stepper + */ +public class DisconnectActionDelegate implements IObjectActionDelegate +{ + private IProject project; + + public DisconnectActionDelegate() + { + } + + public void setActivePart(IAction action, IWorkbenchPart targetPart) + { + } + + public void selectionChanged(IAction action, ISelection selection) + { + project = UIUtil.getElement(selection, IProject.class); + } + + public void run(IAction action) + { + try + { + RepositoryManager.INSTANCE.removeElement(project); + RepositoryTeamProvider.unmapProject(project); + } + catch (Exception ex) + { + OM.LOG.error(ex); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ExportResourceActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ExportResourceActionDelegate.java index 98fbbfede6..1df54c429b 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ExportResourceActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ExportResourceActionDelegate.java @@ -1,110 +1,110 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.ui.dialogs.ImportResourceDialog;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-
-import org.eclipse.net4j.util.io.IORuntimeException;
-
-import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class ExportResourceActionDelegate extends TransactionalBackgroundActionDelegate
-{
- private URI targetURI;
-
- public ExportResourceActionDelegate()
- {
- super(Messages.getString("ExportSelectedResourceAction_0")); //$NON-NLS-1$
- }
-
- @Override
- protected final CDOObject preRun(CDOObject object)
- {
- ResourceDialog dialog = new ResourceDialog(new Shell(),
- Messages.getString("ExportSelectedResourceAction_1"), SWT.SAVE); //$NON-NLS-1$
- if (dialog.open() == ImportResourceDialog.OK)
- {
- List<URI> uris = dialog.getURIs();
- if (uris.size() == 1)
- {
- targetURI = uris.get(0);
- CDOTransaction transaction = object.cdoView().getSession().openTransaction();
- CDOObject transactionalObject = transaction.getObject(object);
- return transactionalObject;
- }
-
- MessageDialog.openError(new Shell(), Messages.getString("ExportResourceActionDelegate.0"), //$NON-NLS-1$
- Messages.getString("ExportSelectedResourceAction_2")); //$NON-NLS-1$
- cancel();
- }
- else
- {
- cancel();
- }
-
- return null;
- }
-
- @Override
- protected void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor) throws Exception
- {
- // Source Resource
- Resource source = object instanceof CDOResource ? (CDOResource)object : object.cdoResource();
- List<EObject> sourceContents = new ArrayList<EObject>(source.getContents());
- exportObjects(sourceContents);
- }
-
- private void exportObjects(List<EObject> sourceContents)
- {
- // Target Resource
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
- .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
- Resource resource = resourceSet.createResource(targetURI);
-
- Collection<EObject> copiedRoots = EcoreUtil.copyAll(sourceContents);
- resource.getContents().addAll(copiedRoots);
-
- try
- {
- resource.save(null);
- }
- catch (IOException ex)
- {
- throw new IORuntimeException(ex);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.internal.ui.dialogs.ImportResourceDialog; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; + +import org.eclipse.net4j.util.io.IORuntimeException; + +import org.eclipse.emf.common.ui.dialogs.ResourceDialog; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Shell; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * @author Victor Roldan Betancort + */ +public class ExportResourceActionDelegate extends TransactionalBackgroundActionDelegate +{ + private URI targetURI; + + public ExportResourceActionDelegate() + { + super(Messages.getString("ExportSelectedResourceAction_0")); //$NON-NLS-1$ + } + + @Override + protected final CDOObject preRun(CDOObject object) + { + ResourceDialog dialog = new ResourceDialog(new Shell(), + Messages.getString("ExportSelectedResourceAction_1"), SWT.SAVE); //$NON-NLS-1$ + if (dialog.open() == ImportResourceDialog.OK) + { + List<URI> uris = dialog.getURIs(); + if (uris.size() == 1) + { + targetURI = uris.get(0); + CDOTransaction transaction = object.cdoView().getSession().openTransaction(); + CDOObject transactionalObject = transaction.getObject(object); + return transactionalObject; + } + + MessageDialog.openError(new Shell(), Messages.getString("ExportResourceActionDelegate.0"), //$NON-NLS-1$ + Messages.getString("ExportSelectedResourceAction_2")); //$NON-NLS-1$ + cancel(); + } + else + { + cancel(); + } + + return null; + } + + @Override + protected void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor) throws Exception + { + // Source Resource + Resource source = object instanceof CDOResource ? (CDOResource)object : object.cdoResource(); + List<EObject> sourceContents = new ArrayList<EObject>(source.getContents()); + exportObjects(sourceContents); + } + + private void exportObjects(List<EObject> sourceContents) + { + // Target Resource + ResourceSet resourceSet = new ResourceSetImpl(); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() + .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); + Resource resource = resourceSet.createResource(targetURI); + + Collection<EObject> copiedRoots = EcoreUtil.copyAll(sourceContents); + resource.getContents().addAll(copiedRoots); + + try + { + resource.save(null); + } + catch (IOException ex) + { + throw new IORuntimeException(ex); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ImportResourceActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ImportResourceActionDelegate.java index aa908f68be..39448bbad9 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ImportResourceActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ImportResourceActionDelegate.java @@ -1,100 +1,100 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.internal.ui.dialogs.ImportResourceDialog;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class ImportResourceActionDelegate extends NewResourceActionDelegate
-{
- private URI sourceURI;
-
- public ImportResourceActionDelegate()
- {
- }
-
- @Override
- protected final CDOObject preRun(CDOObject object)
- {
- ImportResourceDialog dialog = new ImportResourceDialog(new Shell(),
- Messages.getString("ImportResourceToFolderAction_0"), SWT.OPEN); //$NON-NLS-1$
- if (dialog.open() == ImportResourceDialog.OK)
- {
- List<URI> uris = dialog.getURIs();
- if (uris.size() == 1)
- {
- sourceURI = uris.get(0);
- setNewResourceNode(createNewResourceNode());
- getNewResourceNode().setName(dialog.getTargetPath());
- CDOTransaction transaction = object.cdoView().getSession().openTransaction();
- CDOObject transactionalObject = transaction.getObject(object);
- return transactionalObject;
- }
-
- MessageDialog.openError(new Shell(), Messages.getString("ImportResourceActionDelegate.0"), //$NON-NLS-1$
- Messages.getString("ImportResourceToFolderAction_1")); //$NON-NLS-1$
- cancel();
- }
- else
- {
- cancel();
- }
-
- return null;
- }
-
- @Override
- protected CDOResourceNode createNewResourceNode()
- {
- CDOResource resource = (CDOResource)super.createNewResourceNode();
-
- // Source ResourceSet
- ResourceSet sourceSet = new ResourceSetImpl();
- // sourceSet.setPackageRegistry(transaction.getSession().getPackageRegistry());
-
- // Source Resource
- Resource source = sourceSet.getResource(sourceURI, true);
- List<EObject> sourceContents = new ArrayList<EObject>(source.getContents());
-
- // Target Resource
- EList<EObject> targetContents = resource.getContents();
-
- // Move contents over
- for (EObject root : sourceContents)
- {
- targetContents.add(root);
- }
-
- return resource;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.internal.ui.dialogs.ImportResourceDialog; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Shell; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Victor Roldan Betancort + */ +public class ImportResourceActionDelegate extends NewResourceActionDelegate +{ + private URI sourceURI; + + public ImportResourceActionDelegate() + { + } + + @Override + protected final CDOObject preRun(CDOObject object) + { + ImportResourceDialog dialog = new ImportResourceDialog(new Shell(), + Messages.getString("ImportResourceToFolderAction_0"), SWT.OPEN); //$NON-NLS-1$ + if (dialog.open() == ImportResourceDialog.OK) + { + List<URI> uris = dialog.getURIs(); + if (uris.size() == 1) + { + sourceURI = uris.get(0); + setNewResourceNode(createNewResourceNode()); + getNewResourceNode().setName(dialog.getTargetPath()); + CDOTransaction transaction = object.cdoView().getSession().openTransaction(); + CDOObject transactionalObject = transaction.getObject(object); + return transactionalObject; + } + + MessageDialog.openError(new Shell(), Messages.getString("ImportResourceActionDelegate.0"), //$NON-NLS-1$ + Messages.getString("ImportResourceToFolderAction_1")); //$NON-NLS-1$ + cancel(); + } + else + { + cancel(); + } + + return null; + } + + @Override + protected CDOResourceNode createNewResourceNode() + { + CDOResource resource = (CDOResource)super.createNewResourceNode(); + + // Source ResourceSet + ResourceSet sourceSet = new ResourceSetImpl(); + // sourceSet.setPackageRegistry(transaction.getSession().getPackageRegistry()); + + // Source Resource + Resource source = sourceSet.getResource(sourceURI, true); + List<EObject> sourceContents = new ArrayList<EObject>(source.getContents()); + + // Target Resource + EList<EObject> targetContents = resource.getContents(); + + // Move contents over + for (EObject root : sourceContents) + { + targetContents.add(root); + } + + return resource; + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ManagePackagesActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ManagePackagesActionDelegate.java index 92da75c783..51010aec48 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ManagePackagesActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ManagePackagesActionDelegate.java @@ -1,39 +1,39 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.internal.ui.actions.ManagePackagesAction;
-
-import org.eclipse.jface.action.IAction;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class ManagePackagesActionDelegate extends SessionAwareActionDelegate
-{
- private IAction action;
-
- public ManagePackagesActionDelegate()
- {
- }
-
- @Override
- protected void safeRun() throws Exception
- {
- if (action == null)
- {
- action = new ManagePackagesAction(getPage(), getSession());
- }
-
- action.run();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.internal.ui.actions.ManagePackagesAction; + +import org.eclipse.jface.action.IAction; + +/** + * @author Victor Roldan Betancort + */ +public class ManagePackagesActionDelegate extends SessionAwareActionDelegate +{ + private IAction action; + + public ManagePackagesActionDelegate() + { + } + + @Override + protected void safeRun() throws Exception + { + if (action == null) + { + action = new ManagePackagesAction(getPage(), getSession()); + } + + action.run(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceActionDelegate.java index 62b7b340d5..6b187a2277 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceActionDelegate.java @@ -1,33 +1,33 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.eresource.EresourceFactory;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-
-/**
- * @author Eike Stepper
- */
-public class NewResourceActionDelegate extends NewResourceNodeActionDelegate
-{
- public NewResourceActionDelegate()
- {
- super(Messages.getString("NewResourceAction_0")); //$NON-NLS-1$
- }
-
- @Override
- protected CDOResourceNode createNewResourceNode()
- {
- return EresourceFactory.eINSTANCE.createCDOResource();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.eresource.EresourceFactory; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; + +/** + * @author Eike Stepper + */ +public class NewResourceActionDelegate extends NewResourceNodeActionDelegate +{ + public NewResourceActionDelegate() + { + super(Messages.getString("NewResourceAction_0")); //$NON-NLS-1$ + } + + @Override + protected CDOResourceNode createNewResourceNode() + { + return EresourceFactory.eINSTANCE.createCDOResource(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceFolderActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceFolderActionDelegate.java index 32699fcf26..78e994f7d0 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceFolderActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceFolderActionDelegate.java @@ -1,33 +1,33 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.eresource.EresourceFactory;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-
-/**
- * @author Eike Stepper
- */
-public class NewResourceFolderActionDelegate extends NewResourceNodeActionDelegate
-{
- public NewResourceFolderActionDelegate()
- {
- super(Messages.getString("NewResourceFolderAction_0")); //$NON-NLS-1$
- }
-
- @Override
- protected CDOResourceNode createNewResourceNode()
- {
- return EresourceFactory.eINSTANCE.createCDOResourceFolder();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.eresource.EresourceFactory; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; + +/** + * @author Eike Stepper + */ +public class NewResourceFolderActionDelegate extends NewResourceNodeActionDelegate +{ + public NewResourceFolderActionDelegate() + { + super(Messages.getString("NewResourceFolderAction_0")); //$NON-NLS-1$ + } + + @Override + protected CDOResourceNode createNewResourceNode() + { + return EresourceFactory.eINSTANCE.createCDOResourceFolder(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceNodeActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceNodeActionDelegate.java index cef2593bfe..7c3e0e7ddc 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceNodeActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/NewResourceNodeActionDelegate.java @@ -1,79 +1,79 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
-import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.internal.ui.actions.ResourceNodeNameInputValidator;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.InputDialog;
-
-/**
- * @author Eike Stepper
- */
-public abstract class NewResourceNodeActionDelegate extends TransactionalBackgroundActionDelegate
-{
- private CDOResourceNode newResourceNode;
-
- public NewResourceNodeActionDelegate(String text)
- {
- super(text);
- }
-
- @Override
- protected CDOObject preRun(CDOObject object)
- {
- InputDialog dialog = new InputDialog(
- getTargetPart().getSite().getShell(),
- getText(),
- Messages.getString("NewResourceNodeAction_0"), null, new ResourceNodeNameInputValidator((CDOResourceNode)object)); //$NON-NLS-1$
- if (dialog.open() == Dialog.OK)
- {
- setNewResourceNode(createNewResourceNode());
- getNewResourceNode().setName(dialog.getValue());
- return super.preRun(object);
- }
-
- return null;
- }
-
- @Override
- protected final void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor)
- throws Exception
- {
- if (object instanceof CDOResourceFolder)
- {
- ((CDOResourceFolder)object).getNodes().add(getNewResourceNode());
- }
- else
- {
- transaction.getRootResource().getContents().add(getNewResourceNode());
- }
- }
-
- protected void setNewResourceNode(CDOResourceNode newResourceNode)
- {
- this.newResourceNode = newResourceNode;
- }
-
- protected CDOResourceNode getNewResourceNode()
- {
- return newResourceNode;
- }
-
- protected abstract CDOResourceNode createNewResourceNode();
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.internal.ui.actions.ResourceNodeNameInputValidator; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.InputDialog; + +/** + * @author Eike Stepper + */ +public abstract class NewResourceNodeActionDelegate extends TransactionalBackgroundActionDelegate +{ + private CDOResourceNode newResourceNode; + + public NewResourceNodeActionDelegate(String text) + { + super(text); + } + + @Override + protected CDOObject preRun(CDOObject object) + { + InputDialog dialog = new InputDialog( + getTargetPart().getSite().getShell(), + getText(), + Messages.getString("NewResourceNodeAction_0"), null, new ResourceNodeNameInputValidator((CDOResourceNode)object)); //$NON-NLS-1$ + if (dialog.open() == Dialog.OK) + { + setNewResourceNode(createNewResourceNode()); + getNewResourceNode().setName(dialog.getValue()); + return super.preRun(object); + } + + return null; + } + + @Override + protected final void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor) + throws Exception + { + if (object instanceof CDOResourceFolder) + { + ((CDOResourceFolder)object).getNodes().add(getNewResourceNode()); + } + else + { + transaction.getRootResource().getContents().add(getNewResourceNode()); + } + } + + protected void setNewResourceNode(CDOResourceNode newResourceNode) + { + this.newResourceNode = newResourceNode; + } + + protected CDOResourceNode getNewResourceNode() + { + return newResourceNode; + } + + protected abstract CDOResourceNode createNewResourceNode(); +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RegisterFileSystemPackageActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RegisterFileSystemPackageActionDelegate.java index 24739ad186..974dfefcaf 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RegisterFileSystemPackageActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RegisterFileSystemPackageActionDelegate.java @@ -1,30 +1,30 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.internal.ui.actions.RegisterFilesystemPackagesAction;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class RegisterFileSystemPackageActionDelegate extends SessionAwareActionDelegate
-{
- public RegisterFileSystemPackageActionDelegate()
- {
- }
-
- @Override
- protected void safeRun() throws Exception
- {
- new RegisterFilesystemPackagesAction(getPage(), getSession()).run();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.internal.ui.actions.RegisterFilesystemPackagesAction; + +/** + * @author Victor Roldan Betancort + */ +public class RegisterFileSystemPackageActionDelegate extends SessionAwareActionDelegate +{ + public RegisterFileSystemPackageActionDelegate() + { + } + + @Override + protected void safeRun() throws Exception + { + new RegisterFilesystemPackagesAction(getPage(), getSession()).run(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RegisterWorkspacePackageActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RegisterWorkspacePackageActionDelegate.java index 73b64b3803..de10e9563f 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RegisterWorkspacePackageActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RegisterWorkspacePackageActionDelegate.java @@ -1,30 +1,30 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.internal.ui.actions.RegisterWorkspacePackagesAction;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class RegisterWorkspacePackageActionDelegate extends SessionAwareActionDelegate
-{
- public RegisterWorkspacePackageActionDelegate()
- {
- }
-
- @Override
- protected void safeRun() throws Exception
- {
- new RegisterWorkspacePackagesAction(getPage(), getSession()).run();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.internal.ui.actions.RegisterWorkspacePackagesAction; + +/** + * @author Victor Roldan Betancort + */ +public class RegisterWorkspacePackageActionDelegate extends SessionAwareActionDelegate +{ + public RegisterWorkspacePackageActionDelegate() + { + } + + @Override + protected void safeRun() throws Exception + { + new RegisterWorkspacePackagesAction(getPage(), getSession()).run(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RemoveResourceActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RemoveResourceActionDelegate.java index 77ec36b19b..bdc56c7e04 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RemoveResourceActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RemoveResourceActionDelegate.java @@ -1,153 +1,153 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
-import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-
-import org.eclipse.net4j.util.ui.UIUtil;
-
-import org.eclipse.emf.ecore.EObject;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class RemoveResourceActionDelegate implements IObjectActionDelegate
-{
- // private Image deleteIcon;
-
- private List<CDOResourceNode> nodes;
-
- private Shell shell;
-
- public RemoveResourceActionDelegate()
- {
- }
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart)
- {
- shell = targetPart.getSite().getShell();
- }
-
- public void selectionChanged(IAction action, ISelection selection)
- {
- nodes = UIUtil.getElements(selection, CDOResourceNode.class);
- }
-
- public void run(IAction action)
- {
- if (MessageDialog.openConfirm(shell, Messages.getString("RemoveResourceAction_1"), MessageFormat.format( //$NON-NLS-1$
- Messages.getString("RemoveResourceAction_2"), nodes.size()))) //$NON-NLS-1$
- {
- Job job = new Job(Messages.getString("RemoveResourceAction_3")) //$NON-NLS-1$
- {
- @Override
- protected IStatus run(IProgressMonitor monitor)
- {
- Map<Integer, CDOTransaction> repositoryToTransaction = new HashMap<Integer, CDOTransaction>();
- for (CDOResourceNode node : nodes)
- {
- int sessionID = node.cdoView().getSession().getSessionID();
- CDOTransaction transaction = repositoryToTransaction.get(sessionID);
- if (transaction == null)
- {
- transaction = node.cdoView().getSession().openTransaction();
- repositoryToTransaction.put(sessionID, transaction);
- }
-
- CDOObject writableNode = transaction.getObject(node.cdoID());
- EObject container = writableNode.eContainer();
- if (container == null)
- {
- container = (CDOResource)writableNode.eResource();
- }
-
- if (container instanceof CDOResource)
- {
- ((CDOResource)container).getContents().remove(writableNode);
- }
- else if (container instanceof CDOResourceFolder)
- {
- ((CDOResourceFolder)container).getNodes().remove(writableNode);
- }
- }
-
- for (CDOTransaction transaction : repositoryToTransaction.values())
- {
- try
- {
- transaction.commit();
- }
- catch (Exception ex)
- {
- OM.LOG.error(MessageFormat.format(
- Messages.getString("RemoveResourceAction_4"), this.getClass().getName().toString()), ex); //$NON-NLS-1$
- }
- finally
- {
- transaction.close();
- }
- }
-
- // UIUtil.setStatusBarMessage(
- // MessageFormat.format(Messages.getString("RemoveResourceAction_5"), nodes.size()), getDeleteIcon()); //$NON-NLS-1$
- return Status.OK_STATUS;
- }
- };
-
- job.schedule();
- }
- }
-
- // private Image getDeleteIcon()
- // {
- // if (deleteIcon == null)
- // {
- // deleteIcon = OM.Activator
- // .imageDescriptorFromPlugin(OM.BUNDLE_ID, "icons/full/elcl16/delete_edit.gif").createImage(); //$NON-NLS-1$
- // }
- //
- // return deleteIcon;
- // }
- //
- // @Override
- // protected void finalize() throws Throwable
- // {
- // if (deleteIcon != null)
- // {
- // deleteIcon.dispose();
- // }
- //
- // super.finalize();
- // }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; + +import org.eclipse.net4j.util.ui.UIUtil; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; + +import java.text.MessageFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Victor Roldan Betancort + */ +public class RemoveResourceActionDelegate implements IObjectActionDelegate +{ + // private Image deleteIcon; + + private List<CDOResourceNode> nodes; + + private Shell shell; + + public RemoveResourceActionDelegate() + { + } + + public void setActivePart(IAction action, IWorkbenchPart targetPart) + { + shell = targetPart.getSite().getShell(); + } + + public void selectionChanged(IAction action, ISelection selection) + { + nodes = UIUtil.getElements(selection, CDOResourceNode.class); + } + + public void run(IAction action) + { + if (MessageDialog.openConfirm(shell, Messages.getString("RemoveResourceAction_1"), MessageFormat.format( //$NON-NLS-1$ + Messages.getString("RemoveResourceAction_2"), nodes.size()))) //$NON-NLS-1$ + { + Job job = new Job(Messages.getString("RemoveResourceAction_3")) //$NON-NLS-1$ + { + @Override + protected IStatus run(IProgressMonitor monitor) + { + Map<Integer, CDOTransaction> repositoryToTransaction = new HashMap<Integer, CDOTransaction>(); + for (CDOResourceNode node : nodes) + { + int sessionID = node.cdoView().getSession().getSessionID(); + CDOTransaction transaction = repositoryToTransaction.get(sessionID); + if (transaction == null) + { + transaction = node.cdoView().getSession().openTransaction(); + repositoryToTransaction.put(sessionID, transaction); + } + + CDOObject writableNode = transaction.getObject(node.cdoID()); + EObject container = writableNode.eContainer(); + if (container == null) + { + container = (CDOResource)writableNode.eResource(); + } + + if (container instanceof CDOResource) + { + ((CDOResource)container).getContents().remove(writableNode); + } + else if (container instanceof CDOResourceFolder) + { + ((CDOResourceFolder)container).getNodes().remove(writableNode); + } + } + + for (CDOTransaction transaction : repositoryToTransaction.values()) + { + try + { + transaction.commit(); + } + catch (Exception ex) + { + OM.LOG.error(MessageFormat.format( + Messages.getString("RemoveResourceAction_4"), this.getClass().getName().toString()), ex); //$NON-NLS-1$ + } + finally + { + transaction.close(); + } + } + + // UIUtil.setStatusBarMessage( + // MessageFormat.format(Messages.getString("RemoveResourceAction_5"), nodes.size()), getDeleteIcon()); //$NON-NLS-1$ + return Status.OK_STATUS; + } + }; + + job.schedule(); + } + } + + // private Image getDeleteIcon() + // { + // if (deleteIcon == null) + // { + // deleteIcon = OM.Activator + // .imageDescriptorFromPlugin(OM.BUNDLE_ID, "icons/full/elcl16/delete_edit.gif").createImage(); //$NON-NLS-1$ + // } + // + // return deleteIcon; + // } + // + // @Override + // protected void finalize() throws Throwable + // { + // if (deleteIcon != null) + // { + // deleteIcon.dispose(); + // } + // + // super.finalize(); + // } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RenameResourceNodeActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RenameResourceNodeActionDelegate.java index 190277b0c5..e1188b68de 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RenameResourceNodeActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/RenameResourceNodeActionDelegate.java @@ -1,78 +1,78 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.internal.ui.actions.ResourceNodeNameInputValidator;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.InputDialog;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class RenameResourceNodeActionDelegate extends TransactionalBackgroundActionDelegate
-{
- private String newResourceName;
-
- public RenameResourceNodeActionDelegate()
- {
- super(Messages.getString("RenameResourceNodeActionDelegate.0")); //$NON-NLS-1$
- }
-
- @Override
- protected CDOObject preRun(CDOObject object)
- {
- InputDialog dialog = new InputDialog(
- getTargetPart().getSite().getShell(),
- getText(),
- Messages.getString("NewResourceNodeAction_0"), null, new ResourceNodeNameInputValidator((CDOResourceNode)object)); //$NON-NLS-1$
- if (dialog.open() == Dialog.OK)
- {
- setNewResourceName(dialog.getValue());
- return super.preRun(object);
- }
-
- cancel();
-
- return null;
- }
-
- private void setNewResourceName(String newName)
- {
- newResourceName = newName;
- }
-
- private String getNewResourceName()
- {
- return newResourceName;
- }
-
- @Override
- protected final void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor)
- throws Exception
- {
- if (object instanceof CDOResourceNode)
- {
- ((CDOResourceNode)object).setName(getNewResourceName());
- }
- else
- {
- throw new IllegalArgumentException("object is not a CDOResourceNode"); //$NON-NLS-1$
- }
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.internal.ui.actions.ResourceNodeNameInputValidator; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.InputDialog; + +/** + * @author Victor Roldan Betancort + */ +public class RenameResourceNodeActionDelegate extends TransactionalBackgroundActionDelegate +{ + private String newResourceName; + + public RenameResourceNodeActionDelegate() + { + super(Messages.getString("RenameResourceNodeActionDelegate.0")); //$NON-NLS-1$ + } + + @Override + protected CDOObject preRun(CDOObject object) + { + InputDialog dialog = new InputDialog( + getTargetPart().getSite().getShell(), + getText(), + Messages.getString("NewResourceNodeAction_0"), null, new ResourceNodeNameInputValidator((CDOResourceNode)object)); //$NON-NLS-1$ + if (dialog.open() == Dialog.OK) + { + setNewResourceName(dialog.getValue()); + return super.preRun(object); + } + + cancel(); + + return null; + } + + private void setNewResourceName(String newName) + { + newResourceName = newName; + } + + private String getNewResourceName() + { + return newResourceName; + } + + @Override + protected final void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor) + throws Exception + { + if (object instanceof CDOResourceNode) + { + ((CDOResourceNode)object).setName(getNewResourceName()); + } + else + { + throw new IllegalArgumentException("object is not a CDOResourceNode"); //$NON-NLS-1$ + } + } + +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/SessionAwareActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/SessionAwareActionDelegate.java index fb4ba891a9..86d6b8abfc 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/SessionAwareActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/SessionAwareActionDelegate.java @@ -1,42 +1,42 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.ui.ide.Node;
-
-import org.eclipse.net4j.util.ui.UIUtil;
-import org.eclipse.net4j.util.ui.actions.SafeActionDelegate;
-
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Victor Roldan Betancort
- */
-public abstract class SessionAwareActionDelegate extends SafeActionDelegate
-{
- public SessionAwareActionDelegate()
- {
- }
-
- public CDOSession getSession()
- {
- Node node = UIUtil.getElement(getSelection(), Node.class);
- return node.getRepositoryProject().getView().getSession();
- }
-
- public IWorkbenchPage getPage()
- {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.ui.ide.Node; + +import org.eclipse.net4j.util.ui.UIUtil; +import org.eclipse.net4j.util.ui.actions.SafeActionDelegate; + +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; + +/** + * @author Victor Roldan Betancort + */ +public abstract class SessionAwareActionDelegate extends SafeActionDelegate +{ + public SessionAwareActionDelegate() + { + } + + public CDOSession getSession() + { + Node node = UIUtil.getElement(getSelection(), Node.class); + return node.getRepositoryProject().getView().getSession(); + } + + public IWorkbenchPage getPage() + { + return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/SwitchToBranchActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/SwitchToBranchActionDelegate.java index baa2625aef..6174f64a55 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/SwitchToBranchActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/SwitchToBranchActionDelegate.java @@ -1,35 +1,35 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.ui.ide.Node.BranchNode;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.ui.UIUtil;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class SwitchToBranchActionDelegate extends SessionAwareActionDelegate
-{
- public SwitchToBranchActionDelegate()
- {
- }
-
- @Override
- protected void safeRun() throws Exception
- {
- BranchNode branchNode = UIUtil.getElement(getSelection(), BranchNode.class);
- CDOView view = branchNode.getRepositoryProject().getView();
- view.setBranch(branchNode.getBranch());
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.ui.ide.Node.BranchNode; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.net4j.util.ui.UIUtil; + +/** + * @author Victor Roldan Betancort + */ +public class SwitchToBranchActionDelegate extends SessionAwareActionDelegate +{ + public SwitchToBranchActionDelegate() + { + } + + @Override + protected void safeRun() throws Exception + { + BranchNode branchNode = UIUtil.getElement(getSelection(), BranchNode.class); + CDOView view = branchNode.getRepositoryProject().getView(); + view.setBranch(branchNode.getBranch()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/TransactionalBackgroundActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/TransactionalBackgroundActionDelegate.java index 05c377b3a9..02e5bdd89f 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/TransactionalBackgroundActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/TransactionalBackgroundActionDelegate.java @@ -1,133 +1,133 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.AdapterUtil;
-import org.eclipse.net4j.util.ui.UIUtil;
-import org.eclipse.net4j.util.ui.actions.LongRunningActionDelegate;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-import java.text.MessageFormat;
-
-/**
- * @author Victor Roldan Betancort
- */
-public abstract class TransactionalBackgroundActionDelegate extends LongRunningActionDelegate implements
- IObjectActionDelegate
-{
- private IWorkbenchPart targetPart;
-
- private String text;
-
- private CDOObject transactionalObject;
-
- public TransactionalBackgroundActionDelegate(String text)
- {
- this.text = text;
- }
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart)
- {
- this.targetPart = targetPart;
- selectionChanged(action, getSelection());
- }
-
- public IWorkbenchPart getTargetPart()
- {
- return targetPart;
- }
-
- @Override
- protected String getText()
- {
- return text;
- }
-
- protected int getCommitWorkPercent()
- {
- return 90;
- }
-
- @Override
- protected final void preRun() throws Exception
- {
- Object element = UIUtil.getElement(getSelection());
- CDOObject object = AdapterUtil.adapt(element, CDOObject.class);
- if (object != null)
- {
- transactionalObject = preRun(object);
- if (transactionalObject != null)
- {
- CDOView view = transactionalObject.cdoView();
- if (!(view instanceof CDOTransaction))
- {
- throw new IllegalStateException(MessageFormat.format(
- Messages.getString("TransactionalBackgroundAction_0"), transactionalObject)); //$NON-NLS-1$
- }
-
- // Bypass cancel()
- return;
- }
- }
-
- cancel();
- }
-
- /**
- * Usually opens a new transaction based on the passed object and its view/session and returns a "contextualized" copy
- * of this object. Clients may override to access the UI thread before the background job is started or change the
- * contextualization procedure.
- *
- * @param object
- * Usually an object in a read-only view that needs to be modified in a separate transaction.
- * @return A transactional copy of the passed object, or <code>null</code> to indicate cancelation of this action.
- */
- protected CDOObject preRun(CDOObject object)
- {
- CDOTransaction transaction = object.cdoView().getSession().openTransaction();
- CDOObject transactionalObject = transaction.getObject(object);
- return transactionalObject;
- }
-
- @Override
- protected final void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- CDOTransaction transaction = (CDOTransaction)transactionalObject.cdoView();
- int commitWorkPercent = getCommitWorkPercent();
- progressMonitor.beginTask(Messages.getString("TransactionalBackgroundAction_1"), 100); //$NON-NLS-1$
-
- try
- {
- doRun(transaction, transactionalObject, new SubProgressMonitor(progressMonitor, 100 - commitWorkPercent));
- transaction.commit(new SubProgressMonitor(progressMonitor, commitWorkPercent));
- }
- finally
- {
- progressMonitor.done();
- transaction.close();
- transactionalObject = null;
- }
- }
-
- protected abstract void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor)
- throws Exception;
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.net4j.util.AdapterUtil; +import org.eclipse.net4j.util.ui.UIUtil; +import org.eclipse.net4j.util.ui.actions.LongRunningActionDelegate; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.jface.action.IAction; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; + +import java.text.MessageFormat; + +/** + * @author Victor Roldan Betancort + */ +public abstract class TransactionalBackgroundActionDelegate extends LongRunningActionDelegate implements + IObjectActionDelegate +{ + private IWorkbenchPart targetPart; + + private String text; + + private CDOObject transactionalObject; + + public TransactionalBackgroundActionDelegate(String text) + { + this.text = text; + } + + public void setActivePart(IAction action, IWorkbenchPart targetPart) + { + this.targetPart = targetPart; + selectionChanged(action, getSelection()); + } + + public IWorkbenchPart getTargetPart() + { + return targetPart; + } + + @Override + protected String getText() + { + return text; + } + + protected int getCommitWorkPercent() + { + return 90; + } + + @Override + protected final void preRun() throws Exception + { + Object element = UIUtil.getElement(getSelection()); + CDOObject object = AdapterUtil.adapt(element, CDOObject.class); + if (object != null) + { + transactionalObject = preRun(object); + if (transactionalObject != null) + { + CDOView view = transactionalObject.cdoView(); + if (!(view instanceof CDOTransaction)) + { + throw new IllegalStateException(MessageFormat.format( + Messages.getString("TransactionalBackgroundAction_0"), transactionalObject)); //$NON-NLS-1$ + } + + // Bypass cancel() + return; + } + } + + cancel(); + } + + /** + * Usually opens a new transaction based on the passed object and its view/session and returns a "contextualized" copy + * of this object. Clients may override to access the UI thread before the background job is started or change the + * contextualization procedure. + * + * @param object + * Usually an object in a read-only view that needs to be modified in a separate transaction. + * @return A transactional copy of the passed object, or <code>null</code> to indicate cancelation of this action. + */ + protected CDOObject preRun(CDOObject object) + { + CDOTransaction transaction = object.cdoView().getSession().openTransaction(); + CDOObject transactionalObject = transaction.getObject(object); + return transactionalObject; + } + + @Override + protected final void doRun(IProgressMonitor progressMonitor) throws Exception + { + CDOTransaction transaction = (CDOTransaction)transactionalObject.cdoView(); + int commitWorkPercent = getCommitWorkPercent(); + progressMonitor.beginTask(Messages.getString("TransactionalBackgroundAction_1"), 100); //$NON-NLS-1$ + + try + { + doRun(transaction, transactionalObject, new SubProgressMonitor(progressMonitor, 100 - commitWorkPercent)); + transaction.commit(new SubProgressMonitor(progressMonitor, commitWorkPercent)); + } + finally + { + progressMonitor.done(); + transaction.close(); + transactionalObject = null; + } + } + + protected abstract void doRun(CDOTransaction transaction, CDOObject object, IProgressMonitor progressMonitor) + throws Exception; +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ViewAwareActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ViewAwareActionDelegate.java index c51a78dcab..60032df4ed 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ViewAwareActionDelegate.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/actions/ViewAwareActionDelegate.java @@ -1,42 +1,42 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.actions;
-
-import org.eclipse.emf.cdo.ui.ide.Node;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.ui.UIUtil;
-import org.eclipse.net4j.util.ui.actions.SafeActionDelegate;
-
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Victor Roldan Betancort
- */
-public abstract class ViewAwareActionDelegate extends SafeActionDelegate
-{
- public ViewAwareActionDelegate()
- {
- }
-
- public CDOView getView()
- {
- Node node = UIUtil.getElement(getSelection(), Node.class);
- return node.getRepositoryProject().getView();
- }
-
- public IWorkbenchPage getPage()
- {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.actions; + +import org.eclipse.emf.cdo.ui.ide.Node; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.net4j.util.ui.UIUtil; +import org.eclipse.net4j.util.ui.actions.SafeActionDelegate; + +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; + +/** + * @author Victor Roldan Betancort + */ +public abstract class ViewAwareActionDelegate extends SafeActionDelegate +{ + public ViewAwareActionDelegate() + { + } + + public CDOView getView() + { + Node node = UIUtil.getElement(getSelection(), Node.class); + return node.getRepositoryProject().getView(); + } + + public IWorkbenchPage getPage() + { + return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/messages/Messages.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/messages/Messages.java index e7c203a417..13fff8534b 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/messages/Messages.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/messages/Messages.java @@ -1,40 +1,40 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.ui.internal.ide.messages;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author Eike Stepper
- */
-public class Messages
-{
- private static final String BUNDLE_NAME = "org.eclipse.emf.cdo.ui.internal.ide.messages.messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private Messages()
- {
- }
-
- public static String getString(String key)
- {
- try
- {
- return RESOURCE_BUNDLE.getString(key);
- }
- catch (MissingResourceException e)
- {
- return '!' + key + '!';
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.ui.internal.ide.messages; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * @author Eike Stepper + */ +public class Messages +{ + private static final String BUNDLE_NAME = "org.eclipse.emf.cdo.ui.internal.ide.messages.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + private Messages() + { + } + + public static String getString(String key) + { + try + { + return RESOURCE_BUNDLE.getString(key); + } + catch (MissingResourceException e) + { + return '!' + key + '!'; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/messages/messages.properties b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/messages/messages.properties index 419aa3aa05..6a203f96d6 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/messages/messages.properties +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/messages/messages.properties @@ -1,48 +1,48 @@ -# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
-# Victor Roldan Betancort - initial API and implementation
-# Eike Stepper - maintenance
-
-ExportSelectedResourceAction_0=Export Resource
-ImportResourceActionDelegate.0=Couldn't Import CDOResource
-ImportResourceToFolderAction_0=Import Resource
-ImportResourceToFolderAction_1=No URI has been introduced
-NewResourceAction_0=Creating CDO resource
-NewResourceFolderAction_0=Creating CDO folder
-NewResourceNodeAction_0=Enter the name
-Node.0=Sessions
-Node.1=Repository does not support branching
-Node.2=Packages
-Node.4=Resources
-RemoveResourceAction_1=Delete Resource
-RemoveResourceAction_2=Are you sure you want to delete the selected {0} item(s)?
-RemoveResourceAction_3=Deleting CDOResource(s)
-RemoveResourceAction_4={0}: Cannot perform commit
-RemoveResourceAction_5={0} element(s) removed
-RenameResourceNodeActionDelegate.0=Rename
-RepositoryContentProvider_0=An error happened. See Error Log for more details.
-TeamConfigurationWizard_1=Share Project to CDO
-TeamConfigurationWizard_2=Enter CDO repository location information
-TeamConfigurationWizard_3=Provide a URL to the target server and a repository name
-TransactionalBackgroundAction_0=Object is not transactional: {0}
-TransactionalBackgroundAction_1=Commit Transaction
-CDOProjectCreationWizard.0=New Project
-CDOProjectCreationWizard.1=Creation Problems
-CDOProjectCreationWizard.2=Create a new project resource.
-CDOProjectCreationWizard.4=Create and Share to CDO a new Project
-CDOProjectCreationWizard.5=Change perspective
-CDOProjectCreationWizard.6=Do you want to switch to CDO Explorer perspective?
-CDOShareProjectWizardPage_0=Please introduce a valid server URL and repository name
-CreateBranchActionDelegate_0=Create a new branch
-CreateBranchActionDelegate_1=Please specify the name of the new branch
-CreateBranchActionDelegate_3=Branch name cannot be empty
-CreateBranchActionDelegate_4=Branch name cannot contain path separators
-CreateBranchActionDelegate_5=A branch with that name already exists
-ExportResourceActionDelegate.0=Couldn't Export CDOResource
-ExportSelectedResourceAction_1=Export CDOResource
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: +# Victor Roldan Betancort - initial API and implementation +# Eike Stepper - maintenance + +ExportSelectedResourceAction_0=Export Resource +ImportResourceActionDelegate.0=Couldn't Import CDOResource +ImportResourceToFolderAction_0=Import Resource +ImportResourceToFolderAction_1=No URI has been introduced +NewResourceAction_0=Creating CDO resource +NewResourceFolderAction_0=Creating CDO folder +NewResourceNodeAction_0=Enter the name +Node.0=Sessions +Node.1=Repository does not support branching +Node.2=Packages +Node.4=Resources +RemoveResourceAction_1=Delete Resource +RemoveResourceAction_2=Are you sure you want to delete the selected {0} item(s)? +RemoveResourceAction_3=Deleting CDOResource(s) +RemoveResourceAction_4={0}: Cannot perform commit +RemoveResourceAction_5={0} element(s) removed +RenameResourceNodeActionDelegate.0=Rename +RepositoryContentProvider_0=An error happened. See Error Log for more details. +TeamConfigurationWizard_1=Share Project to CDO +TeamConfigurationWizard_2=Enter CDO repository location information +TeamConfigurationWizard_3=Provide a URL to the target server and a repository name +TransactionalBackgroundAction_0=Object is not transactional: {0} +TransactionalBackgroundAction_1=Commit Transaction +CDOProjectCreationWizard.0=New Project +CDOProjectCreationWizard.1=Creation Problems +CDOProjectCreationWizard.2=Create a new project resource. +CDOProjectCreationWizard.4=Create and Share to CDO a new Project +CDOProjectCreationWizard.5=Change perspective +CDOProjectCreationWizard.6=Do you want to switch to CDO Explorer perspective? +CDOShareProjectWizardPage_0=Please introduce a valid server URL and repository name +CreateBranchActionDelegate_0=Create a new branch +CreateBranchActionDelegate_1=Please specify the name of the new branch +CreateBranchActionDelegate_3=Branch name cannot be empty +CreateBranchActionDelegate_4=Branch name cannot contain path separators +CreateBranchActionDelegate_5=A branch with that name already exists +ExportResourceActionDelegate.0=Couldn't Export CDOResource +ExportSelectedResourceAction_1=Export CDOResource ExportSelectedResourceAction_2=No URI has been introduced
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/CDOProjectCreationWizard.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/CDOProjectCreationWizard.java index 867adb7297..9bafcf686a 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/CDOProjectCreationWizard.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/CDOProjectCreationWizard.java @@ -1,233 +1,233 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.wizards;
-
-import org.eclipse.emf.cdo.internal.team.RepositoryManager;
-import org.eclipse.emf.cdo.internal.team.RepositoryTeamProvider;
-import org.eclipse.emf.cdo.internal.ui.perspectives.CDOExplorerPerspective;
-import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWizard;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
-import org.eclipse.ui.ide.undo.CreateProjectOperation;
-import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
-import org.eclipse.ui.statushandlers.IStatusAdapterConstants;
-import org.eclipse.ui.statushandlers.StatusAdapter;
-import org.eclipse.ui.statushandlers.StatusManager;
-
-import java.lang.reflect.InvocationTargetException;
-import java.net.URI;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class CDOProjectCreationWizard extends Wizard implements IWorkbenchWizard
-{
- private WizardNewProjectCreationPage projectCreationPage;
-
- private CDOShareProjectWizardPage sharePage;
-
- // Cache of newly-created project
- private IProject newProject;
-
- private IWorkbench workbench;
-
- public CDOProjectCreationWizard()
- {
- }
-
- @Override
- public boolean performFinish()
- {
- createNewProject();
- if (newProject == null)
- {
- return false;
- }
-
- try
- {
- RepositoryTeamProvider.mapProject(newProject, sharePage.getSessionDescription());
- }
- catch (TeamException ex)
- {
- OM.LOG.equals(ex);
- return false;
- }
-
- RepositoryManager.INSTANCE.addElement(newProject);
- if (!CDOExplorerPerspective.isCurrent())
- {
- openCDOExplorerPerspective(workbench);
- }
-
- return true;
- }
-
- @Override
- public void addPages()
- {
- super.addPages();
- projectCreationPage = new WizardNewProjectCreationPage("basicNewProjectPage"); //$NON-NLS-1$
- projectCreationPage.setTitle(Messages.getString("CDOProjectCreationWizard.4")); //$NON-NLS-1$
- projectCreationPage.setDescription(Messages.getString("CDOProjectCreationWizard.2")); //$NON-NLS-1$
- super.addPage(projectCreationPage);
-
- sharePage = new CDOShareProjectWizardPage("shareProject"); //$NON-NLS-1$
- sharePage.setTitle(Messages.getString("TeamConfigurationWizard_2")); //$NON-NLS-1$
- super.addPage(sharePage);
- }
-
- public void init(IWorkbench workbench, IStructuredSelection currentSelection)
- {
- this.workbench = workbench;
- setNeedsProgressMonitor(true);
- setWindowTitle(Messages.getString("CDOProjectCreationWizard.4")); //$NON-NLS-1$
- initializeDefaultPageImageDescriptor();
- }
-
- protected void initializeDefaultPageImageDescriptor()
- {
- ImageDescriptor desc = OM.getImageDescriptor("icons/full/wizban/wizard_icon.gif");//$NON-NLS-1$
- setDefaultPageImageDescriptor(desc);
- }
-
- private IProject createNewProject()
- {
- if (newProject != null)
- {
- return newProject;
- }
-
- // get a project handle
- final IProject newProjectHandle = projectCreationPage.getProjectHandle();
-
- // get a project descriptor
- URI location = null;
- if (!projectCreationPage.useDefaults())
- {
- location = projectCreationPage.getLocationURI();
- }
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- final IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
- description.setLocationURI(location);
-
- // create the new project operation
- IRunnableWithProgress op = new IRunnableWithProgress()
- {
- public void run(IProgressMonitor monitor) throws InvocationTargetException
- {
- CreateProjectOperation op = new CreateProjectOperation(description,
- Messages.getString("CDOProjectCreationWizard.0")); //$NON-NLS-1$
- try
- {
- op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell()));
- }
- catch (ExecutionException e)
- {
- throw new InvocationTargetException(e);
- }
- }
- };
-
- // run the new project creation operation
- try
- {
- getContainer().run(true, true, op);
- }
- catch (InterruptedException e)
- {
- return null;
- }
-
- catch (InvocationTargetException e)
- {
- Throwable t = e.getTargetException();
- if (t instanceof ExecutionException && t.getCause() instanceof CoreException)
- {
- CoreException cause = (CoreException)t.getCause();
- StatusAdapter status;
- if (cause.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS)
- {
- status = new StatusAdapter(new Status(IStatus.WARNING, OM.BUNDLE_ID, cause.getMessage(), cause));
- }
- else
- {
- status = new StatusAdapter(new Status(cause.getStatus().getSeverity(), OM.BUNDLE_ID, cause.getMessage(),
- cause));
- }
-
- status.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, Messages.getString("CDOProjectCreationWizard.1")); //$NON-NLS-1$
- StatusManager.getManager().handle(status, StatusManager.BLOCK);
- }
- else
- {
- StatusAdapter status = new StatusAdapter(new Status(IStatus.WARNING, OM.BUNDLE_ID, t.getMessage(), t));
- status.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, Messages.getString("CDOProjectCreationWizard.1")); //$NON-NLS-1$
- StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.BLOCK);
- }
-
- return null;
- }
-
- newProject = newProjectHandle;
- return newProject;
- }
-
- /**
- * Opens CDO Explorer perspective
- */
- public void openCDOExplorerPerspective(final IWorkbench workbench)
- {
- Display.getDefault().asyncExec(new Runnable()
- {
- public void run()
- {
- try
- {
- boolean result = MessageDialog.openQuestion(getShell(), Messages.getString("CDOProjectCreationWizard.5"), //$NON-NLS-1$
- Messages.getString("CDOProjectCreationWizard.6")); //$NON-NLS-1$
- if (result)
- {
- workbench.showPerspective(CDOExplorerPerspective.ID, workbench.getActiveWorkbenchWindow());
- }
- }
- catch (WorkbenchException ex)
- {
- OM.LOG.error(ex);
- // ignore
- }
- }
- });
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.wizards; + +import org.eclipse.emf.cdo.internal.team.RepositoryManager; +import org.eclipse.emf.cdo.internal.team.RepositoryTeamProvider; +import org.eclipse.emf.cdo.internal.ui.perspectives.CDOExplorerPerspective; +import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.swt.widgets.Display; +import org.eclipse.team.core.TeamException; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWizard; +import org.eclipse.ui.WorkbenchException; +import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; +import org.eclipse.ui.ide.undo.CreateProjectOperation; +import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; +import org.eclipse.ui.statushandlers.IStatusAdapterConstants; +import org.eclipse.ui.statushandlers.StatusAdapter; +import org.eclipse.ui.statushandlers.StatusManager; + +import java.lang.reflect.InvocationTargetException; +import java.net.URI; + +/** + * @author Victor Roldan Betancort + */ +public class CDOProjectCreationWizard extends Wizard implements IWorkbenchWizard +{ + private WizardNewProjectCreationPage projectCreationPage; + + private CDOShareProjectWizardPage sharePage; + + // Cache of newly-created project + private IProject newProject; + + private IWorkbench workbench; + + public CDOProjectCreationWizard() + { + } + + @Override + public boolean performFinish() + { + createNewProject(); + if (newProject == null) + { + return false; + } + + try + { + RepositoryTeamProvider.mapProject(newProject, sharePage.getSessionDescription()); + } + catch (TeamException ex) + { + OM.LOG.equals(ex); + return false; + } + + RepositoryManager.INSTANCE.addElement(newProject); + if (!CDOExplorerPerspective.isCurrent()) + { + openCDOExplorerPerspective(workbench); + } + + return true; + } + + @Override + public void addPages() + { + super.addPages(); + projectCreationPage = new WizardNewProjectCreationPage("basicNewProjectPage"); //$NON-NLS-1$ + projectCreationPage.setTitle(Messages.getString("CDOProjectCreationWizard.4")); //$NON-NLS-1$ + projectCreationPage.setDescription(Messages.getString("CDOProjectCreationWizard.2")); //$NON-NLS-1$ + super.addPage(projectCreationPage); + + sharePage = new CDOShareProjectWizardPage("shareProject"); //$NON-NLS-1$ + sharePage.setTitle(Messages.getString("TeamConfigurationWizard_2")); //$NON-NLS-1$ + super.addPage(sharePage); + } + + public void init(IWorkbench workbench, IStructuredSelection currentSelection) + { + this.workbench = workbench; + setNeedsProgressMonitor(true); + setWindowTitle(Messages.getString("CDOProjectCreationWizard.4")); //$NON-NLS-1$ + initializeDefaultPageImageDescriptor(); + } + + protected void initializeDefaultPageImageDescriptor() + { + ImageDescriptor desc = OM.getImageDescriptor("icons/full/wizban/wizard_icon.gif");//$NON-NLS-1$ + setDefaultPageImageDescriptor(desc); + } + + private IProject createNewProject() + { + if (newProject != null) + { + return newProject; + } + + // get a project handle + final IProject newProjectHandle = projectCreationPage.getProjectHandle(); + + // get a project descriptor + URI location = null; + if (!projectCreationPage.useDefaults()) + { + location = projectCreationPage.getLocationURI(); + } + + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + final IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); + description.setLocationURI(location); + + // create the new project operation + IRunnableWithProgress op = new IRunnableWithProgress() + { + public void run(IProgressMonitor monitor) throws InvocationTargetException + { + CreateProjectOperation op = new CreateProjectOperation(description, + Messages.getString("CDOProjectCreationWizard.0")); //$NON-NLS-1$ + try + { + op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell())); + } + catch (ExecutionException e) + { + throw new InvocationTargetException(e); + } + } + }; + + // run the new project creation operation + try + { + getContainer().run(true, true, op); + } + catch (InterruptedException e) + { + return null; + } + + catch (InvocationTargetException e) + { + Throwable t = e.getTargetException(); + if (t instanceof ExecutionException && t.getCause() instanceof CoreException) + { + CoreException cause = (CoreException)t.getCause(); + StatusAdapter status; + if (cause.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) + { + status = new StatusAdapter(new Status(IStatus.WARNING, OM.BUNDLE_ID, cause.getMessage(), cause)); + } + else + { + status = new StatusAdapter(new Status(cause.getStatus().getSeverity(), OM.BUNDLE_ID, cause.getMessage(), + cause)); + } + + status.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, Messages.getString("CDOProjectCreationWizard.1")); //$NON-NLS-1$ + StatusManager.getManager().handle(status, StatusManager.BLOCK); + } + else + { + StatusAdapter status = new StatusAdapter(new Status(IStatus.WARNING, OM.BUNDLE_ID, t.getMessage(), t)); + status.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, Messages.getString("CDOProjectCreationWizard.1")); //$NON-NLS-1$ + StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.BLOCK); + } + + return null; + } + + newProject = newProjectHandle; + return newProject; + } + + /** + * Opens CDO Explorer perspective + */ + public void openCDOExplorerPerspective(final IWorkbench workbench) + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + try + { + boolean result = MessageDialog.openQuestion(getShell(), Messages.getString("CDOProjectCreationWizard.5"), //$NON-NLS-1$ + Messages.getString("CDOProjectCreationWizard.6")); //$NON-NLS-1$ + if (result) + { + workbench.showPerspective(CDOExplorerPerspective.ID, workbench.getActiveWorkbenchWindow()); + } + } + catch (WorkbenchException ex) + { + OM.LOG.error(ex); + // ignore + } + } + }); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/CDOShareProjectWizardPage.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/CDOShareProjectWizardPage.java index 0c9050e632..677a6e008c 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/CDOShareProjectWizardPage.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/CDOShareProjectWizardPage.java @@ -1,78 +1,78 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.wizards;
-
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-import org.eclipse.emf.cdo.ui.widgets.SessionComposite;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class CDOShareProjectWizardPage extends WizardPage
-{
- private SessionComposite sessionComposite;
-
- private Listener modifyListener = new Listener()
- {
- public void handleEvent(Event e)
- {
- boolean valid = isPageComplete();
- setPageComplete(valid);
- }
- };
-
- public CDOShareProjectWizardPage(String id)
- {
- super(id);
- }
-
- public SessionComposite getSessionComposite()
- {
- return sessionComposite;
- }
-
- public void createControl(Composite parent)
- {
- sessionComposite = new SessionComposite(parent, SWT.NONE);
- setControl(sessionComposite);
- sessionComposite.addListener(SWT.Modify, modifyListener);
- }
-
- public String getSessionDescription()
- {
- return sessionComposite != null ? sessionComposite.getSessionDescription() : null;
- }
-
- public boolean isDescriptionValid()
- {
- return sessionComposite.isDescriptionValid();
- }
-
- @Override
- public boolean isPageComplete()
- {
- if (isDescriptionValid())
- {
- CDOShareProjectWizardPage.this.setErrorMessage(null);
- return true;
- }
-
- CDOShareProjectWizardPage.this.setErrorMessage(Messages.getString("CDOShareProjectWizardPage_0")); //$NON-NLS-1$
- return false;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.wizards; + +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; +import org.eclipse.emf.cdo.ui.widgets.SessionComposite; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; + +/** + * @author Victor Roldan Betancort + */ +public class CDOShareProjectWizardPage extends WizardPage +{ + private SessionComposite sessionComposite; + + private Listener modifyListener = new Listener() + { + public void handleEvent(Event e) + { + boolean valid = isPageComplete(); + setPageComplete(valid); + } + }; + + public CDOShareProjectWizardPage(String id) + { + super(id); + } + + public SessionComposite getSessionComposite() + { + return sessionComposite; + } + + public void createControl(Composite parent) + { + sessionComposite = new SessionComposite(parent, SWT.NONE); + setControl(sessionComposite); + sessionComposite.addListener(SWT.Modify, modifyListener); + } + + public String getSessionDescription() + { + return sessionComposite != null ? sessionComposite.getSessionDescription() : null; + } + + public boolean isDescriptionValid() + { + return sessionComposite.isDescriptionValid(); + } + + @Override + public boolean isPageComplete() + { + if (isDescriptionValid()) + { + CDOShareProjectWizardPage.this.setErrorMessage(null); + return true; + } + + CDOShareProjectWizardPage.this.setErrorMessage(Messages.getString("CDOShareProjectWizardPage_0")); //$NON-NLS-1$ + return false; + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/TeamConfigurationWizard.java b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/TeamConfigurationWizard.java index 4616f51648..c046a3dc01 100644 --- a/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/TeamConfigurationWizard.java +++ b/plugins/org.eclipse.emf.cdo.ui.ide/src/org/eclipse/emf/cdo/ui/internal/ide/wizards/TeamConfigurationWizard.java @@ -1,74 +1,74 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.ui.internal.ide.wizards;
-
-import org.eclipse.emf.cdo.internal.team.RepositoryManager;
-import org.eclipse.emf.cdo.internal.team.RepositoryTeamProvider;
-import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM;
-import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages;
-import org.eclipse.emf.cdo.ui.widgets.SessionComposite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.team.ui.IConfigurationWizard;
-import org.eclipse.ui.IWorkbench;
-
-/**
- * @author Eike Stepper
- */
-public class TeamConfigurationWizard extends Wizard implements IConfigurationWizard
-{
- private IProject project;
-
- private CDOShareProjectWizardPage page1;
-
- public TeamConfigurationWizard()
- {
- }
-
- public void init(IWorkbench workbench, IProject project)
- {
- this.project = project;
- setWindowTitle(Messages.getString("TeamConfigurationWizard_1")); //$NON-NLS-1$
- ImageDescriptor desc = OM.getImageDescriptor("icons/full/wizban/wizard_icon.gif");//$NON-NLS-1$
- setDefaultPageImageDescriptor(desc);
- }
-
- @Override
- public void addPages()
- {
- page1 = new CDOShareProjectWizardPage("page1"); //$NON-NLS-1$
- page1.setTitle(Messages.getString("TeamConfigurationWizard_2")); //$NON-NLS-1$
- addPage(page1);
- }
-
- @Override
- public boolean performFinish()
- {
- try
- {
- SessionComposite sessionComposite = page1.getSessionComposite();
- String sessionDescription = sessionComposite.getSessionDescription();
- sessionComposite.rememberSettings();
-
- RepositoryTeamProvider.mapProject(project, sessionDescription);
- RepositoryManager.INSTANCE.addElement(project);
- return true;
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- return false;
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.ui.internal.ide.wizards; + +import org.eclipse.emf.cdo.internal.team.RepositoryManager; +import org.eclipse.emf.cdo.internal.team.RepositoryTeamProvider; +import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM; +import org.eclipse.emf.cdo.ui.internal.ide.messages.Messages; +import org.eclipse.emf.cdo.ui.widgets.SessionComposite; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.team.ui.IConfigurationWizard; +import org.eclipse.ui.IWorkbench; + +/** + * @author Eike Stepper + */ +public class TeamConfigurationWizard extends Wizard implements IConfigurationWizard +{ + private IProject project; + + private CDOShareProjectWizardPage page1; + + public TeamConfigurationWizard() + { + } + + public void init(IWorkbench workbench, IProject project) + { + this.project = project; + setWindowTitle(Messages.getString("TeamConfigurationWizard_1")); //$NON-NLS-1$ + ImageDescriptor desc = OM.getImageDescriptor("icons/full/wizban/wizard_icon.gif");//$NON-NLS-1$ + setDefaultPageImageDescriptor(desc); + } + + @Override + public void addPages() + { + page1 = new CDOShareProjectWizardPage("page1"); //$NON-NLS-1$ + page1.setTitle(Messages.getString("TeamConfigurationWizard_2")); //$NON-NLS-1$ + addPage(page1); + } + + @Override + public boolean performFinish() + { + try + { + SessionComposite sessionComposite = page1.getSessionComposite(); + String sessionDescription = sessionComposite.getSessionDescription(); + sessionComposite.rememberSettings(); + + RepositoryTeamProvider.mapProject(project, sessionDescription); + RepositoryManager.INSTANCE.addElement(project); + return true; + } + catch (Exception ex) + { + OM.LOG.error(ex); + return false; + } + } +} |