diff options
author | Eike Stepper | 2012-07-19 08:22:04 +0000 |
---|---|---|
committer | Eike Stepper | 2012-07-19 08:22:04 +0000 |
commit | 1460904fd3c193ffaf809913b2983a400fce9d94 (patch) | |
tree | 72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions | |
parent | 5f360965ae87478e0681899bf310a210cafc2c44 (diff) | |
download | cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.gz cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.xz cdo-1460904fd3c193ffaf809913b2983a400fce9d94.zip |
Fix line endings in master (dos2unix)
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions')
41 files changed, 2736 insertions, 2736 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractContainerAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractContainerAction.java index 0c3271c145..aade6a67b3 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractContainerAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractContainerAction.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.internal.ui.actions;
-
-import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.net4j.util.ui.actions.LongRunningAction;
-
-/**
- * @author Victor Roldan Betancort
- */
-public abstract class AbstractContainerAction<E> extends LongRunningAction
-{
- private IContainer.Modifiable<E> container;
-
- public AbstractContainerAction(IContainer.Modifiable<E> container)
- {
- setContainer(container);
- }
-
- protected IContainer.Modifiable<E> getContainer()
- {
- return container;
- }
-
- protected void setContainer(IContainer.Modifiable<E> container)
- {
- this.container = container;
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.net4j.util.container.IContainer; +import org.eclipse.net4j.util.ui.actions.LongRunningAction; + +/** + * @author Victor Roldan Betancort + */ +public abstract class AbstractContainerAction<E> extends LongRunningAction +{ + private IContainer.Modifiable<E> container; + + public AbstractContainerAction(IContainer.Modifiable<E> container) + { + setContainer(container); + } + + protected IContainer.Modifiable<E> getContainer() + { + return container; + } + + protected void setContainer(IContainer.Modifiable<E> container) + { + this.container = container; + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractLockObjectsAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractLockObjectsAction.java index 0553897d5e..0986cb1feb 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractLockObjectsAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractLockObjectsAction.java @@ -1,127 +1,127 @@ -/*
- * 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:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.CDOLock;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.ui.CDOEditorUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchPage;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Simon McDuff
- */
-public abstract class AbstractLockObjectsAction extends EditingDomainAction
-{
- private List<InternalCDOObject> objects = new ArrayList<InternalCDOObject>();
-
- private List<InternalCDOObject> lockObjects = new ArrayList<InternalCDOObject>();
-
- private Boolean lock;
-
- public AbstractLockObjectsAction(String title)
- {
- super(title);
- }
-
- public void selectionChanged(IStructuredSelection selection)
- {
- objects.clear();
- lock = null;
- if (selection != null)
- {
- for (Iterator<?> it = selection.iterator(); it.hasNext();)
- {
- Object object = it.next();
- if (object instanceof InternalCDOObject)
- {
- objects.add((InternalCDOObject)object);
- }
- }
- }
- }
-
- @Override
- public void update()
- {
- updateLockInfo();
- setEnabled(!lockObjects.isEmpty() && lock != null);
- setChecked(lock != null && lock);
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- if (!objects.isEmpty())
- {
- InternalCDOObject[] array = objects.toArray(new InternalCDOObject[objects.size()]);
- for (InternalCDOObject object : lockObjects)
- {
- CDOLock cdoLock = getLock(object);
- if (lock)
- {
- cdoLock.unlock();
- }
- else
- {
- if (!cdoLock.tryLock())
- {
- getDisplay().syncExec(new Runnable()
- {
- public void run()
- {
- MessageDialog.openError(
- getShell(),
- Messages.getString("AbstractLockObjectsAction.0"), Messages.getString("AbstractLockObjectsAction.1")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- }
- }
- }
-
- IWorkbenchPage page = getPage();
- if (page != null)
- {
- CDOView view = array[0].cdoView();
- CDOEditorUtil.refreshEditors(page, view);
- }
- }
- }
-
- protected abstract CDOLock getLock(InternalCDOObject object);
-
- private void updateLockInfo()
- {
- lock = null;
- lockObjects.clear();
- for (InternalCDOObject object : objects)
- {
- boolean isLocked = getLock(object).isLocked();
- if (lock == null || isLocked == lock)
- {
- lock = isLocked;
- lockObjects.add(object);
- }
- }
- }
-}
+/* + * 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.CDOLock; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.ui.CDOEditorUtil; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.spi.cdo.InternalCDOObject; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbenchPage; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author Simon McDuff + */ +public abstract class AbstractLockObjectsAction extends EditingDomainAction +{ + private List<InternalCDOObject> objects = new ArrayList<InternalCDOObject>(); + + private List<InternalCDOObject> lockObjects = new ArrayList<InternalCDOObject>(); + + private Boolean lock; + + public AbstractLockObjectsAction(String title) + { + super(title); + } + + public void selectionChanged(IStructuredSelection selection) + { + objects.clear(); + lock = null; + if (selection != null) + { + for (Iterator<?> it = selection.iterator(); it.hasNext();) + { + Object object = it.next(); + if (object instanceof InternalCDOObject) + { + objects.add((InternalCDOObject)object); + } + } + } + } + + @Override + public void update() + { + updateLockInfo(); + setEnabled(!lockObjects.isEmpty() && lock != null); + setChecked(lock != null && lock); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + if (!objects.isEmpty()) + { + InternalCDOObject[] array = objects.toArray(new InternalCDOObject[objects.size()]); + for (InternalCDOObject object : lockObjects) + { + CDOLock cdoLock = getLock(object); + if (lock) + { + cdoLock.unlock(); + } + else + { + if (!cdoLock.tryLock()) + { + getDisplay().syncExec(new Runnable() + { + public void run() + { + MessageDialog.openError( + getShell(), + Messages.getString("AbstractLockObjectsAction.0"), Messages.getString("AbstractLockObjectsAction.1")); //$NON-NLS-1$ //$NON-NLS-2$ + } + }); + } + } + } + + IWorkbenchPage page = getPage(); + if (page != null) + { + CDOView view = array[0].cdoView(); + CDOEditorUtil.refreshEditors(page, view); + } + } + } + + protected abstract CDOLock getLock(InternalCDOObject object); + + private void updateLockInfo() + { + lock = null; + lockObjects.clear(); + for (InternalCDOObject object : objects) + { + boolean isLocked = getLock(object).isLocked(); + if (lock == null || isLocked == lock) + { + lock = isLocked; + lockObjects.add(object); + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractOpenViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractOpenViewAction.java index b9a6132a08..eda04d090f 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractOpenViewAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractOpenViewAction.java @@ -1,34 +1,34 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public abstract class AbstractOpenViewAction extends SessionAction
-{
- public AbstractOpenViewAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image,
- CDOSession session)
- {
- super(page, text, toolTipText, image, session);
- }
-
- @Override
- public boolean isEnabled()
- {
- return !getSession().getPackageRegistry().isEmpty() && super.isEnabled();
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public abstract class AbstractOpenViewAction extends SessionAction +{ + public AbstractOpenViewAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image, + CDOSession session) + { + super(page, text, toolTipText, image, session); + } + + @Override + public boolean isEnabled() + { + return !getSession().getPackageRegistry().isEmpty() && super.isEnabled(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ChangePassiveUpdateAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ChangePassiveUpdateAction.java index 6d88b9554e..53c6ea8bd3 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ChangePassiveUpdateAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ChangePassiveUpdateAction.java @@ -1,90 +1,90 @@ -/*
- * 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
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSession.Options;
-
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * Changes the state of the {@link Options#isPassiveUpdateEnabled() passive update} option for a given
- * {@link CDOSession session}.
- *
- * @author Victor Roldan Betancort
- */
-public class ChangePassiveUpdateAction extends EditingDomainAction
-{
- public static final String ID = "change-passiveupdate"; //$NON-NLS-1$
-
- private static final String TITLE = Messages.getString("ChangePassiveUpdateAction.1"); //$NON-NLS-1$
-
- private CDOSession session;
-
- private IListener passiveUpdateListener = new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- if (session != null)
- {
- if (event instanceof CDOSession.Options.PassiveUpdateEvent)
- {
- setChecked(session.options().isPassiveUpdateEnabled());
- }
- }
- }
- };
-
- public ChangePassiveUpdateAction()
- {
- super(TITLE);
- setId(ID);
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- if (session != null)
- {
- session.options().setPassiveUpdateEnabled(!session.options().isPassiveUpdateEnabled());
- }
-
- update();
- }
-
- @Override
- public void update()
- {
- super.update();
- setChecked(session != null ? session.options().isPassiveUpdateEnabled() : false);
- }
-
- /**
- * Sets the {@link CDOSession session} to be associated with this action.
- */
- public void setSession(CDOSession session)
- {
- if (this.session != null)
- {
- session.options().removeListener(passiveUpdateListener);
- }
-
- this.session = session;
- if (this.session != null)
- {
- session.options().addListener(passiveUpdateListener);
- }
- }
-}
+/* + * 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 + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.session.CDOSession.Options; + +import org.eclipse.net4j.util.event.IEvent; +import org.eclipse.net4j.util.event.IListener; + +import org.eclipse.core.runtime.IProgressMonitor; + +/** + * Changes the state of the {@link Options#isPassiveUpdateEnabled() passive update} option for a given + * {@link CDOSession session}. + * + * @author Victor Roldan Betancort + */ +public class ChangePassiveUpdateAction extends EditingDomainAction +{ + public static final String ID = "change-passiveupdate"; //$NON-NLS-1$ + + private static final String TITLE = Messages.getString("ChangePassiveUpdateAction.1"); //$NON-NLS-1$ + + private CDOSession session; + + private IListener passiveUpdateListener = new IListener() + { + public void notifyEvent(IEvent event) + { + if (session != null) + { + if (event instanceof CDOSession.Options.PassiveUpdateEvent) + { + setChecked(session.options().isPassiveUpdateEnabled()); + } + } + } + }; + + public ChangePassiveUpdateAction() + { + super(TITLE); + setId(ID); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + if (session != null) + { + session.options().setPassiveUpdateEnabled(!session.options().isPassiveUpdateEnabled()); + } + + update(); + } + + @Override + public void update() + { + super.update(); + setChecked(session != null ? session.options().isPassiveUpdateEnabled() : false); + } + + /** + * Sets the {@link CDOSession session} to be associated with this action. + */ + public void setSession(CDOSession session) + { + if (this.session != null) + { + session.options().removeListener(passiveUpdateListener); + } + + this.session = session; + if (this.session != null) + { + session.options().addListener(passiveUpdateListener); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java index fc3d7ec3a0..d2a660a325 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java @@ -1,57 +1,57 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class CloseSessionAction extends SessionAction
-{
- private static final String TITLE = Messages.getString("CloseSessionAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("CloseSessionAction.1"); //$NON-NLS-1$
-
- public CloseSessionAction(IWorkbenchPage page, CDOSession session)
- {
- super(page, TITLE, TOOL_TIP, null, session);
- }
-
- @Override
- protected void preRun() throws Exception
- {
- if (CDOUtil.isSessionDirty(getSession()))
- {
- MessageDialog dialog = new MessageDialog(getShell(), TITLE, null,
- Messages.getString("CloseSessionAction.2"), MessageDialog.QUESTION, new String[] { //$NON-NLS-1$
- IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
- if (dialog.open() != MessageDialog.OK)
- {
- cancel();
- }
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- getSession().close();
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.util.CDOUtil; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class CloseSessionAction extends SessionAction +{ + private static final String TITLE = Messages.getString("CloseSessionAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("CloseSessionAction.1"); //$NON-NLS-1$ + + public CloseSessionAction(IWorkbenchPage page, CDOSession session) + { + super(page, TITLE, TOOL_TIP, null, session); + } + + @Override + protected void preRun() throws Exception + { + if (CDOUtil.isSessionDirty(getSession())) + { + MessageDialog dialog = new MessageDialog(getShell(), TITLE, null, + Messages.getString("CloseSessionAction.2"), MessageDialog.QUESTION, new String[] { //$NON-NLS-1$ + IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); + if (dialog.open() != MessageDialog.OK) + { + cancel(); + } + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + getSession().close(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseViewAction.java index 27b5bbb3b1..73d4c7dfc9 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseViewAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseViewAction.java @@ -1,56 +1,56 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class CloseViewAction extends ViewAction
-{
- private static final String TITLE = Messages.getString("CloseViewAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("CloseViewAction.1"); //$NON-NLS-1$
-
- public CloseViewAction(IWorkbenchPage page, CDOView view)
- {
- super(page, TITLE, TOOL_TIP, null, view);
- }
-
- @Override
- protected void preRun() throws Exception
- {
- if (getView().isDirty())
- {
- MessageDialog dialog = new MessageDialog(getShell(), TITLE, null,
- Messages.getString("CloseViewAction.2"), MessageDialog.QUESTION, new String[] { //$NON-NLS-1$
- IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
- if (dialog.open() != MessageDialog.OK)
- {
- cancel();
- }
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- getView().close();
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class CloseViewAction extends ViewAction +{ + private static final String TITLE = Messages.getString("CloseViewAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("CloseViewAction.1"); //$NON-NLS-1$ + + public CloseViewAction(IWorkbenchPage page, CDOView view) + { + super(page, TITLE, TOOL_TIP, null, view); + } + + @Override + protected void preRun() throws Exception + { + if (getView().isDirty()) + { + MessageDialog dialog = new MessageDialog(getShell(), TITLE, null, + Messages.getString("CloseViewAction.2"), MessageDialog.QUESTION, new String[] { //$NON-NLS-1$ + IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); + if (dialog.open() != MessageDialog.OK) + { + cancel(); + } + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + getView().close(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CommitTransactionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CommitTransactionAction.java index 79cd506780..f82ea660f4 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CommitTransactionAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CommitTransactionAction.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
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class CommitTransactionAction extends ViewAction
-{
- private static final String TITLE = Messages.getString("CommitTransactionAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("CommitTransactionAction.1"); //$NON-NLS-1$
-
- public CommitTransactionAction(IWorkbenchPage page, CDOView view)
- {
- super(page, TITLE, TOOL_TIP, null, view);
- setEnabled(getTransaction().isDirty());
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- getTransaction().commit();
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class CommitTransactionAction extends ViewAction +{ + private static final String TITLE = Messages.getString("CommitTransactionAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("CommitTransactionAction.1"); //$NON-NLS-1$ + + public CommitTransactionAction(IWorkbenchPage page, CDOView view) + { + super(page, TITLE, TOOL_TIP, null, view); + setEnabled(getTransaction().isDirty()); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + getTransaction().commit(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java index 83d6d81037..81d9e0748b 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java @@ -1,126 +1,126 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.internal.ui.dialogs.SelectBranchPointDialog;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.ui.shared.SharedIcons;
-
-import org.eclipse.net4j.util.StringUtil;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public class CreateBranchAction extends SessionAction
-{
- public static final String ID = "create-branch"; //$NON-NLS-1$
-
- private static final String TITLE = Messages.getString("CreateBranchAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("CreateBranchAction.1"); //$NON-NLS-1$
-
- private String name;
-
- private CDOBranchPoint base;
-
- public CreateBranchAction(IWorkbenchPage page, CDOSession session)
- {
- super(page, TITLE + INTERACTIVE, TOOL_TIP, null, session);
- setId(ID);
- }
-
- @Override
- protected void preRun() throws Exception
- {
- SelectBranchPointDialog.WithName dialog = new SelectBranchPointDialog.WithName(getPage(), getSession(), null, true,
- null)
- {
- @Override
- protected Control createDialogArea(Composite parent)
- {
- getShell().setText(TITLE);
- setTitle(TITLE);
- setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_TARGET_SELECTION));
- setMessage("Enter the name of the new branch and compose a valid base point.\nYou may also choose a base point from existing commits, tags or views.");
- return super.createDialogArea(parent);
- }
-
- @Override
- protected String getComposeTabTitle()
- {
- return "Base Point";
- }
-
- @Override
- protected void validate()
- {
- super.validate();
- String name = getName();
- if (StringUtil.isEmpty(name))
- {
- aggregator.setValidationError(getNameText(), "Branch name is empty.");
- return;
- }
-
- CDOBranchPoint branchPoint = getBranchPoint();
- if (branchPoint != null)
- {
- CDOBranch branch = branchPoint.getBranch().getBranch(name);
- if (branch != null)
- {
- aggregator.setValidationError(getNameText(), "Branch " + branch.getPathName() + " does already exist.");
- return;
- }
- }
-
- aggregator.setValidationError(getNameText(), null);
- }
- };
-
- if (dialog.open() == Dialog.OK)
- {
- name = dialog.getName();
- base = dialog.getBranchPoint();
- if (StringUtil.isEmpty(name) || base == null)
- {
- cancel();
- }
- }
- else
- {
- cancel();
- }
-
- super.preRun();
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- long timeStamp = base.getTimeStamp();
- if (timeStamp == CDOBranchPoint.UNSPECIFIED_DATE || timeStamp == CDOBranchPoint.INVALID_DATE)
- {
- timeStamp = getSession().getRepositoryInfo().getTimeStamp();
- }
-
- base.getBranch().createBranch(name, timeStamp);
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.internal.ui.dialogs.SelectBranchPointDialog; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.ui.shared.SharedIcons; + +import org.eclipse.net4j.util.StringUtil; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public class CreateBranchAction extends SessionAction +{ + public static final String ID = "create-branch"; //$NON-NLS-1$ + + private static final String TITLE = Messages.getString("CreateBranchAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("CreateBranchAction.1"); //$NON-NLS-1$ + + private String name; + + private CDOBranchPoint base; + + public CreateBranchAction(IWorkbenchPage page, CDOSession session) + { + super(page, TITLE + INTERACTIVE, TOOL_TIP, null, session); + setId(ID); + } + + @Override + protected void preRun() throws Exception + { + SelectBranchPointDialog.WithName dialog = new SelectBranchPointDialog.WithName(getPage(), getSession(), null, true, + null) + { + @Override + protected Control createDialogArea(Composite parent) + { + getShell().setText(TITLE); + setTitle(TITLE); + setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_TARGET_SELECTION)); + setMessage("Enter the name of the new branch and compose a valid base point.\nYou may also choose a base point from existing commits, tags or views."); + return super.createDialogArea(parent); + } + + @Override + protected String getComposeTabTitle() + { + return "Base Point"; + } + + @Override + protected void validate() + { + super.validate(); + String name = getName(); + if (StringUtil.isEmpty(name)) + { + aggregator.setValidationError(getNameText(), "Branch name is empty."); + return; + } + + CDOBranchPoint branchPoint = getBranchPoint(); + if (branchPoint != null) + { + CDOBranch branch = branchPoint.getBranch().getBranch(name); + if (branch != null) + { + aggregator.setValidationError(getNameText(), "Branch " + branch.getPathName() + " does already exist."); + return; + } + } + + aggregator.setValidationError(getNameText(), null); + } + }; + + if (dialog.open() == Dialog.OK) + { + name = dialog.getName(); + base = dialog.getBranchPoint(); + if (StringUtil.isEmpty(name) || base == null) + { + cancel(); + } + } + else + { + cancel(); + } + + super.preRun(); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + long timeStamp = base.getTimeStamp(); + if (timeStamp == CDOBranchPoint.UNSPECIFIED_DATE || timeStamp == CDOBranchPoint.INVALID_DATE) + { + timeStamp = getSession().getRepositoryInfo().getTimeStamp(); + } + + base.getBranch().createBranch(name, timeStamp); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceNodeAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceNodeAction.java index d33e2b697a..c1780ff876 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceNodeAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceNodeAction.java @@ -1,119 +1,119 @@ -/*
- * 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.internal.ui.actions;
-
-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.eresource.EresourceFactory;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.ui.CDOEditorUtil;
-import org.eclipse.emf.cdo.ui.CDOItemProvider;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public class CreateResourceNodeAction extends ViewAction
-{
- private static final String TITLE_RESOURCE = Messages.getString("CreateResourceAction.0"); //$NON-NLS-1$
-
- private static final String TITLE_FOLDER = Messages.getString("CreateResourceNodeAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP_RESOURCE = Messages.getString("CreateResourceAction.1"); //$NON-NLS-1$
-
- private static final String TOOL_TIP_FOLDER = Messages.getString("CreateResourceNodeAction.1"); //$NON-NLS-1$
-
- private CDOItemProvider itemProvider;
-
- private CDOResourceNode selectedNode;
-
- private boolean createFolder;
-
- private String resourceNodeName;
-
- public CreateResourceNodeAction(CDOItemProvider itemProvider, IWorkbenchPage page, CDOView view,
- CDOResourceNode node, boolean createFolder)
- {
- super(page, createFolder ? TITLE_FOLDER + INTERACTIVE : TITLE_RESOURCE + INTERACTIVE,
- createFolder ? TOOL_TIP_FOLDER : TOOL_TIP_RESOURCE, null, view);
- selectedNode = node;
- this.itemProvider = itemProvider;
- this.createFolder = createFolder;
- }
-
- @Override
- protected void preRun() throws Exception
- {
- InputDialog dialog = new InputDialog(getShell(), createFolder ? TITLE_FOLDER : TITLE_RESOURCE,
- createFolder ? "Enter folder name" : Messages.getString("CreateResourceAction.2"), "res" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + (ViewAction.lastResourceNumber + 1), new ResourceNodeNameInputValidator(selectedNode));
-
- if (dialog.open() == InputDialog.OK)
- {
- ++ViewAction.lastResourceNumber;
- resourceNodeName = dialog.getValue();
- }
- else
- {
- cancel();
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- CDOTransaction transaction = getTransaction();
- CDOResourceNode node = null;
-
- if (createFolder)
- {
- node = EresourceFactory.eINSTANCE.createCDOResourceFolder();
- node.setName(resourceNodeName);
- if (selectedNode instanceof CDOResourceFolder)
- {
- ((CDOResourceFolder)selectedNode).getNodes().add(node);
- }
- else
- {
- ((CDOResource)selectedNode).getContents().add(node);
- }
- }
- else
- {
- if (selectedNode instanceof CDOResourceFolder)
- {
- node = transaction.createResource(selectedNode.getPath() + "/" + resourceNodeName); //$NON-NLS-1$
- }
- else
- {
- node = transaction.createResource(resourceNodeName);
- }
- }
-
- transaction.commit();
-
- itemProvider.refreshViewer(true);
- itemProvider.selectElement(node, true);
-
- if (!createFolder)
- {
- String resourcePath = node.getPath();
- CDOEditorUtil.openEditor(getPage(), transaction, resourcePath);
- }
- }
-}
+/* + * 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.internal.ui.actions; + +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.eresource.EresourceFactory; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.ui.CDOEditorUtil; +import org.eclipse.emf.cdo.ui.CDOItemProvider; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public class CreateResourceNodeAction extends ViewAction +{ + private static final String TITLE_RESOURCE = Messages.getString("CreateResourceAction.0"); //$NON-NLS-1$ + + private static final String TITLE_FOLDER = Messages.getString("CreateResourceNodeAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP_RESOURCE = Messages.getString("CreateResourceAction.1"); //$NON-NLS-1$ + + private static final String TOOL_TIP_FOLDER = Messages.getString("CreateResourceNodeAction.1"); //$NON-NLS-1$ + + private CDOItemProvider itemProvider; + + private CDOResourceNode selectedNode; + + private boolean createFolder; + + private String resourceNodeName; + + public CreateResourceNodeAction(CDOItemProvider itemProvider, IWorkbenchPage page, CDOView view, + CDOResourceNode node, boolean createFolder) + { + super(page, createFolder ? TITLE_FOLDER + INTERACTIVE : TITLE_RESOURCE + INTERACTIVE, + createFolder ? TOOL_TIP_FOLDER : TOOL_TIP_RESOURCE, null, view); + selectedNode = node; + this.itemProvider = itemProvider; + this.createFolder = createFolder; + } + + @Override + protected void preRun() throws Exception + { + InputDialog dialog = new InputDialog(getShell(), createFolder ? TITLE_FOLDER : TITLE_RESOURCE, + createFolder ? "Enter folder name" : Messages.getString("CreateResourceAction.2"), "res" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + (ViewAction.lastResourceNumber + 1), new ResourceNodeNameInputValidator(selectedNode)); + + if (dialog.open() == InputDialog.OK) + { + ++ViewAction.lastResourceNumber; + resourceNodeName = dialog.getValue(); + } + else + { + cancel(); + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + CDOTransaction transaction = getTransaction(); + CDOResourceNode node = null; + + if (createFolder) + { + node = EresourceFactory.eINSTANCE.createCDOResourceFolder(); + node.setName(resourceNodeName); + if (selectedNode instanceof CDOResourceFolder) + { + ((CDOResourceFolder)selectedNode).getNodes().add(node); + } + else + { + ((CDOResource)selectedNode).getContents().add(node); + } + } + else + { + if (selectedNode instanceof CDOResourceFolder) + { + node = transaction.createResource(selectedNode.getPath() + "/" + resourceNodeName); //$NON-NLS-1$ + } + else + { + node = transaction.createResource(resourceNodeName); + } + } + + transaction.commit(); + + itemProvider.refreshViewer(true); + itemProvider.selectElement(node, true); + + if (!createFolder) + { + String resourcePath = node.getPath(); + CDOEditorUtil.openEditor(getPage(), transaction, resourcePath); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/DisableViewDurabilityAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/DisableViewDurabilityAction.java index 7c0014facc..470c55db22 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/DisableViewDurabilityAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/DisableViewDurabilityAction.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:
- * Eike Stepper - initial API and implementation
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class DisableViewDurabilityAction extends ViewAction
-{
- private static final String TITLE = Messages.getString("DisableViewDurabilityAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("DisableViewDurabilityAction.1"); //$NON-NLS-1$
-
- public DisableViewDurabilityAction(IWorkbenchPage page, CDOView view)
- {
- super(page, TITLE, TOOL_TIP, null, view);
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- getView().disableDurableLocking(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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class DisableViewDurabilityAction extends ViewAction +{ + private static final String TITLE = Messages.getString("DisableViewDurabilityAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("DisableViewDurabilityAction.1"); //$NON-NLS-1$ + + public DisableViewDurabilityAction(IWorkbenchPage page, CDOView view) + { + super(page, TITLE, TOOL_TIP, null, view); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + getView().disableDurableLocking(false); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java index 4948f75715..5debfe3ab6 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java @@ -1,75 +1,75 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.net4j.util.ui.actions.LongRunningAction;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * @author Eike Stepper
- * @ADDED
- */
-public abstract class EditingDomainAction extends LongRunningAction
-{
- protected EditingDomain editingDomain;
-
- public EditingDomainAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public EditingDomainAction(String text, int style)
- {
- super(text, style);
- }
-
- public EditingDomainAction(String text, String toolTipText, ImageDescriptor image)
- {
- super(text, toolTipText, image);
- }
-
- public EditingDomainAction(String text, String toolTipText)
- {
- super(text, toolTipText);
- }
-
- public EditingDomainAction(String text)
- {
- super(text);
- }
-
- public EditingDomain getEditingDomain()
- {
- return editingDomain;
- }
-
- public void setEditingDomain(EditingDomain editingDomain)
- {
- this.editingDomain = editingDomain;
- }
-
- public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart)
- {
- setPage(workbenchPart == null ? null : workbenchPart.getSite().getPage());
- setEditingDomain(workbenchPart instanceof IEditingDomainProvider ? ((IEditingDomainProvider)workbenchPart)
- .getEditingDomain() : null);
- }
-
- public void update()
- {
- setEnabled(editingDomain != 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.net4j.util.ui.actions.LongRunningAction; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPart; + +/** + * @author Eike Stepper + * @ADDED + */ +public abstract class EditingDomainAction extends LongRunningAction +{ + protected EditingDomain editingDomain; + + public EditingDomainAction(String text, ImageDescriptor image) + { + super(text, image); + } + + public EditingDomainAction(String text, int style) + { + super(text, style); + } + + public EditingDomainAction(String text, String toolTipText, ImageDescriptor image) + { + super(text, toolTipText, image); + } + + public EditingDomainAction(String text, String toolTipText) + { + super(text, toolTipText); + } + + public EditingDomainAction(String text) + { + super(text); + } + + public EditingDomain getEditingDomain() + { + return editingDomain; + } + + public void setEditingDomain(EditingDomain editingDomain) + { + this.editingDomain = editingDomain; + } + + public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart) + { + setPage(workbenchPart == null ? null : workbenchPart.getSite().getPage()); + setEditingDomain(workbenchPart instanceof IEditingDomainProvider ? ((IEditingDomainProvider)workbenchPart) + .getEditingDomain() : null); + } + + public void update() + { + setEnabled(editingDomain != null); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EnableViewDurabilityAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EnableViewDurabilityAction.java index 4a35798653..3a10c964df 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EnableViewDurabilityAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EnableViewDurabilityAction.java @@ -1,54 +1,54 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.ui.UIUtil;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class EnableViewDurabilityAction extends ViewAction
-{
- private static final String TITLE = Messages.getString("EnableViewDurabilityAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("EnableViewDurabilityAction.1"); //$NON-NLS-1$
-
- public EnableViewDurabilityAction(IWorkbenchPage page, CDOView view)
- {
- super(page, TITLE, TOOL_TIP, null, view);
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- final String durableLockingID = getView().enableDurableLocking();
-
- final Display display = getDisplay();
- display.syncExec(new Runnable()
- {
- public void run()
- {
- UIUtil.copyToClipboard(display, durableLockingID);
- MessageDialog.openInformation(getShell(), TITLE, "The following area ID has been copied to the clipboard:\n"
- + durableLockingID);
- }
- });
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.net4j.util.ui.UIUtil; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class EnableViewDurabilityAction extends ViewAction +{ + private static final String TITLE = Messages.getString("EnableViewDurabilityAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("EnableViewDurabilityAction.1"); //$NON-NLS-1$ + + public EnableViewDurabilityAction(IWorkbenchPage page, CDOView view) + { + super(page, TITLE, TOOL_TIP, null, view); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + final String durableLockingID = getView().enableDurableLocking(); + + final Display display = getDisplay(); + display.syncExec(new Runnable() + { + public void run() + { + UIUtil.copyToClipboard(display, durableLockingID); + MessageDialog.openInformation(getShell(), TITLE, "The following area ID has been copied to the clipboard:\n" + + durableLockingID); + } + }); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java index 543d897750..29f8911974 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java @@ -1,112 +1,112 @@ -/*
- * 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 - bug 244801
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.dialogs.ExportResourceDialog;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.io.IORuntimeException;
-
-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.ui.IWorkbenchPage;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class ExportResourceAction extends ViewAction
-{
- public static final String ID = "export-resource"; //$NON-NLS-1$
-
- private static final String TITLE = Messages.getString("ExportResourceAction.1"); //$NON-NLS-1$
-
- public ExportResourceAction(IWorkbenchPage page, CDOView view)
- {
- super(page, TITLE + INTERACTIVE, Messages.getString("ExportResourceAction.2"), null, view); //$NON-NLS-1$
- setId(ID);
- }
-
- private URI sourceURI;
-
- private String targetPath;
-
- @Override
- protected void preRun() throws Exception
- {
- ExportResourceDialog dialog = new ExportResourceDialog(getShell(), TITLE, SWT.OPEN);
- if (dialog.open() == ExportResourceDialog.OK)
- {
- List<URI> uris = dialog.getURIs();
- if (uris.size() == 1)
- {
- sourceURI = uris.get(0);
- targetPath = dialog.getTargetPath();
- }
- else
- {
- MessageDialog.openError(getShell(), TITLE, Messages.getString("ExportResourceAction.3")); //$NON-NLS-1$
- cancel();
- }
- }
- else
- {
- cancel();
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- CDOView view = getView();
-
- // Source Resource
- Resource source = view.getResource(targetPath);
- 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(sourceURI);
-
- 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: + * Eike Stepper - initial API and implementation + * Victor Roldan Betancort - bug 244801 + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.dialogs.ExportResourceDialog; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.net4j.util.io.IORuntimeException; + +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.ui.IWorkbenchPage; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class ExportResourceAction extends ViewAction +{ + public static final String ID = "export-resource"; //$NON-NLS-1$ + + private static final String TITLE = Messages.getString("ExportResourceAction.1"); //$NON-NLS-1$ + + public ExportResourceAction(IWorkbenchPage page, CDOView view) + { + super(page, TITLE + INTERACTIVE, Messages.getString("ExportResourceAction.2"), null, view); //$NON-NLS-1$ + setId(ID); + } + + private URI sourceURI; + + private String targetPath; + + @Override + protected void preRun() throws Exception + { + ExportResourceDialog dialog = new ExportResourceDialog(getShell(), TITLE, SWT.OPEN); + if (dialog.open() == ExportResourceDialog.OK) + { + List<URI> uris = dialog.getURIs(); + if (uris.size() == 1) + { + sourceURI = uris.get(0); + targetPath = dialog.getTargetPath(); + } + else + { + MessageDialog.openError(getShell(), TITLE, Messages.getString("ExportResourceAction.3")); //$NON-NLS-1$ + cancel(); + } + } + else + { + cancel(); + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + CDOView view = getView(); + + // Source Resource + Resource source = view.getResource(targetPath); + 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(sourceURI); + + 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/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java index 39b3d1acab..6217de18ae 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java @@ -1,109 +1,109 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.dialogs.ImportResourceDialog;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.ui.CDOEditorUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-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.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.IWorkbenchPage;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class ImportResourceAction extends ViewAction
-{
- public static final String ID = "import-resource"; //$NON-NLS-1$
-
- private static final String TITLE = Messages.getString("ImportResourceAction.1"); //$NON-NLS-1$
-
- private URI sourceURI;
-
- private String targetPath;
-
- public ImportResourceAction(IWorkbenchPage page, CDOView view)
- {
- super(page, TITLE + INTERACTIVE, Messages.getString("ImportResourceAction.2"), null, view); //$NON-NLS-1$
- setId(ID);
- }
-
- @Override
- protected void preRun() throws Exception
- {
- ImportResourceDialog dialog = new ImportResourceDialog(getShell(), TITLE, SWT.OPEN);
- if (dialog.open() == ImportResourceDialog.OK)
- {
- List<URI> uris = dialog.getURIs();
- if (uris.size() == 1)
- {
- sourceURI = uris.get(0);
- targetPath = dialog.getTargetPath();
- }
- else
- {
- MessageDialog.openError(getShell(), TITLE, Messages.getString("ImportResourceAction.3")); //$NON-NLS-1$
- cancel();
- }
- }
- else
- {
- cancel();
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- CDOTransaction transaction = getTransaction();
-
- // 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
- Resource target = transaction.createResource(targetPath);
- EList<EObject> targetContents = target.getContents();
-
- // Move contents over
- for (EObject root : sourceContents)
- {
- targetContents.add(root);
- }
-
- getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- CDOEditorUtil.openEditor(getPage(), getView(), targetPath);
- }
- });
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.dialogs.ImportResourceDialog; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.ui.CDOEditorUtil; +import org.eclipse.emf.cdo.view.CDOView; + +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.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.ui.IWorkbenchPage; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class ImportResourceAction extends ViewAction +{ + public static final String ID = "import-resource"; //$NON-NLS-1$ + + private static final String TITLE = Messages.getString("ImportResourceAction.1"); //$NON-NLS-1$ + + private URI sourceURI; + + private String targetPath; + + public ImportResourceAction(IWorkbenchPage page, CDOView view) + { + super(page, TITLE + INTERACTIVE, Messages.getString("ImportResourceAction.2"), null, view); //$NON-NLS-1$ + setId(ID); + } + + @Override + protected void preRun() throws Exception + { + ImportResourceDialog dialog = new ImportResourceDialog(getShell(), TITLE, SWT.OPEN); + if (dialog.open() == ImportResourceDialog.OK) + { + List<URI> uris = dialog.getURIs(); + if (uris.size() == 1) + { + sourceURI = uris.get(0); + targetPath = dialog.getTargetPath(); + } + else + { + MessageDialog.openError(getShell(), TITLE, Messages.getString("ImportResourceAction.3")); //$NON-NLS-1$ + cancel(); + } + } + else + { + cancel(); + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + CDOTransaction transaction = getTransaction(); + + // 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 + Resource target = transaction.createResource(targetPath); + EList<EObject> targetContents = target.getContents(); + + // Move contents over + for (EObject root : sourceContents) + { + targetContents.add(root); + } + + getDisplay().asyncExec(new Runnable() + { + public void run() + { + CDOEditorUtil.openEditor(getPage(), getView(), targetPath); + } + }); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java index dc56e32f27..7039004f38 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java @@ -1,128 +1,128 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
-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.impl.ResourceSetImpl;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.SWT;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class ImportRootsAction extends EditingDomainAction
-{
- public static final String ID = "import-roots"; //$NON-NLS-1$
-
- private static final String TITLE = Messages.getString("ImportRootsAction.1"); //$NON-NLS-1$
-
- private CDOResource targetResource;
-
- private transient List<URI> uris;
-
- public ImportRootsAction()
- {
- super(TITLE + INTERACTIVE);
- setId(ID);
- }
-
- public CDOResource getTargetResource()
- {
- return targetResource;
- }
-
- public void setTargetResource(CDOResource targetResource)
- {
- this.targetResource = targetResource;
- }
-
- @Override
- public boolean isEnabled()
- {
- return targetResource != null && super.isEnabled();
- }
-
- @Override
- protected void preRun() throws Exception
- {
- ResourceDialog dialog = new ResourceDialog(getShell(), TITLE, SWT.OPEN | SWT.MULTI)
- {
- @Override
- protected boolean processResources()
- {
- return true;
- }
- };
-
- if (dialog.open() == ResourceDialog.OK)
- {
- uris = dialog.getURIs();
- }
- else
- {
- cancel();
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- EList<EObject> targetContents = targetResource.getContents();
- List<Resource> resources = getSourceResources();
- for (Resource resource : resources)
- {
- List<EObject> contents = new ArrayList<EObject>(resource.getContents());
- for (EObject root : contents)
- {
- targetContents.add(root);
- }
- }
- }
-
- protected List<Resource> getSourceResources()
- {
- ResourceSetImpl resourceSet = createSourceResourceSet();
- List<Resource> resources = new ArrayList<Resource>(uris.size());
- for (URI uri : uris)
- {
- Resource resource = resourceSet.getResource(uri, true);
- resources.add(resource);
- }
-
- return resources;
- }
-
- protected ResourceSetImpl createSourceResourceSet()
- {
- CDOView view = targetResource.cdoView();
- CDOSession session = view.getSession();
- CDOPackageRegistry packageRegistry = session.getPackageRegistry();
-
- ResourceSetImpl resourceSet = new ResourceSetImpl();
- resourceSet.setPackageRegistry(packageRegistry);
- return resourceSet;
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.common.ui.dialogs.ResourceDialog; +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.impl.ResourceSetImpl; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.swt.SWT; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class ImportRootsAction extends EditingDomainAction +{ + public static final String ID = "import-roots"; //$NON-NLS-1$ + + private static final String TITLE = Messages.getString("ImportRootsAction.1"); //$NON-NLS-1$ + + private CDOResource targetResource; + + private transient List<URI> uris; + + public ImportRootsAction() + { + super(TITLE + INTERACTIVE); + setId(ID); + } + + public CDOResource getTargetResource() + { + return targetResource; + } + + public void setTargetResource(CDOResource targetResource) + { + this.targetResource = targetResource; + } + + @Override + public boolean isEnabled() + { + return targetResource != null && super.isEnabled(); + } + + @Override + protected void preRun() throws Exception + { + ResourceDialog dialog = new ResourceDialog(getShell(), TITLE, SWT.OPEN | SWT.MULTI) + { + @Override + protected boolean processResources() + { + return true; + } + }; + + if (dialog.open() == ResourceDialog.OK) + { + uris = dialog.getURIs(); + } + else + { + cancel(); + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + EList<EObject> targetContents = targetResource.getContents(); + List<Resource> resources = getSourceResources(); + for (Resource resource : resources) + { + List<EObject> contents = new ArrayList<EObject>(resource.getContents()); + for (EObject root : contents) + { + targetContents.add(root); + } + } + } + + protected List<Resource> getSourceResources() + { + ResourceSetImpl resourceSet = createSourceResourceSet(); + List<Resource> resources = new ArrayList<Resource>(uris.size()); + for (URI uri : uris) + { + Resource resource = resourceSet.getResource(uri, true); + resources.add(resource); + } + + return resources; + } + + protected ResourceSetImpl createSourceResourceSet() + { + CDOView view = targetResource.cdoView(); + CDOSession session = view.getSession(); + CDOPackageRegistry packageRegistry = session.getPackageRegistry(); + + ResourceSetImpl resourceSet = new ResourceSetImpl(); + resourceSet.setPackageRegistry(packageRegistry); + return resourceSet; + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/LoadResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/LoadResourceAction.java index de17e9807e..46832672d7 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/LoadResourceAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/LoadResourceAction.java @@ -1,66 +1,66 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.ui.CDOEditorUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public final class LoadResourceAction extends ViewAction
-{
- private static final String TITLE = Messages.getString("LoadResourceAction.0"); //$NON-NLS-1$
-
- private String resourcePath;
-
- public LoadResourceAction(IWorkbenchPage page, CDOView view)
- {
- super(page, TITLE + INTERACTIVE, Messages.getString("LoadResourceAction.1"), null, view); //$NON-NLS-1$
- }
-
- @Override
- protected void preRun() throws Exception
- {
- String uri = ViewAction.lastResourceNumber == 0 ? "" : "/res" + ViewAction.lastResourceNumber; //$NON-NLS-1$ //$NON-NLS-2$
- InputDialog dialog = new InputDialog(getShell(), TITLE, Messages.getString("LoadResourceAction.4"), uri, null); //$NON-NLS-1$
- if (dialog.open() == InputDialog.OK)
- {
- resourcePath = dialog.getValue();
- if (!getView().hasResource(resourcePath))
- {
- MessageDialog.openError(new Shell(), Messages.getString("LoadResourceAction.2"), MessageFormat.format( //$NON-NLS-1$
- Messages.getString("LoadResourceAction.3"), resourcePath)); //$NON-NLS-1$
- cancel();
- }
- }
- else
- {
- cancel();
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- CDOEditorUtil.openEditor(getPage(), getView(), resourcePath);
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.ui.CDOEditorUtil; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public final class LoadResourceAction extends ViewAction +{ + private static final String TITLE = Messages.getString("LoadResourceAction.0"); //$NON-NLS-1$ + + private String resourcePath; + + public LoadResourceAction(IWorkbenchPage page, CDOView view) + { + super(page, TITLE + INTERACTIVE, Messages.getString("LoadResourceAction.1"), null, view); //$NON-NLS-1$ + } + + @Override + protected void preRun() throws Exception + { + String uri = ViewAction.lastResourceNumber == 0 ? "" : "/res" + ViewAction.lastResourceNumber; //$NON-NLS-1$ //$NON-NLS-2$ + InputDialog dialog = new InputDialog(getShell(), TITLE, Messages.getString("LoadResourceAction.4"), uri, null); //$NON-NLS-1$ + if (dialog.open() == InputDialog.OK) + { + resourcePath = dialog.getValue(); + if (!getView().hasResource(resourcePath)) + { + MessageDialog.openError(new Shell(), Messages.getString("LoadResourceAction.2"), MessageFormat.format( //$NON-NLS-1$ + Messages.getString("LoadResourceAction.3"), resourcePath)); //$NON-NLS-1$ + cancel(); + } + } + else + { + cancel(); + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + CDOEditorUtil.openEditor(getPage(), getView(), resourcePath); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ManagePackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ManagePackagesAction.java index 6f26125a37..87653fa239 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ManagePackagesAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ManagePackagesAction.java @@ -1,47 +1,47 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.dialogs.PackageRegistryDialog;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public class ManagePackagesAction extends SessionAction
-{
- private static final String TITLE = Messages.getString("ManagePackagesAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("ManagePackagesAction.1"); //$NON-NLS-1$
-
- public ManagePackagesAction(IWorkbenchPage page, CDOSession session)
- {
- super(page, TITLE + INTERACTIVE, TOOL_TIP, null, session);
- }
-
- @Override
- protected void preRun() throws Exception
- {
- PackageRegistryDialog dialog = new PackageRegistryDialog(getPage(), getSession());
- dialog.open();
- cancel();
- }
-
- @Override
- protected void doRun(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: + * Eike Stepper - initial API and implementation + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.dialogs.PackageRegistryDialog; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public class ManagePackagesAction extends SessionAction +{ + private static final String TITLE = Messages.getString("ManagePackagesAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("ManagePackagesAction.1"); //$NON-NLS-1$ + + public ManagePackagesAction(IWorkbenchPage page, CDOSession session) + { + super(page, TITLE + INTERACTIVE, TOOL_TIP, null, session); + } + + @Override + protected void preRun() throws Exception + { + PackageRegistryDialog dialog = new PackageRegistryDialog(getPage(), getSession()); + dialog.open(); + cancel(); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenAuditAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenAuditAction.java index b3a2db7ab4..81da748574 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenAuditAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenAuditAction.java @@ -1,57 +1,57 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.dialogs.OpenAuditDialog;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.ui.shared.SharedIcons;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class OpenAuditAction extends AbstractOpenViewAction
-{
- private static final String TITLE = Messages.getString("OpenAuditAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("OpenAuditAction.1"); //$NON-NLS-1$
-
- private long timeStamp;
-
- public OpenAuditAction(IWorkbenchPage page, CDOSession session)
- {
- super(page, TITLE + INTERACTIVE, TOOL_TIP, SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session);
- }
-
- @Override
- protected void preRun() throws Exception
- {
- OpenAuditDialog dialog = new OpenAuditDialog(getPage());
- if (dialog.open() == OpenAuditDialog.OK)
- {
- timeStamp = dialog.getTimeStamp();
- }
- else
- {
- cancel();
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- getSession().openView(timeStamp);
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.dialogs.OpenAuditDialog; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.ui.shared.SharedIcons; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class OpenAuditAction extends AbstractOpenViewAction +{ + private static final String TITLE = Messages.getString("OpenAuditAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("OpenAuditAction.1"); //$NON-NLS-1$ + + private long timeStamp; + + public OpenAuditAction(IWorkbenchPage page, CDOSession session) + { + super(page, TITLE + INTERACTIVE, TOOL_TIP, SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session); + } + + @Override + protected void preRun() throws Exception + { + OpenAuditDialog dialog = new OpenAuditDialog(getPage()); + if (dialog.open() == OpenAuditDialog.OK) + { + timeStamp = dialog.getTimeStamp(); + } + else + { + cancel(); + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + getSession().openView(timeStamp); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenDurableViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenDurableViewAction.java index 2e08a4bbc9..e63e951a18 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenDurableViewAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenDurableViewAction.java @@ -1,65 +1,65 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.dialogs.OpenAuditDialog;
-import org.eclipse.emf.cdo.internal.ui.dialogs.OpenDurableViewDialog;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.ui.shared.SharedIcons;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class OpenDurableViewAction extends AbstractOpenViewAction
-{
- private static final String TITLE = Messages.getString("OpenDurableViewAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("OpenDurableViewAction.1"); //$NON-NLS-1$
-
- private String areaID;
-
- public OpenDurableViewAction(IWorkbenchPage page, CDOSession session)
- {
- super(page, TITLE + INTERACTIVE, TOOL_TIP, SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session);
- }
-
- @Override
- protected void preRun() throws Exception
- {
- OpenDurableViewDialog dialog = new OpenDurableViewDialog(getPage());
- if (dialog.open() == OpenAuditDialog.OK)
- {
- areaID = dialog.getAreaID();
- }
- else
- {
- cancel();
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- try
- {
- getSession().openTransaction(areaID);
- }
- catch (IllegalStateException ex)
- {
- getSession().openView(areaID);
- }
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.dialogs.OpenAuditDialog; +import org.eclipse.emf.cdo.internal.ui.dialogs.OpenDurableViewDialog; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.ui.shared.SharedIcons; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class OpenDurableViewAction extends AbstractOpenViewAction +{ + private static final String TITLE = Messages.getString("OpenDurableViewAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("OpenDurableViewAction.1"); //$NON-NLS-1$ + + private String areaID; + + public OpenDurableViewAction(IWorkbenchPage page, CDOSession session) + { + super(page, TITLE + INTERACTIVE, TOOL_TIP, SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session); + } + + @Override + protected void preRun() throws Exception + { + OpenDurableViewDialog dialog = new OpenDurableViewDialog(getPage()); + if (dialog.open() == OpenAuditDialog.OK) + { + areaID = dialog.getAreaID(); + } + else + { + cancel(); + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + try + { + getSession().openTransaction(areaID); + } + catch (IllegalStateException ex) + { + getSession().openView(areaID); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java index 4ddf6168b3..7ee21afd0a 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java @@ -1,43 +1,43 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.ui.CDOEditorUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class OpenResourceEditorAction extends ResourceNodeAction
-{
- private static final String TITLE = Messages.getString("OpenResourceEditorAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("OpenResourceEditorAction.1"); //$NON-NLS-1$
-
- public OpenResourceEditorAction(IWorkbenchPage page, CDOResourceNode resourceNode)
- {
- super(page, TITLE, TOOL_TIP, null, resourceNode);
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- CDOView view = getResourceNode().cdoView();
- String resourcePath = getResourceNode().getPath();
- CDOEditorUtil.openEditor(getPage(), view, resourcePath);
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.ui.CDOEditorUtil; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class OpenResourceEditorAction extends ResourceNodeAction +{ + private static final String TITLE = Messages.getString("OpenResourceEditorAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("OpenResourceEditorAction.1"); //$NON-NLS-1$ + + public OpenResourceEditorAction(IWorkbenchPage page, CDOResourceNode resourceNode) + { + super(page, TITLE, TOOL_TIP, null, resourceNode); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + CDOView view = getResourceNode().cdoView(); + String resourcePath = getResourceNode().getPath(); + CDOEditorUtil.openEditor(getPage(), view, resourcePath); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java index 7cc454d3bd..83a111bfea 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java @@ -1,46 +1,46 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.LegacyModeRegistry;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.ui.shared.SharedIcons;
-import org.eclipse.emf.cdo.util.CDOUtil;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class OpenTransactionAction extends AbstractOpenViewAction
-{
- private static final String TITLE = Messages.getString("OpenTransactionAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("OpenTransactionAction.1"); //$NON-NLS-1$
-
- public OpenTransactionAction(IWorkbenchPage page, CDOSession session)
- {
- super(page, TITLE, TOOL_TIP, SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session);
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- CDOUtil.setLegacyModeDefault(LegacyModeRegistry.isLegacyEnabled(getSession()));
- getSession().openTransaction();
-
- // CDOTransaction transaction = getSession().openTransaction();
- // transaction.options().getConflictResolvers().add(new CDOObjectConflictResolver.MergeLocalChangesPerFeature());
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.LegacyModeRegistry; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.ui.shared.SharedIcons; +import org.eclipse.emf.cdo.util.CDOUtil; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class OpenTransactionAction extends AbstractOpenViewAction +{ + private static final String TITLE = Messages.getString("OpenTransactionAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("OpenTransactionAction.1"); //$NON-NLS-1$ + + public OpenTransactionAction(IWorkbenchPage page, CDOSession session) + { + super(page, TITLE, TOOL_TIP, SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + CDOUtil.setLegacyModeDefault(LegacyModeRegistry.isLegacyEnabled(getSession())); + getSession().openTransaction(); + + // CDOTransaction transaction = getSession().openTransaction(); + // transaction.options().getConflictResolvers().add(new CDOObjectConflictResolver.MergeLocalChangesPerFeature()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java index e936daa47c..7b7b9eaa01 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.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
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.ui.shared.SharedIcons;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class OpenViewAction extends AbstractOpenViewAction
-{
- private static final String TITLE = Messages.getString("OpenViewAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("OpenViewAction.1"); //$NON-NLS-1$
-
- public OpenViewAction(IWorkbenchPage page, CDOSession session)
- {
- super(page, TITLE, TOOL_TIP, SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session);
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- getSession().openView();
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.ui.shared.SharedIcons; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class OpenViewAction extends AbstractOpenViewAction +{ + private static final String TITLE = Messages.getString("OpenViewAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("OpenViewAction.1"); //$NON-NLS-1$ + + public OpenViewAction(IWorkbenchPage page, CDOSession session) + { + super(page, TITLE, TOOL_TIP, SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + getSession().openView(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewEditorAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewEditorAction.java index 70cdd7dd1e..1681bd662a 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewEditorAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewEditorAction.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
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.ui.CDOEditorUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class OpenViewEditorAction extends ViewAction
-{
- private static final String TITLE = Messages.getString("OpenViewEditorAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("OpenViewEditorAction.1"); //$NON-NLS-1$
-
- public OpenViewEditorAction(IWorkbenchPage page, CDOView view)
- {
- super(page, TITLE, TOOL_TIP, null, view);
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- CDOEditorUtil.openEditor(getPage(), getView(), 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: + * Eike Stepper - initial API and implementation + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.ui.CDOEditorUtil; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class OpenViewEditorAction extends ViewAction +{ + private static final String TITLE = Messages.getString("OpenViewEditorAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("OpenViewEditorAction.1"); //$NON-NLS-1$ + + public OpenViewEditorAction(IWorkbenchPage page, CDOView view) + { + super(page, TITLE, TOOL_TIP, null, view); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + CDOEditorUtil.openEditor(getPage(), getView(), null); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReadLockObjectsAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReadLockObjectsAction.java index ebe40fb348..ec78c7ab8b 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReadLockObjectsAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReadLockObjectsAction.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:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.CDOLock;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-/**
- * @author Simon McDuff
- */
-public class ReadLockObjectsAction extends AbstractLockObjectsAction
-{
- public static final String ID = "readlock-objects"; //$NON-NLS-1$
-
- public ReadLockObjectsAction()
- {
- super(Messages.getString("ReadLockObjectsAction.1")); //$NON-NLS-1$
- setId(ID);
- }
-
- @Override
- protected CDOLock getLock(InternalCDOObject object)
- {
- return object.cdoReadLock();
- }
-}
+/* + * 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.CDOLock; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; + +import org.eclipse.emf.spi.cdo.InternalCDOObject; + +/** + * @author Simon McDuff + */ +public class ReadLockObjectsAction extends AbstractLockObjectsAction +{ + public static final String ID = "readlock-objects"; //$NON-NLS-1$ + + public ReadLockObjectsAction() + { + super(Messages.getString("ReadLockObjectsAction.1")); //$NON-NLS-1$ + setId(ID); + } + + @Override + protected CDOLock getLock(InternalCDOObject object) + { + return object.cdoReadLock(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterFilesystemPackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterFilesystemPackagesAction.java index e268bd6e4f..58bb905820 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterFilesystemPackagesAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterFilesystemPackagesAction.java @@ -1,83 +1,83 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class RegisterFilesystemPackagesAction extends RegisterPackagesAction
-{
- private static final String TITLE = Messages.getString("RegisterFilesystemPackagesAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("RegisterFilesystemPackagesAction.1"); //$NON-NLS-1$
-
- private static final String[] FILTER_NAMES = {
- Messages.getString("RegisterFilesystemPackagesAction.2"), Messages.getString("RegisterFilesystemPackagesAction.3"), Messages.getString("RegisterFilesystemPackagesAction.4"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Messages.getString("RegisterFilesystemPackagesAction.5") }; //$NON-NLS-1$
-
- private static final String[] FILTER_EXTENSIONS = { "ecore", "xmi", "xml", null }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- public RegisterFilesystemPackagesAction(IWorkbenchPage page, CDOSession session)
- {
- super(page, TITLE, TOOL_TIP, null, session);
- }
-
- @Override
- protected List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session)
- {
- Shell shell = page.getWorkbenchWindow().getShell();
- FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
- dialog.setFileName("*.ecore"); //$NON-NLS-1$
- dialog.setFilterNames(FILTER_NAMES);
- dialog.setFilterExtensions(FILTER_EXTENSIONS);
- if (dialog.open() != null)
- {
- String filterPath = dialog.getFilterPath();
- String[] fileNames = dialog.getFileNames();
- if (fileNames != null && fileNames.length != 0)
- {
- ResourceSet resourceSet = EMFUtil.newEcoreResourceSet();
- List<EPackage> ePackages = new ArrayList<EPackage>(fileNames.length);
- for (String fileName : fileNames)
- {
- String path = filterPath + File.separator + fileName;
- URI uri = URI.createFileURI(path);
- Resource resource = resourceSet.getResource(uri, true);
- EPackage ePackage = (EPackage)resource.getContents().get(0);
- ePackages.add(ePackage);
- }
-
- return ePackages;
- }
- }
-
- 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: + * Eike Stepper - initial API and implementation + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class RegisterFilesystemPackagesAction extends RegisterPackagesAction +{ + private static final String TITLE = Messages.getString("RegisterFilesystemPackagesAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("RegisterFilesystemPackagesAction.1"); //$NON-NLS-1$ + + private static final String[] FILTER_NAMES = { + Messages.getString("RegisterFilesystemPackagesAction.2"), Messages.getString("RegisterFilesystemPackagesAction.3"), Messages.getString("RegisterFilesystemPackagesAction.4"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + Messages.getString("RegisterFilesystemPackagesAction.5") }; //$NON-NLS-1$ + + private static final String[] FILTER_EXTENSIONS = { "ecore", "xmi", "xml", null }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + public RegisterFilesystemPackagesAction(IWorkbenchPage page, CDOSession session) + { + super(page, TITLE, TOOL_TIP, null, session); + } + + @Override + protected List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session) + { + Shell shell = page.getWorkbenchWindow().getShell(); + FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI); + dialog.setFileName("*.ecore"); //$NON-NLS-1$ + dialog.setFilterNames(FILTER_NAMES); + dialog.setFilterExtensions(FILTER_EXTENSIONS); + if (dialog.open() != null) + { + String filterPath = dialog.getFilterPath(); + String[] fileNames = dialog.getFileNames(); + if (fileNames != null && fileNames.length != 0) + { + ResourceSet resourceSet = EMFUtil.newEcoreResourceSet(); + List<EPackage> ePackages = new ArrayList<EPackage>(fileNames.length); + for (String fileName : fileNames) + { + String path = filterPath + File.separator + fileName; + URI uri = URI.createFileURI(path); + Resource resource = resourceSet.getResource(uri, true); + EPackage ePackage = (EPackage)resource.getContents().get(0); + ePackages.add(ePackage); + } + + return ePackages; + } + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterGeneratedPackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterGeneratedPackagesAction.java index 97ef287e1f..9064522c7c 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterGeneratedPackagesAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterGeneratedPackagesAction.java @@ -1,94 +1,94 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.bundle.OM;
-import org.eclipse.emf.cdo.internal.ui.dialogs.SelectPackageDialog;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.emf.ecore.EPackage;
-
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class RegisterGeneratedPackagesAction extends RegisterPackagesAction
-{
- private static final String TITLE = Messages.getString("RegisterGeneratedPackagesAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("RegisterGeneratedPackagesAction.1"); //$NON-NLS-1$
-
- private EPackage.Registry registry = EPackage.Registry.INSTANCE;
-
- public RegisterGeneratedPackagesAction(IWorkbenchPage page, CDOSession session)
- {
- super(page, TITLE, TOOL_TIP, null, session);
- }
-
- @Override
- protected List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session)
- {
- Shell shell = page.getWorkbenchWindow().getShell();
- SelectPackageDialog dialog = new SelectPackageDialog(shell,
- Messages.getString("RegisterGeneratedPackagesAction.2"), //$NON-NLS-1$
- Messages.getString("RegisterGeneratedPackagesAction.3"), session.getPackageRegistry() //$NON-NLS-1$
- .keySet());
-
- if (dialog.open() == SelectPackageDialog.OK)
- {
- Set<String> checkedURIs = dialog.getCheckedURIs();
- List<EPackage> ePackages = new ArrayList<EPackage>(checkedURIs.size());
- for (String uri : checkedURIs)
- {
- try
- {
- EPackage ePackage = registry.getEPackage(uri);
- ePackages.add(ePackage);
- }
- catch (RuntimeException ex)
- {
- OM.LOG.error(ex);
- }
- }
-
- return ePackages;
- }
-
- return null;
- }
-
- /**
- * @author Eike Stepper
- */
- public class EPackageFactoryValidator implements IInputValidator
- {
- public String isValid(String uri)
- {
- if (uri == null || uri.length() == 0)
- {
- return ""; //$NON-NLS-1$
- }
-
- return registry.containsKey(uri) ? null : MessageFormat.format(
- Messages.getString("RegisterGeneratedPackagesAction.5"), uri); //$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 + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.bundle.OM; +import org.eclipse.emf.cdo.internal.ui.dialogs.SelectPackageDialog; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.jface.dialogs.IInputValidator; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class RegisterGeneratedPackagesAction extends RegisterPackagesAction +{ + private static final String TITLE = Messages.getString("RegisterGeneratedPackagesAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("RegisterGeneratedPackagesAction.1"); //$NON-NLS-1$ + + private EPackage.Registry registry = EPackage.Registry.INSTANCE; + + public RegisterGeneratedPackagesAction(IWorkbenchPage page, CDOSession session) + { + super(page, TITLE, TOOL_TIP, null, session); + } + + @Override + protected List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session) + { + Shell shell = page.getWorkbenchWindow().getShell(); + SelectPackageDialog dialog = new SelectPackageDialog(shell, + Messages.getString("RegisterGeneratedPackagesAction.2"), //$NON-NLS-1$ + Messages.getString("RegisterGeneratedPackagesAction.3"), session.getPackageRegistry() //$NON-NLS-1$ + .keySet()); + + if (dialog.open() == SelectPackageDialog.OK) + { + Set<String> checkedURIs = dialog.getCheckedURIs(); + List<EPackage> ePackages = new ArrayList<EPackage>(checkedURIs.size()); + for (String uri : checkedURIs) + { + try + { + EPackage ePackage = registry.getEPackage(uri); + ePackages.add(ePackage); + } + catch (RuntimeException ex) + { + OM.LOG.error(ex); + } + } + + return ePackages; + } + + return null; + } + + /** + * @author Eike Stepper + */ + public class EPackageFactoryValidator implements IInputValidator + { + public String isValid(String uri) + { + if (uri == null || uri.length() == 0) + { + return ""; //$NON-NLS-1$ + } + + return registry.containsKey(uri) ? null : MessageFormat.format( + Messages.getString("RegisterGeneratedPackagesAction.5"), uri); //$NON-NLS-1$ + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java index 5465e5e7ae..59f0dcaea0 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.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:
- * Eike Stepper - initial API and implementation
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.internal.ui.bundle.OM;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-
-import java.text.MessageFormat;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public abstract class RegisterPackagesAction extends SessionAction
-{
- private List<EPackage> ePackages;
-
- private int errors;
-
- public RegisterPackagesAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image,
- CDOSession session)
- {
- super(page, text, toolTipText, image, session);
- }
-
- @Override
- protected void preRun() throws Exception
- {
- ePackages = getEPackages(getPage(), getSession());
- if (ePackages == null)
- {
- cancel();
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- errors = 0;
- CDOPackageRegistry packageRegistry = getSession().getPackageRegistry();
- for (EPackage ePackage : ePackages)
- {
- EcoreUtil.freeze(ePackage);
- Resource resource = ePackage.eResource();
- URI uri = resource == null ? null : resource.getURI();
-
- try
- {
- packageRegistry.putEPackage(ePackage);
- }
- catch (RuntimeException ex)
- {
- ++errors;
- if (uri == null)
- {
- OM.LOG.error(ex);
- }
- else
- {
- OM.LOG.error(MessageFormat.format(Messages.getString("RegisterPackagesAction.0"), uri), ex); //$NON-NLS-1$
- }
- }
- }
-
- postRegistration(ePackages);
- if (errors != 0)
- {
- final String label = errors == 1 ? MessageFormat.format(Messages.getString("RegisterPackagesAction.1"), errors) : MessageFormat.format(Messages.getString("RegisterPackagesAction.2"), errors); //$NON-NLS-1$ //$NON-NLS-2$
- getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- Shell shell = getShell();
- if (!shell.isDisposed())
- {
- MessageDialog.openError(shell, getText(), label);
- }
- }
- });
- }
- }
-
- protected void postRegistration(List<EPackage> ePackages)
- {
- }
-
- protected abstract List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session);
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.internal.ui.bundle.OM; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.EcoreUtil; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; + +import java.text.MessageFormat; +import java.util.List; + +/** + * @author Eike Stepper + */ +public abstract class RegisterPackagesAction extends SessionAction +{ + private List<EPackage> ePackages; + + private int errors; + + public RegisterPackagesAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image, + CDOSession session) + { + super(page, text, toolTipText, image, session); + } + + @Override + protected void preRun() throws Exception + { + ePackages = getEPackages(getPage(), getSession()); + if (ePackages == null) + { + cancel(); + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + errors = 0; + CDOPackageRegistry packageRegistry = getSession().getPackageRegistry(); + for (EPackage ePackage : ePackages) + { + EcoreUtil.freeze(ePackage); + Resource resource = ePackage.eResource(); + URI uri = resource == null ? null : resource.getURI(); + + try + { + packageRegistry.putEPackage(ePackage); + } + catch (RuntimeException ex) + { + ++errors; + if (uri == null) + { + OM.LOG.error(ex); + } + else + { + OM.LOG.error(MessageFormat.format(Messages.getString("RegisterPackagesAction.0"), uri), ex); //$NON-NLS-1$ + } + } + } + + postRegistration(ePackages); + if (errors != 0) + { + final String label = errors == 1 ? MessageFormat.format(Messages.getString("RegisterPackagesAction.1"), errors) : MessageFormat.format(Messages.getString("RegisterPackagesAction.2"), errors); //$NON-NLS-1$ //$NON-NLS-2$ + getDisplay().asyncExec(new Runnable() + { + public void run() + { + Shell shell = getShell(); + if (!shell.isDisposed()) + { + MessageDialog.openError(shell, getText(), label); + } + } + }); + } + } + + protected void postRegistration(List<EPackage> ePackages) + { + } + + protected abstract List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session); +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterSinglePackageAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterSinglePackageAction.java index bc9482a805..e5da70ff34 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterSinglePackageAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterSinglePackageAction.java @@ -1,77 +1,77 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.common.model.CDOPackageTypeRegistry;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit.Type;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.ui.shared.SharedIcons;
-
-import org.eclipse.emf.ecore.EPackage;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbenchPage;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class RegisterSinglePackageAction extends RegisterPackagesAction
-{
- private String packageURI;
-
- private EPackage.Registry registry = EPackage.Registry.INSTANCE;
-
- public RegisterSinglePackageAction(IWorkbenchPage page, CDOSession session, String packageURI)
- {
- super(page, packageURI,
- Messages.getString("RegisterSinglePackageAction.0") + packageURI, getDescriptor(packageURI), session); //$NON-NLS-1$
- this.packageURI = packageURI;
- }
-
- @Override
- protected List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session)
- {
- EPackage ePackage = registry.getEPackage(packageURI);
- if (ePackage != null)
- {
- return Collections.singletonList(ePackage);
- }
-
- return Collections.emptyList();
- }
-
- private static ImageDescriptor getDescriptor(String nsURI)
- {
- Type type = CDOPackageTypeRegistry.INSTANCE.lookup(nsURI);
- switch (type)
- {
- case LEGACY:
- return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_LEGACY);
-
- case NATIVE:
- return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_NATIVE);
-
- case DYNAMIC:
- return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_DYNAMIC);
-
- case UNKNOWN:
- return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_UNKNOWN);
-
- default:
- 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: + * Eike Stepper - initial API and implementation + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.common.model.CDOPackageTypeRegistry; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit.Type; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.ui.shared.SharedIcons; + +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPage; + +import java.util.Collections; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class RegisterSinglePackageAction extends RegisterPackagesAction +{ + private String packageURI; + + private EPackage.Registry registry = EPackage.Registry.INSTANCE; + + public RegisterSinglePackageAction(IWorkbenchPage page, CDOSession session, String packageURI) + { + super(page, packageURI, + Messages.getString("RegisterSinglePackageAction.0") + packageURI, getDescriptor(packageURI), session); //$NON-NLS-1$ + this.packageURI = packageURI; + } + + @Override + protected List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session) + { + EPackage ePackage = registry.getEPackage(packageURI); + if (ePackage != null) + { + return Collections.singletonList(ePackage); + } + + return Collections.emptyList(); + } + + private static ImageDescriptor getDescriptor(String nsURI) + { + Type type = CDOPackageTypeRegistry.INSTANCE.lookup(nsURI); + switch (type) + { + case LEGACY: + return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_LEGACY); + + case NATIVE: + return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_NATIVE); + + case DYNAMIC: + return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_DYNAMIC); + + case UNKNOWN: + return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_UNKNOWN); + + default: + return null; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java index 93ac4636b8..b81d2e2fad 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java @@ -1,75 +1,75 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.internal.ui.dialogs.OpenResourcesDialog;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class RegisterWorkspacePackagesAction extends RegisterPackagesAction
-{
- private static final String TITLE = Messages.getString("RegisterWorkspacePackagesAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("RegisterWorkspacePackagesAction.1"); //$NON-NLS-1$
-
- public RegisterWorkspacePackagesAction(IWorkbenchPage page, CDOSession session)
- {
- super(page, TITLE, TOOL_TIP, null, session);
- }
-
- @Override
- protected List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session)
- {
- Shell shell = page.getWorkbenchWindow().getShell();
- OpenResourcesDialog dialog = new OpenResourcesDialog(shell);
- if (dialog.open() == OpenResourcesDialog.OK)
- {
- Object[] result = dialog.getResult();
- if (result != null && result.length != 0)
- {
- ResourceSet resourceSet = EMFUtil.newEcoreResourceSet();
- List<EPackage> ePackages = new ArrayList<EPackage>(result.length);
- for (Object object : result)
- {
- if (object instanceof IFile)
- {
- IFile file = (IFile)object;
- URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
- Resource resource = resourceSet.getResource(uri, true);
- EPackage ePackage = (EPackage)resource.getContents().get(0);
- ePackages.add(ePackage);
- }
- }
-
- return ePackages;
- }
- }
-
- 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: + * Eike Stepper - initial API and implementation + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.internal.ui.dialogs.OpenResourcesDialog; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; + +import org.eclipse.core.resources.IFile; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class RegisterWorkspacePackagesAction extends RegisterPackagesAction +{ + private static final String TITLE = Messages.getString("RegisterWorkspacePackagesAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("RegisterWorkspacePackagesAction.1"); //$NON-NLS-1$ + + public RegisterWorkspacePackagesAction(IWorkbenchPage page, CDOSession session) + { + super(page, TITLE, TOOL_TIP, null, session); + } + + @Override + protected List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session) + { + Shell shell = page.getWorkbenchWindow().getShell(); + OpenResourcesDialog dialog = new OpenResourcesDialog(shell); + if (dialog.open() == OpenResourcesDialog.OK) + { + Object[] result = dialog.getResult(); + if (result != null && result.length != 0) + { + ResourceSet resourceSet = EMFUtil.newEcoreResourceSet(); + List<EPackage> ePackages = new ArrayList<EPackage>(result.length); + for (Object object : result) + { + if (object instanceof IFile) + { + IFile file = (IFile)object; + URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true); + Resource resource = resourceSet.getResource(uri, true); + EPackage ePackage = (EPackage)resource.getContents().get(0); + ePackages.add(ePackage); + } + } + + return ePackages; + } + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java index 48283ad289..004a82a7ba 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java @@ -1,88 +1,88 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.ui.CDOEditorUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.internal.cdo.view.CDOStateMachine;
-
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchPage;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class ReloadObjectsAction extends EditingDomainAction
-{
- public static final String ID = "reload-objects"; //$NON-NLS-1$
-
- private static final String TITLE = Messages.getString("ReloadObjectsAction.1"); //$NON-NLS-1$
-
- private List<InternalCDOObject> objects = new ArrayList<InternalCDOObject>();
-
- public ReloadObjectsAction()
- {
- super(TITLE);
- setId(ID);
- }
-
- public void selectionChanged(IStructuredSelection selection)
- {
- objects.clear();
- if (selection != null)
- {
- for (Iterator<?> it = selection.iterator(); it.hasNext();)
- {
- Object object = it.next();
- if (object instanceof InternalCDOObject)
- {
- objects.add((InternalCDOObject)object);
- }
- }
- }
-
- update();
- }
-
- @Override
- public void update()
- {
- setEnabled(!objects.isEmpty());
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- if (!objects.isEmpty())
- {
- InternalCDOObject[] array = objects.toArray(new InternalCDOObject[objects.size()]);
-
- CDOStateMachine.INSTANCE.reload(array);
-
- IWorkbenchPage page = getPage();
- if (page != null)
- {
- CDOView view = array[0].cdoView();
- CDOEditorUtil.refreshEditors(page, view);
- }
- }
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.ui.CDOEditorUtil; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.internal.cdo.view.CDOStateMachine; + +import org.eclipse.emf.spi.cdo.InternalCDOObject; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbenchPage; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class ReloadObjectsAction extends EditingDomainAction +{ + public static final String ID = "reload-objects"; //$NON-NLS-1$ + + private static final String TITLE = Messages.getString("ReloadObjectsAction.1"); //$NON-NLS-1$ + + private List<InternalCDOObject> objects = new ArrayList<InternalCDOObject>(); + + public ReloadObjectsAction() + { + super(TITLE); + setId(ID); + } + + public void selectionChanged(IStructuredSelection selection) + { + objects.clear(); + if (selection != null) + { + for (Iterator<?> it = selection.iterator(); it.hasNext();) + { + Object object = it.next(); + if (object instanceof InternalCDOObject) + { + objects.add((InternalCDOObject)object); + } + } + } + + update(); + } + + @Override + public void update() + { + setEnabled(!objects.isEmpty()); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + if (!objects.isEmpty()) + { + InternalCDOObject[] array = objects.toArray(new InternalCDOObject[objects.size()]); + + CDOStateMachine.INSTANCE.reload(array); + + IWorkbenchPage page = getPage(); + if (page != null) + { + CDOView view = array[0].cdoView(); + CDOEditorUtil.refreshEditors(page, view); + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java index 434076c3f9..1a6dd2f20a 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java @@ -1,43 +1,43 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.ui.CDOEditorUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class ReloadViewAction extends ViewAction
-{
- private static final String TITLE = Messages.getString("ReloadViewAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("ReloadViewAction.1"); //$NON-NLS-1$
-
- public ReloadViewAction(IWorkbenchPage page, CDOView view)
- {
- super(page, TITLE, TOOL_TIP, null, view);
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- if (getView().reload() != 0)
- {
- CDOEditorUtil.refreshEditors(getPage(), getView());
- }
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.ui.CDOEditorUtil; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class ReloadViewAction extends ViewAction +{ + private static final String TITLE = Messages.getString("ReloadViewAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("ReloadViewAction.1"); //$NON-NLS-1$ + + public ReloadViewAction(IWorkbenchPage page, CDOView view) + { + super(page, TITLE, TOOL_TIP, null, view); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + if (getView().reload() != 0) + { + CDOEditorUtil.refreshEditors(getPage(), getView()); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveAllContainerItemAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveAllContainerItemAction.java index 2f043875df..758e27e903 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveAllContainerItemAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveAllContainerItemAction.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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.net4j.util.container.IContainer.Modifiable;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import java.util.ArrayList;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class RemoveAllContainerItemAction<E> extends AbstractContainerAction<E>
-{
- public RemoveAllContainerItemAction(IContainer.Modifiable<E> container)
- {
- super(container);
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- Modifiable<E> container = getContainer();
- ArrayList<E> elementsToRemove = new ArrayList<E>();
- for (E element : container.getElements())
- {
- elementsToRemove.add(element);
- }
-
- container.removeAllElements(elementsToRemove);
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.net4j.util.container.IContainer; +import org.eclipse.net4j.util.container.IContainer.Modifiable; + +import org.eclipse.core.runtime.IProgressMonitor; + +import java.util.ArrayList; + +/** + * @author Victor Roldan Betancort + */ +public class RemoveAllContainerItemAction<E> extends AbstractContainerAction<E> +{ + public RemoveAllContainerItemAction(IContainer.Modifiable<E> container) + { + super(container); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + Modifiable<E> container = getContainer(); + ArrayList<E> elementsToRemove = new ArrayList<E>(); + for (E element : container.getElements()) + { + elementsToRemove.add(element); + } + + container.removeAllElements(elementsToRemove); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveContainerItemAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveContainerItemAction.java index 9f618b2f61..f01a6b7b21 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveContainerItemAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RemoveContainerItemAction.java @@ -1,69 +1,69 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.net4j.util.container.IContainer;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import java.util.List;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class RemoveContainerItemAction<E> extends AbstractContainerAction<E>
-{
- private ISelectionProvider selectionProvider;
-
- private transient List<E> targets;
-
- public RemoveContainerItemAction(IContainer.Modifiable<E> container, ISelectionProvider selectionProvider)
- {
- super(container);
- this.selectionProvider = selectionProvider;
- }
-
- @Override
- protected void preRun() throws Exception
- {
- ISelection selection = selectionProvider.getSelection();
- if (selection instanceof IStructuredSelection)
- {
- IStructuredSelection ssel = (IStructuredSelection)selection;
- if (!ssel.isEmpty())
- {
- @SuppressWarnings("unchecked")
- List<E> cast = ssel.toList();
- targets = cast;
- return;
- }
- }
-
- cancel();
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- if (targets != null)
- {
- List<E> useTargets = targets;
- targets = null;
-
- IContainer.Modifiable<E> container = getContainer();
- container.removeAllElements(useTargets);
- }
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.net4j.util.container.IContainer; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; + +import java.util.List; + +/** + * @author Victor Roldan Betancort + */ +public class RemoveContainerItemAction<E> extends AbstractContainerAction<E> +{ + private ISelectionProvider selectionProvider; + + private transient List<E> targets; + + public RemoveContainerItemAction(IContainer.Modifiable<E> container, ISelectionProvider selectionProvider) + { + super(container); + this.selectionProvider = selectionProvider; + } + + @Override + protected void preRun() throws Exception + { + ISelection selection = selectionProvider.getSelection(); + if (selection instanceof IStructuredSelection) + { + IStructuredSelection ssel = (IStructuredSelection)selection; + if (!ssel.isEmpty()) + { + @SuppressWarnings("unchecked") + List<E> cast = ssel.toList(); + targets = cast; + return; + } + } + + cancel(); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + if (targets != null) + { + List<E> useTargets = targets; + targets = null; + + IContainer.Modifiable<E> container = getContainer(); + container.removeAllElements(useTargets); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeAction.java index 9e94dbfe94..967cef79b6 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeAction.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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-
-import org.eclipse.net4j.util.ui.actions.LongRunningAction;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public abstract class ResourceNodeAction extends LongRunningAction
-{
- private CDOResourceNode resourceNode;
-
- public ResourceNodeAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image,
- CDOResourceNode resourceNode)
- {
- super(page, text, toolTipText, image);
- this.resourceNode = resourceNode;
- }
-
- public CDOResourceNode getResourceNode()
- {
- return resourceNode;
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.eresource.CDOResourceNode; + +import org.eclipse.net4j.util.ui.actions.LongRunningAction; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public abstract class ResourceNodeAction extends LongRunningAction +{ + private CDOResourceNode resourceNode; + + public ResourceNodeAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image, + CDOResourceNode resourceNode) + { + super(page, text, toolTipText, image); + this.resourceNode = resourceNode; + } + + public CDOResourceNode getResourceNode() + { + return resourceNode; + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeNameInputValidator.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeNameInputValidator.java index 3fee598298..7a7f20e3b9 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeNameInputValidator.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ResourceNodeNameInputValidator.java @@ -1,64 +1,64 @@ -/*
- * 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
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
-import org.eclipse.emf.cdo.eresource.CDOResourceNode;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-
-import org.eclipse.net4j.util.StringUtil;
-
-import org.eclipse.emf.ecore.EObject;
-
-import org.eclipse.jface.dialogs.IInputValidator;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class ResourceNodeNameInputValidator implements IInputValidator
-{
- private CDOResourceNode node;
-
- private boolean isFolder;
-
- public ResourceNodeNameInputValidator(CDOResourceNode node)
- {
- this.node = node;
- isFolder = node instanceof CDOResourceFolder;
- }
-
- public String isValid(String newText)
- {
- // Do not allow empty names
- if (StringUtil.isEmpty(newText))
- {
- return isFolder ? Messages.getString("CreateResourceNodeAction.3") : Messages.getString("CreateResourceNodeAction.4"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Do not allow "/"
- if (newText.contains("/") || newText.contains("\\")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- return Messages.getString("CreateResourceNodeAction.2"); //$NON-NLS-1$
- }
-
- for (EObject nodeObject : node.eContents())
- {
- CDOResourceNode node = (CDOResourceNode)nodeObject;
- if (node.getName().equals(newText))
- {
- return isFolder ? Messages.getString("CreateResourceNodeAction.5") + newText : Messages.getString("CreateResourceNodeAction.6") //$NON-NLS-1$ //$NON-NLS-2$
- + newText;
- }
- }
-
- 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 + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; + +import org.eclipse.net4j.util.StringUtil; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.jface.dialogs.IInputValidator; + +/** + * @author Victor Roldan Betancort + */ +public class ResourceNodeNameInputValidator implements IInputValidator +{ + private CDOResourceNode node; + + private boolean isFolder; + + public ResourceNodeNameInputValidator(CDOResourceNode node) + { + this.node = node; + isFolder = node instanceof CDOResourceFolder; + } + + public String isValid(String newText) + { + // Do not allow empty names + if (StringUtil.isEmpty(newText)) + { + return isFolder ? Messages.getString("CreateResourceNodeAction.3") : Messages.getString("CreateResourceNodeAction.4"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + // Do not allow "/" + if (newText.contains("/") || newText.contains("\\")) //$NON-NLS-1$ //$NON-NLS-2$ + { + return Messages.getString("CreateResourceNodeAction.2"); //$NON-NLS-1$ + } + + for (EObject nodeObject : node.eContents()) + { + CDOResourceNode node = (CDOResourceNode)nodeObject; + if (node.getName().equals(newText)) + { + return isFolder ? Messages.getString("CreateResourceNodeAction.5") + newText : Messages.getString("CreateResourceNodeAction.6") //$NON-NLS-1$ //$NON-NLS-2$ + + newText; + } + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java index 10afef5264..e371342bd2 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java @@ -1,53 +1,53 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.dialogs.RollbackTransactionDialog;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public final class RollbackTransactionAction extends ViewAction
-{
- private static final String TITLE = Messages.getString("RollbackTransactionAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("RollbackTransactionAction.1"); //$NON-NLS-1$
-
- public RollbackTransactionAction(IWorkbenchPage page, CDOView view)
- {
- super(page, TITLE + INTERACTIVE, TOOL_TIP, null, view);
- setEnabled(getTransaction().isDirty());
- }
-
- @Override
- protected void preRun() throws Exception
- {
- CDOTransaction transaction = (CDOTransaction)getView();
- RollbackTransactionDialog dialog = new RollbackTransactionDialog(getPage(), TITLE, TOOL_TIP, transaction);
- if (dialog.open() != RollbackTransactionDialog.OK)
- {
- cancel();
- }
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- getTransaction().rollback();
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.dialogs.RollbackTransactionDialog; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public final class RollbackTransactionAction extends ViewAction +{ + private static final String TITLE = Messages.getString("RollbackTransactionAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("RollbackTransactionAction.1"); //$NON-NLS-1$ + + public RollbackTransactionAction(IWorkbenchPage page, CDOView view) + { + super(page, TITLE + INTERACTIVE, TOOL_TIP, null, view); + setEnabled(getTransaction().isDirty()); + } + + @Override + protected void preRun() throws Exception + { + CDOTransaction transaction = (CDOTransaction)getView(); + RollbackTransactionDialog dialog = new RollbackTransactionDialog(getPage(), TITLE, TOOL_TIP, transaction); + if (dialog.open() != RollbackTransactionDialog.OK) + { + cancel(); + } + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + getTransaction().rollback(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SessionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SessionAction.java index f0749f83bc..4e07dc0d56 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SessionAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SessionAction.java @@ -1,37 +1,37 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.net4j.util.ui.actions.LongRunningAction;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public abstract class SessionAction extends LongRunningAction
-{
- private CDOSession session;
-
- public SessionAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image, CDOSession session)
- {
- super(page, text, toolTipText, image);
- this.session = session;
- }
-
- public CDOSession getSession()
- {
- return session;
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.net4j.util.ui.actions.LongRunningAction; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public abstract class SessionAction extends LongRunningAction +{ + private CDOSession session; + + public SessionAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image, CDOSession session) + { + super(page, text, toolTipText, image); + this.session = session; + } + + public CDOSession getSession() + { + return session; + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SwitchTargetAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SwitchTargetAction.java index efb57fb498..e3768cf74d 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SwitchTargetAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SwitchTargetAction.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
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.internal.ui.dialogs.SelectBranchPointDialog;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.ui.shared.SharedIcons;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class SwitchTargetAction extends ViewAction
-{
- public static final String ID = "switch-target"; //$NON-NLS-1$
-
- private static final String TITLE = Messages.getString("SwitchTargetAction.0"); //$NON-NLS-1$
-
- private static final String TOOL_TIP = Messages.getString("SwitchTargetAction.1"); //$NON-NLS-1$
-
- private CDOBranchPoint target;
-
- public SwitchTargetAction(IWorkbenchPage page, CDOView view)
- {
- super(page, TITLE + INTERACTIVE, TOOL_TIP, null, view);
- setId(ID);
- }
-
- @Override
- protected void preRun() throws Exception
- {
- CDOView view = getView();
- SelectBranchPointDialog dialog = new SelectBranchPointDialog(getPage(), view.getSession(), view, view.isReadOnly())
- {
- @Override
- protected Control createDialogArea(Composite parent)
- {
- getShell().setText(TITLE);
- setTitle(TITLE);
- setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_TARGET_SELECTION));
- setMessage("Compose a valid target point or select one from commits, tags or views.");
- return super.createDialogArea(parent);
- }
-
- @Override
- protected String getComposeTabTitle()
- {
- return "Target Point";
- }
- };
-
- if (dialog.open() == Dialog.OK)
- {
- target = dialog.getBranchPoint();
- if (target == null)
- {
- cancel();
- }
- }
- else
- {
- cancel();
- }
-
- super.preRun();
- }
-
- @Override
- protected void doRun(IProgressMonitor progressMonitor) throws Exception
- {
- CDOView view = getView();
- view.setBranchPoint(target);
- }
-}
+/* + * 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 + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.internal.ui.dialogs.SelectBranchPointDialog; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; +import org.eclipse.emf.cdo.ui.shared.SharedIcons; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Victor Roldan Betancort + */ +public class SwitchTargetAction extends ViewAction +{ + public static final String ID = "switch-target"; //$NON-NLS-1$ + + private static final String TITLE = Messages.getString("SwitchTargetAction.0"); //$NON-NLS-1$ + + private static final String TOOL_TIP = Messages.getString("SwitchTargetAction.1"); //$NON-NLS-1$ + + private CDOBranchPoint target; + + public SwitchTargetAction(IWorkbenchPage page, CDOView view) + { + super(page, TITLE + INTERACTIVE, TOOL_TIP, null, view); + setId(ID); + } + + @Override + protected void preRun() throws Exception + { + CDOView view = getView(); + SelectBranchPointDialog dialog = new SelectBranchPointDialog(getPage(), view.getSession(), view, view.isReadOnly()) + { + @Override + protected Control createDialogArea(Composite parent) + { + getShell().setText(TITLE); + setTitle(TITLE); + setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_TARGET_SELECTION)); + setMessage("Compose a valid target point or select one from commits, tags or views."); + return super.createDialogArea(parent); + } + + @Override + protected String getComposeTabTitle() + { + return "Target Point"; + } + }; + + if (dialog.open() == Dialog.OK) + { + target = dialog.getBranchPoint(); + if (target == null) + { + cancel(); + } + } + else + { + cancel(); + } + + super.preRun(); + } + + @Override + protected void doRun(IProgressMonitor progressMonitor) throws Exception + { + CDOView view = getView(); + view.setBranchPoint(target); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ToggleLegacyModeDefaultAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ToggleLegacyModeDefaultAction.java index 650aa00e94..453463abfc 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ToggleLegacyModeDefaultAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ToggleLegacyModeDefaultAction.java @@ -1,43 +1,43 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.internal.ui.LegacyModeRegistry;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.net4j.util.ui.actions.SafeAction;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class ToggleLegacyModeDefaultAction extends SafeAction
-{
- private static final String TITLE = "Legacy Mode";
-
- private static final String TOOL_TIP = "Toggles the default for legacy mode";
-
- private CDOSession session;
-
- public ToggleLegacyModeDefaultAction(CDOSession session)
- {
- super(TITLE, AS_CHECK_BOX);
- setToolTipText(TOOL_TIP);
- this.session = session;
- setChecked(LegacyModeRegistry.isLegacyEnabled(session));
- }
-
- @Override
- protected void safeRun() throws Exception
- {
- LegacyModeRegistry.setLegacyEnabled(session, !LegacyModeRegistry.isLegacyEnabled(session));
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.internal.ui.LegacyModeRegistry; +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.net4j.util.ui.actions.SafeAction; + +/** + * @author Victor Roldan Betancort + */ +public class ToggleLegacyModeDefaultAction extends SafeAction +{ + private static final String TITLE = "Legacy Mode"; + + private static final String TOOL_TIP = "Toggles the default for legacy mode"; + + private CDOSession session; + + public ToggleLegacyModeDefaultAction(CDOSession session) + { + super(TITLE, AS_CHECK_BOX); + setToolTipText(TOOL_TIP); + this.session = session; + setChecked(LegacyModeRegistry.isLegacyEnabled(session)); + } + + @Override + protected void safeRun() throws Exception + { + LegacyModeRegistry.setLegacyEnabled(session, !LegacyModeRegistry.isLegacyEnabled(session)); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java index 1159b9630f..5ec4de16c6 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java @@ -1,47 +1,47 @@ -/*
- * 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.internal.ui.actions;
-
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.ui.actions.LongRunningAction;
-
-import org.eclipse.emf.spi.cdo.InternalCDOView;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * @author Eike Stepper
- */
-public abstract class ViewAction extends LongRunningAction
-{
- protected static int lastResourceNumber = 0;
-
- private CDOView view;
-
- public ViewAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image, CDOView view)
- {
- super(page, text, toolTipText, image);
- this.view = view;
- }
-
- public CDOView getView()
- {
- return view;
- }
-
- public CDOTransaction getTransaction()
- {
- return ((InternalCDOView)view).toTransaction();
- }
-}
+/* + * 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.internal.ui.actions; + +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.net4j.util.ui.actions.LongRunningAction; + +import org.eclipse.emf.spi.cdo.InternalCDOView; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Eike Stepper + */ +public abstract class ViewAction extends LongRunningAction +{ + protected static int lastResourceNumber = 0; + + private CDOView view; + + public ViewAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image, CDOView view) + { + super(page, text, toolTipText, image); + this.view = view; + } + + public CDOView getView() + { + return view; + } + + public CDOTransaction getTransaction() + { + return ((InternalCDOView)view).toTransaction(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/WriteLockObjectsAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/WriteLockObjectsAction.java index 58698cd315..1ab40b66c0 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/WriteLockObjectsAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/WriteLockObjectsAction.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:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.internal.ui.actions;
-
-import org.eclipse.emf.cdo.CDOLock;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-/**
- * @author Simon McDuff
- */
-public class WriteLockObjectsAction extends AbstractLockObjectsAction
-{
- public static final String ID = "writelock-objects"; //$NON-NLS-1$
-
- public WriteLockObjectsAction()
- {
- super(Messages.getString("WriteLockObjectsAction.1")); //$NON-NLS-1$
- setId(ID);
- }
-
- @Override
- protected CDOLock getLock(InternalCDOObject object)
- {
- return object.cdoWriteLock();
- }
-}
+/* + * 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.internal.ui.actions; + +import org.eclipse.emf.cdo.CDOLock; +import org.eclipse.emf.cdo.internal.ui.messages.Messages; + +import org.eclipse.emf.spi.cdo.InternalCDOObject; + +/** + * @author Simon McDuff + */ +public class WriteLockObjectsAction extends AbstractLockObjectsAction +{ + public static final String ID = "writelock-objects"; //$NON-NLS-1$ + + public WriteLockObjectsAction() + { + super(Messages.getString("WriteLockObjectsAction.1")); //$NON-NLS-1$ + setId(ID); + } + + @Override + protected CDOLock getLock(InternalCDOObject object) + { + return object.cdoWriteLock(); + } +} |