diff options
author | Eike Stepper | 2012-11-08 18:28:58 +0000 |
---|---|---|
committer | Eike Stepper | 2012-11-08 18:36:57 +0000 |
commit | 9b6392f3ffa6e68e3076b5a43300e5a1bebae1aa (patch) | |
tree | 40b1dcc2311bba613a47a7ae1080ab0a210b76ff /plugins/org.eclipse.emf.cdo.ui | |
parent | 36a064c02556267eafbc4cb57ecb99533d553035 (diff) | |
download | cdo-9b6392f3ffa6e68e3076b5a43300e5a1bebae1aa.tar.gz cdo-9b6392f3ffa6e68e3076b5a43300e5a1bebae1aa.tar.xz cdo-9b6392f3ffa6e68e3076b5a43300e5a1bebae1aa.zip |
[393910] Stabilize state management in SynchronizableRepositories
https://bugs.eclipse.org/bugs/show_bug.cgi?id=393910
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui')
4 files changed, 71 insertions, 59 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractOpenViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractOpenViewAction.java index eda04d090f..2912ca4ca5 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractOpenViewAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/AbstractOpenViewAction.java @@ -4,12 +4,13 @@ * 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.common.CDOCommonRepository.State; import org.eclipse.emf.cdo.session.CDOSession; import org.eclipse.jface.resource.ImageDescriptor; @@ -29,6 +30,17 @@ public abstract class AbstractOpenViewAction extends SessionAction @Override public boolean isEnabled() { - return !getSession().getPackageRegistry().isEmpty() && super.isEnabled(); + CDOSession session = getSession(); + if (session.getRepositoryInfo().getState() == State.INITIAL) + { + return false; + } + + if (session.getPackageRegistry().isEmpty()) + { + return false; + } + + return super.isEnabled(); } } diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java index 675fa4c7bd..891ab82c33 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateBranchAction.java @@ -4,13 +4,14 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Eike Stepper - initial API and implementation * Victor Roldan Betancort - maintenance */ package org.eclipse.emf.cdo.internal.ui.actions; +import org.eclipse.emf.cdo.common.CDOCommonRepository.State; import org.eclipse.emf.cdo.common.branch.CDOBranch; import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.internal.ui.dialogs.CreateBranchDialog; @@ -48,6 +49,17 @@ public class CreateBranchAction extends SessionAction } @Override + public boolean isEnabled() + { + if (getSession().getRepositoryInfo().getState() == State.INITIAL) + { + return false; + } + + return super.isEnabled(); + } + + @Override protected void preRun() throws Exception { CreateBranchDialog dialog = new CreateBranchDialog(getPage(), getSession(), null, true, null) 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 index 4fd873bad6..ac7d6f52cf 100644 --- 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 @@ -10,7 +10,6 @@ */ package org.eclipse.emf.cdo.internal.ui.views; -import org.eclipse.emf.cdo.eresource.CDOResourceFolder; import org.eclipse.emf.cdo.eresource.CDOResourceLeaf; import org.eclipse.emf.cdo.internal.ui.actions.OpenSessionAction; import org.eclipse.emf.cdo.internal.ui.transfer.RepositoryTransferDragListener; @@ -23,15 +22,12 @@ 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.ContainerNameSorter; import org.eclipse.net4j.util.ui.views.ContainerView; import org.eclipse.net4j.util.ui.views.IElementFilter; import org.eclipse.core.runtime.Path; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IWorkbenchPage; @@ -70,35 +66,6 @@ public class CDOSessionsView extends ContainerView } @Override - protected ViewerSorter createViewerSorter() - { - return new ContainerNameSorter() - { - @Override - public int compare(Viewer viewer, Object e1, Object e2) - { - if (e1 instanceof CDOResourceFolder) - { - if (e2 instanceof CDOResourceLeaf) - { - return -1; - } - } - - if (e1 instanceof CDOResourceLeaf) - { - if (e2 instanceof CDOResourceFolder) - { - return 1; - } - } - - return super.compare(viewer, e1, e2); - } - }; - } - - @Override protected IManagedContainer getContainer() { return IPluginContainer.INSTANCE; 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 index 8b9c11bf6f..a516533205 100644 --- 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 @@ -71,6 +71,7 @@ import org.eclipse.jface.resource.LocalResourceManager; import org.eclipse.jface.resource.ResourceManager; import org.eclipse.jface.viewers.ITreeSelection; import org.eclipse.jface.viewers.LabelProviderChangedEvent; +import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.IEditorRegistry; @@ -449,8 +450,11 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>> return super.getFont(obj); } + /** + * @since 4.2 + */ @Override - protected void fillContextMenu(IMenuManager manager, ITreeSelection selection) + public void fillContextMenu(IMenuManager manager, ITreeSelection selection) { if (selection.size() == 1) { @@ -482,9 +486,9 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>> } /** - * @since 2.0 + * @since 4.2 */ - protected void fillSession(IMenuManager manager, CDOSession session) + public void fillSession(IMenuManager manager, CDOSession session) { manager.add(new OpenTransactionAction(page, session)); manager.add(new OpenViewAction(page, session)); @@ -499,14 +503,6 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>> 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); - if (session.getRepositoryInfo().isSupportingBranches()) { manager.add(new Separator()); @@ -520,9 +516,9 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>> } /** - * @since 2.0 + * @since 4.2 */ - protected boolean fillGenerated(MenuManager manager, CDOSession session) + public boolean fillGenerated(MenuManager manager, CDOSession session) { List<String> registeredURIs = new ArrayList<String>(EPackage.Registry.INSTANCE.keySet()); Collections.sort(registeredURIs, new Comparator<String>() @@ -561,9 +557,9 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>> } /** - * @since 2.0 + * @since 4.2 */ - protected void fillView(IMenuManager manager, CDOView view) + public void fillView(IMenuManager manager, CDOView view) { if (!view.isReadOnly()) { @@ -611,23 +607,23 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>> /** * @since 4.2 */ - protected void fillBranch(IMenuManager manager, CDOBranch branch) + public void fillBranch(IMenuManager manager, CDOBranch branch) { CDOSession session = CDOUtil.getSession(branch); manager.add(new CreateBranchAction(page, session)); } /** - * @since 3.0 + * @since 4.2 */ - protected void fillResourceFolder(IMenuManager manager, CDOResourceFolder folder) + public void fillResourceFolder(IMenuManager manager, CDOResourceFolder folder) { } /** * @since 4.2 */ - protected void fillResourceLeaf(IMenuManager manager, Object object) + public void fillResourceLeaf(IMenuManager manager, Object object) { CDOEditorUtil.populateMenu(manager, (CDOResourceLeaf)object, page); @@ -646,9 +642,9 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>> } /** - * @since 3.0 + * @since 4.2 */ - protected void fillResource(IMenuManager manager, CDOResource resource) + public void fillResource(IMenuManager manager, CDOResource resource) { // manager.add(new OpenResourceEditorAction(page, resource)); } @@ -656,7 +652,7 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>> /** * @since 4.2 */ - protected void fillTextResource(IMenuManager manager, CDOTextResource resource) + public void fillTextResource(IMenuManager manager, CDOTextResource resource) { // manager.add(new OpenResourceEditorAction(page, resource)); } @@ -664,7 +660,7 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>> /** * @since 4.2 */ - protected void fillBinaryResource(IMenuManager manager, CDOBinaryResource resource) + public void fillBinaryResource(IMenuManager manager, CDOBinaryResource resource) { // manager.add(new OpenResourceEditorAction(page, resource)); } @@ -704,6 +700,31 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>> } /** + * @since 4.2 + */ + @Override + public int compare(Viewer viewer, Object e1, Object e2) + { + if (e1 instanceof CDOResourceFolder) + { + if (e2 instanceof CDOResourceLeaf) + { + return -1; + } + } + + if (e1 instanceof CDOResourceLeaf) + { + if (e2 instanceof CDOResourceFolder) + { + return 1; + } + } + + return super.compare(viewer, e1, e2); + } + + /** * @since 3.0 */ public static ImageDescriptor getViewImageDescriptor(CDOView view) |