for (Object o : selection) {
if ((o instanceof IAdaptable)) {
NodeContext nodeContext = ((IAdaptable) o).getAdapter(NodeContext.class);
- if (nodeContext != null)
+ if (nodeContext != null) {
result.add(nodeContext);
- } else if (o instanceof WorkbenchSelectionElement) {
- try {
- Resource res = WorkbenchSelectionUtils.getPossibleResource((WorkbenchSelectionElement)o);
- if(res != null) {
- result.add(NodeContextBuilder.buildWithInput(res));
- }
- } catch (DatabaseException e) {
- LOGGER.error("Failed to get node contexts for selection.", e);
- }
+ continue;
+ }
+ }
+ try {
+ Resource res = WorkbenchSelectionUtils.getPossibleResource(o);
+ if(res != null) {
+ result.add(NodeContextBuilder.buildWithInput(res));
+ }
+ } catch (DatabaseException e) {
+ LOGGER.error("Failed to get node contexts for selection.", e);
}
}
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
-import org.simantics.ui.utils.ResourceAdaptionUtils;
+import org.simantics.ui.selection.WorkbenchSelectionUtils;
import org.simantics.ui.workbench.action.ResourceEditorAdapterAction;
import org.simantics.ui.workbench.editor.EditorAdapter;
import org.simantics.ui.workbench.editor.EditorRegistry;
}
protected Object extractResource(ReadGraph graph, Object object) throws DatabaseException {
- Resource resource = ResourceAdaptionUtils.adaptToResource(graph, object);
+ Resource resource = WorkbenchSelectionUtils.getPossibleResource(object);
+ //Resource resource = ResourceAdaptionUtils.adaptToResource(graph, object);
if(resource != null) return resource;
else return object;
}
import org.simantics.project.IProject;
import org.simantics.ui.SimanticsUI;
import org.simantics.ui.icons.ImageUtil;
+import org.simantics.ui.selection.WorkbenchSelectionUtils;
import org.simantics.ui.utils.ResourceAdaptionUtils;
import org.simantics.utils.datastructures.persistent.ContextMap;
}
@Override
- protected IAction[] getActions(ReadGraph g, Object[] selection) {
+ protected IAction[] getActions(ReadGraph g, Object[] selection) throws DatabaseException {
if(selection.length == 1) {
- final Resource r = ResourceAdaptionUtils.adaptToResource(selection[0]);
+ final Resource r = WorkbenchSelectionUtils.getPossibleResource(selection[0]);
if(r == null)
return NO_ACTIONS;
try {