package com.onaro.sanscreen.client.view; import java.awt.Component; import java.util.List; import java.util.ResourceBundle; import java.util.Set; import java.util.concurrent.Future; import javax.swing.Icon; import javax.swing.JMenu; import org.eclipse.core.runtime.IAdaptable; import com.onaro.client.leekui.ui.IMemento; import com.onaro.client.leekui.ui.IWorkbenchPart; import com.onaro.commons.beans.IPropertyChangeSupport; import com.onaro.sanscreen.client.view.init.ViewDirectorInitInfo; import com.onaro.sanscreen.client.view.refresh.RefreshDataListener; import com.onaro.sanscreen.client.view.selection.ObjectSelectionListener; import com.onaro.sanscreen.client.view.selection.ObjectSelectionModel; import com.onaro.sanscreen.client.view.tabular.NavigationInfo; import com.onaro.sanscreen.server.interfaces.data.Context; import com.onaro.util.IllegalInitException; /** * A ViewDirector manages the components of a view allowing the view to setup its own menu and tool bars * and load its content. *

* A director may provide multiple views and the director's user can choose which one is visible. *

* A director uses an ObjectSelectionModel to represent selection of objects it displays. */ public interface ViewDirector extends IPropertyChangeSupport, RefreshDataListener { /** * Initializes the director based on the given configuration. * @param resources locale dependent resources * @param menuActions actions provided by higher level director to the use of this director * @param site context site for this view director */ public void init(ViewDirectorInitInfo viewDirectorInitInfo, ResourceBundle resources, ActionFactory menuActions, IViewDirectorSite site) throws IllegalInitException; /** * Get the context site used to initialize the view. * @return context site for this view director */ public IViewDirectorSite getSite(); /** * Gets this director's view component. * @param create true if the component should be created if not already initialized, false to avoid creation * * @return the view component if it has been initialized, otherwise {@code null} */ public Component getComponent(boolean create); /** * Displays the director's view with the given name. The data is displayed according to the specified context. * *If this view does work asynchronously, returns a future. * * @param viewName specific view name allowing a view to manage its own sub views * @param context time context, may be null to present "LATEST" * @param navigationInfo * * @return a Future, or null */ public Future show(String viewName, List selectedAdaptables, Context context, NavigationInfo navigationInfo); /** * Called for each view that is about to be hidden (opposite of show) * * @param visible */ public void setVisible(boolean visible); /** * Indicates if view is visible. * * @return {@code true} if view is visible, {@code false} otherwise */ public boolean isVisible(); /** * Gets the current selection in this director. * * @return the current object selection */ public ObjectSelectionModel getObjectSelectionModel(); public NavigationInfo getNavigationInfo(); /** * Registers a listener for this job's state changes. * * @param listener the listener */ public void addObjectSelectionListener(ObjectSelectionListener listener); /** * Clears the view's display. */ public void clear(); /** * Asks the view to fill in its specific menu items. The menu is rebuilt every time it is opened. * * @param menuName identifies the menu * @param menu the menu that the view should add its items too */ public void buildMenu(String menuName, JMenu menu); /** * TODO: rename this to something else. * * Gets the name of this view. * * @return the name of this view */ public String getName(); public IViewDirectorDescriptor getViewDirectorDescriptor(); public String getDisplayName(); public Icon getIcon(); public Icon getSmallIcon(); /** * Get the globally unique name of this view. */ public String getId(); /** * Get the help context for the view. */ public String getHelpContext(); /** * Get the IAdaptable(s) which are being shown. * * @return the selection in the deriving view or null if not supported or nothing is selected */ public List getShowingAdaptables(); /** * Get the IAdaptabe(s) which are selected in this view. * * @return a list of the selected objects or null if the selection model is not set */ public List getSelectedAdaptables(); /** * Marks the view as dirty according to the given value. * * @param dirty dirty value to set */ public void setDirty(boolean dirty); /** * @return true if the view is marked as dirty */ public boolean isDirty(); /** * Refreshes the view. * * If this view does work asynchronously, returns a future. * @param clear true if the view's content should be cleared prior to performing the refresh, false if * the contents should remain until the refresh completes. * * @return a Future, or null */ public Future refresh(boolean clear); /** * Asks the view to request Swing to get the focus. * * @see IWorkbenchPart#setFocus */ public void setFocus(); /** * Asks the view to react to gaining focus. * The focus may have formerly belonged to a child of the view. */ public void focusGained(); /** * Asks the view to react to losing focus. * The focus may actually belong to a child of the view. */ public void focusLost(); /** * Indicates if a view component owns the focus. * * @return {@code true} if view owns focus, {@code false} otherwise */ public boolean isFocusOwner(); /** * Disposes of this workbench part. *

* Within this method a part may release any resources, etc.  held by this part. It is also very important to * de-register all listeners from the workbench. * * @see IWorkbenchPart#dispose() */ public void dispose(); /** * Which selection types can this view consume. * * @return null if do not know what types. */ public Set getConsumableSelectionTypes(ViewDirector producer); /** * Which selection types can this view produce. * * @return null if do not know what types. */ public Set getProducibleSelectionTypes(); public void setViewType(ViewType viewType); public ViewType getViewType(); public void saveViewProfile(IMemento memento); public void loadViewProfile(IMemento memento); }