Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2014-05-20 00:20:21 -0400
committerTobias Schwarz2014-05-20 00:21:39 -0400
commit238187605aa38745a13a3f8fd276b9cbc957453a (patch)
treebab92b4f6da23556103ddf5e960bf2350246a070
parentc6a05a2acede6170ff7e6fadf80b934019e82d3d (diff)
downloadorg.eclipse.tcf-238187605aa38745a13a3f8fd276b9cbc957453a.tar.gz
org.eclipse.tcf-238187605aa38745a13a3f8fd276b9cbc957453a.tar.xz
org.eclipse.tcf-238187605aa38745a13a3f8fd276b9cbc957453a.zip
Target Explorer: fix stack overflow when executing an action twice
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/utils/DataHelper.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessContextItem.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/ProcessContextItem.java13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/util/ProcessDataHelper.java26
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java1
7 files changed, 22 insertions, 54 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/utils/DataHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/utils/DataHelper.java
index 52f9b4c78..e8ad5d3c7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/utils/DataHelper.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/utils/DataHelper.java
@@ -12,7 +12,6 @@ package org.eclipse.tcf.te.runtime.persistence.utils;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -43,8 +42,6 @@ public class DataHelper {
return null;
}
- private static final Map<String, IPropertiesContainer> cache = new LinkedHashMap<String, IPropertiesContainer>();
-
/**
* Decode a string encoded properties container.
* @param encoded The string encoded properties container.
@@ -52,21 +49,12 @@ public class DataHelper {
*/
public static final IPropertiesContainer decodePropertiesContainer(String encoded) {
if (encoded != null && encoded.trim().length() > 0) {
- IPropertiesContainer result = cache.remove(encoded);
- if (result == null) {
- try {
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(Map.class, String.class);
- result = (IPropertiesContainer)delegate.read(IPropertiesContainer.class, encoded);
- }
- catch (Exception e) {
- }
-
- if (cache.size() == 10) cache.remove(cache.keySet().toArray()[0]);
+ try {
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(Map.class, String.class);
+ return (IPropertiesContainer)delegate.read(IPropertiesContainer.class, encoded);
+ }
+ catch (Exception e) {
}
-
- cache.put(encoded, result);
-
- return result;
}
return new PropertiesContainer();
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessContextItem.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessContextItem.java
index a6768fb22..39b9571c1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessContextItem.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessContextItem.java
@@ -22,6 +22,8 @@ public interface IProcessContextItem extends IPropertiesContainer {
public static final String PROPERTY_NAME = "name"; //$NON-NLS-1$
public static final String PROPERTY_PATH = "path"; //$NON-NLS-1$
+ public static final String PATH_SEPARATOR = "/"; //$NON-NLS-1$
+
/**
* Return the context id.
*/
@@ -35,5 +37,5 @@ public interface IProcessContextItem extends IPropertiesContainer {
/**
* Return the context path.
*/
- public String[] getPath();
+ public String getPath();
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/ProcessContextItem.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/ProcessContextItem.java
index ce83190eb..4715476c6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/ProcessContextItem.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/ProcessContextItem.java
@@ -10,8 +10,6 @@
package org.eclipse.tcf.te.tcf.processes.core.persistence;
-import java.util.List;
-
import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem;
@@ -47,15 +45,8 @@ public class ProcessContextItem extends PropertiesContainer implements IProcessC
* @see org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem#getPath()
*/
@Override
- public String[] getPath() {
- Object path = getProperty(PROPERTY_PATH);
- if (path instanceof String[]) {
- return (String[])path;
- }
- if (path instanceof List<?>) {
- return ((List<?>)path).toArray(new String[((List<?>)path).size()]);
- }
- return null;
+ public String getPath() {
+ return getStringProperty(PROPERTY_PATH);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/util/ProcessDataHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/util/ProcessDataHelper.java
index cb66803c1..3e8a45511 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/util/ProcessDataHelper.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/util/ProcessDataHelper.java
@@ -82,13 +82,13 @@ public class ProcessDataHelper {
return ctxItem.get();
}
- protected static final String[] getProcessContextNodePath(IProcessContextNode node) {
- List<String> path = new ArrayList<String>();
+ protected static final String getProcessContextNodePath(IProcessContextNode node) {
+ String path = null;
while (node.getParent() instanceof IProcessContextNode) {
node = (IProcessContextNode)node.getParent();
- path.add(0, node.getProcessContext().getName());
+ path = node.getProcessContext().getName() + (path != null ? IProcessContextItem.PATH_SEPARATOR + path : ""); //$NON-NLS-1$
}
- return path.toArray(new String[path.size()]);
+ return path;
}
public static final IProcessContextNode[] getProcessContextNodes(final IPeerNode peerNode, final IProcessContextItem item) {
@@ -118,21 +118,9 @@ public class ProcessDataHelper {
protected static final boolean isValid(IProcessContextNode node, IProcessContextItem item) {
if (item.getName() != null && node.getProcessContext().getName().equals(item.getName())) {
- if (item.getPath() != null) {
- String[] itemPath = item.getPath();
- String[] nodePath = getProcessContextNodePath(node);
- if (itemPath.length == nodePath.length) {
- for (int i=0; i<itemPath.length; i++) {
- if (!itemPath[i].equals(nodePath[i])) {
- return false;
- }
- }
- return true;
- }
- }
- else {
- return true;
- }
+ String itemPath = item.getPath();
+ String nodePath = getProcessContextNodePath(node);
+ return (itemPath == null && nodePath == null) || (itemPath != null && itemPath.equals(nodePath));
}
return false;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java
index 10df25f6c..1456b1d02 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java
@@ -92,11 +92,9 @@ public class DefaultContextToolbarDelegate extends AbstractDefaultContextToolbar
else {
contexts += "\n\t"; //$NON-NLS-1$
}
- String[] path = item.getPath();
- if (path != null && path.length > 0) {
- for (String segment : path) {
- contexts += segment + "/"; //$NON-NLS-1$
- }
+ String path = item.getPath();
+ if (path != null && path.length() > 0) {
+ contexts += path + IProcessContextItem.PATH_SEPARATOR;
}
contexts += item.getName();
IUIService service = peerNode != null ? ServiceManager.getInstance().getService(peerNode, IUIService.class) : null;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java
index decb43b40..45fa5e627 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java
@@ -148,7 +148,7 @@ public class AttachContextSelectionDialog extends CustomTitleAreaDialog implemen
viewer = new TreeViewer(panel, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
Tree fModuleTree = viewer.getTree();
gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
- gd.minimumHeight = 300;
+ gd.minimumHeight = 250;
gd.minimumWidth = 300;
gd.widthHint = 300;
gd.heightHint = 300;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java
index 257d0a660..637ef2a94 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java
@@ -158,6 +158,7 @@ public abstract class AbstractContextStepperCommandHandler extends AbstractStepp
@Override
protected Object getContext(IPropertiesContainer data) {
IPeerNode[] contexts = PeerDataHelper.decodeContextList(data.getStringProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST));
+ data.setProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST, null);
return contexts.length == 1 ? contexts[0] : null;
}

Back to the top