diff options
2 files changed, 55 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java index 4c3508f8e..c1d1daed9 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java @@ -63,6 +63,11 @@ public interface IPeerNodeProperties { public static final String PROPERTY_WARNINGS = "Warnings"; //$NON-NLS-1$ /** + * Property: Contains for warnings origins (Map<String,String) + */ + public static final String PROPERTY_WARNING_ORIGINS = "WarningOrigins"; //$NON-NLS-1$ + + /** * Property: Exit error if any simulator or other started process died during connect. */ public static final String PROP_EXIT_ERROR = "ExitError"; //$NON-NLS-1$ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/CommonUtils.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/CommonUtils.java index 293c65257..d96a742a2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/CommonUtils.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/CommonUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014, 2015 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -179,4 +179,53 @@ public final class CommonUtils { peerNode.fireChangeEvent(IPeerNodeProperties.PROPERTY_WARNINGS, null, null); return changed.get(); } + + @SuppressWarnings("unchecked") + public static String getPeerWarningOrigin(final IPeerNode peerNode, final String warningKey) { + final AtomicReference<Object> warningOrigins = new AtomicReference<Object>(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + warningOrigins.set(peerNode.getProperty(IPeerNodeProperties.PROPERTY_WARNING_ORIGINS)); + } + }); + + if (warningOrigins.get() != null && warningOrigins.get() instanceof Map<?,?>) { + return ((Map<String,String>)warningOrigins.get()).get(warningKey); + } + return null; + } + + public static boolean setPeerWarningOrigin(final IPeerNode peerNode, final String warningKey, final String value) { + final AtomicBoolean changed = new AtomicBoolean(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + @SuppressWarnings("unchecked") + Map<String,String> warningsOrigins = (Map<String,String>)peerNode.getProperty(IPeerNodeProperties.PROPERTY_WARNING_ORIGINS); + if (warningsOrigins == null) { + if (value == null) { + return; + } + warningsOrigins = new HashMap<String,String>(); + } + if (value != null) { + changed.set(!value.equals(warningsOrigins.get(warningKey))); + warningsOrigins.put(warningKey, value); + } + else { + changed.set(warningsOrigins.get(warningKey) != null); + warningsOrigins.remove(warningKey); + if (warningsOrigins.isEmpty()) { + warningsOrigins = null; + } + } + peerNode.setChangeEventsEnabled(false); + peerNode.setProperty(IPeerNodeProperties.PROPERTY_WARNING_ORIGINS, warningsOrigins); + peerNode.setChangeEventsEnabled(true); + } + }); + peerNode.fireChangeEvent(IPeerNodeProperties.PROPERTY_WARNING_ORIGINS, null, null); + return changed.get(); + } } |