de.cau.cs.kieler.sim.kiem.config.managers
Class ScheduleManager

java.lang.Object
  extended by de.cau.cs.kieler.sim.kiem.config.managers.AbstractManager
      extended by de.cau.cs.kieler.sim.kiem.config.managers.ScheduleManager
All Implemented Interfaces:
IRefactoringHistoryListener

public final class ScheduleManager
extends AbstractManager
implements IRefactoringHistoryListener

Manages all data for the scheduling preferences.

Rating proposed yellow
(2010-01-27)

Field Summary
static int DEFAULT_RECENT_CAPACITY
          the default capacity for the recent list.
 
Method Summary
 ScheduleData addSchedule(EditorDefinition editor, IPath location, int priority)
          Create a new schedule.
 List<ScheduleData> getAllSchedules()
          Getter for the list of all schedules.
 List<ScheduleData> getImportedSchedules()
          Getter for the list of schedules that were imported through the extension point.
static ScheduleManager getInstance()
          Returns the singleton instance of this manager.
 List<ScheduleData> getMatchingSchedules(EditorIdWrapper editorID, String editorName)
          Get the list of all schedules that apply to the current editorID.
 MostRecentCollection<String> getRecentScheduleIds()
          Get the list of Ids of the most recently used schedules.
 List<ScheduleData> getRecentSchedules()
          Get the list of most recently used schedules.
 ScheduleData getScheduleData(String id)
          Try to find the schedule data with the specified id.
 void historyNotification(RefactoringHistoryEvent event)
          
 void importAllFilesInWorkspace()
          Import all files in the workspace into the manager.
 boolean isEnabled()
           
 void load()
          Load the saved data from the plugin's preference store.
 void openSchedule(ScheduleData schedule)
          Load a schedule from the file system into the plugin.
 void removeSchedule(ScheduleData schedule)
          Remove a schedule from the list.
 void removeSchedule(String scheduleId)
          Remove a schedule with a specific key.
 void save()
          Saves the data inside the manager into the plugin's preference store.
 void setEnabled(boolean enabled)
           
 void userLoaded(IPath location)
          Notify the manager that the user triggered a load.
 void userSaved(IPath location)
          Notify the manager that the user triggered a save.
 
Methods inherited from class de.cau.cs.kieler.sim.kiem.config.managers.AbstractManager
addEventListener, load, notifyListeners, remove, removeEventListener, save, saveAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RECENT_CAPACITY

public static final int DEFAULT_RECENT_CAPACITY
the default capacity for the recent list.

See Also:
Constant Field Values
Method Detail

getInstance

public static ScheduleManager getInstance()
Returns the singleton instance of this manager.

Returns:
the instance.

setEnabled

public void setEnabled(boolean enabled)

isEnabled

public boolean isEnabled()

getImportedSchedules

public List<ScheduleData> getImportedSchedules()
Getter for the list of schedules that were imported through the extension point.

Returns:
the list of imported schedules.

getMatchingSchedules

public List<ScheduleData> getMatchingSchedules(EditorIdWrapper editorID,
                                               String editorName)
Get the list of all schedules that apply to the current editorID.

The list is sorted by the supported priority for the matching editor. The best schedules have the lowest index to appear at the top of any list.

Parameters:
editorID - the ID to look for.
editorName - the name of the editor if the editor hasn't been added yet
Returns:
the list of applicable schedules.

getRecentScheduleIds

public MostRecentCollection<String> getRecentScheduleIds()
Get the list of Ids of the most recently used schedules.

Returns:
the list

getRecentSchedules

public List<ScheduleData> getRecentSchedules()
Get the list of most recently used schedules.

Returns:
the list of most recently used schedules.

getAllSchedules

public List<ScheduleData> getAllSchedules()
Getter for the list of all schedules.

Returns:
the list of all saved schedules.

getScheduleData

public ScheduleData getScheduleData(String id)
Try to find the schedule data with the specified id.

Parameters:
id - the scheduleID to look for.
Returns:
the found schedule data, may be null

historyNotification

public void historyNotification(RefactoringHistoryEvent event)

Specified by:
historyNotification in interface IRefactoringHistoryListener

importAllFilesInWorkspace

public void importAllFilesInWorkspace()
Import all files in the workspace into the manager.


addSchedule

public ScheduleData addSchedule(EditorDefinition editor,
                                IPath location,
                                int priority)
Create a new schedule.

First the method checks if the editor is already in the list of currently available editors. If not the new editor is created and added to that list.

After that the new Schedule is created and the default priority assigned to the editor that the schedule was first used with.

Parameters:
editor - the editor that created the schedule.
location - the save location of the schedule.
priority - the priority to assign to the editor
Returns:
the added schedule, or null if no schedule was added.

removeSchedule

public void removeSchedule(ScheduleData schedule)
Remove a schedule from the list.

Parameters:
schedule - the schedule to be removed

removeSchedule

public void removeSchedule(String scheduleId)
Remove a schedule with a specific key.

Parameters:
scheduleId - the scheduleID to look for.

openSchedule

public void openSchedule(ScheduleData schedule)
                  throws ScheduleFileMissingException
Load a schedule from the file system into the plugin. If the editor is dirty a save is triggered. Then the plugin tries to load the .execution file through the method provided by the main KIEM plugin. If that method fails because the file is no longer at the saved location an Exception is thrown to inform the loader. It is suggested that in this case the faulty schedule should either be removed or the location updated and the load tried again.

This method can be called from another plug-in and is part of the KIEM Configurations API.

Parameters:
schedule - the schedule data to load.
Throws:
ScheduleFileMissingException - if the location in the schedule is no longer valid

userSaved

public void userSaved(IPath location)
Notify the manager that the user triggered a save. The manager gathers all information needed to create a new schedule and adds that schedule to the list.

Parameters:
location - the location where the file was saved.

userLoaded

public void userLoaded(IPath location)
Notify the manager that the user triggered a load. The manager gathers all information needed to create a new schedule and adds that schedule to the list.

Parameters:
location - the location where the file was loaded from.

load

public void load()
Load the saved data from the plugin's preference store. Usually not necessary as data is loaded on demand.

Specified by:
load in class AbstractManager

save

public void save()
Saves the data inside the manager into the plugin's preference store.

Specified by:
save in class AbstractManager