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.ui.plugin;
034:
035: import java.util.Iterator;
036:
037: import com.vividsolutions.jump.workbench.WorkbenchContext;
038: import com.vividsolutions.jump.workbench.model.Layer;
039: import com.vividsolutions.jump.workbench.model.LayerManagerProxy;
040: import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
041: import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
042: import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
043: import com.vividsolutions.jump.workbench.plugin.PlugInContext;
044: import com.vividsolutions.jump.workbench.ui.InfoFrame;
045: import com.vividsolutions.jump.workbench.ui.SelectionManagerProxy;
046: import com.vividsolutions.jump.workbench.ui.TaskFrameProxy;
047:
048: public class FeatureInfoPlugIn extends AbstractPlugIn {
049: public FeatureInfoPlugIn() {
050: }
051:
052: public static MultiEnableCheck createEnableCheck(
053: WorkbenchContext workbenchContext) {
054: EnableCheckFactory checkFactory = new EnableCheckFactory(
055: workbenchContext);
056:
057: return new MultiEnableCheck()
058: .add(
059: checkFactory
060: .createWindowWithSelectionManagerMustBeActiveCheck())
061: .add(
062: checkFactory
063: .createWindowWithLayerManagerMustBeActiveCheck())
064: .add(
065: checkFactory
066: .createWindowWithAssociatedTaskFrameMustBeActiveCheck())
067: .add(
068: checkFactory
069: .createAtLeastNItemsMustBeSelectedCheck(1));
070: }
071:
072: public boolean execute(PlugInContext context) throws Exception {
073: reportNothingToUndoYet(context);
074: //Don't pass in TaskFrame as LayerManagerProxy, because the TaskFrame may
075: //be closed and thus the LayerManagerProxy may return null. [Jon Aquino]
076: InfoFrame infoFrame = new InfoFrame(context
077: .getWorkbenchContext(), (LayerManagerProxy) context
078: .getActiveInternalFrame(), ((TaskFrameProxy) context
079: .getActiveInternalFrame()).getTaskFrame());
080: infoFrame.setSize(500, 300);
081:
082: for (Iterator i = context.getLayerManager().iterator(); i
083: .hasNext();) {
084: Layer layer = (Layer) i.next();
085:
086: if (((SelectionManagerProxy) context
087: .getActiveInternalFrame()).getSelectionManager()
088: .getFeaturesWithSelectedItems(layer).isEmpty()) {
089: continue;
090: }
091:
092: infoFrame.getModel().add(
093: layer,
094: ((SelectionManagerProxy) context
095: .getActiveInternalFrame())
096: .getSelectionManager()
097: .getFeaturesWithSelectedItems(layer));
098: }
099:
100: infoFrame.setSelectedTab(infoFrame.getGeometryTab());
101: context.getWorkbenchFrame().addInternalFrame(infoFrame);
102:
103: return true;
104: }
105:
106: }
|