X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.debug.ui%2Fsrc%2Forg%2Fsimantics%2Fdebug%2Fui%2FVariableDebugger.java;h=697a589395dae9eab29af679020ee53780d6b444;hp=9c02bbe2a70806dfb8833e9b7a23a12310e7a015;hb=59724aa55a75a4efc3ec17e3b4a4ef62f463526e;hpb=1fe7ef332a6f996a13b4dda38bc85a743a154baa 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 9c02bbe2a..697a58939 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 @@ -102,12 +102,12 @@ public class VariableDebugger extends Composite { void historyChanged(); } - private final static String DEFAULT_DEBUGGER_CSS_FILE = "debugger.css"; - private final static String DEFAULT_DEBUGGER_CSS_PATH = "css/" + DEFAULT_DEBUGGER_CSS_FILE; + private final static String DEFAULT_DEBUGGER_CSS_FILE = "debugger.css"; //$NON-NLS-1$ + private final static String DEFAULT_DEBUGGER_CSS_PATH = "css/" + DEFAULT_DEBUGGER_CSS_FILE; //$NON-NLS-1$ private static int RESOURCE_NAME_MAX_LENGTH = 1000; - private final Charset utf8 = Charset.forName("UTF-8"); + private final Charset utf8 = Charset.forName("UTF-8"); //$NON-NLS-1$ private final LocalResourceManager resourceManager; @@ -157,7 +157,7 @@ public class VariableDebugger extends Composite { if (!browser.isDisposed()) browser.setText(content); if (!updateTriggerCounter.isDisposed()) - updateTriggerCounter.setText(updateCount + "/" + triggerCounter); + updateTriggerCounter.setText(updateCount + "/" + triggerCounter); //$NON-NLS-1$ } }); } @@ -181,7 +181,7 @@ public class VariableDebugger extends Composite { */ public VariableDebugger(Composite parent, int style, final Session session, String initialURI) { super(parent, style); - Assert.isNotNull(session, "session is null"); + Assert.isNotNull(session, "session is null"); //$NON-NLS-1$ this.session = session; this.currentElement = initialURI; this.resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent); @@ -222,7 +222,7 @@ public class VariableDebugger extends Composite { if (!css.exists()) { URL url = FileLocator.find(Activator.getDefault().getBundle(), new Path(DEFAULT_DEBUGGER_CSS_PATH), null); if (url == null) - throw new FileNotFoundException("Could not find '" + DEFAULT_DEBUGGER_CSS_PATH + "' in bundle '" + Activator.PLUGIN_ID + "'"); + throw new FileNotFoundException("Could not find '" + DEFAULT_DEBUGGER_CSS_PATH + "' in bundle '" + Activator.PLUGIN_ID + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ cssPath = FileUtils.copyResource(url, css, true).toURI().toString(); } else { cssPath = css.toURI().toString(); @@ -238,7 +238,7 @@ public class VariableDebugger extends Composite { public Label createDropLabel(Composite parent) { final Label label = new Label(parent, SWT.BORDER | SWT.FLAT); label.setAlignment(SWT.CENTER); - label.setText(" Drag a resource or a variable here to examine it in this debugger! "); + label.setText(Messages.VariableDebugger_DragResourceToDebugger); label.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); GridData data = new GridData(SWT.LEFT, SWT.FILL, false, false); label.setLayoutData(data); @@ -316,7 +316,7 @@ public class VariableDebugger extends Composite { text.setLayoutData(data); Button button = new Button(parent, SWT.NONE); - button.setText("Lookup"); + button.setText(Messages.VariableDebugger_Lookup); GridData data2 = new GridData(SWT.FILL, SWT.FILL, false, false); button.setLayoutData(data2); @@ -347,7 +347,7 @@ public class VariableDebugger extends Composite { protected Text createUpdateTriggerCounter(Composite parent) { Text label = new Text(parent, SWT.BORDER | SWT.FLAT); label.setEditable(false); - label.setToolTipText("Amount of Screen/Listener Updates Received for Shown Variable"); + label.setToolTipText(Messages.VariableDebugger_TextToolTip); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL) .grab(false, false).hint(32, SWT.DEFAULT).applyTo(label); updateTriggerCounter = label; @@ -385,21 +385,21 @@ public class VariableDebugger extends Composite { @Override public void changing(LocationEvent event) { String location = event.location; - if (location.startsWith("simantics:browser")) - location = "about:" + location.substring(17); + if (location.startsWith("simantics:browser")) //$NON-NLS-1$ + location = "about:" + location.substring(17); //$NON-NLS-1$ //System.out.println("changing: location=" + location); // Do not follow links that are meant as actions that are // handled below. event.doit = false; - if ("about:blank".equals(location)) { + if ("about:blank".equals(location)) { //$NON-NLS-1$ // Just changing to the same old blank url is ok since it // allows the browser to refresh itself. event.doit = true; } - if (location.startsWith("about:-link")) { - String target = location.replace("about:-link", ""); + if (location.startsWith("about:-link")) { //$NON-NLS-1$ + String target = location.replace("about:-link", ""); //$NON-NLS-1$ //$NON-NLS-2$ try { byte[] bytes = Base64.decode(target); String url = new String(bytes, utf8); @@ -411,8 +411,8 @@ public class VariableDebugger extends Composite { } catch (IOException e) { ErrorLogger.defaultLogError(e); } - } else if (location.startsWith("about:-remove")) { - } else if (location.startsWith("about:-edit-value")) { + } else if (location.startsWith("about:-remove")) { //$NON-NLS-1$ + } else if (location.startsWith("about:-edit-value")) { //$NON-NLS-1$ } } }); @@ -508,43 +508,43 @@ public class VariableDebugger extends Composite { if (o instanceof byte[]) { byte[] arr = (byte[]) o; byte[] arr2 = Arrays.copyOf(arr, RESOURCE_NAME_MAX_LENGTH); - return truncated("byte", Arrays.toString(arr2), arr.length); + return truncated("byte", Arrays.toString(arr2), arr.length); //$NON-NLS-1$ } else if (o instanceof int[]) { int[] arr = (int[]) o; int[] arr2 = Arrays.copyOf(arr, RESOURCE_NAME_MAX_LENGTH); - return truncated("int", Arrays.toString(arr2), arr.length); + return truncated("int", Arrays.toString(arr2), arr.length); //$NON-NLS-1$ } else if (o instanceof long[]) { long[] arr = (long[]) o; long[] arr2 = Arrays.copyOf(arr, RESOURCE_NAME_MAX_LENGTH); - return truncated("long", Arrays.toString(arr2), arr.length); + return truncated("long", Arrays.toString(arr2), arr.length); //$NON-NLS-1$ } else if (o instanceof float[]) { float[] arr = (float[]) o; float[] arr2 = Arrays.copyOf(arr, RESOURCE_NAME_MAX_LENGTH); - return truncated("float", Arrays.toString(arr2), arr.length); + return truncated("float", Arrays.toString(arr2), arr.length); //$NON-NLS-1$ } else if (o instanceof double[]) { double[] arr = (double[]) o; double[] arr2 = Arrays.copyOf(arr, RESOURCE_NAME_MAX_LENGTH); - return truncated("double", Arrays.toString(arr2), arr.length); + return truncated("double", Arrays.toString(arr2), arr.length); //$NON-NLS-1$ } else if (o instanceof boolean[]) { boolean[] arr = (boolean[]) o; boolean[] arr2 = Arrays.copyOf(arr, RESOURCE_NAME_MAX_LENGTH); - return truncated("boolean", Arrays.toString(arr2), arr.length); + return truncated("boolean", Arrays.toString(arr2), arr.length); //$NON-NLS-1$ } else if (o instanceof Object[]) { Object[] arr = (Object[]) o; Object[] arr2 = Arrays.copyOf(arr, RESOURCE_NAME_MAX_LENGTH); - return truncated("Object", Arrays.toString(arr2), arr.length); + return truncated("Object", Arrays.toString(arr2), arr.length); //$NON-NLS-1$ } else { - return "Unknown big array " + o.getClass(); + return "Unknown big array " + o.getClass(); //$NON-NLS-1$ } } else { - return o.getClass().getComponentType() + "[" + length + "] = " + ObjectUtils.toString(o); + return o.getClass().getComponentType() + "[" + length + "] = " + ObjectUtils.toString(o); //$NON-NLS-1$ //$NON-NLS-2$ } } return null; } protected String truncated(String type, String string, int originalLength) { - return type + "[" + RESOURCE_NAME_MAX_LENGTH + "/" + originalLength + "] = " + string; + return type + "[" + RESOURCE_NAME_MAX_LENGTH + "/" + originalLength + "] = " + string; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } protected String getVariableName(ReadGraph graph, Variable r) { @@ -563,7 +563,7 @@ public class VariableDebugger extends Composite { for(VariableConnectionPointDescriptor v : c.getConnectionPointDescriptors(graph, null)) { result.add(v.getRelativeRVI(graph, base)); } - return "c " + result.toString(); + return "c " + result.toString(); //$NON-NLS-1$ } else if (clazz.isArray()) { if(int[].class == clazz) { return Arrays.toString((int[])o); @@ -591,10 +591,10 @@ public class VariableDebugger extends Composite { Object value = r.getValue(graph); if(value instanceof Resource) return getResourceRef(graph, (Resource)value); else if (value instanceof Variable) return getVariableRef(graph, (Variable)value); - else return value != null ? getValue(graph, r, value) : "null"; + else return value != null ? getValue(graph, r, value) : "null"; //$NON-NLS-1$ } catch (Throwable e) { try { - Logger.defaultLogError("getValue " + r.getURI(graph), e); + Logger.defaultLogError("getValue " + r.getURI(graph), e); //$NON-NLS-1$ } catch (DatabaseException e1) { Logger.defaultLogError(e1); } @@ -605,7 +605,7 @@ public class VariableDebugger extends Composite { protected String getDatatype(ReadGraph graph, Variable r) { try { Datatype dt = r.getPossibleDatatype(graph); - return dt != null ? dt.toSingleLineString() : "undefined"; + return dt != null ? dt.toSingleLineString() : "undefined"; //$NON-NLS-1$ } catch (Exception e) { return e.getMessage(); } @@ -616,9 +616,9 @@ public class VariableDebugger extends Composite { } private String getVariableRef(ReadGraph graph, Variable r) throws DatabaseException { - String ret = "" + String ret = "" //$NON-NLS-1$ //$NON-NLS-2$ + getVariableName(graph, r) - + ""; + + ""; //$NON-NLS-1$ // if (graph.isInstanceOf(r, L0.Literal)) { // ret += " " // + "(edit value)" @@ -645,11 +645,11 @@ public class VariableDebugger extends Composite { // } catch (Exception e) { // e.printStackTrace(); // } - content.append(""); - content.append("").append(getVariableRef(graph, property)).append(""); - content.append("").append(getValue(graph, property)).append(""); - content.append("").append(getDatatype(graph, property)).append(""); - content.append(""); + content.append(""); //$NON-NLS-1$ + content.append("").append(getVariableRef(graph, property)).append(""); //$NON-NLS-1$ //$NON-NLS-2$ + content.append("").append(getValue(graph, property)).append(""); //$NON-NLS-1$ //$NON-NLS-2$ + content.append("").append(getDatatype(graph, property)).append(""); //$NON-NLS-1$ //$NON-NLS-2$ + content.append(""); //$NON-NLS-1$ } protected String getRVIString(ReadGraph graph, Variable var) throws DatabaseException { @@ -657,7 +657,7 @@ public class VariableDebugger extends Composite { try { return var.getRVI(graph).toString(graph); } catch (Throwable e) { - return "No RVI"; + return "No RVI"; //$NON-NLS-1$ } } @@ -669,9 +669,9 @@ public class VariableDebugger extends Composite { StringBuilder content = new StringBuilder(); // Generate HTML -page - content.append("").append(getHead()).append("\n"); - content.append("\n"); - content.append("
\n"); + content.append("").append(getHead()).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ + content.append("\n"); //$NON-NLS-1$ + content.append("
\n"); //$NON-NLS-1$ for (String uri : uris) { //System.out.println("URI: " + uri); Variable var = Variables.getPossibleVariable(graph, uri); @@ -690,14 +690,14 @@ public class VariableDebugger extends Composite { } // Begin #top DIV - content.append("
\n"); - content.append("\n"); - content.append("\n"); - content.append("\n"); - content.append("\n"); - content.append("\n"); - content.append("
URI").append(uri).append("
RVI").append(rviString).append("
Class").append(var.getClass().getCanonicalName()).append("
Solver node").append(node).append("
\n"); - content.append("
\n"); + content.append("
\n"); //$NON-NLS-1$ + content.append("\n"); //$NON-NLS-1$ + content.append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ + content.append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ + content.append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ + content.append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ + content.append("
URI").append(uri).append("
RVI").append(rviString).append("
Class").append(var.getClass().getCanonicalName()).append("
Solver node").append(node).append("
\n"); //$NON-NLS-1$ + content.append("
\n"); //$NON-NLS-1$ // Close #top DIV // Content @@ -709,7 +709,7 @@ public class VariableDebugger extends Composite { } } catch (DatabaseException e) { // This may happen if the Variable implementation is broken - ErrorLogger.defaultLogError("Broken variable child retrieval implementation or serious modelling error encountered. See exception for details.", e); + ErrorLogger.defaultLogError("Broken variable child retrieval implementation or serious modelling error encountered. See exception for details.", e); //$NON-NLS-1$ } TreeMap map2 = new TreeMap(); @@ -720,37 +720,37 @@ public class VariableDebugger extends Composite { } } catch (DatabaseException e) { // This may happen if the Variable implementation is broken - ErrorLogger.defaultLogError("Broken variable property retrieval implementation or serious modelling error encountered. See exception for details.", e); + ErrorLogger.defaultLogError("Broken variable property retrieval implementation or serious modelling error encountered. See exception for details.", e); //$NON-NLS-1$ } - content.append("\n
\n"); - content.append("\n"); + content.append("\n
\n"); //$NON-NLS-1$ + content.append("
\n"); //$NON-NLS-1$ - content.append(""); + content.append(""); //$NON-NLS-1$ for (Variable child : map.values()) { - content.append(""); + content.append(""); //$NON-NLS-1$ //$NON-NLS-2$ } - content.append(""); + content.append(""); //$NON-NLS-1$ for (Variable property : map2.values()) { updateProperty(content, graph, property); } // Close #data - content.append("\n\n"); + content.append("\n\n"); //$NON-NLS-1$ } // Close #mainContent - content.append("\n"); - content.append("\n"); + content.append("\n"); //$NON-NLS-1$ + content.append("\n"); //$NON-NLS-1$ // Update content return content.toString(); } private String getHead() { - String result = ""; + String result = ""; //$NON-NLS-1$ if (cssPath != null) { - result = ""; + result = ""; //$NON-NLS-1$ //$NON-NLS-2$ } return result; }
Child
Child
").append(getVariableRef(graph, child)).append("
").append(getVariableRef(graph, child)).append("
PropertyValueDatatype
PropertyValueDatatype