blob: 5a56b7a103b9b343108ad11ff07ea7c032c52a3d (
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
61
62
63
64
65
|
/*******************************************************************************
* Copyright (c) 2011 CEA LIST.
* 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
*
* Vincent Lorenzo (CEA-LIST) - Bug 351931 - Use local cell editor in table
* Gregoire Dupe (Mia-Software) - Bug 351931 - Use local cell editor in table
*/
package org.eclipse.papyrus.emf.facet.widgets.celleditors;
import java.util.Iterator;
import java.util.List;
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.papyrus.emf.facet.widgets.celleditors.modelCellEditor.AbstractModelCellEditor;
import org.eclipse.papyrus.emf.facet.widgets.celleditors.modelCellEditor.ModelCellEditorDeclarations;
/**
* @since 0.1.1
* @author gdupe
*
*/
public final class CellEditorsUtils {
private static final String FILE_EXTENSION = "modelcelleditors"; //$NON-NLS-1$
private CellEditorsUtils() {
// This is an utility class which must not be instantiated
}
/**
* This method allows to find the bundle name for an editor
*
* @param editor
* an editor
* @return the bundle name for this editor
*/
public static String getBundleNameFor(final AbstractModelCellEditor editor, final ResourceSet resourceSet) {
for (Resource ressource : resourceSet.getResources()) {
if (CellEditorsUtils.FILE_EXTENSION.equals(ressource.getURI().fileExtension())) {
Iterator<EObject> allContents = ressource.getContents().iterator();
while (allContents.hasNext()) {
EObject currentContent = allContents.next();
if (currentContent instanceof ModelCellEditorDeclarations) {
if (((ModelCellEditorDeclarations) currentContent).getModelCellEditors()
.contains(editor)) {
URI uri = ressource.getURI();
if (uri.isPlatformPlugin()) {
List<String> list = uri.segmentsList();
return list.get(1);
}
}
}
}
}
}
return null;
}
}
|