blob: ebad5be651ee440885ac1dfb53c0c090b82d0964 (
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
56
57
58
59
60
|
/*******************************************************************************
* Copyright (c) 2013 Obeo.
* 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:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.handler.propertytester;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.rcp.ui.internal.EMFCompareConstants;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
/**
* A property tester that checks if a diff is selected in the compare editor.
*
* @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
* @since 3.0
*/
public class DiffSelectedPropertyTester extends PropertyTester {
/**
* {@inheritDoc}
*
* @see org.eclipse.core.expressions.PropertyTester#test(java.lang.Object, java.lang.String,
* java.lang.Object[], java.lang.Object)
*/
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (receiver instanceof IEditorPart) {
IEditorInput i = ((IEditorPart)receiver).getEditorInput();
if (i instanceof CompareEditorInput) {
CompareConfiguration configuration = ((CompareEditorInput)i).getCompareConfiguration();
ISelection selection = (ISelection)configuration
.getProperty(EMFCompareConstants.SMV_SELECTION);
if (selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection)selection).getFirstElement();
if (element instanceof Adapter) {
Notifier diffNode = ((Adapter)element).getTarget();
if (diffNode instanceof Diff) {
return true;
}
}
}
}
}
return false;
}
}
|