001: /*
002: * uDig - User Friendly Desktop Internet GIS client
003: * http://udig.refractions.net
004: * (C) 2004, Refractions Research Inc.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package net.refractions.udig.project.ui.tool;
018:
019: import org.eclipse.jface.action.IStatusLineManager;
020: import org.eclipse.ui.IActionBars2;
021:
022: import net.refractions.udig.project.IAbstractContext;
023: import net.refractions.udig.project.command.Command;
024: import net.refractions.udig.project.command.MapCommand;
025: import net.refractions.udig.project.command.factory.BasicCommandFactory;
026: import net.refractions.udig.project.command.factory.EditCommandFactory;
027: import net.refractions.udig.project.command.factory.NavigationCommandFactory;
028: import net.refractions.udig.project.command.factory.SelectionCommandFactory;
029: import net.refractions.udig.project.ui.commands.DrawCommandFactory;
030: import net.refractions.udig.project.ui.render.displayAdapter.ViewportPane;
031:
032: /**
033: * A set of tools that is provided to Tool extensions.
034: * <p>
035: * In addition to the references available in the Toolkit class, ToolContext provides access to
036: * command factories and and to sendCommand methods.
037: * </p>
038: * <p>
039: * Responsibilities:
040: * <ul>
041: * <li>Provide access to the objects that an extension can use for its operations.</li>
042: * <li>Provide convenience methods for extension developers to use.</li>
043: * <li>Provide a consistent interface for extensions which will not easily change in future
044: * versions</li>
045: * </ul>
046: * </p>
047: *
048: * @author Jesse
049: * @since 0.5
050: */
051: public interface IToolContext extends IAbstractContext {
052: /**
053: * Casts getDisplay to ViewportPane;
054: *
055: * @return getDisplay cast to ViewportPane
056: * @see ViewportPane
057: */
058: public ViewportPane getViewportPane();
059:
060: /**
061: * Returns a DrawCommandFactory. Used to create commands that draw on the display.
062: *
063: * @return a DrawCommandFactory
064: * @see DrawCommandFactory
065: */
066: public DrawCommandFactory getDrawFactory();
067:
068: /**
069: * Returns a EditCommandFactory. Used to create commands that edit the data model.
070: *
071: * @return a EditCommandFactory
072: * @see EditCommandFactory
073: */
074: public EditCommandFactory getEditFactory();
075:
076: /**
077: * Returns a NavigationCommandFactory. Used to create commands that change the current view of
078: * the map.
079: *
080: * @return a NavigationCommandFactory
081: * @see NavigationCommandFactory
082: */
083: public NavigationCommandFactory getNavigationFactory();
084:
085: /**
086: * Returns a SelectionCommandFactory. Used to create commands that changes the current
087: * selection.
088: *
089: * @return a SelectionCommandFactory
090: */
091: public SelectionCommandFactory getSelectionFactory();
092:
093: /**
094: * Returns a BasicCommandFactory.
095: *
096: * @return a BasicCommandFactory
097: */
098: public BasicCommandFactory getBasicCommandFactory();
099:
100: /**
101: * Dispatches a command. If the command is a IDrawCommand the command will
102: * be added to the ViewportPane and the ViewportPane will be refreshed.
103: *
104: * @param command The command to execute.
105: * @see MapCommand
106: */
107: public void sendASyncCommand(Command command);
108:
109: /**
110: * Dispatches a command and blocks until the command has executed.
111: *
112: * @param command The command to execute.
113: * @see MapCommand
114: */
115: public void sendSyncCommand(Command command);
116:
117: /**
118: * Gets an instance of the status bar from the current editor or null if there is no editor
119: * open.
120: *
121: * @return an instance of the status bar from the current editor or null if there is no editor
122: * open.
123: * @deprecated use getActionBars().getStatusLineManager()
124: */
125: IStatusLineManager getStatusBar();
126:
127: /**
128: * Gets an instance of the ActionsBars from the current editor or null if there is no editor
129: * open.
130: *
131: * @return an instance of the ActionsBars from the current editor or null if there is no editor
132: * open.
133: */
134: IActionBars2 getActionBars();
135:
136: /**
137: * Run a code block in the UI thread. This method should always be used when modifying the ui.
138: *
139: * @param runnable the code block to execute in the ui thread.
140: */
141: public void updateUI(Runnable runnable);
142:
143: public IToolContext copy();
144: }
|