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.internal.tool;
018:
019: import net.refractions.udig.project.command.factory.EditCommandFactory;
020: import net.refractions.udig.project.command.factory.NavigationCommandFactory;
021: import net.refractions.udig.project.command.factory.SelectionCommandFactory;
022: import net.refractions.udig.project.internal.AbstractContext;
023: import net.refractions.udig.project.ui.commands.DrawCommandFactory;
024: import net.refractions.udig.project.ui.render.displayAdapter.ViewportPane;
025: import net.refractions.udig.project.ui.tool.IToolContext;
026:
027: import org.eclipse.core.runtime.Plugin;
028: import org.eclipse.swt.widgets.Display;
029: import org.eclipse.ui.IWorkbench;
030:
031: /**
032: * A set of tools that is provided to Tool extensions.
033: * <p>
034: * In addition to the references available in the Toolkit class, ToolContext provides access to
035: * command factories and and to sendCommand methods.
036: * </p>
037: * <p>
038: * Responsibilities:
039: * <ul>
040: * <li>Provide access to the objects that an extension can use for its operations.</li>
041: * <li>Provide convenience methods for extension developers to use.</li>
042: * <li>Provide a consistent interface for extensions which will not easily change in future
043: * versions</li>
044: * </ul>
045: * </p>
046: *
047: * @author Jesse
048: * @since 0.5
049: */
050: public interface ToolContext extends IToolContext, AbstractContext {
051: /**
052: * Casts getDisplay to ViewportPane;
053: *
054: * @return getDisplay cast to ViewportPane
055: */
056: ViewportPane getViewportPane();
057:
058: /**
059: * Returns a DrawCommandFactory
060: *
061: * @return a DrawCommandFactory
062: */
063: DrawCommandFactory getDrawFactory();
064:
065: /**
066: * Returns a EditCommandFactory
067: *
068: * @return a EditCommandFactory
069: */
070: EditCommandFactory getEditFactory();
071:
072: /**
073: * Returns a NavigationCommandFactory
074: *
075: * @return a NavigationCommandFactory
076: */
077: NavigationCommandFactory getNavigationFactory();
078:
079: /**
080: * Returns the current workbench.
081: * <p>
082: * Convenience for PlatformUI.getWorkbench()
083: *
084: * @return the current workbench.
085: */
086: IWorkbench getWorkbench();
087:
088: /**
089: * Returns the default display.
090: * <p>
091: * Convenience for Display.getDefault()
092: * </p>
093: *
094: * @return the default display.
095: */
096: Display getDisplay();
097:
098: /**
099: * Logs an exception to the current plugin.
100: *
101: * @param currentPlugin the plugin that the exception will be logged in.
102: * @param message the message to log
103: * @param severity the severity of the exception. IF null ERROR will be assumed.
104: * {@linkplain org.eclipse.core.runtime.IStatus#ERROR},
105: * {@linkplain org.eclipse.core.runtime.IStatus#INFO},
106: * {@linkplain org.eclipse.core.runtime.IStatus#WARNING}
107: * @param exception the exception to log. Can be null.
108: */
109: void log(Plugin currentPlugin, String message, int severity,
110: Throwable exception);
111:
112: /**
113: * Returns a SelectionCommandFactory
114: *
115: * @return a SelectionCommandFactory�
116: */
117: SelectionCommandFactory getSelectionFactory();
118:
119: public ToolContext copy();
120: }
|