X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.debug.ui%2Fsrc%2Forg%2Fsimantics%2Fdebug%2Fui%2FVariableDebugger.java;h=996efb19626617aed12596a868762fd1dca91690;hb=785f638bab44e70ec6103c3891daea95bcda9a07;hp=697a589395dae9eab29af679020ee53780d6b444;hpb=236aa4e765e0acd6e31cbc42dd9df9c2c23677e2;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/VariableDebugger.java b/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/VariableDebugger.java index 697a58939..996efb196 100644 --- a/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/VariableDebugger.java +++ b/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/VariableDebugger.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * Copyright (c) 2007, 2020 Association for Decentralized Information Management * in Industry THTH ry. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -17,10 +17,10 @@ import java.io.IOException; import java.lang.reflect.Array; import java.net.URL; import java.nio.charset.Charset; -import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.TreeMap; +import java.util.TreeSet; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicReference; @@ -65,7 +65,6 @@ import org.simantics.db.Session; import org.simantics.db.common.ResourceArray; import org.simantics.db.common.procedure.adapter.DisposableListener; import org.simantics.db.common.request.UnaryRead; -import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.SelectionHints; import org.simantics.db.layer0.request.PossibleURI; @@ -90,6 +89,8 @@ import org.simantics.utils.bytes.Base64; import org.simantics.utils.ui.ErrorLogger; import org.simantics.utils.ui.ISelectionUtils; import org.simantics.utils.ui.PathUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -98,6 +99,8 @@ import org.simantics.utils.ui.PathUtils; */ public class VariableDebugger extends Composite { + private static final Logger LOGGER = LoggerFactory.getLogger(VariableDebugger.class); + public interface HistoryListener { void historyChanged(); } @@ -166,7 +169,7 @@ public class VariableDebugger extends Composite { @Override public void exception(Throwable t) { - Logger.defaultLogError(t); + LOGGER.error("Page content listener failed unexpectedly", t); } } @@ -261,15 +264,16 @@ public class VariableDebugger extends Composite { @Override public void drop(DropTargetEvent event) { label.setBackground(null); + String uri = null; try { - String uri = parseUri(event); + uri = parseUri(event); if (uri == null) { event.detail = DND.DROP_NONE; return; } changeLocation(uri); } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("Changing location to URI {} failed", uri, e); } } @@ -330,13 +334,14 @@ public class VariableDebugger extends Composite { @Override public void widgetSelected(SelectionEvent e) { + String uri = null; try { - String uri = text.getText(); + uri = text.getText(); // Make sure that URI is resolvable to Variable session.sync(new ResourceURIToVariable(uri)); changeLocation(uri); } catch (DatabaseException e1) { - Logger.defaultLogError(e1); + LOGGER.error("Lookup failed for URI {}", uri, e1); } } @@ -356,7 +361,7 @@ public class VariableDebugger extends Composite { public Browser createBrowser(Composite parent) { try { - browser = new Browser(parent, SWT.MOZILLA); + browser = new Browser(parent, SWT.NONE); } catch (SWTError e) { //System.out.println("Could not instantiate Browser: " + e.getMessage()); browser = new Browser(parent, SWT.NONE); @@ -559,11 +564,11 @@ public class VariableDebugger extends Composite { Class clazz = o.getClass(); if(o instanceof Connection) { Connection c = (Connection)o; - ArrayList result = new ArrayList(); + TreeSet rvis = new TreeSet<>(); for(VariableConnectionPointDescriptor v : c.getConnectionPointDescriptors(graph, null)) { - result.add(v.getRelativeRVI(graph, base)); + rvis.add(v.getRelativeRVI(graph, base)); } - return "c " + result.toString(); //$NON-NLS-1$ + return "c " + rvis.toString(); //$NON-NLS-1$ } else if (clazz.isArray()) { if(int[].class == clazz) { return Arrays.toString((int[])o); @@ -594,9 +599,9 @@ public class VariableDebugger extends Composite { else return value != null ? getValue(graph, r, value) : "null"; //$NON-NLS-1$ } catch (Throwable e) { try { - Logger.defaultLogError("getValue " + r.getURI(graph), e); //$NON-NLS-1$ + LOGGER.error("getValue({})", r.getURI(graph), e); //$NON-NLS-1$ } catch (DatabaseException e1) { - Logger.defaultLogError(e1); + LOGGER.error("Failed to get URI for problematic value variable", e1); } return e.getMessage(); } @@ -634,7 +639,7 @@ public class VariableDebugger extends Composite { String encoded = Base64.encode(uri.getBytes(utf8)); return encoded; } catch (Exception e) { - Logger.defaultLogError(e); + LOGGER.error("Failed to construct link string for variable", e); //$NON-NLS-1$ return e.getMessage(); } } @@ -681,11 +686,11 @@ public class VariableDebugger extends Composite { String rviString = getRVIString(graph, var); Object node = null; if(var instanceof AbstractChildVariable) { - VariableNode vn = ((AbstractChildVariable)var).node; + VariableNode vn = ((AbstractChildVariable)var).node; if(vn != null) node = vn.node; } if(var instanceof AbstractPropertyVariable) { - VariableNode vn = ((AbstractPropertyVariable)var).node; + VariableNode vn = ((AbstractPropertyVariable)var).node; if(vn != null) node = vn.node; }