Search in sources :

Example 1 with CommandHistory

use of org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory in project eclipse-integration-commons by spring-projects.

the class CommandHistoryTest method testSaveLoad.

public void testSaveLoad() throws Exception {
    saveFile = new File("saveit.gch");
    CommandHistory hist = new CommandHistory("test", "test", false);
    hist.add(new Entry("run-app foo", "kris"));
    assertFalse(hist.isEmpty());
    assertEquals(new Entry("run-app foo", "kris"), hist.getLast());
    hist.add(new Entry("run-app bar", "nieraj"));
    assertFalse(hist.isEmpty());
    assertEquals(new Entry("run-app bar", "nieraj"), hist.getLast());
    assertEquals(2, hist.size());
    assertTrue(hist.isDirty());
    hist.save(saveFile);
    assertFalse(hist.isDirty());
    hist = new CommandHistory("test", "test", false);
    assertTrue(hist.isEmpty());
    hist.load(saveFile);
    assertFalse(hist.isDirty());
    assertEquals(2, hist.size());
    assertIterator(hist, new Entry("run-app bar", "nieraj"), new Entry("run-app foo", "kris"));
}
Also used : CommandHistory(org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory) Entry(org.springsource.ide.eclipse.commons.core.Entry) File(java.io.File)

Example 2 with CommandHistory

use of org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory in project eclipse-integration-commons by spring-projects.

the class CommandHistoryTest method testAddElements.

public void testAddElements() throws Exception {
    CommandHistory hist = new CommandHistory("test", "test", false);
    assertFalse(hist.isDirty());
    hist.add(new Entry("run-app foo", "kris"));
    assertTrue(hist.isDirty());
    assertFalse(hist.isEmpty());
    assertEquals(new Entry("run-app foo", "kris"), hist.getLast());
    hist.add(new Entry("run-app bar", "nieraj"));
    assertTrue(hist.isDirty());
    assertFalse(hist.isEmpty());
    assertEquals(new Entry("run-app bar", "nieraj"), hist.getLast());
}
Also used : CommandHistory(org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory) Entry(org.springsource.ide.eclipse.commons.core.Entry)

Example 3 with CommandHistory

use of org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory in project eclipse-integration-commons by spring-projects.

the class CommandHistoryProvider method getCommandHistory.

public static synchronized ICommandHistory getCommandHistory(String historyId, String natureId) {
    String key = getKey(historyId, natureId);
    if (COMMAND_HISTORIES.containsKey(key)) {
        return COMMAND_HISTORIES.get(key);
    } else {
        try {
            CommandHistory commandHistory = new CommandHistory(historyId, natureId, true);
            COMMAND_HISTORIES.put(key, commandHistory);
            return commandHistory;
        } catch (CoreException e) {
            CorePlugin.log("Warning: couldn't get persistent command history, using non-persistent history instead", e);
            return new CommandHistory(historyId, natureId);
        }
    }
}
Also used : CommandHistory(org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory) CoreException(org.eclipse.core.runtime.CoreException)

Example 4 with CommandHistory

use of org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory in project eclipse-integration-commons by spring-projects.

the class CommandHistoryTest method testNewHistory.

public void testNewHistory() throws Exception {
    CommandHistory hist = new CommandHistory("test", "test", false);
    assertTrue(hist.isEmpty());
}
Also used : CommandHistory(org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory)

Example 5 with CommandHistory

use of org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory in project eclipse-integration-commons by spring-projects.

the class CommandHistoryTest method testToArray.

public void testToArray() throws Exception {
    Entry[] entries = new Entry[] { new Entry("run-app foo", "kris"), new Entry("run-app bar", "nieraj"), new Entry("blah blah", "ka.da.na.za") };
    CommandHistory hist = new CommandHistory("test", "test", false);
    assertTrue(hist.isEmpty());
    for (int i = entries.length - 1; i >= 0; i--) {
        hist.add(entries[i]);
    }
    assertTrue(Arrays.equals(entries, hist.toArray()));
}
Also used : CommandHistory(org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory) Entry(org.springsource.ide.eclipse.commons.core.Entry)

Aggregations

CommandHistory (org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory)6 Entry (org.springsource.ide.eclipse.commons.core.Entry)4 File (java.io.File)2 CoreException (org.eclipse.core.runtime.CoreException)1