Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-09-10 09:19:34 +0000
committerTobias Schwarz2013-09-10 09:19:34 +0000
commitf219b36b888088e50eea3047b7f3671dcf4b90b0 (patch)
tree9a13fc3670c3bff6cec90b39fbc7d6e9aeea6461 /target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence
parentab743939814e635ca03180585634395bc7c5767d (diff)
downloadorg.eclipse.tcf-f219b36b888088e50eea3047b7f3671dcf4b90b0.tar.gz
org.eclipse.tcf-f219b36b888088e50eea3047b7f3671dcf4b90b0.tar.xz
org.eclipse.tcf-f219b36b888088e50eea3047b7f3671dcf4b90b0.zip
Target Explorer: extend history manager with clear and set functionality
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/history/HistoryManager.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/history/HistoryManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/history/HistoryManager.java
index 334d44ff1..51021bde5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/history/HistoryManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/history/HistoryManager.java
@@ -12,6 +12,7 @@ package org.eclipse.tcf.te.runtime.persistence.history;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -157,6 +158,29 @@ public class HistoryManager {
}
/**
+ * Set a new list of history entries to the history ids list.
+ * If the list size exceeds the HISTORY_LENGTH, the last element of the list will be removed.
+ * @param historyId The history id.
+ * @param ids The ids to be set to the history ids list.
+ * @return <code>true</code> if the id
+ */
+ public void set(String historyId, String[] ids) {
+ Assert.isNotNull(historyId);
+ Assert.isNotNull(ids);
+
+ history.put(historyId, Arrays.asList(ids));
+ List<String> newIds = history.get(historyId);
+
+ while (newIds.size() > HISTORY_LENGTH) {
+ newIds.remove(HISTORY_LENGTH);
+ }
+
+ flush();
+
+ EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_CHANGED, historyId, historyId));
+ }
+
+ /**
* Remove a id from the history ids list.
* @param historyId The history id.
* @param id The id to be removed from the history ids list.
@@ -184,4 +208,19 @@ public class HistoryManager {
return removed;
}
+ /**
+ * Remove all ids from the history ids list.
+ * @param historyId The history id.
+ **/
+ public void clear(String historyId) {
+ Assert.isNotNull(historyId);
+
+ List<String> ids = history.remove(historyId);
+
+ if (ids != null) {
+ flush();
+ EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_REMOVED, historyId, historyId));
+ }
+ }
+
}

Back to the top