001: /*
002: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003: * for visualizing and manipulating spatial features with geometry and attributes.
004: *
005: * Copyright (C) 2003 Vivid Solutions
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: *
021: * For more information, contact:
022: *
023: * Vivid Solutions
024: * Suite #1A
025: * 2328 Government Street
026: * Victoria BC V8T 5G5
027: * Canada
028: *
029: * (250)385-6040
030: * www.vividsolutions.com
031: */
032:
033: package com.vividsolutions.jump.workbench;
034:
035: import javax.swing.JInternalFrame;
036:
037: import com.vividsolutions.jump.util.Blackboard;
038: import com.vividsolutions.jump.workbench.driver.DriverManager;
039: import com.vividsolutions.jump.workbench.model.LayerManager;
040: import com.vividsolutions.jump.workbench.model.LayerManagerProxy;
041: import com.vividsolutions.jump.workbench.model.Task;
042: import com.vividsolutions.jump.workbench.ui.ErrorHandler;
043: import com.vividsolutions.jump.workbench.ui.LayerNamePanel;
044: import com.vividsolutions.jump.workbench.ui.LayerNamePanelProxy;
045: import com.vividsolutions.jump.workbench.ui.LayerViewPanel;
046: import com.vividsolutions.jump.workbench.ui.LayerViewPanelProxy;
047: import com.vividsolutions.jump.workbench.ui.TaskFrameProxy;
048:
049: /**
050: * Implementation of {@link WorkbenchContext} for the {@link
051: * JUMPWorkbench}.
052: */
053: public class JUMPWorkbenchContext extends WorkbenchContext {
054: private JUMPWorkbench workbench;
055:
056: public JUMPWorkbenchContext(JUMPWorkbench workbench) {
057: this .workbench = workbench;
058: }
059:
060: public JUMPWorkbench getWorkbench() {
061: return workbench;
062: }
063:
064: public Blackboard getBlackboard() {
065: return workbench.getBlackboard();
066: }
067:
068: public DriverManager getDriverManager() {
069: return workbench.getDriverManager();
070: }
071:
072: public ErrorHandler getErrorHandler() {
073: return workbench.getFrame();
074: }
075:
076: public Task getTask() {
077: if (!(activeInternalFrame() instanceof TaskFrameProxy)) {
078: return null;
079: }
080:
081: return ((TaskFrameProxy) activeInternalFrame()).getTaskFrame()
082: .getTask();
083: }
084:
085: public LayerNamePanel getLayerNamePanel() {
086: if (!(activeInternalFrame() instanceof LayerNamePanelProxy)) {
087: return null;
088: }
089:
090: return ((LayerNamePanelProxy) activeInternalFrame())
091: .getLayerNamePanel();
092: }
093:
094: public LayerManager getLayerManager() {
095: if (!(activeInternalFrame() instanceof LayerManagerProxy)) {
096: //WarpingPanel assumes that this method returns null if the active frame is not
097: //a LayerManagerProxy. [Jon Aquino]
098: return null;
099: }
100:
101: return ((LayerManagerProxy) activeInternalFrame())
102: .getLayerManager();
103: }
104:
105: public LayerViewPanel getLayerViewPanel() {
106: if (!(activeInternalFrame() instanceof LayerViewPanelProxy)) {
107: return null;
108: }
109:
110: return ((LayerViewPanelProxy) activeInternalFrame())
111: .getLayerViewPanel();
112: }
113:
114: private JInternalFrame activeInternalFrame() {
115: return workbench.getFrame().getActiveInternalFrame();
116: }
117: }
|