]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "Catch Throwable instead of Exception in SCL AsyncUtils"
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 19 Dec 2019 11:28:07 +0000 (11:28 +0000)
committerGerrit Code Review <gerrit2@simantics>
Thu, 19 Dec 2019 11:28:07 +0000 (11:28 +0000)
bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/internal/GECache.java
bundles/org.simantics.charts/src/org/simantics/charts/internal/JsonUtils.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/AssignSymbolGroupsDialog.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/WorkbenchMessages.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/messages.properties

index 014a5c0d54b37c0fbd06810137ca04b83a9f88f9..bdc0e16a04920de2029da3f919fa118e293a8c89 100644 (file)
@@ -24,38 +24,38 @@ import org.simantics.browsing.ui.NodeContext.CacheKey;
 
 public class GECache implements IGECache {
 
-    final Map<GECacheKey, IGECacheEntry> entries = new THashMap<GECacheKey, IGECacheEntry>();
-    final Map<GECacheKey, Set<UIElementReference>> treeReferences = new THashMap<GECacheKey, Set<UIElementReference>>();
+    final Map<GECacheKey, IGECacheEntry> entries = new THashMap<>();
+    final Map<GECacheKey, Set<UIElementReference>> treeReferences = new THashMap<>();
 
     final private static class GECacheKey {
 
         private NodeContext context;
         private CacheKey<?> key;
+        private int hash;
 
         GECacheKey(NodeContext context, CacheKey<?> key) {
-            this.context = context;
-            this.key = key;
-            if (context == null || key == null) 
-               throw new IllegalArgumentException("Null context or key is not accepted");
+            setValues(context, key);
         }
 
         GECacheKey(GECacheKey other) {
-            this.context = other.context;
-            this.key = other.key;
-            if (context == null || key == null) 
-               throw new IllegalArgumentException("Null context or key is not accepted");
+            setValues(other.context, other.key);
         }
 
         void setValues(NodeContext context, CacheKey<?> key) {
+            if (context == null || key == null) 
+                throw new IllegalArgumentException("Null context or key is not accepted");
             this.context = context;
             this.key = key;
-            if (context == null || key == null) 
-               throw new IllegalArgumentException("Null context or key is not accepted");
+            this.hash = calcHash();
+        }
+
+        private int calcHash() {
+            return (31 * context.hashCode()) + key.hashCode();
         }
 
         @Override
         public int hashCode() {
-            return context.hashCode() | key.hashCode();
+            return hash;
         }
 
         @Override
@@ -74,6 +74,11 @@ public class GECache implements IGECache {
 
         }
 
+        @Override
+        public String toString() {
+            return String.format("%s@%d [key=%s, context=%s]", getClass().getSimpleName(), System.identityHashCode(this), key, context); //$NON-NLS-1$
+        }
+
     };
 
     /**
@@ -116,9 +121,7 @@ public class GECache implements IGECache {
     public <T> T get(NodeContext context, CacheKey<T> key) {
         getKey.setValues(context, key);
         IGECacheEntry entry = entries.get(getKey);
-        if (entry == null)
-            return null;
-        return (T) entry.getValue();
+        return entry != null ? (T) entry.getValue() : null;
     }
 
     @Override
@@ -171,7 +174,7 @@ public class GECache implements IGECache {
        return references.get(context) > 0;
     }
 
-    private TObjectIntHashMap<NodeContext> references = new TObjectIntHashMap<NodeContext>();
+    private TObjectIntHashMap<NodeContext> references = new TObjectIntHashMap<>();
     
     @Override
     synchronized public void incRef(NodeContext context) {
index 19d9d48430d6109bf18acb930d15774b0a41e050..49bc6f08d40f41c109fa40abd25376a771f244b7 100644 (file)
@@ -54,6 +54,9 @@ public class JsonUtils {
         while (jp.nextToken() != JsonToken.END_OBJECT) {
             String fieldName = jp.getCurrentName();
             jp.nextToken();
+            if (fieldName == null)
+                continue;
+
             if (fieldName.equals("uri")) {
                 uri = jp.getValueAsString();
             } else if (fieldName.equals("type")) {
index b768a05ab728068fcc29a819ffaaf92512974752..a85c35628fb1a69252eed0359ed3ae7c7fdb8c7c 100644 (file)
@@ -38,10 +38,6 @@ public abstract class AssignSymbolGroupsDialog extends SelectionDialog {
 
     private static final String DIALOG = "AssignSymbolGroupsDialog"; //$NON-NLS-1$
 
-    static String SELECT_ALL_TITLE = ""; //$NON-NLS-1$
-
-    static String DESELECT_ALL_TITLE = ""; //$NON-NLS-1$
-
     // the root element to populate the viewer with
     protected Object inputElement;
 
@@ -86,7 +82,7 @@ public abstract class AssignSymbolGroupsDialog extends SelectionDialog {
         if (message != null) {
             setMessage(message);
         } else {
-            setMessage(""); //$NON-NLS-1$
+            setMessage(WorkbenchMessages.ListSelection_message);
         }
 
         IDialogSettings settings = Activator.getDefault().getDialogSettings();
@@ -114,7 +110,7 @@ public abstract class AssignSymbolGroupsDialog extends SelectionDialog {
         buttonComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true));
 
         Button selectButton = createButton(buttonComposite,
-                IDialogConstants.SELECT_ALL_ID, SELECT_ALL_TITLE, false);
+                IDialogConstants.SELECT_ALL_ID, WorkbenchMessages.SelectionDialog_selectLabel, false);
 
         SelectionListener listener = new SelectionAdapter() {
             public void widgetSelected(SelectionEvent e) {
@@ -125,7 +121,7 @@ public abstract class AssignSymbolGroupsDialog extends SelectionDialog {
         selectButton.addSelectionListener(listener);
 
         Button deselectButton = createButton(buttonComposite,
-                IDialogConstants.DESELECT_ALL_ID, DESELECT_ALL_TITLE, false);
+                IDialogConstants.DESELECT_ALL_ID, WorkbenchMessages.SelectionDialog_deselectLabel, false);
 
         listener = new SelectionAdapter() {
             public void widgetSelected(SelectionEvent e) {
@@ -139,7 +135,7 @@ public abstract class AssignSymbolGroupsDialog extends SelectionDialog {
         Label label = new Label(buttonComposite, SWT.NONE);
 
         Button newButton = createButton(buttonComposite,
-                IDialogConstants.INTERNAL_ID-1, org.simantics.modeling.ui.actions.WorkbenchMessages.AssignSymbolGroupsDialog_NewDots, false);
+                IDialogConstants.INTERNAL_ID-1, org.simantics.modeling.ui.actions.WorkbenchMessages.AssignSymbolGroupsDialog_New, false);
 
         listener = new SelectionAdapter() {
             public void widgetSelected(SelectionEvent e) {
@@ -149,7 +145,7 @@ public abstract class AssignSymbolGroupsDialog extends SelectionDialog {
         newButton.addSelectionListener(listener);
 
         Button removeButton = createButton(buttonComposite,
-                IDialogConstants.INTERNAL_ID-2, org.simantics.modeling.ui.actions.WorkbenchMessages.AssignSymbolGroupsDialog_RemoveAnd, false);
+                IDialogConstants.INTERNAL_ID-2, org.simantics.modeling.ui.actions.WorkbenchMessages.AssignSymbolGroupsDialog_Remove, false);
 
         listener = new SelectionAdapter() {
             public void widgetSelected(SelectionEvent e) {
index 36ed5b8fb97172777520d4722a3735d129e3de96..24e7b8af4e7b4a895df37d03151567336168705e 100644 (file)
@@ -4,8 +4,8 @@ import org.eclipse.osgi.util.NLS;
 
 public class WorkbenchMessages extends NLS {
        private static final String BUNDLE_NAME = "org.simantics.modeling.ui.actions.messages"; //$NON-NLS-1$
-       public static String AssignSymbolGroupsDialog_NewDots;
-       public static String AssignSymbolGroupsDialog_RemoveAnd;
+       public static String AssignSymbolGroupsDialog_New;
+       public static String AssignSymbolGroupsDialog_Remove;
        static {
                // initialize resource bundle
                NLS.initializeMessages(BUNDLE_NAME, WorkbenchMessages.class);
index 57f9e15cbd8c6619109d692afa59952a29bbac38..0020e272b22d1b94bd65f9b5d42f06c86bfd0c29 100644 (file)
@@ -10,8 +10,8 @@ AssignSymbolGroup_SelectSymbolGroupsTheSelectedSymbolIsShownIn=Select symbol gro
 AssignSymbolGroup_SelectSymbolGroupsTheSelectedSymbolsAreShownIn=Select symbol groups the selected {0} symbols are shown in.
 AssignSymbolGroup_SymbolGroupAssignments=Symbol Group Assignments
 AssignSymbolGroup_WriteSymbolGroupName=Write the name of the new symbol group.
-AssignSymbolGroupsDialog_NewDots=&New...
-AssignSymbolGroupsDialog_RemoveAnd=&Remove
+AssignSymbolGroupsDialog_New=&New...
+AssignSymbolGroupsDialog_Remove=&Remove
 CompilePGraphsAction_CompilePGraphs=Compile PGraphs
 CompilePGraphsAction_Continue=Continue
 CompilePGraphsAction_FollowingIssuesFound=The following issues were found: