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: * JUMP is Copyright (C) 2003 Vivid Solutions
006: *
007: * This program implements extensions to JUMP and is
008: * Copyright (C) Stefan Steiniger.
009: *
010: * This program is free software; you can redistribute it and/or
011: * modify it under the terms of the GNU General Public License
012: * as published by the Free Software Foundation; either version 2
013: * of the License, or (at your option) any later version.
014: *
015: * This program is distributed in the hope that it will be useful,
016: * but WITHOUT ANY WARRANTY; without even the implied warranty of
017: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
018: * GNU General Public License for more details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with this program; if not, write to the Free Software
022: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
023: *
024: * For more information, contact:
025: * Stefan Steiniger
026: * perriger@gmx.de
027: */
028: /*****************************************************
029: * created: 16.05.2005
030: * last modified: 18.05.2005
031: *
032: * description:
033: * selects items within a fence of the actual selected layers
034: * and informs about the number of selected items<p>
035: * uses DrawFenceTool class for user interaction and
036: * determination of selection
037: *
038: *****************************************************/package org.openjump.core.ui.plugin.edit;
039:
040: import org.openjump.core.ui.plugin.edit.helpclassesselection.DrawFenceTool;
041:
042: import com.vividsolutions.jump.I18N;
043: import com.vividsolutions.jump.workbench.WorkbenchContext;
044: import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
045: import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
046: import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
047: import com.vividsolutions.jump.workbench.plugin.PlugInContext;
048: import com.vividsolutions.jump.workbench.ui.LayerNamePanelProxy;
049: import com.vividsolutions.jump.workbench.ui.MenuNames;
050: import com.vividsolutions.jump.workbench.ui.cursortool.CursorTool;
051:
052: /**
053: * @description:
054: * selects items within a fence of the actual layer
055: * and informs about the number of selected items
056: *
057: * @author sstein
058: *
059: */
060: public class SelectItemsByFenceFromSelectedLayersPlugIn extends
061: AbstractPlugIn {
062:
063: public void initialize(PlugInContext context) throws Exception {
064: context
065: .getFeatureInstaller()
066: .addMainMenuItemWithJava14Fix(
067: this ,
068: new String[] { MenuNames.EDIT },
069: I18N
070: .get("org.openjump.core.ui.plugin.edit.SelectItemsByFenceFromSelectedLayersPlugIn.select-items-by-fence-from-selected-layers")
071: + "{pos:6}",
072: false,
073: null,
074: createEnableCheck(context.getWorkbenchContext()));
075: }
076:
077: public static MultiEnableCheck createEnableCheck(
078: WorkbenchContext workbenchContext) {
079: EnableCheckFactory checkFactory = new EnableCheckFactory(
080: workbenchContext);
081: return new MultiEnableCheck().add(checkFactory
082: .createAtLeastNLayersMustExistCheck(1));
083: }
084:
085: public boolean execute(PlugInContext context) throws Exception {
086:
087: this .reportNothingToUndoYet(context);
088: try {
089: CursorTool polyTool = DrawFenceTool.create(
090: (LayerNamePanelProxy) context
091: .getActiveInternalFrame(), context);
092: context.getLayerViewPanel().setCurrentCursorTool(polyTool);
093: } catch (Exception e) {
094: context.getWorkbenchFrame().warnUser(
095: "DrawFenceTool Exception:" + e.toString());
096: return false;
097: }
098:
099: System.gc();
100: return true;
101: }
102:
103: }
|