From 47a483d842c3fc4d3b005e3b722ba9e7f2a4eff3 Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Fri, 8 Aug 2008 21:40:58 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'simone_merge_238414_before_merge_from_HEAD_to'. --- .../emf/cdo/internal/ui/ItemsProcessor.java | 111 - .../eclipse/emf/cdo/internal/ui/SharedIcons.java | 120 - .../ui/actions/AbstractOpenViewAction.java | 34 - .../internal/ui/actions/CloseSessionAction.java | 36 - .../cdo/internal/ui/actions/CloseViewAction.java | 36 - .../ui/actions/CommitTransactionAction.java | 37 - .../internal/ui/actions/CreateResourceAction.java | 57 - .../internal/ui/actions/EditingDomainAction.java | 75 - .../emf/cdo/internal/ui/actions/EntryAction.java | 38 - .../internal/ui/actions/ExportResourceAction.java | 33 - .../internal/ui/actions/ImportResourceAction.java | 188 -- .../cdo/internal/ui/actions/ImportRootsAction.java | 125 -- .../internal/ui/actions/LoadResourceAction.java | 53 - .../internal/ui/actions/ManagePackagesAction.java | 44 - .../cdo/internal/ui/actions/OpenAuditAction.java | 56 - .../ui/actions/OpenResourceEditorAction.java | 42 - .../cdo/internal/ui/actions/OpenSessionAction.java | 111 - .../internal/ui/actions/OpenTransactionAction.java | 37 - .../cdo/internal/ui/actions/OpenViewAction.java | 39 - .../internal/ui/actions/OpenViewEditorAction.java | 37 - .../actions/RegisterFilesystemPackagesAction.java | 80 - .../actions/RegisterGeneratedPackagesAction.java | 89 - .../ui/actions/RegisterPackagesAction.java | 104 - .../ui/actions/RegisterSinglePackageAction.java | 70 - .../actions/RegisterWorkspacePackagesAction.java | 73 - .../internal/ui/actions/ReloadObjectsAction.java | 84 - .../cdo/internal/ui/actions/ReloadViewAction.java | 40 - .../ui/actions/RollbackTransactionAction.java | 62 - .../emf/cdo/internal/ui/actions/SessionAction.java | 37 - .../emf/cdo/internal/ui/actions/ViewAction.java | 47 - .../org/eclipse/emf/cdo/internal/ui/bundle/OM.java | 97 - .../emf/cdo/internal/ui/dialogs/BulkAddDialog.java | 182 -- .../cdo/internal/ui/dialogs/IPackageProvider.java | 29 - .../cdo/internal/ui/dialogs/OpenAuditDialog.java | 100 - .../internal/ui/dialogs/OpenResourcesDialog.java | 26 - .../cdo/internal/ui/dialogs/OpenSessionDialog.java | 181 -- .../internal/ui/dialogs/PackageManagerDialog.java | 430 ---- .../ui/dialogs/RollbackTransactionDialog.java | 156 -- .../internal/ui/dialogs/SelectPackageDialog.java | 192 -- .../ui/editor/CDOActionBarContributor.java | 653 ------ .../emf/cdo/internal/ui/editor/CDOEditor.java | 2339 -------------------- .../emf/cdo/internal/ui/editor/CDOEditorInput.java | 121 - .../cdo/internal/ui/editor/PluginDelegator.java | 110 - .../internal/ui/preferences/CDOPreferencePage.java | 148 -- .../ui/preferences/CDOUIPreferencePage.java | 82 - .../emf/cdo/internal/ui/views/CDOSessionsView.java | 88 - .../org/eclipse/emf/cdo/ui/CDOEventHandler.java | 198 -- .../org/eclipse/emf/cdo/ui/CDOItemProvider.java | 399 ---- .../org/eclipse/emf/cdo/ui/CDOLabelProvider.java | 200 -- .../src/org/eclipse/emf/cdo/ui/CDOViewHistory.java | 156 -- .../eclipse/emf/cdo/ui/CDOViewHistoryEntry.java | 74 - .../eclipse/emf/cdo/ui/CDOViewHistoryEvent.java | 30 - 52 files changed, 7986 deletions(-) delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/SharedIcons.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractOpenViewAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseViewAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CommitTransactionAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EntryAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/LoadResourceAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ManagePackagesAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenAuditAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewEditorAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterFilesystemPackagesAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterGeneratedPackagesAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterSinglePackageAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SessionAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/BulkAddDialog.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/IPackageProvider.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenAuditDialog.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenResourcesDialog.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/PluginDelegator.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOPreferencePage.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOUIPreferencePage.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelProvider.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistory.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistoryEntry.java delete mode 100644 plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistoryEvent.java (limited to 'plugins/org.eclipse.emf.cdo.ui/src') diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java deleted file mode 100644 index b7f81f0cf8..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java +++ /dev/null @@ -1,111 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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; - -import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.common.id.CDOID; - -import org.eclipse.emf.internal.cdo.InternalCDOObject; -import org.eclipse.emf.internal.cdo.util.FSMUtil; - -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.widgets.TreeItem; - -import java.util.Set; - -/** - * @author Eike Stepper - */ -public abstract class ItemsProcessor -{ - private CDOView view; - - public ItemsProcessor(CDOView view) - { - this.view = view; - } - - public CDOView getView() - { - return view; - } - - public void processCDOObjects(TreeViewer viewer) - { - processCDOObjects(viewer, null); - } - - public void processCDOObjects(final TreeViewer viewer, final Set ids) - { - try - { - viewer.getControl().getDisplay().syncExec(new Runnable() - { - public void run() - { - try - { - processObject(viewer, ids, viewer.getInput()); - processItems(viewer, ids, viewer.getTree().getItems()); - } - catch (Exception ignore) - { - } - } - }); - } - catch (Exception ignore) - { - } - } - - protected InternalCDOObject getCDOObject(Object object) - { - if (object instanceof InternalCDOObject) - { - return (InternalCDOObject)object; - } - - if (object != null && view != null) - { - return FSMUtil.adapt(object, view); - } - - return null; - } - - protected abstract void processCDOObject(TreeViewer viewer, InternalCDOObject cdoObject); - - private void processItems(TreeViewer viewer, Set ids, TreeItem[] items) - { - for (TreeItem item : items) - { - Object object = item.getData(); - processObject(viewer, ids, object); - if (item.getItemCount() != 0) - { - processItems(viewer, ids, item.getItems()); - } - } - } - - private void processObject(TreeViewer viewer, Set ids, Object object) - { - InternalCDOObject cdoObject = getCDOObject(object); - if (cdoObject != null) - { - if (ids == null || ids.contains(cdoObject.cdoID())) - { - processCDOObject(viewer, cdoObject); - } - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/SharedIcons.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/SharedIcons.java deleted file mode 100644 index e5ccfa98b9..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/SharedIcons.java +++ /dev/null @@ -1,120 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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; - -import org.eclipse.emf.cdo.internal.ui.bundle.OM; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -/** - * @author Eike Stepper - */ -public class SharedIcons -{ - private static final ImageRegistry REGISTRY = new ImageRegistry(getDisplay()); - - private static final String ETOOL = "etool16/"; - - private static final String OBJ = "obj16/"; - - private static final String VIEW = "view16/"; - - private static final String WIZBAN = "wizban/"; - - public static final String ETOOL_OPEN_SESSION = ETOOL + "open_session"; - - public static final String ETOOL_OPEN_EDITOR = ETOOL + "open_editor"; - - public static final String OBJ_SESSION = OBJ + "cdo_session"; - - public static final String OBJ_EDITOR = OBJ + "cdo_editor"; - - public static final String OBJ_EDITOR_READWRITE = OBJ + "cdo_editor_readwrite"; - - public static final String OBJ_EDITOR_READONLY = OBJ + "cdo_editor_readonly"; - - public static final String OBJ_EDITOR_HISTORICAL = OBJ + "cdo_editor_historical"; - - public static final String OBJ_EPACKAGE = OBJ + "EPackage"; - - public static final String OBJ_EPACKAGE_CONVERTED = OBJ + "EPackageConverted"; - - public static final String OBJ_EPACKAGE_LEGACY = OBJ + "EPackageLegacy"; - - public static final String OBJ_EPACKAGE_NATIVE = OBJ + "EPackageNative"; - - public static final String OBJ_ECLASS = OBJ + "EClass"; - - public static final String VIEW_SESSIONS = VIEW + "cdo_sessions"; - - public static final String WIZBAN_PACKAGE_MANAGER = WIZBAN + "PackageManager"; - - public static Image getImage(String key) - { - key = mangleKey(key); - Image image = REGISTRY.get(key); - if (image == null) - { - createDescriptor(key); - image = REGISTRY.get(key); - } - - return image; - } - - public static ImageDescriptor getDescriptor(String key) - { - key = mangleKey(key); - ImageDescriptor descriptor = REGISTRY.getDescriptor(key); - if (descriptor == null) - { - descriptor = createDescriptor(key); - } - - return descriptor; - } - - private static ImageDescriptor createDescriptor(String key) - { - ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(OM.BUNDLE_ID, key); - if (descriptor != null) - { - REGISTRY.put(key, descriptor); - } - - return descriptor; - } - - private static Display getDisplay() - { - Display display = Display.getCurrent(); - if (display == null) - { - display = Display.getDefault(); - } - - if (display == null) - { - throw new IllegalStateException("display == null"); - } - - return display; - } - - private static String mangleKey(String key) - { - return "icons/full/" + key + ".gif"; - } -} 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 deleted file mode 100644 index a08c6c709a..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractOpenViewAction.java +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.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/CloseSessionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java deleted file mode 100644 index cd120f46da..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseSessionAction.java +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; - -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class CloseSessionAction extends SessionAction -{ - private static final String TITLE = "Close"; - - private static final String TOOL_TIP = "Close the CDO session"; - - public CloseSessionAction(IWorkbenchPage page, CDOSession session) - { - super(page, TITLE, TOOL_TIP, null, session); - } - - @Override - protected void doRun() 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 deleted file mode 100644 index f4d86dca2e..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CloseViewAction.java +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOView; - -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class CloseViewAction extends ViewAction -{ - private static final String TITLE = "Close"; - - private static final String TOOL_TIP = "Close the CDO view"; - - public CloseViewAction(IWorkbenchPage page, CDOView view) - { - super(page, TITLE, TOOL_TIP, null, view); - } - - @Override - protected void doRun() 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 deleted file mode 100644 index e960f7da6b..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CommitTransactionAction.java +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOView; - -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class CommitTransactionAction extends ViewAction -{ - private static final String TITLE = "Commit"; - - private static final String TOOL_TIP = "Commit this transaction"; - - public CommitTransactionAction(IWorkbenchPage page, CDOView view) - { - super(page, TITLE, TOOL_TIP, null, view); - setEnabled(getTransaction().isDirty()); - } - - @Override - protected void doRun() throws Exception - { - getTransaction().commit(); - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java deleted file mode 100644 index e99ae6cd39..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOView; -import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor; - -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class CreateResourceAction extends ViewAction -{ - private static final String TITLE = "Create Resource"; - - private static final String TOOL_TIP = "Create a CDO resource"; - - private String resourcePath; - - public CreateResourceAction(IWorkbenchPage page, CDOView view) - { - super(page, TITLE + INTERACTIVE, TOOL_TIP, null, view); - } - - @Override - protected void preRun() throws Exception - { - InputDialog dialog = new InputDialog(getShell(), TITLE, "Enter resource path:", "/res" - + (ViewAction.lastResourceNumber + 1), null); - if (dialog.open() == InputDialog.OK) - { - ++ViewAction.lastResourceNumber; - resourcePath = dialog.getValue(); - } - else - { - cancel(); - } - } - - @Override - protected void doRun() throws Exception - { - getTransaction().createResource(resourcePath); - CDOEditor.open(getPage(), getView(), resourcePath); - } -} 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 deleted file mode 100644 index 052ff16910..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EditingDomainAction.java +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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/EntryAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EntryAction.java deleted file mode 100644 index 60bfbf4cb1..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/EntryAction.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.ui.CDOViewHistoryEntry; - -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 EntryAction extends LongRunningAction -{ - private CDOViewHistoryEntry entry; - - public EntryAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image, - CDOViewHistoryEntry entry) - { - super(page, text, toolTipText, image); - this.entry = entry; - } - - public CDOViewHistoryEntry getEntry() - { - return entry; - } -} 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 deleted file mode 100644 index f8ab70255c..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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; - -/** - * @author Eike Stepper - */ -@Deprecated -public class ExportResourceAction extends EditingDomainAction -{ - public static final String ID = "export-resource"; - - private static final String TITLE = "Export Resource"; - - public ExportResourceAction() - { - super(TITLE + INTERACTIVE); - setId(ID); - } - - @Override - protected void doRun() throws Exception - { - } -} 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 deleted file mode 100644 index b14341e54d..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java +++ /dev/null @@ -1,188 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOTransaction; -import org.eclipse.emf.cdo.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.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchPage; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class ImportResourceAction extends ViewAction -{ - public static final String ID = "import-resource"; - - private static final String TITLE = "Import Resource"; - - private URI sourceURI; - - private String targetPath; - - public ImportResourceAction(IWorkbenchPage page, CDOView view) - { - super(page, TITLE + INTERACTIVE, "Import a CDO resource", null, view); - setId(ID); - } - - @Override - protected void preRun() throws Exception - { - ImportResourceDialog dialog = new ImportResourceDialog(getShell(), TITLE, SWT.OPEN); - if (dialog.open() == ImportResourceDialog.OK) - { - List uris = dialog.getURIs(); - if (uris.size() == 1) - { - sourceURI = uris.get(0); - targetPath = dialog.getTargetPath(); - } - else - { - MessageDialog.openError(getShell(), TITLE, "A single URI must be entered!"); - cancel(); - } - } - else - { - cancel(); - } - } - - @Override - protected void doRun() throws Exception - { - CDOTransaction transaction = getTransaction(); - - // Source ResourceSet - ResourceSet sourceSet = new ResourceSetImpl(); - Map map = sourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap(); - map.put("*", new XMIResourceFactoryImpl()); - sourceSet.setPackageRegistry(transaction.getSession().getPackageRegistry()); - - // Source Resource - Resource source = sourceSet.getResource(sourceURI, true); - List sourceContents = new ArrayList(source.getContents()); - - // Target Resource - Resource target = transaction.createResource(targetPath); - EList targetContents = target.getContents(); - - // Move contents over - for (EObject root : sourceContents) - { - targetContents.add(root); - } - } - - /** - * @author Eike Stepper - */ - public static class ImportResourceDialog extends ResourceDialog - { - private String targetPath = "/"; - - private Text targetText; - - public ImportResourceDialog(Shell parent, String title, int style) - { - super(parent, title, style); - } - - public String getTargetPath() - { - return targetPath; - } - - public void setTargetPath(String targetPath) - { - this.targetPath = targetPath; - } - - @Override - protected Control createDialogArea(Composite parent) - { - Composite composite = (Composite)super.createDialogArea(parent); - - Label separatorLabel1 = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL); - { - FormData data = new FormData(); - data.top = new FormAttachment(uriField, (int)(1.5 * CONTROL_OFFSET)); - data.left = new FormAttachment(0, -CONTROL_OFFSET); - data.right = new FormAttachment(100, CONTROL_OFFSET); - separatorLabel1.setLayoutData(data); - } - - Label label = new Label(composite, SWT.NONE); - label.setText("Target path:"); - { - FormData data = new FormData(); - data.top = new FormAttachment(separatorLabel1, CONTROL_OFFSET); - data.left = new FormAttachment(0, CONTROL_OFFSET); - data.right = new FormAttachment(100, -CONTROL_OFFSET); - label.setLayoutData(data); - } - - targetText = new Text(composite, SWT.BORDER); - { - FormData data = new FormData(); - data.top = new FormAttachment(label, CONTROL_OFFSET); - data.left = new FormAttachment(0, CONTROL_OFFSET); - data.right = new FormAttachment(100, -CONTROL_OFFSET); - targetText.setLayoutData(data); - targetText.setText(targetPath); - targetText.addModifyListener(new ModifyListener() - { - public void modifyText(ModifyEvent e) - { - targetPath = targetText.getText(); - } - }); - } - - Label separatorLabel2 = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL); - { - FormData data = new FormData(); - data.top = new FormAttachment(targetText, (int)(1.5 * CONTROL_OFFSET)); - data.left = new FormAttachment(0, -CONTROL_OFFSET); - data.right = new FormAttachment(100, CONTROL_OFFSET); - separatorLabel2.setLayoutData(data); - } - - return composite; - } - } -} 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 deleted file mode 100644 index 2481c21c10..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; -import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.util.CDOPackageRegistry; - -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.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"; - - private static final String TITLE = "Import Roots"; - - private CDOResource targetResource; - - private transient List 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() throws Exception - { - EList targetContents = targetResource.getContents(); - List resources = getSourceResources(); - for (Resource resource : resources) - { - List contents = new ArrayList(resource.getContents()); - for (EObject root : contents) - { - targetContents.add(root); - } - } - } - - protected List getSourceResources() - { - ResourceSetImpl resourceSet = createSourceResourceSet(); - List resources = new ArrayList(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 deleted file mode 100644 index 95208cbc87..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/LoadResourceAction.java +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOView; -import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor; - -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class LoadResourceAction extends ViewAction -{ - private static final String TITLE = "Load Resource"; - - private String resourcePath; - - public LoadResourceAction(IWorkbenchPage page, CDOView view) - { - super(page, TITLE + INTERACTIVE, "Load a CDO resource", null, view); - } - - @Override - protected void preRun() throws Exception - { - String uri = ViewAction.lastResourceNumber == 0 ? "" : "/res" + ViewAction.lastResourceNumber; - InputDialog dialog = new InputDialog(getShell(), TITLE, "Enter resource path:", uri, null); - if (dialog.open() == InputDialog.OK) - { - resourcePath = dialog.getValue(); - } - else - { - cancel(); - } - } - - @Override - protected void doRun() throws Exception - { - CDOEditor.open(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 deleted file mode 100644 index c591936c53..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ManagePackagesAction.java +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; -import org.eclipse.emf.cdo.internal.ui.dialogs.PackageManagerDialog; - -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public class ManagePackagesAction extends SessionAction -{ - private static final String TITLE = "Package Manager"; - - private static final String TOOL_TIP = "Browse and install model packages"; - - public ManagePackagesAction(IWorkbenchPage page, CDOSession session) - { - super(page, TITLE + INTERACTIVE, TOOL_TIP, null, session); - } - - @Override - protected void preRun() throws Exception - { - PackageManagerDialog dialog = new PackageManagerDialog(getPage(), getSession()); - dialog.open(); - cancel(); - } - - @Override - protected void doRun() 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 deleted file mode 100644 index 9b2a6dad99..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenAuditAction.java +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; -import org.eclipse.emf.cdo.internal.ui.SharedIcons; -import org.eclipse.emf.cdo.internal.ui.dialogs.OpenAuditDialog; - -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; - -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class OpenAuditAction extends AbstractOpenViewAction -{ - private static final String TITLE = "Open Audit"; - - private static final String TOOL_TIP = "Open a historical CDO view"; - - 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() throws Exception - { - getSession().openAudit(new ResourceSetImpl(), timeStamp); - } -} 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 deleted file mode 100644 index a25ae72179..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenResourceEditorAction.java +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOView; -import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor; -import org.eclipse.emf.cdo.ui.CDOViewHistoryEntry; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class OpenResourceEditorAction extends EntryAction -{ - private static final String TITLE = "Open Editor"; - - private static final String TOOL_TIP = "Open a CDO editor for this resource"; - - public OpenResourceEditorAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image, - CDOViewHistoryEntry entry) - { - super(page, TITLE, TOOL_TIP, null, entry); - } - - @Override - protected void doRun() throws Exception - { - CDOView view = getEntry().getView(); - String resourcePath = getEntry().getResourcePath(); - CDOEditor.open(getPage(), view, resourcePath); - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java deleted file mode 100644 index 6b252eb565..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java +++ /dev/null @@ -1,111 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; -import org.eclipse.emf.cdo.common.CDOProtocolConstants; -import org.eclipse.emf.cdo.internal.ui.bundle.OM; -import org.eclipse.emf.cdo.internal.ui.dialogs.OpenSessionDialog; -import org.eclipse.emf.cdo.internal.ui.views.CDOSessionsView; - -import org.eclipse.emf.internal.cdo.CDOSessionFactory; - -import org.eclipse.net4j.util.container.IPluginContainer; -import org.eclipse.net4j.util.ui.actions.LongRunningAction; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class OpenSessionAction extends LongRunningAction -{ - private static final String TITLE = OpenSessionDialog.TITLE; - - private static final String TOOL_TIP = "Open a new CDO session"; - - private String description; - - public OpenSessionAction(IWorkbenchPage page) - { - super(page, TITLE + INTERACTIVE, TOOL_TIP, CDOSessionsView.getAddImageDescriptor()); - } - - @Override - protected void preRun() throws Exception - { - OpenSessionDialog dialog = new OpenSessionDialog(getPage()); - if (dialog.open() == OpenSessionDialog.OK) - { - StringBuilder builder = new StringBuilder(); - builder.append(dialog.getServerDescription()); - builder.append("?repositoryName="); - builder.append(dialog.getRepositoryName()); - if (dialog.isAutomaticPackageRegistry()) - { - builder.append("&automaticPackageRegistry=true"); - } - - if (dialog.isLegacyModelSupport()) - { - builder.append("&legacySupportEnabled=true"); - } - - description = builder.toString(); - } - else - { - cancel(); - } - } - - @Override - protected void doRun() throws Exception - { - CDOSession session = null; - - try - { - String productGroup = CDOSessionFactory.PRODUCT_GROUP; - String type = CDOProtocolConstants.PROTOCOL_NAME; - session = (CDOSession)IPluginContainer.INSTANCE.getElement(productGroup, type, description); - } - catch (RuntimeException ex) - { - OM.LOG.error(ex); - } - - if (session == null) - { - try - { - getShell().getDisplay().syncExec(new Runnable() - { - public void run() - { - try - { - MessageDialog.openError(getShell(), getText(), "Unable to open a session on the specified repository.\n" - + description); - } - catch (RuntimeException ignoe) - { - } - } - }); - } - catch (RuntimeException ignoe) - { - } - } - } -} 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 deleted file mode 100644 index ff7729e30c..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; -import org.eclipse.emf.cdo.internal.ui.SharedIcons; - -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class OpenTransactionAction extends AbstractOpenViewAction -{ - private static final String TITLE = "Open Transaction"; - - private static final String TOOL_TIP = "Open a read-write CDO view"; - - public OpenTransactionAction(IWorkbenchPage page, CDOSession session) - { - super(page, TITLE, TOOL_TIP, SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session); - } - - @Override - protected void doRun() throws Exception - { - getSession().openTransaction(); - } -} 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 deleted file mode 100644 index 1e77c62159..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; -import org.eclipse.emf.cdo.internal.ui.SharedIcons; - -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; - -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class OpenViewAction extends AbstractOpenViewAction -{ - private static final String TITLE = "Open View"; - - private static final String TOOL_TIP = "Open a read-only CDO view"; - - public OpenViewAction(IWorkbenchPage page, CDOSession session) - { - super(page, TITLE, TOOL_TIP, SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session); - } - - @Override - protected void doRun() throws Exception - { - getSession().openView(new ResourceSetImpl()); - } -} 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 deleted file mode 100644 index 03e7be5e00..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewEditorAction.java +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOView; -import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor; - -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class OpenViewEditorAction extends ViewAction -{ - private static final String TITLE = "Open Editor"; - - private static final String TOOL_TIP = "Open a CDO editor for this view"; - - public OpenViewEditorAction(IWorkbenchPage page, CDOView view) - { - super(page, TITLE, TOOL_TIP, null, view); - } - - @Override - protected void doRun() throws Exception - { - CDOEditor.open(getPage(), getView(), null); - } -} 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 deleted file mode 100644 index 056ba8f6f6..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterFilesystemPackagesAction.java +++ /dev/null @@ -1,80 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; -import org.eclipse.emf.cdo.util.EMFUtil; - -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 = "Register Filesystem Packages"; - - private static final String TOOL_TIP = "Register dynamic packages from the filesystem"; - - private static final String[] FILTER_NAMES = { "Ecore models (*.ecore)", "XMI files (*.xmi)", "XML files (*.xml)", - "All files (*.*)" }; - - private static final String[] FILTER_EXTENSIONS = { "ecore", "xmi", "xml", null }; - - public RegisterFilesystemPackagesAction(IWorkbenchPage page, CDOSession session) - { - super(page, TITLE, TOOL_TIP, null, session); - } - - @Override - protected List getEPackages(IWorkbenchPage page, CDOSession session) - { - Shell shell = page.getWorkbenchWindow().getShell(); - FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI); - dialog.setFileName("*.ecore"); - 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 ePackages = new ArrayList(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 deleted file mode 100644 index 9aed0b080a..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterGeneratedPackagesAction.java +++ /dev/null @@ -1,89 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; -import org.eclipse.emf.cdo.internal.ui.bundle.OM; -import org.eclipse.emf.cdo.internal.ui.dialogs.SelectPackageDialog; - -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.util.ArrayList; -import java.util.List; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public class RegisterGeneratedPackagesAction extends RegisterPackagesAction -{ - private static final String TITLE = "Register Generated Packages"; - - private static final String TOOL_TIP = "Register native, legacy or converted packages"; - - private EPackage.Registry registry = EPackage.Registry.INSTANCE; - - public RegisterGeneratedPackagesAction(IWorkbenchPage page, CDOSession session) - { - super(page, TITLE, TOOL_TIP, null, session); - } - - @Override - protected List getEPackages(IWorkbenchPage page, CDOSession session) - { - Shell shell = page.getWorkbenchWindow().getShell(); - SelectPackageDialog dialog = new SelectPackageDialog(shell, "Generated Packages", - "Select one or more packages for registration with the CDO package registry", session.getPackageRegistry() - .keySet()); - - if (dialog.open() == SelectPackageDialog.OK) - { - Set checkedURIs = dialog.getCheckedURIs(); - List ePackages = new ArrayList(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 ""; - } - - return registry.containsKey(uri) ? null : "Package " + uri + " not found."; - } - } -} 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 deleted file mode 100644 index af085733b3..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java +++ /dev/null @@ -1,104 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; -import org.eclipse.emf.cdo.internal.ui.bundle.OM; -import org.eclipse.emf.cdo.util.CDOPackageRegistry; - -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.jface.dialogs.MessageDialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPage; - -import java.util.List; - -/** - * @author Eike Stepper - */ -public abstract class RegisterPackagesAction extends SessionAction -{ - private List 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() 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("Failed to register package " + uri, ex); - } - } - } - - postRegistration(ePackages); - if (errors != 0) - { - final String label = String.valueOf(errors) + (errors == 1 ? " package has" : " packages have"); - final Shell shell = getShell(); - shell.getDisplay().asyncExec(new Runnable() - { - public void run() - { - MessageDialog.openError(shell, getText(), label - + " not been registered due to errors.\nSee the log for details."); - } - }); - } - } - - protected void postRegistration(List ePackages) - { - } - - protected abstract List 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 deleted file mode 100644 index fa3d5db48c..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterSinglePackageAction.java +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; -import org.eclipse.emf.cdo.internal.ui.SharedIcons; -import org.eclipse.emf.cdo.util.CDOPackageType; - -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, - CDOPackageType packageType) - { - super(page, packageURI, "Register the package " + packageURI, getDescriptor(packageType), session); - this.packageURI = packageURI; - } - - @Override - protected List getEPackages(IWorkbenchPage page, CDOSession session) - { - EPackage ePackage = registry.getEPackage(packageURI); - if (ePackage != null) - { - return Collections.singletonList(ePackage); - } - - return Collections.emptyList(); - } - - private static ImageDescriptor getDescriptor(CDOPackageType packageType) - { - switch (packageType) - { - case CONVERTED: - return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_CONVERTED); - - case LEGACY: - return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_LEGACY); - - case NATIVE: - return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_NATIVE); - - 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 deleted file mode 100644 index 13b6f7f83c..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterWorkspacePackagesAction.java +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOSession; -import org.eclipse.emf.cdo.internal.ui.dialogs.OpenResourcesDialog; -import org.eclipse.emf.cdo.util.EMFUtil; - -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 = "Register Workspace Packages"; - - private static final String TOOL_TIP = "Register dynamic packages from the workspace"; - - public RegisterWorkspacePackagesAction(IWorkbenchPage page, CDOSession session) - { - super(page, TITLE, TOOL_TIP, null, session); - } - - @Override - protected List 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 ePackages = new ArrayList(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 deleted file mode 100644 index cbabbc30f7..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java +++ /dev/null @@ -1,84 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOView; -import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor; - -import org.eclipse.emf.internal.cdo.CDOStateMachine; -import org.eclipse.emf.internal.cdo.InternalCDOObject; - -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"; - - private static final String TITLE = "Reload"; - - private List objects = new ArrayList(); - - 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() 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(); - CDOEditor.refresh(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 deleted file mode 100644 index ab9c6dff45..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOView; -import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor; - -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class ReloadViewAction extends ViewAction -{ - private static final String TITLE = "Reload"; - - private static final String TOOL_TIP = "Reload this view"; - - public ReloadViewAction(IWorkbenchPage page, CDOView view) - { - super(page, TITLE, TOOL_TIP, null, view); - } - - @Override - protected void doRun() throws Exception - { - if (getView().reload() != 0) - { - CDOEditor.refresh(getPage(), getView()); - } - } -} 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 deleted file mode 100644 index c1c135ea2a..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOTransaction; -import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.internal.ui.dialogs.RollbackTransactionDialog; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public final class RollbackTransactionAction extends ViewAction -{ - private static final String TITLE = "Rollback"; - - private static final String TOOL_TIP = "Rollback this transaction"; - - private boolean remote; - - 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(); - Dialog dialog = new RollbackTransactionDialog(getPage(), TITLE, "Choose how to rollback this transaction.", - transaction); - switch (dialog.open()) - { - case RollbackTransactionDialog.REMOTE: - remote = true; - break; - case RollbackTransactionDialog.LOCAL: - remote = false; - break; - default: - cancel(); - break; - } - } - - @Override - protected void doRun() throws Exception - { - getTransaction().rollback(remote); - } -} 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 deleted file mode 100644 index 99debcf1cf..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/SessionAction.java +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.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/ViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java deleted file mode 100644 index 926bd4f88e..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.CDOTransaction; -import org.eclipse.emf.cdo.CDOView; - -import org.eclipse.emf.internal.cdo.CDOViewImpl; - -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 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 ((CDOViewImpl)view).toTransaction(); - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java deleted file mode 100644 index b458fefd1b..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java +++ /dev/null @@ -1,97 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.bundle; - -import org.eclipse.emf.cdo.ui.CDOLabelProvider; - -import org.eclipse.net4j.Net4jTransportInjector; -import org.eclipse.net4j.util.internal.ui.security.InteractiveCredentialsProvider; -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.OMPlatform; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.pref.OMPreference; -import org.eclipse.net4j.util.om.pref.OMPreferences; -import org.eclipse.net4j.util.om.trace.OMTracer; -import org.eclipse.net4j.util.security.ResponseNegotiator; -import org.eclipse.net4j.util.ui.UIActivator; - -/** - * The Operations & Maintenance class of this bundle. - * - * @author Eike Stepper - */ -public abstract class OM -{ - public static final String BUNDLE_ID = "org.eclipse.emf.cdo.ui"; //$NON-NLS-1$ - - public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); - - public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ - - public static final OMTracer TEST = BUNDLE.tracer("test"); //$NON-NLS-1$ - - public static final OMTracer TEST_BULK_ADD = TEST.tracer("bulk_add"); //$NON-NLS-1$ - - public static final OMLogger LOG = BUNDLE.logger(); - - public static final OMPreferences PREFS = BUNDLE.preferences(); - - public static final OMPreference PREF_LABEL_DECORATION = // - PREFS.init("PREF_LABEL_DECORATION", CDOLabelProvider.DEFAULT_DECORATION); //$NON-NLS-1$ - - public static final OMPreference PREF_HISTORY_SELECT_PACKAGES = // - PREFS.initArray("PREF_HISTORY_SELECT_PACKAGES"); //$NON-NLS-1$ - - public static final OMPreference PREF_HISTORY_CONNECTORS = // - PREFS.initArray("PREF_HISTORY_CONNECTORS"); //$NON-NLS-1$ - - public static final OMPreference PREF_HISTORY_REPOSITORIES = // - PREFS.initArray("PREF_HISTORY_REPOSITORIES"); //$NON-NLS-1$ - - public static final OMPreference PREF_AUTOMATIC_PACKAGE_REGISTY = // - PREFS.init("PREF_AUTOMATIC_PACKAGE_REGISTY", true); //$NON-NLS-1$ - - public static final OMPreference PREF_LEGACY_MODEL_SUPPORT = // - PREFS.init("PREF_LEGACY_MODEL_SUPPORT", false); //$NON-NLS-1$ - - static void start() - { - if (false) - { - try - { - ResponseNegotiator responseNegotiator = new ResponseNegotiator(); - responseNegotiator.setCredentialsProvider(new InteractiveCredentialsProvider()); - responseNegotiator.activate(); - - Net4jTransportInjector.clientNegotiator = responseNegotiator; - } - catch (Exception ex) - { - LOG.error(ex); - } - } - } - - /** - * @author Eike Stepper - */ - public static final class Activator extends UIActivator - { - public static Activator INSTANCE; - - public Activator() - { - super(BUNDLE); - INSTANCE = this; - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/BulkAddDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/BulkAddDialog.java deleted file mode 100644 index 807f2bf114..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/BulkAddDialog.java +++ /dev/null @@ -1,182 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.dialogs; - -import org.eclipse.net4j.util.ui.StaticContentProvider; -import org.eclipse.net4j.util.ui.UIUtil; - -import org.eclipse.emf.ecore.EReference; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.TitleAreaDialog; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchPage; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class BulkAddDialog extends TitleAreaDialog -{ - public static final String TITLE = "Bulk Add"; - - private IWorkbenchPage page; - - private List features = new ArrayList(); - - private EReference feature; - - private int instances = 100; - - public BulkAddDialog(IWorkbenchPage page, List features) - { - super(new Shell(page.getWorkbenchWindow().getShell())); - setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.MAX | SWT.TITLE | SWT.RESIZE); - this.page = page; - this.features = features; - } - - public IWorkbenchPage getPage() - { - return page; - } - - public List getFeatures() - { - return features; - } - - public EReference getFeature() - { - return feature; - } - - public int getInstances() - { - return instances; - } - - @Override - protected void configureShell(Shell newShell) - { - super.configureShell(newShell); - newShell.setText(TITLE); - } - - @Override - protected Control createDialogArea(Composite parent) - { - Composite composite = new Composite((Composite)super.createDialogArea(parent), SWT.NONE); - composite.setLayoutData(UIUtil.createGridData()); - composite.setLayout(new GridLayout(2, false)); - - setTitle("Select a child type and number of child instances"); - - Label label = new Label(composite, SWT.NONE); - label.setText("Type:"); - label.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); - - final TableViewer featureViewer = new TableViewer(composite, SWT.BORDER | SWT.SINGLE); - featureViewer.getTable().setLayoutData(UIUtil.createGridData(true, true)); - featureViewer.setContentProvider(new StaticContentProvider(features)); - featureViewer.setLabelProvider(new LabelProvider() - { - @Override - public String getText(Object element) - { - return ((EReference)element).getName(); - } - }); - - featureViewer.setInput(features); - featureViewer.addSelectionChangedListener(new ISelectionChangedListener() - { - public void selectionChanged(SelectionChangedEvent event) - { - IStructuredSelection selection = (IStructuredSelection)featureViewer.getSelection(); - feature = selection.isEmpty() ? null : (EReference)selection.getFirstElement(); - dialogChanged(); - } - }); - - new Label(composite, SWT.NONE).setText("Instances:"); - final Text instancesText = new Text(composite, SWT.BORDER); - instancesText.setLayoutData(UIUtil.createGridData(true, false)); - instancesText.setText(String.valueOf(instances)); - instancesText.addModifyListener(new ModifyListener() - { - public void modifyText(ModifyEvent e) - { - try - { - String text = instancesText.getText(); - instances = Integer.parseInt(text); - } - catch (NumberFormatException ex) - { - instances = 0; - } - - dialogChanged(); - } - }); - - return composite; - } - - @Override - protected Control createButtonBar(Composite parent) - { - try - { - return super.createButtonBar(parent); - } - finally - { - dialogChanged(); - } - } - - protected void dialogChanged() - { - getButton(IDialogConstants.OK_ID).setEnabled(false); - if (feature == null) - { - setErrorMessage("Select a feature"); - return; - } - - if (instances == 0) - { - setErrorMessage("Enter a valid number of instances (>0)"); - return; - } - - getButton(IDialogConstants.OK_ID).setEnabled(true); - setErrorMessage(null); - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/IPackageProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/IPackageProvider.java deleted file mode 100644 index 2003814a8e..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/IPackageProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.dialogs; - -import org.eclipse.emf.cdo.CDOSession; - -import org.eclipse.emf.ecore.EPackage; - -import org.eclipse.swt.events.SelectionEvent; - -/** - * TODO Is this used/needed? - * - * @author Eike Stepper - */ -public interface IPackageProvider -{ - public String getTitle(); - - public EPackage getPackage(CDOSession session, SelectionEvent event); -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenAuditDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenAuditDialog.java deleted file mode 100644 index 9f19c208b7..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenAuditDialog.java +++ /dev/null @@ -1,100 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.dialogs; - -import org.eclipse.emf.cdo.internal.ui.SharedIcons; - -import org.eclipse.net4j.util.ui.UIUtil; - -import org.eclipse.jface.dialogs.TitleAreaDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.DateTime; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPage; - -import java.util.Calendar; -import java.util.GregorianCalendar; - -/** - * @author Eike Stepper - */ -public class OpenAuditDialog extends TitleAreaDialog -{ - public static final String TITLE = "Open Audit"; - - private IWorkbenchPage page; - - private DateTime dateControl; - - private DateTime timeControl; - - private long timeStamp; - - public OpenAuditDialog(IWorkbenchPage page) - { - super(new Shell(page.getWorkbenchWindow().getShell())); - this.page = page; - setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.MAX | SWT.TITLE | SWT.RESIZE); - } - - public IWorkbenchPage getPage() - { - return page; - } - - public long getTimeStamp() - { - return timeStamp; - } - - @Override - protected void configureShell(Shell newShell) - { - super.configureShell(newShell); - newShell.setText(TITLE); - } - - @Override - protected Control createDialogArea(Composite parent) - { - Composite composite = new Composite((Composite)super.createDialogArea(parent), SWT.NONE); - composite.setLayoutData(UIUtil.createGridData()); - composite.setLayout(new GridLayout(3, false)); - - setTitle(TITLE); - setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_PACKAGE_MANAGER)); - - new Label(composite, SWT.NONE).setText("Target Time:"); - dateControl = new DateTime(composite, SWT.DATE); - timeControl = new DateTime(composite, SWT.TIME); - - return composite; - } - - @Override - protected void okPressed() - { - GregorianCalendar calendar = new GregorianCalendar(); - calendar.set(Calendar.YEAR, dateControl.getYear()); - calendar.set(Calendar.MONTH, dateControl.getMonth()); - calendar.set(Calendar.DATE, dateControl.getDay()); - calendar.set(Calendar.HOUR_OF_DAY, timeControl.getHours()); - calendar.set(Calendar.MINUTE, timeControl.getMinutes()); - calendar.set(Calendar.SECOND, timeControl.getSeconds()); - - timeStamp = calendar.getTimeInMillis(); - super.okPressed(); - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenResourcesDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenResourcesDialog.java deleted file mode 100644 index fc49e85604..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenResourcesDialog.java +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.dialogs; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog; - -public class OpenResourcesDialog extends FilteredResourcesSelectionDialog -{ - public OpenResourcesDialog(Shell parentShell) - { - super(parentShell, true, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE); - setTitle("Open Resources"); - setInitialPattern("*.ecore"); - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java deleted file mode 100644 index a92c1166e4..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java +++ /dev/null @@ -1,181 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.dialogs; - -import org.eclipse.emf.cdo.internal.ui.SharedIcons; -import org.eclipse.emf.cdo.internal.ui.bundle.OM; - -import org.eclipse.emf.internal.cdo.util.FSMUtil; - -import org.eclipse.net4j.util.collection.IHistory; -import org.eclipse.net4j.util.collection.PreferenceHistory; -import org.eclipse.net4j.util.ui.UIUtil; -import org.eclipse.net4j.util.ui.widgets.HistoryText; -import org.eclipse.net4j.util.ui.widgets.PreferenceButton; - -import org.eclipse.jface.dialogs.TitleAreaDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public class OpenSessionDialog extends TitleAreaDialog -{ - public static final String TITLE = "Open Session"; - - private IWorkbenchPage page; - - private IHistory connectorHistory = new PreferenceHistory(OM.PREF_HISTORY_CONNECTORS); - - private IHistory repositoryHistory = new PreferenceHistory(OM.PREF_HISTORY_REPOSITORIES); - - private HistoryText connectorText; - - private Label exampleLabel; - - private HistoryText repositoryText; - - private PreferenceButton automaticButton; - - private PreferenceButton legacyButton; - - private String serverDescription; - - private String repositoryName; - - private boolean automaticPackageRegistry; - - private boolean legacyModelSupport; - - static - { - OM.PREF_LEGACY_MODEL_SUPPORT.setValue(FSMUtil.isLegacySystemAvailable()); - } - - public OpenSessionDialog(IWorkbenchPage page) - { - super(new Shell(page.getWorkbenchWindow().getShell())); - this.page = page; - setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.MAX | SWT.TITLE | SWT.RESIZE); - } - - public IWorkbenchPage getPage() - { - return page; - } - - public String getServerDescription() - { - return serverDescription; - } - - public String getRepositoryName() - { - return repositoryName; - } - - public boolean isAutomaticPackageRegistry() - { - return automaticPackageRegistry; - } - - public boolean isLegacyModelSupport() - { - return legacyModelSupport; - } - - @Override - protected void configureShell(Shell newShell) - { - super.configureShell(newShell); - newShell.setText(TITLE); - } - - @Override - protected Control createDialogArea(Composite parent) - { - Composite composite = new Composite((Composite)super.createDialogArea(parent), SWT.NONE); - composite.setLayoutData(UIUtil.createGridData()); - composite.setLayout(new GridLayout(2, false)); - - setTitle(TITLE); - setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_PACKAGE_MANAGER)); - - new Label(composite, SWT.NONE).setText("Server Description:"); - connectorText = new HistoryText(composite, SWT.BORDER | SWT.SINGLE, connectorHistory); - connectorText.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); - - if (connectorHistory.isEmpty()) - { - new Label(composite, SWT.NONE); - exampleLabel = new Label(composite, SWT.NONE); - exampleLabel.setText("for example 'tcp://estepper@dev.eclipse.org:2036'"); - exampleLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); - } - - new Label(composite, SWT.NONE).setText("Repository Name:"); - repositoryText = new HistoryText(composite, SWT.BORDER | SWT.SINGLE, repositoryHistory); - repositoryText.getCombo().setLayoutData(new GridData(150, SWT.DEFAULT)); - - new Label(composite, SWT.NONE); - automaticButton = new PreferenceButton(composite, SWT.CHECK, "Automatic Package Registry", - OM.PREF_AUTOMATIC_PACKAGE_REGISTY); - - new Label(composite, SWT.NONE); - legacyButton = new PreferenceButton(composite, SWT.CHECK, "Legacy Model Support", OM.PREF_LEGACY_MODEL_SUPPORT); - legacyButton.getButton().setEnabled(FSMUtil.isLegacySystemAvailable()); - - connectorText.setFocus(); - connectorText.getCombo().addFocusListener(new FocusListener() - { - public void focusGained(FocusEvent e) - { - if (exampleLabel != null) - { - exampleLabel.setVisible(true); - } - } - - public void focusLost(FocusEvent e) - { - if (exampleLabel != null) - { - exampleLabel.setVisible(false); - } - } - }); - - return composite; - } - - @Override - protected void okPressed() - { - serverDescription = connectorText.getText(true); - repositoryName = repositoryText.getText(true); - automaticPackageRegistry = automaticButton.getSelection(true); - legacyModelSupport = legacyButton.getSelection(true); - super.okPressed(); - } - - public void closeWithSuccess() - { - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java deleted file mode 100644 index d8824f1228..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java +++ /dev/null @@ -1,430 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.dialogs; - -import org.eclipse.emf.cdo.CDOSession; -import org.eclipse.emf.cdo.common.model.CDOPackage; -import org.eclipse.emf.cdo.internal.ui.SharedIcons; -import org.eclipse.emf.cdo.internal.ui.actions.RegisterFilesystemPackagesAction; -import org.eclipse.emf.cdo.internal.ui.actions.RegisterGeneratedPackagesAction; -import org.eclipse.emf.cdo.internal.ui.actions.RegisterWorkspacePackagesAction; -import org.eclipse.emf.cdo.ui.CDOItemProvider; -import org.eclipse.emf.cdo.util.CDOPackageRegistry; -import org.eclipse.emf.cdo.util.CDOPackageType; -import org.eclipse.emf.cdo.util.CDOPackageTypeRegistry; - -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.ui.UIUtil; - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.ecore.impl.EPackageImpl; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.TitleAreaDialog; -import org.eclipse.jface.viewers.BaseLabelProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.IWorkbenchPage; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * @author Eike Stepper - */ -public class PackageManagerDialog extends TitleAreaDialog -{ - private static final int REGISTER_GENERATED_PACKAGES_ID = IDialogConstants.CLIENT_ID + 1; - - private static final int REGISTER_WORKSPACE_PACKAGES_ID = IDialogConstants.CLIENT_ID + 2; - - private static final int REGISTER_FILESYSTEM_PACKAGES_ID = IDialogConstants.CLIENT_ID + 3; - - private static final String TITLE = "CDO Package Manager"; - - private static final String EMPTY = ""; - - private IWorkbenchPage page; - - private CDOSession session; - - private TableViewer viewer; - - public PackageManagerDialog(IWorkbenchPage page, CDOSession session) - { - super(new Shell(page.getWorkbenchWindow().getShell())); - this.page = page; - this.session = session; - setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.MAX | SWT.TITLE | SWT.RESIZE); - } - - @Override - protected void configureShell(Shell newShell) - { - super.configureShell(newShell); - newShell.setText(TITLE); - } - - @Override - protected Control createDialogArea(Composite parent) - { - Composite composite = (Composite)super.createDialogArea(parent); - setTitle(CDOItemProvider.getSessionLabel(session)); - setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_PACKAGE_MANAGER)); - - viewer = new TableViewer(composite, SWT.NONE); - Table table = viewer.getTable(); - - table.setHeaderVisible(true); - table.setLayoutData(UIUtil.createGridData()); - addColumn(table, "Package", 400, SWT.LEFT); - addColumn(table, "Registry", 80, SWT.CENTER); - addColumn(table, "Repository", 80, SWT.CENTER); - - viewer.setContentProvider(new ContentProvider()); - viewer.setLabelProvider(new LabelProvider()); - viewer.setInput(session); - - return composite; - } - - @Override - protected void createButtonsForButtonBar(Composite parent) - { - createButton(parent, REGISTER_GENERATED_PACKAGES_ID, "Generated...", false); - createButton(parent, REGISTER_WORKSPACE_PACKAGES_ID, "Workspace...", false); - createButton(parent, REGISTER_FILESYSTEM_PACKAGES_ID, "Filesystem...", false); - createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false); - } - - @Override - protected void buttonPressed(int buttonId) - { - switch (buttonId) - { - case REGISTER_GENERATED_PACKAGES_ID: - new RegisterGeneratedPackagesAction(page, session) - { - @Override - protected void postRegistration(List ePackages) - { - refreshViewer(); - } - }.run(); - break; - - case REGISTER_WORKSPACE_PACKAGES_ID: - new RegisterWorkspacePackagesAction(page, session) - { - @Override - protected void postRegistration(List ePackages) - { - refreshViewer(); - } - }.run(); - break; - - case REGISTER_FILESYSTEM_PACKAGES_ID: - new RegisterFilesystemPackagesAction(page, session) - { - @Override - protected void postRegistration(List ePackages) - { - refreshViewer(); - } - }.run(); - break; - - case IDialogConstants.CLOSE_ID: - close(); - break; - } - } - - protected Image getContentIcon(Content content) - { - return null; - } - - protected String getEPackageText(Object ePackage) - { - if (ePackage == EcorePackage.eINSTANCE) - { - return "ECORE"; - } - - if (ePackage.getClass() == EPackageImpl.class) - { - return "DYNAMIC"; - } - - String uri = EMPTY; - if (ePackage instanceof EPackage.Descriptor) - { - CDOPackageRegistry registry = session.getPackageRegistry(); - for (Map.Entry entry : registry.entrySet()) - { - if (entry.getValue() == ePackage) - { - uri = entry.getKey(); - break; - } - } - } - else - { - uri = ((EPackage)ePackage).getNsURI(); - } - - CDOPackageType packageType = CDOPackageTypeRegistry.INSTANCE.get(uri); - if (packageType == null) - { - return "?"; - } - - return packageType.toString(); - } - - protected String getCDOPackageText(CDOPackage cdoPackage) - { - if (cdoPackage.isSystem()) - { - return "SYSTEM"; - } - - if (!cdoPackage.isPersistent()) - { - return EMPTY; - } - - return cdoPackage.isDynamic() ? "DYNAMIC" : "STATIC"; - } - - private void addColumn(Table table, String title, int width, int alignment) - { - TableColumn column = new TableColumn(table, alignment); - column.setText(title); - column.setWidth(width); - } - - protected void refreshViewer() - { - page.getWorkbenchWindow().getShell().getDisplay().syncExec(new Runnable() - { - public void run() - { - try - { - viewer.refresh(); - } - catch (RuntimeException ignore) - { - } - } - }); - } - - /** - * @author Eike Stepper - */ - public class LabelProvider extends BaseLabelProvider implements ITableLabelProvider - { - public LabelProvider() - { - } - - public String getColumnText(Object element, int columnIndex) - { - if (element instanceof Content) - { - Content content = (Content)element; - switch (columnIndex) - { - case 0: - return content.getPackageURI(); - case 1: - return content.getEPackage() == null ? EMPTY : getEPackageText(content.getEPackage()); - case 2: - return content.getCDOPackage() == null ? EMPTY : getCDOPackageText(content.getCDOPackage()); - } - } - - return element.toString(); - } - - public Image getColumnImage(Object element, int columnIndex) - { - if (element instanceof Content) - { - Content content = (Content)element; - if (columnIndex == 0) - { - return getContentIcon(content); - } - } - - return null; - } - } - - /** - * @author Eike Stepper - */ - public static class ContentProvider implements IStructuredContentProvider - { - private static final Object[] NO_ELEMENTS = {}; - - private CDOSession session; - - public ContentProvider() - { - } - - public void dispose() - { - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - if (newInput instanceof CDOSession) - { - if (!ObjectUtil.equals(session, newInput)) - { - session = (CDOSession)newInput; - } - } - } - - public Object[] getElements(Object inputElement) - { - if (inputElement != session) - { - return NO_ELEMENTS; - } - - Map map = new HashMap(); - for (Entry entry : session.getPackageRegistry().entrySet()) - { - String packageURI = entry.getKey(); - Content content = new Content(packageURI); - map.put(packageURI, content); - content.setEPackage(entry.getValue()); - } - - for (CDOPackage cdoPackage : session.getPackageManager().getPackages()) - { - String packageURI = cdoPackage.getPackageURI(); - Content content = map.get(packageURI); - if (content == null) - { - content = new Content(packageURI); - map.put(packageURI, content); - } - - content.setCDOPackage(cdoPackage); - } - - ArrayList list = new ArrayList(map.values()); - Collections.sort(list); - return list.toArray(new Content[list.size()]); - } - } - - /** - * @author Eike Stepper - */ - public static final class Content implements Comparable - { - private String packageURI; - - private Object ePackage; - - private CDOPackage cdoPackage; - - public Content(String packageURI) - { - this.packageURI = packageURI; - } - - public String getPackageURI() - { - return packageURI; - } - - public Object getEPackage() - { - return ePackage; - } - - public void setEPackage(Object ePackage) - { - this.ePackage = ePackage; - } - - public CDOPackage getCDOPackage() - { - return cdoPackage; - } - - public void setCDOPackage(CDOPackage cdoPackage) - { - this.cdoPackage = cdoPackage; - } - - public int compareTo(Content content) - { - return packageURI.compareTo(content.packageURI); - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - - if (obj instanceof Content) - { - Content that = (Content)obj; - return ObjectUtil.equals(packageURI, that.packageURI); - } - - return false; - } - - @Override - public int hashCode() - { - return ObjectUtil.hashCode(packageURI); - } - - @Override - public String toString() - { - return packageURI; - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java deleted file mode 100644 index 7e20f9cadf..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java +++ /dev/null @@ -1,156 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.dialogs; - -import org.eclipse.emf.cdo.CDOTransaction; - -import org.eclipse.net4j.util.ui.UIUtil; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.TitleAreaDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Eike Stepper - */ -public class RollbackTransactionDialog extends TitleAreaDialog -{ - // public static final String TITLE = "Rollback Transaction"; - - public static final int REMOTE = CANCEL + 1; - - public static final int LOCAL = CANCEL + 2; - - private static final int REMOTE_ID = IDialogConstants.CLIENT_ID + REMOTE; - - private static final int LOCAL_ID = IDialogConstants.CLIENT_ID + LOCAL; - - private IWorkbenchPage page; - - private String title; - - private String description; - - private CDOTransaction transaction; - - public RollbackTransactionDialog(IWorkbenchPage page, String title, String description, CDOTransaction transaction) - { - super(new Shell(page.getWorkbenchWindow().getShell())); - this.page = page; - this.title = title; - this.description = description; - this.transaction = transaction; - setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.MAX | SWT.TITLE | SWT.RESIZE); - } - - public IWorkbenchPage getPage() - { - return page; - } - - @Override - protected void configureShell(Shell newShell) - { - super.configureShell(newShell); - newShell.setText(title); - } - - @Override - protected Control createDialogArea(Composite parent) - { - Composite composite = new Composite((Composite)super.createDialogArea(parent), SWT.NONE); - composite.setLayoutData(UIUtil.createGridData()); - composite.setLayout(new GridLayout(1, false)); - - setTitle(description); - setTitleImage(getShell().getDisplay().getSystemImage(SWT.ICON_QUESTION)); - - Label label = new Label(composite, SWT.NONE); - label.setText(formatMessage()); - label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); - - return composite; - } - - @Override - protected void createButtonsForButtonBar(Composite parent) - { - createButton(parent, REMOTE_ID, "Remote Rollback", true); - createButton(parent, LOCAL_ID, "Local Rollback", false); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - @Override - protected void buttonPressed(int buttonId) - { - if (buttonId == REMOTE_ID) - { - setReturnCode(REMOTE); - close(); - } - else if (buttonId == LOCAL_ID) - { - setReturnCode(LOCAL); - close(); - } - else - { - super.buttonPressed(buttonId); - } - } - - protected String formatMessage() - { - int newObjects = transaction.getNewObjects().size(); - int dirtyObjects = transaction.getDirtyObjects().size(); - int count = (newObjects > 0 ? 1 : 0) + (dirtyObjects > 0 ? 1 : 0); - - StringBuilder builder = new StringBuilder(); - builder.append("This transaction contains "); - - if (newObjects > 0) - { - builder.append(newObjects); - builder.append(" new object"); - if (newObjects > 1) - { - builder.append("s"); - } - } - - if (dirtyObjects > 0) - { - if (count > 0) - { - builder.append(" and "); - } - - builder.append(dirtyObjects); - builder.append(" dirty object"); - if (dirtyObjects > 1) - { - builder.append("s"); - } - } - - builder.append(".\n\nBe careful, rolling back to local state can result\n" - + "in visible state that is different from the remote state!"); - builder.append("\n\nAre you sure to rollback this transaction?"); - return builder.toString(); - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java deleted file mode 100644 index a79be83ee0..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java +++ /dev/null @@ -1,192 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.dialogs; - -import org.eclipse.emf.cdo.internal.ui.SharedIcons; -import org.eclipse.emf.cdo.internal.ui.bundle.OM; -import org.eclipse.emf.cdo.util.CDOPackageType; -import org.eclipse.emf.cdo.util.CDOPackageTypeRegistry; - -import org.eclipse.net4j.util.ui.UIUtil; -import org.eclipse.net4j.util.ui.widgets.BaseDialog; - -import org.eclipse.emf.ecore.EcorePackage; - -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableColorProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public class SelectPackageDialog extends BaseDialog -{ - private static final Set NO_URIS = Collections.emptySet(); - - private Set excludedURIs = new HashSet(); - - private Set checkedURIs = new HashSet(); - - public SelectPackageDialog(Shell shell, String title, String message, Set excludedURIs) - { - super(shell, DEFAULT_SHELL_STYLE | SWT.APPLICATION_MODAL, title, message, OM.Activator.INSTANCE.getDialogSettings()); - this.excludedURIs = excludedURIs; - } - - public SelectPackageDialog(Shell shell, String title, String message) - { - this(shell, title, message, NO_URIS); - } - - public Set getCheckedURIs() - { - return checkedURIs; - } - - @Override - protected void createUI(Composite parent) - { - CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.SINGLE | SWT.BORDER); - viewer.getTable().setLayoutData(UIUtil.createGridData()); - viewer.setContentProvider(new PackageContentProvider()); - viewer.setLabelProvider(new PackageLabelProvider()); - viewer.setInput(CDOPackageTypeRegistry.INSTANCE); - - String[] uris = OM.PREF_HISTORY_SELECT_PACKAGES.getValue(); - if (uris != null) - { - viewer.setCheckedElements(uris); - } - - setCurrentViewer(viewer); - } - - @Override - protected void okPressed() - { - Object[] checkedElements = getCurrentViewer().getCheckedElements(); - for (Object checkedElement : checkedElements) - { - checkedURIs.add((String)checkedElement); - } - - OM.PREF_HISTORY_SELECT_PACKAGES.setValue(checkedURIs.toArray(new String[checkedURIs.size()])); - super.okPressed(); - } - - /** - * @author Eike Stepper - */ - private class PackageContentProvider implements IStructuredContentProvider - { - public PackageContentProvider() - { - } - - public void dispose() - { - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - } - - public Object[] getElements(Object inputElement) - { - Set uris = new HashSet(CDOPackageTypeRegistry.INSTANCE.keySet()); - uris.removeAll(excludedURIs); - - List elements = new ArrayList(uris); - Collections.sort(elements); - return elements.toArray(); - } - } - - /** - * @author Eike Stepper - */ - private class PackageLabelProvider extends LabelProvider implements ITableLabelProvider, ITableColorProvider - { - private final Color red = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_MAGENTA); - - public PackageLabelProvider() - { - } - - @Override - public String getText(Object element) - { - return element.toString(); - } - - @Override - public Image getImage(Object element) - { - if (element instanceof String) - { - CDOPackageType packageType = CDOPackageTypeRegistry.INSTANCE.get(element); - switch (packageType) - { - case CONVERTED: - return SharedIcons.getImage(SharedIcons.OBJ_EPACKAGE_CONVERTED); - - case LEGACY: - return SharedIcons.getImage(SharedIcons.OBJ_EPACKAGE_LEGACY); - - case NATIVE: - return SharedIcons.getImage(SharedIcons.OBJ_EPACKAGE_NATIVE); - } - } - - return null; - } - - public String getColumnText(Object element, int columnIndex) - { - return getText(element); - } - - public Image getColumnImage(Object element, int columnIndex) - { - return getImage(element); - } - - public Color getBackground(Object element, int columnIndex) - { - return null; - } - - public Color getForeground(Object element, int columnIndex) - { - if (EcorePackage.eINSTANCE.getNsURI().equals(element)) - { - return red; - } - - return null; - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java deleted file mode 100644 index c42e1cb17f..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java +++ /dev/null @@ -1,653 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.editor; - -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.internal.ui.actions.ImportRootsAction; -import org.eclipse.emf.cdo.internal.ui.actions.ReloadObjectsAction; - -import org.eclipse.emf.common.ui.viewer.IViewerProvider; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; -import org.eclipse.emf.edit.ui.action.ControlAction; -import org.eclipse.emf.edit.ui.action.CreateChildAction; -import org.eclipse.emf.edit.ui.action.CreateSiblingAction; -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; -import org.eclipse.emf.edit.ui.action.LoadResourceAction; -import org.eclipse.emf.edit.ui.action.ValidateAction; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IContributionManager; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.action.SubContributionItem; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; - -import java.util.ArrayList; -import java.util.Collection; - -/** - * @author Eike Stepper - * @generated - */ -public class CDOActionBarContributor extends EditingDomainActionBarContributor implements ISelectionChangedListener -{ - /** - * @ADDED - */ - public static final String LOAD_RESOURCE_ID = "load-resource"; - - /** - * @ADDED - */ - public static final String REFRESH_VIEWER_ID = "refresh-viewer"; - - /** - * @ADDED - */ - protected ImportRootsAction importRootsAction; - - /** - * @ADDED - */ - protected ReloadObjectsAction reloadObjectsAction; - - /** - * This keeps track of the active editor. - * - * @generated - */ - protected IEditorPart activeEditorPart; - - /** - * This keeps track of the current selection provider. - * - * @generated - */ - protected ISelectionProvider selectionProvider; - - /** - * This action opens the Properties view. - * - * @generated - */ - protected IAction showPropertiesViewAction = new Action(PluginDelegator.INSTANCE - .getString("_UI_ShowPropertiesView_menu_item")) - { - @Override - public void run() - { - try - { - getPage().showView("org.eclipse.ui.views.PropertySheet"); - } - catch (PartInitException exception) - { - PluginDelegator.INSTANCE.log(exception); - } - } - }; - - /** - * This action refreshes the viewer of the current editor if the editor implements - * {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}. - * - * @generated - */ - protected IAction refreshViewerAction = new Action(PluginDelegator.INSTANCE.getString("_UI_RefreshViewer_menu_item")) - { - @Override - public boolean isEnabled() - { - return activeEditorPart instanceof IViewerProvider; - } - - @Override - public void run() - { - if (activeEditorPart instanceof IViewerProvider) - { - Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer(); - if (viewer != null) - { - viewer.refresh(); - } - } - } - }; - - /** - * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor - * generated for the current selection by the item provider. - * - * @generated - */ - protected Collection createChildActions; - - /** - * This is the menu manager into which menu contribution items should be added for CreateChild actions. - * - * @generated - */ - protected IMenuManager createChildMenuManager; - - /** - * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor - * generated for the current selection by the item provider. - * - * @generated - */ - protected Collection createSiblingActions; - - /** - * This is the menu manager into which menu contribution items should be added for CreateSibling actions. - * - * @generated - */ - protected IMenuManager createSiblingMenuManager; - - /** - * This creates an instance of the contributor. - * - * @generated NOT - */ - public CDOActionBarContributor() - { - super(ADDITIONS_LAST_STYLE); - loadResourceAction = new LoadResourceAction(); - loadResourceAction.setId(LOAD_RESOURCE_ID); - - importRootsAction = new ImportRootsAction(); - importRootsAction.setId(ImportRootsAction.ID); - - reloadObjectsAction = new ReloadObjectsAction(); - - validateAction = new ValidateAction(); - controlAction = new ControlAction(); - } - - /** - * This adds Separators for editor additions to the tool bar. - * - * @generated - */ - @Override - public void contributeToToolBar(IToolBarManager toolBarManager) - { - toolBarManager.add(new Separator("cdo-settings")); - toolBarManager.add(new Separator("cdo-additions")); - } - - /** - * This adds to the menu bar a menu and some separators for editor additions, as well as the sub-menus for object - * creation items. - * - * @generated - */ - @Override - public void contributeToMenu(IMenuManager menuManager) - { - super.contributeToMenu(menuManager); - - IMenuManager submenuManager = new MenuManager(PluginDelegator.INSTANCE.getString("_UI_CDOEditor_menu"), - "org.eclipse.emf.cdo.internal.ui.editorMenuID"); - menuManager.insertAfter("additions", submenuManager); - submenuManager.add(new Separator("settings")); - submenuManager.add(new Separator("actions")); - submenuManager.add(new Separator("additions")); - submenuManager.add(new Separator("additions-end")); - - // Prepare for CreateChild item addition or removal. - // - createChildMenuManager = new MenuManager(PluginDelegator.INSTANCE.getString("_UI_CreateChild_menu_item")); - submenuManager.insertBefore("additions", createChildMenuManager); - - // Prepare for CreateSibling item addition or removal. - // - createSiblingMenuManager = new MenuManager(PluginDelegator.INSTANCE.getString("_UI_CreateSibling_menu_item")); - submenuManager.insertBefore("additions", createSiblingMenuManager); - - // Force an update because Eclipse hides empty menus now. - // - submenuManager.addMenuListener(new IMenuListener() - { - public void menuAboutToShow(IMenuManager menuManager) - { - menuManager.updateAll(true); - } - }); - - addGlobalActions(submenuManager); - } - - /** - * When the active editor changes, this remembers the change and registers with it as a selection provider. - * - * @generated - */ - @Override - public void setActiveEditor(IEditorPart part) - { - super.setActiveEditor(part); - activeEditorPart = part; - - // Switch to the new selection provider. - // - if (selectionProvider != null) - { - selectionProvider.removeSelectionChangedListener(this); - } - if (part == null) - { - selectionProvider = null; - } - else - { - selectionProvider = part.getSite().getSelectionProvider(); - selectionProvider.addSelectionChangedListener(this); - - // Fake a selection changed event to update the menus. - // - if (selectionProvider.getSelection() != null) - { - selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection())); - } - } - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, handling - * {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings that can be - * added to the selected object and updating the menus accordingly. - * - * @generated - */ - public void selectionChangedGen(SelectionChangedEvent event) - { - // Remove any menu items for old selection. - // - if (createChildMenuManager != null) - { - depopulateManager(createChildMenuManager, createChildActions); - } - if (createSiblingMenuManager != null) - { - depopulateManager(createSiblingMenuManager, createSiblingActions); - } - - // Query the new selection for appropriate new child/sibling descriptors - // - Collection newChildDescriptors = null; - Collection newSiblingDescriptors = null; - - ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) - { - Object object = ((IStructuredSelection)selection).getFirstElement(); - - EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); - - newChildDescriptors = domain.getNewChildDescriptors(object, null); - newSiblingDescriptors = domain.getNewChildDescriptors(null, object); - } - - // Generate actions for selection; populate and redraw the menus. - // - createChildActions = generateCreateChildActions(newChildDescriptors, selection); - createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection); - - if (createChildMenuManager != null) - { - populateManager(createChildMenuManager, createChildActions, null); - createChildMenuManager.update(true); - } - if (createSiblingMenuManager != null) - { - populateManager(createSiblingMenuManager, createSiblingActions, null); - createSiblingMenuManager.update(true); - } - } - - /** - * @ADDED - */ - public void selectionChanged(SelectionChangedEvent event) - { - // Remove any menu items for old selection. - // - if (createChildMenuManager != null) - { - depopulateManager(createChildMenuManager, createChildActions); - } - if (createSiblingMenuManager != null) - { - depopulateManager(createSiblingMenuManager, createSiblingActions); - } - - // Query the new selection for appropriate new child/sibling descriptors - // - Collection newChildDescriptors = null; - Collection newSiblingDescriptors = null; - - ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection) - { - if (reloadObjectsAction != null) - { - reloadObjectsAction.selectionChanged((IStructuredSelection)selection); - } - - if (((IStructuredSelection)selection).size() == 1) - { - Object object = ((IStructuredSelection)selection).getFirstElement(); - - EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); - - newChildDescriptors = domain.getNewChildDescriptors(object, null); - newSiblingDescriptors = domain.getNewChildDescriptors(null, object); - - if (importRootsAction != null) - { - if (object instanceof CDOResource) - { - importRootsAction.setTargetResource((CDOResource)object); - } - else - { - importRootsAction.setTargetResource(null); - } - } - } - } - - // Generate actions for selection; populate and redraw the menus. - // - createChildActions = generateCreateChildActions(newChildDescriptors, selection); - createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection); - - if (createChildMenuManager != null) - { - populateManager(createChildMenuManager, createChildActions, null); - createChildMenuManager.update(true); - } - if (createSiblingMenuManager != null) - { - populateManager(createSiblingMenuManager, createSiblingActions, null); - createSiblingMenuManager.update(true); - } - } - - /** - * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in - * descriptors, and returns the collection of these actions. - * - * @generated - */ - protected Collection generateCreateChildActions(Collection descriptors, ISelection selection) - { - Collection actions = new ArrayList(); - if (descriptors != null) - { - for (Object descriptor : descriptors) - { - actions.add(new CreateChildAction(activeEditorPart, selection, descriptor)); - } - } - return actions; - } - - /** - * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in - * descriptors, and returns the collection of these actions. - * - * @generated - */ - protected Collection generateCreateSiblingActions(Collection descriptors, ISelection selection) - { - Collection actions = new ArrayList(); - if (descriptors != null) - { - for (Object descriptor : descriptors) - { - actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor)); - } - } - return actions; - } - - /** - * This populates the specified manager with {@link org.eclipse.jface.action.ActionContributionItem}s - * based on the {@link org.eclipse.jface.action.IAction}s contained in the actions collection, by - * inserting them before the specified contribution item contributionID. If contributionID - * is null, they are simply added. - * - * @generated - */ - protected void populateManager(IContributionManager manager, Collection actions, - String contributionID) - { - if (actions != null) - { - for (IAction action : actions) - { - if (contributionID != null) - { - manager.insertBefore(contributionID, action); - } - else - { - manager.add(action); - } - } - } - } - - /** - * This removes from the specified manager all {@link org.eclipse.jface.action.ActionContributionItem}s - * based on the {@link org.eclipse.jface.action.IAction}s contained in the actions collection. - * - * @generated - */ - protected void depopulateManager(IContributionManager manager, Collection actions) - { - if (actions != null) - { - IContributionItem[] items = manager.getItems(); - for (int i = 0; i < items.length; i++) - { - // Look into SubContributionItems - // - IContributionItem contributionItem = items[i]; - while (contributionItem instanceof SubContributionItem) - { - contributionItem = ((SubContributionItem)contributionItem).getInnerItem(); - } - - // Delete the ActionContributionItems with matching action. - // - if (contributionItem instanceof ActionContributionItem) - { - IAction action = ((ActionContributionItem)contributionItem).getAction(); - if (actions.contains(action)) - { - manager.remove(contributionItem); - } - } - } - } - } - - /** - * This populates the pop-up menu before it appears. - * - * @generated - */ - @Override - public void menuAboutToShow(IMenuManager menuManager) - { - super.menuAboutToShow(menuManager); - MenuManager submenuManager = null; - - submenuManager = new MenuManager(PluginDelegator.INSTANCE.getString("_UI_CreateChild_menu_item")); - populateManager(submenuManager, createChildActions, null); - menuManager.insertBefore("edit", submenuManager); - - submenuManager = new MenuManager(PluginDelegator.INSTANCE.getString("_UI_CreateSibling_menu_item")); - populateManager(submenuManager, createSiblingActions, null); - menuManager.insertBefore("edit", submenuManager); - } - - /** - * This inserts global actions before the "additions-end" separator. - * - * @generated - */ - protected void addGlobalActionsGen(IMenuManager menuManager) - { - menuManager.insertAfter("additions-end", new Separator("ui-actions")); - menuManager.insertAfter("ui-actions", showPropertiesViewAction); - - refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); - menuManager.insertAfter("ui-actions", refreshViewerAction); - - super.addGlobalActions(menuManager); - } - - /** - * @ADDED - */ - @Override - protected void addGlobalActions(IMenuManager menuManager) - { - menuManager.insertAfter("additions-end", new Separator("ui-actions")); - menuManager.insertAfter("ui-actions", showPropertiesViewAction); - - refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); - refreshViewerAction.setId(REFRESH_VIEWER_ID); - menuManager.insertAfter("ui-actions", refreshViewerAction); - menuManager.insertBefore(refreshViewerAction.getId(), reloadObjectsAction); - super.addGlobalActions(menuManager); - - if (loadResourceAction != null) - { - if (importRootsAction != null) - { - menuManager.insertAfter(loadResourceAction.getId(), importRootsAction); - } - } - else - { - if (importRootsAction != null) - { - menuManager.insertBefore("additions-end", importRootsAction); - } - - menuManager.insertBefore("additions-end", new Separator()); - } - } - - /** - * This ensures that a delete action will clean up all references to deleted objects. - * - * @generated - */ - @Override - protected boolean removeAllReferencesOnDelete() - { - return true; - } - - /** - * @ADDED - */ - @Override - public void activate() - { - if (importRootsAction != null) - { - importRootsAction.setActiveWorkbenchPart(activeEditor); - Object input = ((CDOEditor)getActiveEditor()).getViewer().getInput(); - if (input instanceof CDOResource) - { - importRootsAction.setTargetResource((CDOResource)input); - } - else - { - importRootsAction.setTargetResource(null); - } - } - - if (reloadObjectsAction != null) - { - reloadObjectsAction.setActiveWorkbenchPart(activeEditor); - } - - super.activate(); - } - - /** - * @ADDED - */ - @Override - public void deactivate() - { - if (importRootsAction != null) - { - importRootsAction.setActiveWorkbenchPart(null); - importRootsAction.setTargetResource(null); - } - - if (reloadObjectsAction != null) - { - reloadObjectsAction.setActiveWorkbenchPart(null); - } - - super.deactivate(); - } - - /** - * @ADDED - */ - @Override - public void update() - { - super.update(); - if (importRootsAction != null) - { - importRootsAction.update(); - } - - if (reloadObjectsAction != null) - { - reloadObjectsAction.update(); - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java deleted file mode 100644 index 0fc8889282..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java +++ /dev/null @@ -1,2339 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.editor; - -import org.eclipse.emf.cdo.CDOObject; -import org.eclipse.emf.cdo.CDOTransaction; -import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.common.model.CDOClass; -import org.eclipse.emf.cdo.common.model.CDOPackage; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.internal.ui.SharedIcons; -import org.eclipse.emf.cdo.internal.ui.bundle.OM; -import org.eclipse.emf.cdo.internal.ui.dialogs.BulkAddDialog; -import org.eclipse.emf.cdo.internal.ui.dialogs.RollbackTransactionDialog; -import org.eclipse.emf.cdo.ui.CDOEventHandler; -import org.eclipse.emf.cdo.ui.CDOLabelProvider; -import org.eclipse.emf.cdo.util.CDOUtil; - -import org.eclipse.emf.internal.cdo.CDOLegacyImpl; -import org.eclipse.emf.internal.cdo.CDOStateMachine; -import org.eclipse.emf.internal.cdo.CDOTransactionImpl; -import org.eclipse.emf.internal.cdo.InternalCDOObject; - -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.transaction.TransactionException; -import org.eclipse.net4j.util.ui.actions.LongRunningAction; -import org.eclipse.net4j.util.ui.actions.SafeAction; - -import org.eclipse.emf.common.command.BasicCommandStack; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CommandStack; -import org.eclipse.emf.common.command.CommandStackListener; -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.ui.MarkerHelper; -import org.eclipse.emf.common.ui.editor.ProblemEditorPart; -import org.eclipse.emf.common.ui.viewer.IViewerProvider; -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.Diagnostic; -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.EReference; -import org.eclipse.emf.ecore.EValidator; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.util.EContentAdapter; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.edit.EMFEditPlugin; -import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; -import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator; -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; -import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; -import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor; -import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter; -import org.eclipse.emf.edit.ui.dnd.LocalTransfer; -import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider; -import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper; -import org.eclipse.emf.edit.ui.util.EditUIUtil; -import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.dialogs.SaveAsDialog; -import org.eclipse.ui.ide.IGotoMarker; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.MultiPageEditorPart; -import org.eclipse.ui.views.contentoutline.ContentOutline; -import org.eclipse.ui.views.contentoutline.ContentOutlinePage; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; -import org.eclipse.ui.views.properties.IPropertySheetPage; -import org.eclipse.ui.views.properties.PropertySheet; -import org.eclipse.ui.views.properties.PropertySheetPage; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.EventObject; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Eike Stepper - * @generated - */ -public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProvider, ISelectionProvider, - IMenuListener, IViewerProvider, IGotoMarker -{ - /** - * @ADDED - */ - public static final String EDITOR_ID = "org.eclipse.emf.cdo.ui.CDOEditor"; - - /** - * @ADDED - */ - private CDOView view; - - /** - * @ADDED - */ - private Object viewerInput; - - /** - * @ADDED - */ - private CDOEventHandler eventHandler; - - /** - * This keeps track of the editing domain that is used to track all changes to the model. - * - * @generated - */ - protected AdapterFactoryEditingDomain editingDomain; - - /** - * This is the one adapter factory used for providing views of the model. - * - * @generated - */ - protected ComposedAdapterFactory adapterFactory; - - /** - * This is the content outline page. - * - * @generated - */ - protected IContentOutlinePage contentOutlinePage; - - /** - * This is a kludge... - * - * @generated - */ - protected IStatusLineManager contentOutlineStatusLineManager; - - /** - * This is the content outline page's viewer. - * - * @generated - */ - protected TreeViewer contentOutlineViewer; - - /** - * This is the property sheet page. - * - * @generated - */ - protected PropertySheetPage propertySheetPage; - - /** - * This is the viewer that shadows the selection in the content outline. The parent relation must be correctly defined - * for this to work. - * - * @generated - */ - protected TreeViewer selectionViewer; - - /** - * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content - * outline viewer. - * - * @generated - */ - protected Viewer currentViewer; - - /** - * This listens to which ever viewer is active. - * - * @generated - */ - protected ISelectionChangedListener selectionChangedListener; - - /** - * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this - * editor. - * - * @generated - */ - protected Collection selectionChangedListeners = new ArrayList(); - - /** - * This keeps track of the selection of the editor as a whole. - * - * @generated - */ - protected ISelection editorSelection = StructuredSelection.EMPTY; - - /** - * The MarkerHelper is responsible for creating workspace resource markers presented in Eclipse's Problems View. - * - * @generated - */ - protected MarkerHelper markerHelper = new EditUIMarkerHelper(); - - /** - * This listens for when the outline becomes active - * - * @generated - */ - protected IPartListener partListener = new IPartListener() - { - public void partActivated(IWorkbenchPart p) - { - if (p instanceof ContentOutline) - { - if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) - { - getActionBarContributor().setActiveEditor(CDOEditor.this); - - setCurrentViewer(contentOutlineViewer); - } - } - else if (p instanceof PropertySheet) - { - if (((PropertySheet)p).getCurrentPage() == propertySheetPage) - { - getActionBarContributor().setActiveEditor(CDOEditor.this); - handleActivate(); - } - } - else if (p == CDOEditor.this) - { - handleActivate(); - } - } - - public void partBroughtToTop(IWorkbenchPart p) - { - // Ignore. - } - - public void partClosed(IWorkbenchPart p) - { - // Ignore. - } - - public void partDeactivated(IWorkbenchPart p) - { - // Ignore. - } - - public void partOpened(IWorkbenchPart p) - { - // Ignore. - } - }; - - /** - * Resources that have been removed since last activation. - * - * @generated - */ - protected Collection removedResources = new ArrayList(); - - /** - * Resources that have been changed since last activation. - * - * @generated - */ - protected Collection changedResources = new ArrayList(); - - /** - * Resources that have been saved. - * - * @generated - */ - protected Collection savedResources = new ArrayList(); - - /** - * Map to store the diagnostic associated with a resource. - * - * @generated - */ - protected Map resourceToDiagnosticMap = new LinkedHashMap(); - - /** - * Controls whether the problem indication should be updated. - * - * @generated - */ - protected boolean updateProblemIndication = true; - - /** - * Adapter used to update the problem indication when resources are demanded loaded. - * - * @generated - */ - protected EContentAdapter problemIndicationAdapter = new EContentAdapter() - { - @Override - public void notifyChanged(Notification notification) - { - if (notification.getNotifier() instanceof Resource) - { - switch (notification.getFeatureID(Resource.class)) - { - case Resource.RESOURCE__IS_LOADED: - case Resource.RESOURCE__ERRORS: - case Resource.RESOURCE__WARNINGS: - { - Resource resource = (Resource)notification.getNotifier(); - Diagnostic diagnostic = analyzeResourceProblems(resource, null); - if (diagnostic.getSeverity() != Diagnostic.OK) - { - resourceToDiagnosticMap.put(resource, diagnostic); - } - else - { - resourceToDiagnosticMap.remove(resource); - } - - if (updateProblemIndication) - { - getSite().getShell().getDisplay().asyncExec(new Runnable() - { - public void run() - { - updateProblemIndication(); - } - }); - } - break; - } - } - } - else - { - super.notifyChanged(notification); - } - } - - @Override - protected void setTarget(Resource target) - { - basicSetTarget(target); - } - - @Override - protected void unsetTarget(Resource target) - { - basicUnsetTarget(target); - } - }; - - /** - * This listens for workspace changes. - * - * @generated - */ - protected IResourceChangeListener resourceChangeListener = new IResourceChangeListener() - { - public void resourceChanged(IResourceChangeEvent event) - { - IResourceDelta delta = event.getDelta(); - try - { - class ResourceDeltaVisitor implements IResourceDeltaVisitor - { - protected ResourceSet resourceSet = editingDomain.getResourceSet(); - - protected Collection changedResources = new ArrayList(); - - protected Collection removedResources = new ArrayList(); - - public boolean visit(IResourceDelta delta) - { - if (delta.getResource().getType() == IResource.FILE) - { - if (delta.getKind() == IResourceDelta.REMOVED || delta.getKind() == IResourceDelta.CHANGED - && delta.getFlags() != IResourceDelta.MARKERS) - { - Resource resource = resourceSet.getResource(URI.createURI(delta.getFullPath().toString()), false); - if (resource != null) - { - if (delta.getKind() == IResourceDelta.REMOVED) - { - removedResources.add(resource); - } - else if (!savedResources.remove(resource)) - { - changedResources.add(resource); - } - } - } - } - - return true; - } - - public Collection getChangedResources() - { - return changedResources; - } - - public Collection getRemovedResources() - { - return removedResources; - } - } - - ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); - delta.accept(visitor); - - if (!visitor.getRemovedResources().isEmpty()) - { - removedResources.addAll(visitor.getRemovedResources()); - if (!isDirty()) - { - getSite().getShell().getDisplay().asyncExec(new Runnable() - { - public void run() - { - getSite().getPage().closeEditor(CDOEditor.this, false); - CDOEditor.this.dispose(); - } - }); - } - } - - if (!visitor.getChangedResources().isEmpty()) - { - changedResources.addAll(visitor.getChangedResources()); - if (getSite().getPage().getActiveEditor() == CDOEditor.this) - { - getSite().getShell().getDisplay().asyncExec(new Runnable() - { - public void run() - { - handleActivate(); - } - }); - } - } - } - catch (CoreException exception) - { - PluginDelegator.INSTANCE.log(exception); - } - } - }; - - /** - * Handles activation of the editor or it's associated views. - * - * @generated - */ - protected void handleActivate() - { - // Recompute the read only state. - // - if (editingDomain.getResourceToReadOnlyMap() != null) - { - editingDomain.getResourceToReadOnlyMap().clear(); - - // Refresh any actions that may become enabled or disabled. - // - setSelection(getSelection()); - } - - if (!removedResources.isEmpty()) - { - if (handleDirtyConflict()) - { - getSite().getPage().closeEditor(CDOEditor.this, false); - CDOEditor.this.dispose(); - } - else - { - removedResources.clear(); - changedResources.clear(); - savedResources.clear(); - } - } - else if (!changedResources.isEmpty()) - { - changedResources.removeAll(savedResources); - handleChangedResources(); - changedResources.clear(); - savedResources.clear(); - } - } - - /** - * Handles what to do with changed resources on activation. - * - * @generated - */ - protected void handleChangedResources() - { - if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) - { - if (isDirty()) - { - changedResources.addAll(editingDomain.getResourceSet().getResources()); - } - editingDomain.getCommandStack().flush(); - - updateProblemIndication = false; - for (Resource resource : changedResources) - { - if (resource.isLoaded()) - { - resource.unload(); - try - { - resource.load(Collections.EMPTY_MAP); - } - catch (IOException exception) - { - if (!resourceToDiagnosticMap.containsKey(resource)) - { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - } - } - } - - if (AdapterFactoryEditingDomain.isStale(editorSelection)) - { - setSelection(StructuredSelection.EMPTY); - } - - updateProblemIndication = true; - updateProblemIndication(); - } - } - - /** - * Updates the problems indication with the information described in the specified diagnostic. - * - * - * @generated - */ - protected void updateProblemIndication() - { - if (updateProblemIndication) - { - BasicDiagnostic diagnostic = new BasicDiagnostic(Diagnostic.OK, "org.eclipse.emf.cdo.ui.editor", 0, null, - new Object[] { editingDomain.getResourceSet() }); - for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) - { - if (childDiagnostic.getSeverity() != Diagnostic.OK) - { - diagnostic.add(childDiagnostic); - } - } - - int lastEditorPage = getPageCount() - 1; - if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) - { - ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic); - if (diagnostic.getSeverity() != Diagnostic.OK) - { - setActivePage(lastEditorPage); - } - } - else if (diagnostic.getSeverity() != Diagnostic.OK) - { - ProblemEditorPart problemEditorPart = new ProblemEditorPart(); - problemEditorPart.setDiagnostic(diagnostic); - problemEditorPart.setMarkerHelper(markerHelper); - try - { - addPage(++lastEditorPage, problemEditorPart, getEditorInput()); - setPageText(lastEditorPage, problemEditorPart.getPartName()); - setActivePage(lastEditorPage); - showTabs(); - } - catch (PartInitException exception) - { - PluginDelegator.INSTANCE.log(exception); - } - } - - if (markerHelper.hasMarkers(editingDomain.getResourceSet())) - { - markerHelper.deleteMarkers(editingDomain.getResourceSet()); - if (diagnostic.getSeverity() != Diagnostic.OK) - { - try - { - markerHelper.createMarkers(diagnostic); - } - catch (CoreException exception) - { - PluginDelegator.INSTANCE.log(exception); - } - } - } - } - } - - /** - * Shows a dialog that asks if conflicting changes should be discarded. - * - * @generated - */ - protected boolean handleDirtyConflict() - { - return MessageDialog.openQuestion(getSite().getShell(), getString("_UI_FileConflict_label"), - getString("_WARN_FileConflict")); - } - - /** - * This creates a model editor. - * - * @generated - */ - public CDOEditor() - { - super(); - initializeEditingDomain(); - } - - /** - * This sets up the editing domain for the model editor. - * - * @generated - */ - protected void initializeEditingDomainGen() - { - // Create an adapter factory that yields item providers. - // - adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); - - adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); - - // Create the command stack that will notify this editor as commands are executed. - // - BasicCommandStack commandStack = new BasicCommandStack(); - - // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus. - // - commandStack.addCommandStackListener(new CommandStackListener() - { - public void commandStackChanged(final EventObject event) - { - getContainer().getDisplay().asyncExec(new Runnable() - { - public void run() - { - firePropertyChange(IEditorPart.PROP_DIRTY); - - // Try to select the affected objects. - // - Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand(); - if (mostRecentCommand != null) - { - setSelectionToViewer(mostRecentCommand.getAffectedObjects()); - } - if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) - { - propertySheetPage.refresh(); - } - } - }); - } - }); - - // Create the editing domain with a special command stack. - // - editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap()); - } - - /** - * @ADDED - */ - protected void initializeEditingDomain() - { - ComposedAdapterFactory.Descriptor.Registry registry = EMFEditPlugin.getComposedAdapterFactoryDescriptorRegistry(); - adapterFactory = new ComposedAdapterFactory(registry); - adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory()); - adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); - } - - /** - * This is here for the listener to be able to call it. - * - * @generated - */ - @Override - protected void firePropertyChange(int action) - { - super.firePropertyChange(action); - } - - /** - * This sets the selection into whichever viewer is active. - * - * @generated - */ - public void setSelectionToViewer(Collection collection) - { - final Collection theSelection = collection; - // Make sure it's okay. - // - if (theSelection != null && !theSelection.isEmpty()) - { - // I don't know if this should be run this deferred - // because we might have to give the editor a chance to process the viewer update events - // and hence to update the views first. - // - // - Runnable runnable = new Runnable() - { - public void run() - { - // Try to select the items in the current content viewer of the editor. - // - if (currentViewer != null) - { - currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true); - } - } - }; - runnable.run(); - } - } - - /** - * This returns the editing domain as required by the {@link IEditingDomainProvider} interface. This is important for - * implementing the static methods of {@link AdapterFactoryEditingDomain} and for supporting - * {@link org.eclipse.emf.edit.ui.action.CommandAction}. - * - * @generated - */ - public EditingDomain getEditingDomain() - { - return editingDomain; - } - - /** - * - * - * @generated - */ - public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider - { - /** - * - * - * @generated - */ - public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) - { - super(adapterFactory); - } - - /** - * - * - * @generated - */ - @Override - public Object[] getElements(Object object) - { - Object parent = super.getParent(object); - return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); - } - - /** - * - * - * @generated - */ - @Override - public Object[] getChildren(Object object) - { - Object parent = super.getParent(object); - return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); - } - - /** - * - * - * @generated - */ - @Override - public boolean hasChildren(Object object) - { - Object parent = super.getParent(object); - return parent != null; - } - - /** - * - * - * @generated - */ - @Override - public Object getParent(Object object) - { - return null; - } - } - - /** - * This makes sure that one content viewer, either for the current page or the outline view, if it has focus, is the - * current one. - * - * @generated - */ - public void setCurrentViewer(Viewer viewer) - { - // If it is changing... - // - if (currentViewer != viewer) - { - if (selectionChangedListener == null) - { - // Create the listener on demand. - // - selectionChangedListener = new ISelectionChangedListener() - { - // This just notifies those things that are affected by the section. - // - public void selectionChanged(SelectionChangedEvent selectionChangedEvent) - { - setSelection(selectionChangedEvent.getSelection()); - } - }; - } - - // Stop listening to the old one. - // - if (currentViewer != null) - { - currentViewer.removeSelectionChangedListener(selectionChangedListener); - } - - // Start listening to the new one. - // - if (viewer != null) - { - viewer.addSelectionChangedListener(selectionChangedListener); - } - - // Remember it. - // - currentViewer = viewer; - - // Set the editors selection based on the current viewer's selection. - // - setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection()); - } - } - - /** - * This returns the viewer as required by the {@link IViewerProvider} interface. - * - * @generated - */ - public Viewer getViewer() - { - return currentViewer; - } - - /** - * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. - * - * @generated - */ - protected void createContextMenuFor(StructuredViewer viewer) - { - MenuManager contextMenu = new MenuManager("#PopUp"); - contextMenu.add(new Separator("additions")); - contextMenu.setRemoveAllWhenShown(true); - contextMenu.addMenuListener(this); - Menu menu = contextMenu.createContextMenu(viewer.getControl()); - viewer.getControl().setMenu(menu); - getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); - - int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; - Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() }; - viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); - viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); - } - - /** - * @ADDED - */ - public CDOView getView() - { - return view; - } - - /** - * This is the method called to load a resource into the editing domain's resource set based on the editor's input. - * - * - * @generated - */ - public void createModelGen() - { - URI resourceURI = EditUIUtil.getURI(getEditorInput()); - Exception exception = null; - Resource resource = null; - try - { - // Load the resource through the editing domain. - // - resource = editingDomain.getResourceSet().getResource(resourceURI, true); - } - catch (Exception e) - { - exception = e; - resource = editingDomain.getResourceSet().getResource(resourceURI, false); - } - - Diagnostic diagnostic = analyzeResourceProblems(resource, exception); - if (diagnostic.getSeverity() != Diagnostic.OK) - { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter); - } - - /** - * @ADDED - */ - public void createModel() - { - try - { - CDOEditorInput editorInput = (CDOEditorInput)getEditorInput(); - view = editorInput.getView(); - - // TODO Check if a CommandStack is needed - BasicCommandStack commandStack = new BasicCommandStack(); - commandStack.addCommandStackListener(new CommandStackListener() - { - public void commandStackChanged(final EventObject event) - { - getContainer().getDisplay().asyncExec(new Runnable() - { - public void run() - { - Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand(); - if (mostRecentCommand != null) - { - setSelectionToViewer(mostRecentCommand.getAffectedObjects()); - } - if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) - { - propertySheetPage.refresh(); - } - } - }); - } - }); - - ResourceSet resourceSet = view.getResourceSet(); - editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, resourceSet); - - String resourcePath = editorInput.getResourcePath(); - if (resourcePath == null) - { - viewerInput = resourceSet; - } - else - { - URI resourceURI = CDOUtil.createResourceURI(resourcePath); - viewerInput = resourceSet.getResource(resourceURI, true); - } - - // resourceSet.eAdapters().add(problemIndicationAdapter); - } - catch (RuntimeException ex) - { - ex.printStackTrace(); - throw ex; - } - } - - /** - * Returns a diagnostic describing the errors and warnings listed in the resource and the specified exception (if - * any). - * - * @generated - */ - public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) - { - if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) - { - BasicDiagnostic basicDiagnostic = new BasicDiagnostic(Diagnostic.ERROR, "org.eclipse.emf.cdo.ui.editor", 0, - getString("_UI_CreateModelError_message", resource.getURI()), - new Object[] { exception == null ? (Object)resource : exception }); - basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true)); - return basicDiagnostic; - } - else if (exception != null) - { - return new BasicDiagnostic(Diagnostic.ERROR, "org.eclipse.emf.cdo.ui.editor", 0, getString( - "_UI_CreateModelError_message", resource.getURI()), new Object[] { exception }); - } - else - { - return Diagnostic.OK_INSTANCE; - } - } - - /** - * This is the method used by the framework to install your own controls. - * - * @generated - */ - public void createPagesGen() - { - // Creates the model from the editor input - // - createModel(); - - // Only creates the other pages if there is something that can be edited - // - if (!getEditingDomain().getResourceSet().getResources().isEmpty()) - { - // Create a page for the selection tree view. - // - Tree tree = new Tree(getContainer(), SWT.MULTI); - selectionViewer = new TreeViewer(tree); - setCurrentViewer(selectionViewer); - - selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - selectionViewer.setInput(editingDomain.getResourceSet()); - selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); - - new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory); - - createContextMenuFor(selectionViewer); - int pageIndex = addPage(tree); - setPageText(pageIndex, getString("_UI_SelectionPage_label")); - - getSite().getShell().getDisplay().asyncExec(new Runnable() - { - public void run() - { - setActivePage(0); - } - }); - } - - // Ensures that this editor will only display the page's tab - // area if there are more than one page - // - getContainer().addControlListener(new ControlAdapter() - { - boolean guard = false; - - @Override - public void controlResized(ControlEvent event) - { - if (!guard) - { - guard = true; - hideTabs(); - guard = false; - } - } - }); - - getSite().getShell().getDisplay().asyncExec(new Runnable() - { - public void run() - { - updateProblemIndication(); - } - }); - } - - /** - * @ADDED - */ - @Override - public void createPages() - { - try - { - // Creates the model from the editor input - // - createModel(); - - // Create a page for the selection tree view. - // - Tree tree = new Tree(getContainer(), SWT.MULTI); - selectionViewer = new TreeViewer(tree); - setCurrentViewer(selectionViewer); - - selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - selectionViewer.setLabelProvider(new CDOLabelProvider(adapterFactory, view, selectionViewer)); - selectionViewer.setInput(viewerInput); - // selectionViewer.setSelection(new StructuredSelection(viewerInput), - // true); - - new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory); - - createContextMenuFor(selectionViewer); - int pageIndex = addPage(tree); - setPageText(pageIndex, getString("_UI_SelectionPage_label")); - - setActivePage(0); - - // Ensures that this editor will only display the page's tab - // area if there are more than one page - // - getContainer().addControlListener(new ControlAdapter() - { - boolean guard = false; - - @Override - public void controlResized(ControlEvent event) - { - if (!guard) - { - guard = true; - hideTabs(); - guard = false; - } - } - }); - - updateProblemIndication(); - eventHandler = new CDOEventHandler(view, selectionViewer) - { - @Override - protected void objectInvalidated(InternalCDOObject cdoObject) - { - if (cdoObject instanceof CDOLegacyImpl) - { - CDOStateMachine.INSTANCE.read(cdoObject); - } - } - - @Override - protected void viewConflict(final CDOObject conflictingObject, boolean firstConflict) - { - refreshViewer(conflictingObject); - } - - @Override - protected void viewClosed() - { - closeEditor(); - } - - @Override - protected void viewDirtyStateChanged() - { - if (viewerInput instanceof CDOResource) - { - CDOResource resource = (CDOResource)viewerInput; - if (!view.isObjectRegistered(resource.cdoID())) - { - closeEditor(); - return; - } - } - - fireDirtyPropertyChange(); - } - }; - } - catch (RuntimeException ex) - { - OM.LOG.error(ex); - throw ex; - } - } - - /** - * If there is just one page in the multi-page editor part, this hides the single tab at the bottom. - * - * @generated - */ - protected void hideTabs() - { - if (getPageCount() <= 1) - { - setPageText(0, ""); - if (getContainer() instanceof CTabFolder) - { - ((CTabFolder)getContainer()).setTabHeight(1); - Point point = getContainer().getSize(); - getContainer().setSize(point.x, point.y + 6); - } - } - } - - /** - * If there is more than one page in the multi-page editor part, this shows the tabs at the bottom. - * - * @generated - */ - protected void showTabs() - { - if (getPageCount() > 1) - { - setPageText(0, getString("_UI_SelectionPage_label")); - if (getContainer() instanceof CTabFolder) - { - ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT); - Point point = getContainer().getSize(); - getContainer().setSize(point.x, point.y - 6); - } - } - } - - /** - * This is used to track the active viewer. - * - * @generated - */ - @Override - protected void pageChange(int pageIndex) - { - super.pageChange(pageIndex); - - if (contentOutlinePage != null) - { - handleContentOutlineSelection(contentOutlinePage.getSelection()); - } - } - - /** - * This is how the framework determines which interfaces we implement. - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public Object getAdapter(Class key) - { - if (key.equals(IContentOutlinePage.class)) - { - return showOutlineView() ? getContentOutlinePage() : null; - } - else if (key.equals(IPropertySheetPage.class)) - { - return getPropertySheetPage(); - } - else if (key.equals(IGotoMarker.class)) - { - return this; - } - else - { - return super.getAdapter(key); - } - } - - /** - * This accesses a cached version of the content outliner. - * - * @generated - */ - public IContentOutlinePage getContentOutlinePage() - { - if (contentOutlinePage == null) - { - // The content outline is just a tree. - // - class MyContentOutlinePage extends ContentOutlinePage - { - @Override - public void createControl(Composite parent) - { - super.createControl(parent); - contentOutlineViewer = getTreeViewer(); - contentOutlineViewer.addSelectionChangedListener(this); - - // Set up the tree viewer. - // - contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); - contentOutlineViewer.setInput(editingDomain.getResourceSet()); - - // Make sure our popups work. - // - createContextMenuFor(contentOutlineViewer); - - if (!editingDomain.getResourceSet().getResources().isEmpty()) - { - // Select the root object in the view. - // - contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources() - .get(0)), true); - } - } - - @Override - public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, - IStatusLineManager statusLineManager) - { - super.makeContributions(menuManager, toolBarManager, statusLineManager); - contentOutlineStatusLineManager = statusLineManager; - } - - @Override - public void setActionBars(IActionBars actionBars) - { - super.setActionBars(actionBars); - getActionBarContributor().shareGlobalActions(this, actionBars); - } - } - - contentOutlinePage = new MyContentOutlinePage(); - - // Listen to selection so that we can handle it is a special way. - // - contentOutlinePage.addSelectionChangedListener(new ISelectionChangedListener() - { - // This ensures that we handle selections correctly. - // - public void selectionChanged(SelectionChangedEvent event) - { - handleContentOutlineSelection(event.getSelection()); - } - }); - } - - return contentOutlinePage; - } - - /** - * This accesses a cached version of the property sheet. - * - * @generated - */ - public IPropertySheetPage getPropertySheetPage() - { - if (propertySheetPage == null) - { - propertySheetPage = new ExtendedPropertySheetPage(editingDomain) - { - @Override - public void setSelectionToViewer(List selection) - { - CDOEditor.this.setSelectionToViewer(selection); - CDOEditor.this.setFocus(); - } - - @Override - public void setActionBars(IActionBars actionBars) - { - super.setActionBars(actionBars); - getActionBarContributor().shareGlobalActions(this, actionBars); - } - }; - propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory)); - } - - return propertySheetPage; - } - - /** - * This deals with how we want selection in the outliner to affect the other views. - * - * @generated - */ - public void handleContentOutlineSelection(ISelection selection) - { - if (selectionViewer != null && !selection.isEmpty() && selection instanceof IStructuredSelection) - { - Iterator selectedElements = ((IStructuredSelection)selection).iterator(); - if (selectedElements.hasNext()) - { - // Get the first selected element. - // - Object selectedElement = selectedElements.next(); - - ArrayList selectionList = new ArrayList(); - selectionList.add(selectedElement); - while (selectedElements.hasNext()) - { - selectionList.add(selectedElements.next()); - } - - // Set the selection to the widget. - // - selectionViewer.setSelection(new StructuredSelection(selectionList)); - } - } - } - - /** - * This is for implementing {@link IEditorPart} and simply tests the command stack. - * - * @generated NOT - */ - @Override - public boolean isDirty() - { - return view.isDirty(); - } - - /** - * This is for implementing {@link IEditorPart} and simply saves the model file. - * - * @generated - */ - public void doSaveGen(IProgressMonitor progressMonitor) - { - // Save only resources that have actually changed. - // - final Map saveOptions = new HashMap(); - saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); - - // Do the work within an operation because this is a long running activity that modifies the workbench. - // - WorkspaceModifyOperation operation = new WorkspaceModifyOperation() - { - // This is the method that gets invoked when the operation runs. - // - @Override - public void execute(IProgressMonitor monitor) - { - // Save the resources to the file system. - // - boolean first = true; - for (Resource resource : editingDomain.getResourceSet().getResources()) - { - if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) - && !editingDomain.isReadOnly(resource)) - { - try - { - long timeStamp = resource.getTimeStamp(); - resource.save(saveOptions); - if (resource.getTimeStamp() != timeStamp) - { - savedResources.add(resource); - } - } - catch (Exception exception) - { - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - first = false; - } - } - } - }; - - updateProblemIndication = false; - try - { - // This runs the options, and shows progress. - // - new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); - - // Refresh the necessary state. - // - ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone(); - firePropertyChange(IEditorPart.PROP_DIRTY); - } - catch (Exception exception) - { - // Something went wrong that shouldn't. - // - PluginDelegator.INSTANCE.log(exception); - } - updateProblemIndication = true; - updateProblemIndication(); - } - - /** - * @ADDED - */ - @Override - public void doSave(IProgressMonitor progressMonitor) - { - // Save only resources that have actually changed. - // - final Map saveOptions = new HashMap(); - saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); - - // Do the work within an operation because this is a long running activity - // that modifies the workbench. - // - WorkspaceModifyOperation operation = new WorkspaceModifyOperation() - { - // This is the method that gets invoked when the operation runs. - // - @Override - public void execute(IProgressMonitor monitor) - { - // Save the resources to the file system. - // - boolean first = true; - for (Resource resource : editingDomain.getResourceSet().getResources()) - { - if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) - && !editingDomain.isReadOnly(resource)) - { - try - { - savedResources.add(resource); - resource.save(saveOptions); - } - catch (final TransactionException exception) - { - final Shell shell = getSite().getShell(); - shell.getDisplay().syncExec(new Runnable() - { - public void run() - { - CDOTransaction transaction = (CDOTransaction)view; - Dialog dialog = new RollbackTransactionDialog(getEditorSite().getPage(), "Transaction Error", - exception.getMessage(), transaction); - switch (dialog.open()) - { - case RollbackTransactionDialog.REMOTE: - transaction.rollback(true); - break; - case RollbackTransactionDialog.LOCAL: - transaction.rollback(false); - break; - } - } - }); - } - catch (Exception exception) - { - OM.LOG.error(exception); - resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); - } - - first = false; - } - } - } - }; - - updateProblemIndication = false; - try - { - // This runs the options, and shows progress. - // - new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); - - // Refresh the necessary state. - // - ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone(); - } - catch (Exception exception) - { - // Something went wrong that shouldn't. - // - PluginDelegator.INSTANCE.log(exception); - } - updateProblemIndication = true; - updateProblemIndication(); - } - - /** - * This returns whether something has been persisted to the URI of the specified resource. The implementation uses the - * URI converter from the editor's resource set to try to open an input stream. - * - * @generated - */ - protected boolean isPersisted(Resource resource) - { - boolean result = false; - try - { - InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI()); - if (stream != null) - { - result = true; - stream.close(); - } - } - catch (IOException e) - { - // Ignore - } - return result; - } - - /** - * This always returns true because it is not currently supported. - * - * @generated - */ - public boolean isSaveAsAllowedGen() - { - return true; - } - - /** - * @ADDED - */ - @Override - public boolean isSaveAsAllowed() - { - return false; - } - - /** - * This also changes the editor's input. - * - * @generated - */ - @Override - public void doSaveAs() - { - SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell()); - saveAsDialog.open(); - IPath path = saveAsDialog.getResult(); - if (path != null) - { - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); - if (file != null) - { - doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file)); - } - } - } - - /** - * - * - * @generated - */ - protected void doSaveAs(URI uri, IEditorInput editorInput) - { - editingDomain.getResourceSet().getResources().get(0).setURI(uri); - setInputWithNotify(editorInput); - setPartName(editorInput.getName()); - IProgressMonitor progressMonitor = getActionBars().getStatusLineManager() != null ? getActionBars() - .getStatusLineManager().getProgressMonitor() : new NullProgressMonitor(); - doSave(progressMonitor); - } - - /** - * - * - * @generated - */ - public void gotoMarker(IMarker marker) - { - try - { - if (marker.getType().equals(EValidator.MARKER)) - { - String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null); - if (uriAttribute != null) - { - URI uri = URI.createURI(uriAttribute); - EObject eObject = editingDomain.getResourceSet().getEObject(uri, true); - if (eObject != null) - { - setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject))); - } - } - } - } - catch (CoreException exception) - { - PluginDelegator.INSTANCE.log(exception); - } - } - - /** - * This is called during startup. - * - * @generated - */ - public void initGen(IEditorSite site, IEditorInput editorInput) - { - setSite(site); - setInputWithNotify(editorInput); - setPartName(editorInput.getName()); - site.setSelectionProvider(this); - site.getPage().addPartListener(partListener); - ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE); - } - - /** - * @ADDED - */ - @Override - public void init(IEditorSite site, IEditorInput editorInput) - { - setSite(site); - setPartName(editorInput.getName()); - site.setSelectionProvider(this); - site.getPage().addPartListener(partListener); - setInputWithNotify(editorInput); - } - - /** - * - * - * @generated - */ - @Override - public void setFocus() - { - getControl(getActivePage()).setFocus(); - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. - * - * @generated - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) - { - selectionChangedListeners.add(listener); - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. - * - * @generated - */ - public void removeSelectionChangedListener(ISelectionChangedListener listener) - { - selectionChangedListeners.remove(listener); - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection. - * - * - * @generated - */ - public ISelection getSelection() - { - return editorSelection; - } - - /** - * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. - * Calling this result will notify the listeners. - * - * @generated - */ - public void setSelection(ISelection selection) - { - editorSelection = selection; - - for (ISelectionChangedListener listener : selectionChangedListeners) - { - listener.selectionChanged(new SelectionChangedEvent(this, selection)); - } - setStatusLineManager(selection); - } - - /** - * - * - * @generated - */ - public void setStatusLineManager(ISelection selection) - { - IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? contentOutlineStatusLineManager - : getActionBars().getStatusLineManager(); - - if (statusLineManager != null) - { - if (selection instanceof IStructuredSelection) - { - Collection collection = ((IStructuredSelection)selection).toList(); - switch (collection.size()) - { - case 0: - { - statusLineManager.setMessage(getString("_UI_NoObjectSelected")); - break; - } - case 1: - { - String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next()); - statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text)); - break; - } - default: - { - statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size()))); - break; - } - } - } - else - { - statusLineManager.setMessage(""); - } - } - } - - /** - * This looks up a string in the plugin's plugin.properties file. - * - * @generated - */ - private static String getString(String key) - { - return PluginDelegator.INSTANCE.getString(key); - } - - /** - * This looks up a string in plugin.properties, making a substitution. - * - * @generated - */ - private static String getString(String key, Object s1) - { - return PluginDelegator.INSTANCE.getString(key, new Object[] { s1 }); - } - - /** - * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions - * from the Edit menu. - * - * @generated - */ - public void menuAboutToShowGen(IMenuManager menuManager) - { - ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager); - } - - /** - * @ADDED - */ - public void menuAboutToShow(IMenuManager menuManager) - { - menuAboutToShowGen(menuManager); - MenuManager submenuManager = new MenuManager("New Root"); - if (populateNewRoot(submenuManager)) - { - menuManager.insertBefore("edit", submenuManager); - } - - if (OM.TEST_BULK_ADD.isEnabled()) - { - IStructuredSelection sel = (IStructuredSelection)editorSelection; - if (sel.size() == 1) - { - Object element = sel.getFirstElement(); - if (element instanceof EObject) - { - final EObject object = (EObject)element; - final List features = new ArrayList(); - for (EReference containment : object.eClass().getEAllContainments()) - { - if (containment.isMany()) - { - features.add(containment); - } - } - - if (!features.isEmpty()) - { - final IWorkbenchPage page = getSite().getPage(); - menuManager.insertBefore("edit", new LongRunningAction(page, "Bulk Add" + SafeAction.INTERACTIVE) - { - private EReference feature; - - private int instances; - - @Override - protected void preRun() throws Exception - { - BulkAddDialog dialog = new BulkAddDialog(page, features); - if (dialog.open() == BulkAddDialog.OK) - { - feature = dialog.getFeature(); - instances = dialog.getInstances(); - } - else - { - cancel(); - } - } - - @SuppressWarnings("unchecked") - @Override - protected void doRun() throws Exception - { - List children = new ArrayList(); - for (int i = 0; i < instances; i++) - { - EObject child = EcoreUtil.create(feature.getEReferenceType()); - children.add(child); - } - - List list = (EList)object.eGet(feature); - list.addAll(children); - } - }); - } - } - } - } - } - - /** - * @ADDED - */ - protected boolean populateNewRoot(MenuManager menuManager) - { - boolean populated = false; - List cdoPackages = Arrays.asList(view.getSession().getPackageManager().getPackages()); - Collections.sort(cdoPackages); - - for (CDOPackage cdoPackage : cdoPackages) - { - List cdoClasses = Arrays.asList(cdoPackage.getConcreteClasses()); - Collections.sort(cdoClasses); - // TODO Sorting by class name may not have the desired effect if the labels are computed by an ItemProvider! - - if (!cdoClasses.isEmpty()) - { - MenuManager submenuManager = new MenuManager(cdoPackage.getPackageURI()); - for (CDOClass cdoClass : cdoClasses) - { - if (!cdoClass.isResource()) - { - // TODO Optimize/cache this? - CreateRootAction action = new CreateRootAction(cdoClass); - submenuManager.add(action); - populated = true; - } - } - - menuManager.add(submenuManager); - } - } - - return populated; - } - - /** - * - * - * @generated - */ - public EditingDomainActionBarContributor getActionBarContributor() - { - return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor(); - } - - /** - * - * - * @generated - */ - public IActionBars getActionBars() - { - return getActionBarContributor().getActionBars(); - } - - /** - * - * - * @generated - */ - public AdapterFactory getAdapterFactory() - { - return adapterFactory; - } - - /** - * - * - * @generated - */ - public void disposeGen() - { - updateProblemIndication = false; - - ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener); - - getSite().getPage().removePartListener(partListener); - - adapterFactory.dispose(); - - if (getActionBarContributor().getActiveEditor() == this) - { - getActionBarContributor().setActiveEditor(null); - } - - if (propertySheetPage != null) - { - propertySheetPage.dispose(); - } - - if (contentOutlinePage != null) - { - contentOutlinePage.dispose(); - } - - super.dispose(); - } - - /** - * @ADDED - */ - @Override - public void dispose() - { - updateProblemIndication = false; - eventHandler.dispose(); - getSite().getPage().removePartListener(partListener); - adapterFactory.dispose(); - - if (getActionBarContributor().getActiveEditor() == this) - { - getActionBarContributor().setActiveEditor(null); - } - - if (propertySheetPage != null) - { - propertySheetPage.dispose(); - } - - if (contentOutlinePage != null) - { - contentOutlinePage.dispose(); - } - - super.dispose(); - } - - /** - * Returns whether the outline view should be presented to the user. - * - * @generated - */ - protected boolean showOutlineView() - { - return false; - } - - /** - * @ADDED - */ - protected void fireDirtyPropertyChange() - { - try - { - getSite().getShell().getDisplay().syncExec(new Runnable() - { - public void run() - { - try - { - firePropertyChange(IEditorPart.PROP_DIRTY); - } - catch (Exception ignore) - { - } - } - }); - } - catch (Exception ignore) - { - } - } - - /** - * @ADDED - */ - protected void closeEditor() - { - try - { - getSite().getShell().getDisplay().asyncExec(new Runnable() - { - public void run() - { - try - { - getSite().getPage().closeEditor(CDOEditor.this, false); - CDOEditor.this.dispose(); - } - catch (Exception ignore) - { - } - } - }); - } - catch (Exception ignore) - { - } - } - - /** - * @ADDED - */ - public void refreshViewer(final Object element) - { - try - { - selectionViewer.getControl().getDisplay().asyncExec(new Runnable() - { - public void run() - { - try - { - if (element == null) - { - selectionViewer.refresh(true); - } - else - { - selectionViewer.refresh(element, true); - } - } - catch (Exception ignore) - { - } - } - }); - } - catch (Exception ignore) - { - } - } - - /** - * @ADDED - */ - public static void open(final IWorkbenchPage page, final CDOView view, final String resourcePath) - { - Display display = page.getWorkbenchWindow().getShell().getDisplay(); - display.asyncExec(new Runnable() - { - public void run() - { - try - { - IEditorReference[] references = find(page, view, resourcePath); - if (references.length != 0) - { - IEditorPart editor = references[0].getEditor(true); - page.activate(editor); - } - else - { - IEditorInput input = new CDOEditorInput(view, resourcePath); - page.openEditor(input, EDITOR_ID); - } - } - catch (Exception ex) - { - OM.LOG.error(ex); - } - } - }); - } - - /** - * @ADDED - */ - public static IEditorReference[] find(IWorkbenchPage page, CDOView view, String resourcePath) - { - List result = new ArrayList(); - IEditorReference[] editorReferences = page.getEditorReferences(); - for (IEditorReference editorReference : editorReferences) - { - try - { - if (ObjectUtil.equals(editorReference.getId(), EDITOR_ID)) - { - IEditorInput editorInput = editorReference.getEditorInput(); - if (editorInput instanceof CDOEditorInput) - { - CDOEditorInput cdoInput = (CDOEditorInput)editorInput; - if (cdoInput.getView() == view) - { - if (resourcePath == null || ObjectUtil.equals(cdoInput.getResourcePath(), resourcePath)) - { - result.add(editorReference); - } - } - } - } - } - catch (PartInitException ex) - { - OM.LOG.error(ex); - } - } - - return result.toArray(new IEditorReference[result.size()]); - } - - /** - * @ADDED - */ - public static void refresh(IWorkbenchPage page, CDOView view) - { - IEditorReference[] references = find(page, view, null); - for (IEditorReference reference : references) - { - CDOEditor editor = (CDOEditor)reference.getEditor(false); - if (editor != null) - { - editor.refreshViewer(null); - } - } - } - - /** - * @author Eike Stepper - * @ADDED - */ - private final class CreateRootAction extends LongRunningAction - { - private CDOClass cdoClass; - - private CreateRootAction(CDOClass cdoClass) - { - super(getEditorSite().getPage(), cdoClass.getName(), SharedIcons.getDescriptor(SharedIcons.OBJ_ECLASS)); - this.cdoClass = cdoClass; - } - - @Override - protected void doRun() throws Exception - { - Resource resource = null; - IStructuredSelection ssel = (IStructuredSelection)editorSelection; - if (ssel.isEmpty()) - { - if (viewerInput instanceof Resource) - { - resource = (Resource)viewerInput; - } - } - else if (ssel.size() == 1) - { - Object element = ssel.getFirstElement(); - if (element instanceof Resource) - { - resource = (Resource)element; - } - else if (element instanceof EObject) - { - resource = ((EObject)element).eResource(); - } - } - - if (resource != null) - { - InternalCDOObject object = ((CDOTransactionImpl)view).newInstance(cdoClass); - resource.getContents().add(object.cdoInternalInstance()); - } - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java deleted file mode 100644 index bc48e747f2..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditorInput.java +++ /dev/null @@ -1,121 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.editor; - -import org.eclipse.emf.cdo.CDOAudit; -import org.eclipse.emf.cdo.CDOSession; -import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.internal.ui.SharedIcons; - -import org.eclipse.net4j.connector.IConnector; - -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IPersistableElement; - -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class CDOEditorInput extends PlatformObject implements IEditorInput -{ - private CDOView view; - - private String resourcePath; - - public CDOEditorInput(CDOView view, String resourcePath) - { - this.view = view; - this.resourcePath = resourcePath; - } - - public CDOView getView() - { - return view; - } - - public String getResourcePath() - { - return resourcePath; - } - - public boolean exists() - { - return true; - } - - public ImageDescriptor getImageDescriptor() - { - switch (view.getViewType()) - { - case TRANSACTION: - return SharedIcons.getDescriptor(SharedIcons.OBJ_EDITOR); - case READONLY: - return SharedIcons.getDescriptor(SharedIcons.OBJ_EDITOR_READONLY); - case AUDIT: - return SharedIcons.getDescriptor(SharedIcons.OBJ_EDITOR_HISTORICAL); - } - - return null; - } - - public String getName() - { - if (resourcePath != null) - { - return new Path(resourcePath).lastSegment(); - } - - return view.getSession().getRepositoryName(); - } - - public IPersistableElement getPersistable() - { - return null; - } - - public String getToolTipText() - { - CDOSession session = view.getSession(); - IConnector connector = session.getConnector(); - String repositoryName = session.getRepositoryName(); - - StringBuilder builder = new StringBuilder(); - builder.append(connector.getURL()); - builder.append("/"); - builder.append(repositoryName); - if (resourcePath != null) - { - builder.append(resourcePath); - } - - builder.append(" ["); - builder.append(session.getSessionID()); - builder.append(":"); - builder.append(view.getViewID()); - builder.append("]"); - - if (view.getViewType() != CDOView.Type.TRANSACTION) - { - builder.append(" readonly"); - } - - if (view instanceof CDOAudit) - { - builder.append(MessageFormat.format(" {0,date} {0,time}", ((CDOAudit)view).getTimeStamp())); - } - - return builder.toString(); - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/PluginDelegator.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/PluginDelegator.java deleted file mode 100644 index 985d076563..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/PluginDelegator.java +++ /dev/null @@ -1,110 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.editor; - -import org.eclipse.emf.cdo.internal.ui.bundle.OM; - -import org.eclipse.emf.common.EMFPlugin; -import org.eclipse.emf.common.ui.EclipseUIPlugin; -import org.eclipse.emf.common.util.ResourceLocator; - -/** - * @author Eike Stepper - * @generated - */ -public final class PluginDelegator extends EMFPlugin -{ - /** - * Keep track of the singleton. - * - * @generated - */ - public static final PluginDelegator INSTANCE = new PluginDelegator(); - - /** - * Keep track of the singleton. - * - * @generated - */ - private static Implementation plugin; - - /** - * Create the instance. - * - * @generated - */ - public PluginDelegator() - { - super(new ResourceLocator[] {}); - } - - /** - * @ADDED - */ - @Override - public void log(Object logEntry) - { - if (logEntry instanceof Throwable) - { - OM.LOG.error((Throwable)logEntry); - } - else - { - OM.LOG.info(logEntry.toString()); - } - } - - /** - * Returns the singleton instance of the Eclipse plugin. - * - * @return the singleton instance. - * @generated - */ - @Override - public ResourceLocator getPluginResourceLocator() - { - return plugin; - } - - /** - * Returns the singleton instance of the Eclipse plugin. - * - * @return the singleton instance. - * @generated - */ - public static Implementation getPlugin() - { - return plugin; - } - - /** - * The actual implementation of the Eclipse Plugin. - * - * @generated - */ - public static class Implementation extends EclipseUIPlugin - { - /** - * Creates an instance. - * - * @generated - */ - public Implementation() - { - super(); - - // Remember the static instance. - // - plugin = this; - } - } - -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOPreferencePage.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOPreferencePage.java deleted file mode 100644 index e5f41a0a91..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOPreferencePage.java +++ /dev/null @@ -1,148 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.preferences; - -import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.common.revision.CDORevision; - -import org.eclipse.net4j.buffer.BufferInputStream; -import org.eclipse.net4j.util.ui.UIUtil; -import org.eclipse.net4j.util.ui.prefs.OMPreferencePage; -import org.eclipse.net4j.util.ui.widgets.TextAndDisable; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * @author Eike Stepper - */ -public class CDOPreferencePage extends OMPreferencePage -{ - private Text repositoryName; - - private Text userName; - - private Text connectorDescription; - - private TextAndDisable referenceChunkSize; - - private TextAndDisable preloadChunkSize; - - private Button invalidationNotifications; - - private TextAndDisable commitTimeout; - - public CDOPreferencePage() - { - super(org.eclipse.emf.internal.cdo.bundle.OM.PREFS); - } - - @Override - protected Control createUI(Composite parent) - { - Composite composite = UIUtil.createGridComposite(parent, 1); - ((GridLayout)composite.getLayout()).verticalSpacing = 5; - composite.setLayoutData(UIUtil.createGridData()); - - Group sessionGroup = new Group(composite, SWT.NONE); - sessionGroup.setLayout(new GridLayout(2, false)); - sessionGroup.setText("Session Defaults"); - sessionGroup.setLayoutData(UIUtil.createGridData(true, false)); - - new Label(sessionGroup, SWT.NONE).setText("Repository name:"); - repositoryName = new Text(sessionGroup, SWT.BORDER); - repositoryName.setLayoutData(UIUtil.createGridData(true, false)); - - new Label(sessionGroup, SWT.NONE).setText("User name:"); - userName = new Text(sessionGroup, SWT.BORDER); - userName.setLayoutData(UIUtil.createGridData(true, false)); - - new Label(sessionGroup, SWT.NONE).setText("Connector description:"); - connectorDescription = new Text(sessionGroup, SWT.BORDER); - connectorDescription.setLayoutData(UIUtil.createGridData(true, false)); - - new Label(sessionGroup, SWT.NONE).setText("Reference chunk size:"); - referenceChunkSize = new TextAndDisable(sessionGroup, SWT.BORDER, String.valueOf(CDORevision.UNCHUNKED)); - referenceChunkSize.setLayoutData(UIUtil.createGridData(true, false)); - - Group viewGroup = new Group(composite, SWT.NONE); - viewGroup.setLayout(new GridLayout(2, false)); - viewGroup.setText("View Defaults"); - viewGroup.setLayoutData(UIUtil.createGridData(true, false)); - - new Label(viewGroup, SWT.NONE).setText("Preload chunk size:"); - preloadChunkSize = new TextAndDisable(viewGroup, SWT.BORDER, String.valueOf(CDOView.NO_PRELOAD)); - preloadChunkSize.setLayoutData(UIUtil.createGridData(true, false)); - - new Label(viewGroup, SWT.NONE).setText("EMF invalidation notifications:"); - invalidationNotifications = new Button(viewGroup, SWT.CHECK); - - Group transactionGroup = new Group(composite, SWT.NONE); - transactionGroup.setLayout(new GridLayout(2, false)); - transactionGroup.setText("Transaction Defaults"); - transactionGroup.setLayoutData(UIUtil.createGridData(true, false)); - - new Label(transactionGroup, SWT.NONE).setText("Commit timeout (millis):"); - commitTimeout = new TextAndDisable(transactionGroup, SWT.BORDER, String.valueOf(BufferInputStream.NO_TIMEOUT)) - { - @Override - protected GridData createTextLayoutData() - { - GridData gd = super.createTextLayoutData(); - gd.widthHint = 64; - return gd; - } - }; - commitTimeout.setLayoutData(UIUtil.createGridData(true, false)); - - initValues(); - return composite; - } - - protected void initValues() - { - repositoryName.setText(org.eclipse.emf.internal.cdo.bundle.OM.PREF_REPOSITORY_NAME.getValue()); - userName.setText(org.eclipse.emf.internal.cdo.bundle.OM.PREF_USER_NAME.getValue()); - connectorDescription.setText(org.eclipse.emf.internal.cdo.bundle.OM.PREF_CONNECTOR_DESCRIPTION.getValue()); - referenceChunkSize.setValue(String.valueOf(org.eclipse.emf.internal.cdo.bundle.OM.PREF_REFERENCE_CHUNK_SIZE - .getValue())); - preloadChunkSize.setValue(String - .valueOf(org.eclipse.emf.internal.cdo.bundle.OM.PREF_LOAD_REVISION_COLLECTION_CHUNK_SIZE.getValue())); - invalidationNotifications - .setSelection(org.eclipse.emf.internal.cdo.bundle.OM.PREF_ENABLE_INVALIDATION_NOTIFICATIONS.getValue()); - commitTimeout.setValue(String - .valueOf(org.eclipse.emf.internal.cdo.bundle.OM.PREF_DEFAULT_COMMIT_TIMEOUT.getValue())); - } - - @Override - public boolean performOk() - { - org.eclipse.emf.internal.cdo.bundle.OM.PREF_REPOSITORY_NAME.setValue(repositoryName.getText()); - org.eclipse.emf.internal.cdo.bundle.OM.PREF_USER_NAME.setValue(userName.getText()); - org.eclipse.emf.internal.cdo.bundle.OM.PREF_CONNECTOR_DESCRIPTION.setValue(connectorDescription.getText()); - org.eclipse.emf.internal.cdo.bundle.OM.PREF_REFERENCE_CHUNK_SIZE.setValue(Integer.parseInt(referenceChunkSize - .getValue())); - org.eclipse.emf.internal.cdo.bundle.OM.PREF_LOAD_REVISION_COLLECTION_CHUNK_SIZE.setValue(Integer - .parseInt(preloadChunkSize.getValue())); - org.eclipse.emf.internal.cdo.bundle.OM.PREF_ENABLE_INVALIDATION_NOTIFICATIONS.setValue(invalidationNotifications - .getSelection()); - org.eclipse.emf.internal.cdo.bundle.OM.PREF_DEFAULT_COMMIT_TIMEOUT.setValue(Long - .parseLong(commitTimeout.getValue())); - return super.performOk(); - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOUIPreferencePage.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOUIPreferencePage.java deleted file mode 100644 index ea55fbfe88..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOUIPreferencePage.java +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.preferences; - -import org.eclipse.emf.cdo.internal.ui.bundle.OM; -import org.eclipse.emf.cdo.ui.CDOLabelProvider; - -import org.eclipse.net4j.util.ui.UIUtil; -import org.eclipse.net4j.util.ui.prefs.OMPreferencePage; -import org.eclipse.net4j.util.ui.widgets.TextAndDisable; - -import org.eclipse.jface.fieldassist.IContentProposalProvider; -import org.eclipse.jface.fieldassist.IControlContentAdapter; -import org.eclipse.jface.fieldassist.SimpleContentProposalProvider; -import org.eclipse.jface.fieldassist.TextContentAdapter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter; - -/** - * @author Eike Stepper - */ -public class CDOUIPreferencePage extends OMPreferencePage -{ - private TextAndDisable decoration; - - public CDOUIPreferencePage() - { - super(OM.PREFS); - } - - @Override - protected Control createUI(Composite parent) - { - Composite composite = UIUtil.createGridComposite(parent, 2); - composite.setLayoutData(UIUtil.createGridData()); - - new Label(composite, SWT.NONE).setText("Label decoration:"); - decoration = new TextAndDisable(composite, SWT.BORDER, CDOLabelProvider.NO_DECORATION) - { - @Override - protected GridData createTextLayoutData() - { - return UIUtil.createGridData(true, false); - } - }; - decoration.setLayoutData(UIUtil.createGridData(true, false)); - - Text text = decoration.getText(); - IControlContentAdapter contentAdapter = new TextContentAdapter(); - IContentProposalProvider provider = new SimpleContentProposalProvider(CDOLabelProvider.DECORATION_PROPOSALS); - new ContentAssistCommandAdapter(text, contentAdapter, provider, null, new char[] { '$' }, true); - UIUtil.addDecorationMargin(text); - - initValues(); - return composite; - } - - protected void initValues() - { - decoration.setValue(OM.PREF_LABEL_DECORATION.getValue()); - } - - @Override - public boolean performOk() - { - OM.PREF_LABEL_DECORATION.setValue(decoration.getValue()); - return super.performOk(); - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java deleted file mode 100644 index ed4a3a919a..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOSessionsView.java +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.views; - -import org.eclipse.emf.cdo.CDOSession; -import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.internal.ui.actions.OpenSessionAction; -import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor; -import org.eclipse.emf.cdo.ui.CDOItemProvider; -import org.eclipse.emf.cdo.ui.CDOViewHistoryEntry; - -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.container.IManagedContainer; -import org.eclipse.net4j.util.container.IPluginContainer; -import org.eclipse.net4j.util.ui.views.ContainerItemProvider; -import org.eclipse.net4j.util.ui.views.ContainerView; -import org.eclipse.net4j.util.ui.views.IElementFilter; - -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IWorkbenchPage; - -public class CDOSessionsView extends ContainerView -{ - private OpenSessionAction openSessionAction; - - public CDOSessionsView() - { - } - - @Override - protected Control createUI(Composite parent) - { - openSessionAction = new OpenSessionAction(getViewSite().getPage()); - return super.createUI(parent); - } - - @Override - protected IManagedContainer getContainer() - { - return IPluginContainer.INSTANCE; - } - - @Override - protected ContainerItemProvider> createContainerItemProvider() - { - return new CDOItemProvider(getSite().getPage(), new IElementFilter() - { - public boolean filter(Object element) - { - return element instanceof CDOSession; - } - }); - } - - @Override - protected void fillLocalToolBar(IToolBarManager manager) - { - manager.add(openSessionAction); - super.fillLocalToolBar(manager); - } - - @Override - protected void doubleClicked(Object object) - { - if (object instanceof CDOViewHistoryEntry) - { - CDOViewHistoryEntry entry = (CDOViewHistoryEntry)object; - IWorkbenchPage page = getViewSite().getPage(); - CDOView view = entry.getView(); - String resourcePath = entry.getResourcePath(); - CDOEditor.open(page, view, resourcePath); - } - else - { - super.doubleClicked(object); - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java deleted file mode 100644 index d2f37e7b09..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java +++ /dev/null @@ -1,198 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.emf.cdo.ui; - -import org.eclipse.emf.cdo.CDOObject; -import org.eclipse.emf.cdo.CDOSessionInvalidationEvent; -import org.eclipse.emf.cdo.CDOTransactionConflictEvent; -import org.eclipse.emf.cdo.CDOTransactionFinishedEvent; -import org.eclipse.emf.cdo.CDOTransactionStartedEvent; -import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; -import org.eclipse.emf.cdo.internal.ui.ItemsProcessor; - -import org.eclipse.emf.internal.cdo.InternalCDOObject; - -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.IContainerEvent; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.lifecycle.ILifecycleEvent; - -import org.eclipse.jface.viewers.TreeViewer; - -import java.util.HashSet; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public class CDOEventHandler -{ - private CDOView view; - - private TreeViewer treeViewer; - - private IListener sessionListener = new IListener() - { - public void notifyEvent(IEvent event) - { - if (event instanceof CDOSessionInvalidationEvent) - { - CDOSessionInvalidationEvent e = (CDOSessionInvalidationEvent)event; - if (e.getView() != view) - { - sessionInvalidated(e.getDirtyOIDs()); - } - } - else if (event instanceof IContainerEvent) - { - IContainerEvent e = (IContainerEvent)event; - if (e.getDeltaElement() == view && e.getDeltaKind() == IContainerDelta.Kind.REMOVED) - { - viewClosed(); - } - } - else if (event instanceof ILifecycleEvent) - { - ILifecycleEvent e = (ILifecycleEvent)event; - if (e.getKind() == ILifecycleEvent.Kind.DEACTIVATED) - { - viewClosed(); - } - } - } - }; - - private IListener viewListener = new IListener() - { - public void notifyEvent(IEvent event) - { - if (event instanceof CDOTransactionFinishedEvent) - { - // CDOTransactionFinishedEvent e = (CDOTransactionFinishedEvent)event; - // if (e.getType() == CDOTransactionFinishedEvent.Type.COMMITTED) - // { - // Map idMappings = e.getIDMappings(); - // HashSet newOIDs = new HashSet(idMappings.values()); - // new ItemsProcessor(view) - // { - // @Override - // protected void processCDOObject(TreeViewer viewer, InternalCDOObject cdoObject) - // { - // viewer.update(cdoObject.cdoInternalInstance(), null); - // } - // }.processCDOObjects(treeViewer, newOIDs); - // } - // else - { - try - { - treeViewer.getControl().getDisplay().syncExec(new Runnable() - { - public void run() - { - try - { - treeViewer.refresh(true); - } - catch (Exception ignore) - { - } - } - }); - } - catch (Exception ignore) - { - } - } - - viewDirtyStateChanged(); - } - else if (event instanceof CDOTransactionStartedEvent) - { - viewDirtyStateChanged(); - } - else if (event instanceof CDOTransactionConflictEvent) - { - CDOTransactionConflictEvent e = (CDOTransactionConflictEvent)event; - viewConflict(e.getConflictingObject(), e.isFirstConflict()); - } - } - }; - - public CDOEventHandler(CDOView view, TreeViewer treeViewer) - { - this.view = view; - this.treeViewer = treeViewer; - view.getSession().addListener(sessionListener); - view.addListener(viewListener); - } - - public void dispose() - { - view.removeListener(viewListener); - view.getSession().removeListener(sessionListener); - treeViewer = null; - view = null; - } - - public CDOView getView() - { - return view; - } - - public TreeViewer getTreeViewer() - { - return treeViewer; - } - - public void setViewer(TreeViewer viewer) - { - treeViewer = viewer; - } - - protected void sessionInvalidated(Set dirtyOIDs) - { - Set idsWithoutVersion = new HashSet(); - for (CDOIDAndVersion idAandVersion : dirtyOIDs) - { - idsWithoutVersion.add(idAandVersion.getID()); - } - - new ItemsProcessor(view) - { - @Override - protected void processCDOObject(TreeViewer viewer, InternalCDOObject cdoObject) - { - objectInvalidated(cdoObject); - viewer.refresh(cdoObject.cdoInternalInstance(), true); - } - }.processCDOObjects(treeViewer, idsWithoutVersion); - } - - protected void objectInvalidated(InternalCDOObject cdoObject) - { - } - - protected void viewDirtyStateChanged() - { - } - - protected void viewConflict(CDOObject conflictingObject, boolean firstConflict) - { - } - - protected void viewClosed() - { - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java deleted file mode 100644 index 6bc1cc9808..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOItemProvider.java +++ /dev/null @@ -1,399 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.emf.cdo.ui; - -import org.eclipse.emf.cdo.CDOAudit; -import org.eclipse.emf.cdo.CDOSession; -import org.eclipse.emf.cdo.CDOTransaction; -import org.eclipse.emf.cdo.CDOTransactionFinishedEvent; -import org.eclipse.emf.cdo.CDOTransactionStartedEvent; -import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.CDOViewEvent; -import org.eclipse.emf.cdo.internal.ui.SharedIcons; -import org.eclipse.emf.cdo.internal.ui.actions.CloseSessionAction; -import org.eclipse.emf.cdo.internal.ui.actions.CloseViewAction; -import org.eclipse.emf.cdo.internal.ui.actions.CommitTransactionAction; -import org.eclipse.emf.cdo.internal.ui.actions.CreateResourceAction; -import org.eclipse.emf.cdo.internal.ui.actions.ImportResourceAction; -import org.eclipse.emf.cdo.internal.ui.actions.LoadResourceAction; -import org.eclipse.emf.cdo.internal.ui.actions.ManagePackagesAction; -import org.eclipse.emf.cdo.internal.ui.actions.OpenAuditAction; -import org.eclipse.emf.cdo.internal.ui.actions.OpenTransactionAction; -import org.eclipse.emf.cdo.internal.ui.actions.OpenViewAction; -import org.eclipse.emf.cdo.internal.ui.actions.OpenViewEditorAction; -import org.eclipse.emf.cdo.internal.ui.actions.RegisterFilesystemPackagesAction; -import org.eclipse.emf.cdo.internal.ui.actions.RegisterSinglePackageAction; -import org.eclipse.emf.cdo.internal.ui.actions.RegisterWorkspacePackagesAction; -import org.eclipse.emf.cdo.internal.ui.actions.ReloadViewAction; -import org.eclipse.emf.cdo.internal.ui.actions.RollbackTransactionAction; -import org.eclipse.emf.cdo.util.CDOPackageType; -import org.eclipse.emf.cdo.util.CDOPackageTypeRegistry; - -import org.eclipse.net4j.connector.IConnector; -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.ui.actions.SafeAction; -import org.eclipse.net4j.util.ui.views.ContainerItemProvider; -import org.eclipse.net4j.util.ui.views.IElementFilter; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ITreeSelection; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IWorkbenchPage; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public class CDOItemProvider extends ContainerItemProvider> -{ - private IWorkbenchPage page; - - private Map viewHistories = new HashMap(); - - private IListener viewListener = new IListener() - { - public void notifyEvent(IEvent event) - { - if (event instanceof CDOTransactionStartedEvent || event instanceof CDOTransactionFinishedEvent) - { - try - { - final CDOView view = ((CDOViewEvent)event).getView(); - getViewer().getControl().getDisplay().syncExec(new Runnable() - { - public void run() - { - try - { - fireLabelProviderChanged(view); - CDOViewHistory history = viewHistories.get(view); - if (history != null) - { - CDOViewHistoryEntry[] entries = history.getEntries(); - if (entries != null && entries.length != 0) - { - fireLabelProviderChanged(entries); - } - } - } - catch (Exception ignore) - { - } - } - }); - } - catch (Exception ignore) - { - } - } - } - }; - - private IListener historyListener = new IListener() - { - public void notifyEvent(IEvent event) - { - if (event instanceof CDOViewHistoryEvent) - { - CDOViewHistoryEvent e = (CDOViewHistoryEvent)event; - CDOView view = e.getViewHistory().getView(); - refreshElement(view, false); - - CDOViewHistoryEntry addedEntry = e.getAddedEntry(); - if (addedEntry != null) - { - revealElement(addedEntry); - } - } - } - }; - - public CDOItemProvider(IWorkbenchPage page, IElementFilter rootElementFilter) - { - super(rootElementFilter); - this.page = page; - } - - public CDOItemProvider(IWorkbenchPage page) - { - this(page, null); - } - - @Override - public Object[] getChildren(Object element) - { - if (element instanceof CDOView) - { - CDOView view = (CDOView)element; - CDOViewHistory history = viewHistories.get(view); - if (history != null) - { - return history.getEntries(); - } - - return NO_ELEMENTS; - } - - return super.getChildren(element); - } - - @Override - public boolean hasChildren(Object element) - { - if (element instanceof CDOView) - { - CDOView view = (CDOView)element; - CDOViewHistory history = viewHistories.get(view); - if (history != null) - { - return history.hasEntries(); - } - - return false; - } - - return super.hasChildren(element); - } - - @Override - public Object getParent(Object element) - { - if (element instanceof CDOViewHistoryEntry) - { - return ((CDOViewHistoryEntry)element).getView(); - } - - return super.getParent(element); - } - - @Override - public String getText(Object obj) - { - if (obj instanceof CDOSession) - { - return getSessionLabel((CDOSession)obj); - } - - if (obj instanceof CDOView) - { - return getViewLabel((CDOView)obj); - } - - if (obj instanceof CDOViewHistoryEntry) - { - return getHistroyEntryLabel((CDOViewHistoryEntry)obj); - } - - return super.getText(obj); - } - - @Override - public Image getImage(Object obj) - { - if (obj instanceof CDOSession) - { - return SharedIcons.getImage(SharedIcons.OBJ_SESSION); - } - - if (obj instanceof CDOView) - { - CDOView view = (CDOView)obj; - switch (view.getViewType()) - { - case TRANSACTION: - return SharedIcons.getImage(SharedIcons.OBJ_EDITOR); - case READONLY: - return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_READONLY); - case AUDIT: - return SharedIcons.getImage(SharedIcons.OBJ_EDITOR_HISTORICAL); - } - } - - return super.getImage(obj); - } - - public static String getSessionLabel(CDOSession session) - { - IConnector connector = session.getConnector(); - String repositoryName = session.getRepositoryName(); - return "Session " + connector.getURL() + "/" + repositoryName + " [" + session.getSessionID() + "]"; - } - - public static String getViewLabel(CDOView view) - { - if (view instanceof CDOTransaction) - { - CDOTransaction transaction = (CDOTransaction)view; - return MessageFormat.format("{0}Transaction [{1}]", transaction.isDirty() ? "*" : "", transaction.getViewID()); - } - - if (view instanceof CDOAudit) - { - CDOAudit audit = (CDOAudit)view; - return MessageFormat.format("Audit [{0,date} {0,time}]", audit.getTimeStamp()); - } - - return MessageFormat.format("View [{0}]", view.getViewID()); - } - - /** - * @since 2.0 - */ - public static String getHistroyEntryLabel(CDOViewHistoryEntry entry) - { - return (entry.getView().isDirty() ? "*" : "") + entry.getResourcePath(); - } - - @Override - protected void fillContextMenu(IMenuManager manager, ITreeSelection selection) - { - super.fillContextMenu(manager, selection); - if (selection.size() == 1) - { - Object object = selection.getFirstElement(); - if (object instanceof CDOSession) - { - fillSession(manager, (CDOSession)object); - } - else if (object instanceof CDOView) - { - fillView(manager, (CDOView)object); - } - else if (object instanceof CDOViewHistoryEntry) - { - fillHistoryEntry(manager, (CDOViewHistoryEntry)object); - } - } - } - - protected void fillSession(IMenuManager manager, CDOSession session) - { - manager.add(new OpenTransactionAction(page, session)); - manager.add(new OpenViewAction(page, session)); - manager.add(new OpenAuditAction(page, session)); - manager.add(new Separator()); - manager.add(new ManagePackagesAction(page, session)); - - MenuManager generatedManager = new MenuManager("Register Generated Package"); - if (fillGenerated(generatedManager, session)) - { - manager.add(generatedManager); - } - - IAction a1 = new RegisterWorkspacePackagesAction(page, session); - a1.setText(a1.getText() + SafeAction.INTERACTIVE); - manager.add(a1); - - RegisterFilesystemPackagesAction a2 = new RegisterFilesystemPackagesAction(page, session); - a2.setText(a2.getText() + SafeAction.INTERACTIVE); - manager.add(a2); - - manager.add(new Separator()); - manager.add(new CloseSessionAction(page, session)); - } - - protected boolean fillGenerated(MenuManager manager, CDOSession session) - { - Set> entrySet = CDOPackageTypeRegistry.INSTANCE.entrySet(); - List> entryList = new ArrayList>(entrySet); - Collections.sort(entryList, new Comparator>() - { - public int compare(Map.Entry e1, Map.Entry e2) - { - return e1.getKey().compareTo(e2.getKey()); - } - }); - - Set registeredURIs = new HashSet(session.getPackageRegistry().keySet()); - boolean added = false; - for (Map.Entry entry : entryList) - { - String packageURI = entry.getKey(); - if (!registeredURIs.contains(packageURI)) - { - manager.add(new RegisterSinglePackageAction(page, session, packageURI, entry.getValue())); - added = true; - } - } - - return added; - } - - protected void fillView(IMenuManager manager, CDOView view) - { - manager.add(new OpenViewEditorAction(page, view)); - manager.add(new LoadResourceAction(page, view)); - manager.add(new Separator()); - if (view.getViewType() == CDOView.Type.TRANSACTION) - { - manager.add(new CreateResourceAction(page, view)); - manager.add(new ImportResourceAction(page, view)); - manager.add(new CommitTransactionAction(page, view)); - manager.add(new RollbackTransactionAction(page, view)); - } - - manager.add(new Separator()); - manager.add(new ReloadViewAction(page, view)); - manager.add(new Separator()); - manager.add(new CloseViewAction(page, view)); - } - - /** - * @since 2.0 - */ - protected void fillHistoryEntry(IMenuManager manager, CDOViewHistoryEntry entry) - { - } - - @Override - protected void elementAdded(Object element, Object parent) - { - super.elementAdded(element, parent); - if (element instanceof CDOView) - { - CDOView view = (CDOView)element; - view.addListener(viewListener); - - CDOViewHistory history = new CDOViewHistory(view); - history.addListener(historyListener); - viewHistories.put(view, history); - } - } - - @Override - protected void elementRemoved(Object element, Object parent) - { - super.elementRemoved(element, parent); - if (element instanceof CDOView) - { - CDOView view = (CDOView)element; - view.removeListener(viewListener); - - CDOViewHistory history = viewHistories.remove(view); - history.removeListener(historyListener); - history.dispose(); - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelProvider.java deleted file mode 100644 index 3cabe65ed6..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelProvider.java +++ /dev/null @@ -1,200 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.emf.cdo.ui; - -import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.internal.ui.bundle.OM; - -import org.eclipse.emf.internal.cdo.InternalCDOObject; -import org.eclipse.emf.internal.cdo.util.FSMUtil; - -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.StringUtil; -import org.eclipse.net4j.util.ui.UIUtil; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; - -import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.jface.viewers.IFontProvider; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; - -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class CDOLabelProvider extends AdapterFactoryLabelProvider implements IColorProvider, IFontProvider -{ - public static final String[] DECORATION_PROPOSALS = { "${element}", "${id}", "${state}", "${created}", "${revised}" }; - - public static final String DEFAULT_DECORATION = DECORATION_PROPOSALS[0] + " [" + DECORATION_PROPOSALS[1] + "]"; - - public static final String NO_DECORATION = DECORATION_PROPOSALS[0]; - - private static final String[] DECORATION_ARGS = { "{0}", "{1}", "{2}", "{3,date} {3,time}", "{4,date} {4,time}" }; - - private static final Color GRAY = UIUtil.getDisplay().getSystemColor(SWT.COLOR_GRAY); - - private static final Color RED = UIUtil.getDisplay().getSystemColor(SWT.COLOR_RED); - - private Font bold; - - private CDOView view; - - private TreeViewer viewer; - - private String pattern; - - public CDOLabelProvider(AdapterFactory adapterFactory, CDOView view, TreeViewer viewer) - { - super(adapterFactory); - this.view = view; - this.viewer = viewer; - bold = UIUtil.getBoldFont(viewer.getControl()); - - pattern = OM.PREF_LABEL_DECORATION.getValue(); - if (ObjectUtil.equals(pattern, NO_DECORATION)) - { - pattern = null; - } - else - { - pattern = StringUtil.replace(pattern, DECORATION_PROPOSALS, DECORATION_ARGS); - } - } - - public CDOView getView() - { - return view; - } - - public TreeViewer getViewer() - { - return viewer; - } - - @Override - public void dispose() - { - bold.dispose(); - super.dispose(); - } - - @Override - public void notifyChanged(final Notification notification) - { - super.notifyChanged(notification); - - try - { - viewer.getControl().getDisplay().syncExec(new Runnable() - { - public void run() - { - try - { - viewer.refresh(notification.getNotifier(), true); - } - catch (Exception ignore) - { - } - } - }); - } - catch (Exception ignore) - { - } - } - - @Override - public String getText(Object object) - { - return decorateText(super.getText(object), object); - } - - @Override - public String getColumnText(Object object, int columnIndex) - { - return decorateText(super.getColumnText(object, columnIndex), object); - } - - public Color getBackground(Object object) - { - return null; - } - - public Color getForeground(Object object) - { - try - { - InternalCDOObject cdoObject = FSMUtil.adapt(object, view); - switch (cdoObject.cdoState()) - { - case PROXY: - return GRAY; - - case CONFLICT: - return RED; - } - } - catch (RuntimeException ignore) - { - } - - return null; - } - - public Font getFont(Object object) - { - try - { - InternalCDOObject cdoObject = FSMUtil.adapt(object, view); - switch (cdoObject.cdoState()) - { - case NEW: - case DIRTY: - case CONFLICT: - return bold; - } - } - catch (RuntimeException ignore) - { - } - - return null; - } - - protected String decorateText(String text, Object object) - { - try - { - if (pattern != null) - { - InternalCDOObject obj = FSMUtil.adapt(object, view); - CDORevision rev = obj.cdoRevision(); - long created = rev == null ? CDORevision.UNSPECIFIED_DATE : rev.getCreated(); - long revised = rev == null ? CDORevision.UNSPECIFIED_DATE : rev.getRevised(); - text = MessageFormat.format(pattern, text, obj.cdoID(), obj.cdoState(), created, revised); - } - } - catch (RuntimeException ignore) - { - } - - return text; - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistory.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistory.java deleted file mode 100644 index 4e8f08307e..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistory.java +++ /dev/null @@ -1,156 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.emf.cdo.ui; - -import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.CDOViewResourcesEvent; -import org.eclipse.emf.cdo.eresource.CDOResource; - -import org.eclipse.net4j.util.event.Event; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.event.Notifier; - -import org.eclipse.emf.ecore.resource.Resource; - -import java.text.MessageFormat; -import java.util.HashSet; -import java.util.Set; - -/** - * @author Eike Stepper - * @since 2.0 - */ -public final class CDOViewHistory extends Notifier -{ - private CDOView view; - - private Set entries = new HashSet(); - - private IListener viewListener = new IListener() - { - public void notifyEvent(IEvent event) - { - if (event instanceof CDOViewResourcesEvent) - { - CDOViewResourcesEvent e = (CDOViewResourcesEvent)event; - if (e.getView() == view && e.getKind() == CDOViewResourcesEvent.Kind.ADDED) - { - addResource(e.getResourcePath()); - } - } - } - }; - - public CDOViewHistory(CDOView view) - { - this.view = view; - view.addListener(viewListener); - } - - public void dispose() - { - view.removeListener(viewListener); - entries.clear(); - } - - public CDOView getView() - { - return view; - } - - public CDOViewHistoryEntry[] getEntries() - { - synchronized (entries) - { - return entries.toArray(new CDOViewHistoryEntry[entries.size()]); - } - } - - public boolean hasEntries() - { - synchronized (entries) - { - return !entries.isEmpty(); - } - } - - public void reset() - { - Set openResources = new HashSet(); - for (Resource resource : view.getResourceSet().getResources()) - { - if (resource instanceof CDOResource) - { - CDOResource cdoResource = (CDOResource)resource; - openResources.add(new CDOViewHistoryEntry(view, cdoResource.getPath())); - } - } - - boolean changed; - synchronized (entries) - { - changed = entries.retainAll(openResources); - } - - if (changed) - { - fireEvent(new ViewHistoryEvent(null)); - } - } - - protected void addResource(String resourcePath) - { - CDOViewHistoryEntry entry = new CDOViewHistoryEntry(view, resourcePath); - boolean changed; - synchronized (entries) - { - changed = entries.add(entry); - } - - if (changed) - { - fireEvent(new ViewHistoryEvent(entry)); - } - } - - /** - * @author Eike Stepper - */ - private final class ViewHistoryEvent extends Event implements CDOViewHistoryEvent - { - private static final long serialVersionUID = 1L; - - CDOViewHistoryEntry addedEntry; - - public ViewHistoryEvent(CDOViewHistoryEntry addedEntry) - { - super(CDOViewHistory.this); - this.addedEntry = addedEntry; - } - - public CDOViewHistory getViewHistory() - { - return CDOViewHistory.this; - } - - public CDOViewHistoryEntry getAddedEntry() - { - return addedEntry; - } - - @Override - public String toString() - { - return MessageFormat.format("CDOViewHistoryEvent[source={0}, addedEntry={1}]", getSource(), getAddedEntry()); - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistoryEntry.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistoryEntry.java deleted file mode 100644 index 2490c1a0c7..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistoryEntry.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.eclipse.emf.cdo.ui; - -import org.eclipse.emf.cdo.CDOView; - -/** - * @author Eike Stepper - * @since 2.0 - */ -public final class CDOViewHistoryEntry implements Comparable -{ - private CDOView view; - - private String resourcePath; - - public CDOViewHistoryEntry(CDOView view, String resourcePath) - { - if (view == null) - { - throw new IllegalArgumentException("view == null"); - } - - if (resourcePath == null) - { - throw new IllegalArgumentException("resourcePath == null"); - } - - this.view = view; - this.resourcePath = resourcePath; - } - - public CDOView getView() - { - return view; - } - - public String getResourcePath() - { - return resourcePath; - } - - public int compareTo(CDOViewHistoryEntry entry) - { - return resourcePath.compareTo(entry.resourcePath); - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - - if (obj instanceof CDOViewHistoryEntry) - { - CDOViewHistoryEntry that = (CDOViewHistoryEntry)obj; - return view == that.getView() && resourcePath.equals(that.resourcePath); - } - - return false; - } - - @Override - public int hashCode() - { - return resourcePath.hashCode(); - } - - @Override - public String toString() - { - return resourcePath; - } -} diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistoryEvent.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistoryEvent.java deleted file mode 100644 index 2175705c65..0000000000 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOViewHistoryEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.emf.cdo.ui; - -import org.eclipse.net4j.util.event.IEvent; - -/** - * @author Eike Stepper - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOViewHistoryEvent extends IEvent -{ - /** - * @since 2.0 - */ - public CDOViewHistory getViewHistory(); - - /** - * @since 2.0 - */ - public CDOViewHistoryEntry getAddedEntry(); -} -- cgit v1.2.3