@Override\r
public String perform(ReadGraph g) throws DatabaseException {\r
String name = NameUtils.getSafeName(g, r);\r
- String uri = g.getPossibleURI(r);\r
- String label = "[" + r.getResourceId() + "] - " + name;\r
- if (uri != null)\r
- label = label + " - " + uri;\r
- return label;\r
+ String uri = DebugUtils.getPossibleRootRelativePath(g, r);\r
+ return\r
+ "[" + r.getResourceId() + "] - "\r
+ + name\r
+ + (uri != null ? " - " : "")\r
+ + (uri != null ? uri : "");\r
}\r
});\r
} catch (DatabaseException e) {\r
return null;\r
try {\r
try {\r
- return g.adapt(r, String.class);\r
+ return DebugUtils.getSafeLabel(g, r);\r
} catch (Exception ex) {\r
System.out.println("Exception thrown from restoreItemFromMemento");\r
}\r
*******************************************************************************/\r
package org.simantics.debug.ui.internal;\r
\r
+import java.util.Set;\r
+\r
import org.eclipse.swt.widgets.Shell;\r
+import org.simantics.databoard.util.URIStringUtils;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.Session;\r
import org.simantics.db.Statement;\r
import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.PossibleIndexRoot;\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
return name;\r
}\r
\r
+ public static String getPossibleRootRelativePath(ReadGraph graph, Resource r) throws DatabaseException {\r
+ Resource indexRoot = graph.syncRequest(new PossibleIndexRoot(r));\r
+ String uri = graph.getPossibleURI(r);\r
+ if (indexRoot != null && uri != null) {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ Set<Resource> types = graph.getTypes(indexRoot);\r
+ if (!types.contains(L0.Ontology)) {\r
+ Resource indexRootParent = graph.getPossibleObject(indexRoot, L0.PartOf);\r
+ if (indexRootParent != null) {\r
+ String rootParentUri = graph.getPossibleURI(indexRootParent);\r
+ if (rootParentUri != null) {\r
+ return URIStringUtils.unescape( uri.substring(rootParentUri.length()+1) );\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return uri;\r
+ }\r
+\r
@SuppressWarnings("unchecked")\r
public static void addResource(Session s, GraphDebugger debugger) throws DatabaseException {\r
Shell shell = debugger.getShell();\r