blob: b3528d0f93854b1014f7b80806d235be57959004 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*******************************************************************************
* Copyright (c) 2013 Atos
* 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:
* Arthur Daussy - initial implementation
*******************************************************************************/
package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor;
import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
import org.eclipse.papyrus.team.collaborative.utils.CollabUtils;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
/**
* Abstract class for Collaborative handler which are enable only if the project is collaborative.
*
* @author adaussy
*/
public abstract class AbstractCollabHandler extends AbstractHandler {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.commands.AbstractHandler#isEnabled()
*/
@Override
public boolean isEnabled() {
EObject firstSelection = UIUtils.getFirstSelection();
if(firstSelection != null) {
return CollabUtils.isCollab(firstSelection);
}
return false;
}
protected ResourceSet getResourceSet() {
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if(editor instanceof CoreMultiDiagramEditor) {
CoreMultiDiagramEditor papyrusEditor = (CoreMultiDiagramEditor)editor;
return papyrusEditor.getEditingDomain().getResourceSet();
} else {
return null;
}
}
}
|