public void initialize(PlugInContext context) throws Exception {

    context
        .getFeatureInstaller()
        .addMainMenuItem(this, new String[] {"OpenGestorFip"}, getName(), false, null, null);

    context
        .getWorkbenchContext()
        .getIWorkbench()
        .getGuiComponent()
        .getToolBar("OpenGestorFip")
        .addPlugIn(
            getIcon(),
            this,
            createEnableCheck(context.getWorkbenchContext()),
            context.getWorkbenchContext());

    JPopupMenu popupMenu = context.getWorkbenchGuiComponent().getLayerViewPopupMenu();

    FeatureInstaller featureInstaller = new FeatureInstaller(context.getWorkbenchContext());
    featureInstaller.addPopupMenuItem(
        popupMenu,
        this,
        AppContext.getApplicationContext().getI18nString(this.getName()),
        false,
        null,
        createEnableCheck(context.getWorkbenchContext()));
  }
  public boolean execute(PlugInContext context) throws Exception {
    Collection selectedCategories = context.getLayerNamePanel().getSelectedCategories();

    String actualName = aplicacion.getI18nString("GeopistaAddNewLayerPlugIn.New");

    GeopistaLayer layer =
        new GeopistaLayer(
            actualName,
            context.getLayerManager().generateLayerFillColor(),
            createBlankFeatureCollection(),
            context.getLayerManager());
    // Como es una capa creada localmente asignamos el flag isLocal a true
    layer.setLocal(true);

    // com.geopista.io.datasource.GeopistaStandarReaderWriteFileDataSource.GeoGML
    // h = new
    // com.geopista.io.datasource.GeopistaStandarReaderWriteFileDataSource.GeoGML();
    // layer.setDataSourceQuery(new DataSourceQuery());

    context
        .getLayerManager()
        .addLayer(
            selectedCategories.isEmpty()
                ? StandardCategoryNames.WORKING
                : selectedCategories.iterator().next().toString(),
            layer);

    ((EditingPlugIn) context.getWorkbenchContext().getBlackboard().get(EditingPlugIn.KEY))
        .getToolbox(context.getWorkbenchContext())
        .setVisible(true);

    return true;
  }
  public void initialize(PlugInContext context) throws Exception {

    String pluginCategory = aplicacion.getString(toolBarCategory);
    ((WorkbenchGuiComponent) context.getWorkbenchContext().getIWorkbench().getGuiComponent())
        .getToolBar(pluginCategory)
        .addPlugIn(
            getIcon(),
            this,
            createEnableCheck(context.getWorkbenchContext()),
            context.getWorkbenchContext());

    JPopupMenu popupMenu = context.getWorkbenchGuiComponent().getLayerViewPopupMenu();

    // JPopupMenu layerNamePopupMenu = context.getWorkbenchContext().getIWorkbench()
    // .getGuiComponent()
    // .getLayerNamePopupMenu();

    FeatureInstaller featureInstaller = new FeatureInstaller(context.getWorkbenchContext());

    featureInstaller.addPopupMenuItem(
        popupMenu,
        this,
        aplicacion.getI18nString(getName()),
        false,
        GUIUtil.toSmallIcon(ICON),
        createEnableCheck(context.getWorkbenchContext()));
    // null);

  }
  /** Inicialización del plugin para cargarlo desde el fichero workbench.properties */
  public void initialize(PlugInContext context) throws Exception {
    // para internacionalización
    Locale currentLocale = I18N.getLocaleAsObject();
    ResourceBundle bundle =
        ResourceBundle.getBundle(
            "com.geopista.ui.plugin.mobile.language.PluginMobileExtracti18n", currentLocale);
    I18N.plugInsResourceBundle.put(PluginMobileExtracti18n, bundle);

    FeatureInstaller featureInstaller = new FeatureInstaller(context.getWorkbenchContext());

    EnableCheckFactory checkFactory = context.getCheckFactory();
    featureInstaller.addMainMenuItem(
        this,
        new String[] {"Tools", MobilePluginI18NResource.GEOPISTAConfiguration_proyectMovil},
        I18N.get(PluginMobileExtracti18n, MobilePluginI18NResource.MobileModifyPlugin_text),
        false,
        null,
        new MultiEnableCheck()
            .add(checkFactory.createWindowWithLayerNamePanelMustBeActiveCheck())
            .add(checkFactory.createAdminUserCheck()));

    ((WorkbenchGuiComponent) context.getWorkbenchContext().getIWorkbench().getGuiComponent())
        .getToolBar("Movilidad")
        .addPlugIn(
            this.getIcon(),
            this,
            createEnableCheck(context.getWorkbenchContext()),
            context.getWorkbenchContext());
  }
  public void initialize(PlugInContext context) throws Exception {

    context
        .getWorkbenchContext()
        .getIWorkbench()
        .getGuiComponent()
        .getToolBar()
        .addPlugIn(
            this.getIcon(),
            this,
            this.createEnableCheck(context.getWorkbenchContext()),
            context.getWorkbenchContext());
  }
 public void addButton(final PlugInContext context) {
   if (!circleButtonAdded) {
     final ToolboxDialog toolbox =
         ((EditingPlugIn) context.getWorkbenchContext().getBlackboard().get(EditingPlugIn.KEY))
             .getToolbox(context.getWorkbenchContext());
     QuasimodeTool quasimodeTool =
         new QuasimodeTool(DrawConstrainedCircleTool.create(toolbox.getContext()));
     quasimodeTool.add(new QuasimodeTool.ModifierKeySpec(true, false, false), null);
     quasimodeTool.add(new QuasimodeTool.ModifierKeySpec(true, true, false), null);
     toolbox.add(quasimodeTool, null);
     toolbox.finishAddingComponents();
     toolbox.validate();
     circleButtonAdded = true;
   }
 }
  public void initialize(PlugInContext context) throws Exception {
    WorkbenchContext workbenchContext = context.getWorkbenchContext();

    EnableCheck enableCheck = createEnableCheck(workbenchContext);
    FeatureInstaller installer = new FeatureInstaller(workbenchContext);
    installer.addMainMenuItem(
        this,
        new String[] {MenuNames.FILE},
        new JMenuItem(getName(), IconLoader.icon("disk_multiple_16.png")),
        createEnableCheck(context.getWorkbenchContext()),
        9);

    fileChooser = new JFCWithEnterAction();
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fileChooser.setDialogTitle(FILECHOOSER);
  }
  public void initialize(final PlugInContext context) throws Exception {
    // add a listener so that when the toolbox dialog opens the constrained tools will be added
    // we can't just add the tools directly at this point since the toolbox isn't ready yet

    context
        .getWorkbenchContext()
        .getWorkbench()
        .getFrame()
        .addComponentListener(
            new ComponentAdapter() {
              public void componentShown(ComponentEvent e) {
                final ToolboxDialog toolBox =
                    ((EditingPlugIn)
                            context.getWorkbenchContext().getBlackboard().get(EditingPlugIn.KEY))
                        .getToolbox(context.getWorkbenchContext());
                toolBox.addComponentListener(
                    new ComponentAdapter() {

                      public void componentShown(ComponentEvent e) {
                        addButton(context);
                      }

                      public void componentHidden(ComponentEvent e) {}
                    });
              }
            });
  }
  public void initialize(final PlugInContext context) throws Exception {

    GeopistaEditingPlugIn geopistaEditingPlugIn =
        (GeopistaEditingPlugIn)
            (context.getWorkbenchContext().getBlackboard().get(EditingPlugIn.KEY));
    geopistaEditingPlugIn.addAditionalPlugIn(this);
  }
  public void initialize(PlugInContext context) throws Exception {

    FeatureInstaller featureInstaller = new FeatureInstaller(context.getWorkbenchContext());

    featureInstaller.addPopupMenuItem(
        context.getWorkbenchContext().getIWorkbench().getGuiComponent().getCategoryPopupMenu(),
        this,
        GeopistaFunctionUtils.i18n_getname(this.getName()),
        false,
        null,
        null);

    featureInstaller.addLayerViewMenuItem(
        this,
        GeopistaFunctionUtils.i18n_getname("Layer"),
        GeopistaFunctionUtils.i18n_getname(this.getName()));
  }
  @Override
  public void initialize(PlugInContext context) throws Exception {
    super.initialize(context);

    GeopistaNetworkEditingPlugIn geopistaNetworkEditingPlugIn =
        (GeopistaNetworkEditingPlugIn)
            (context.getWorkbenchContext().getBlackboard().get(GeopistaNetworkEditingPlugIn.KEY));
    geopistaNetworkEditingPlugIn.addAditionalPlugIn(this);
  }
Beispiel #12
0
 public boolean execute(PlugInContext context) throws Exception {
   ((LayerManagerProxy)
           context.getWorkbenchContext().getWorkbench().getFrame().getActiveInternalFrame())
       .getLayerManager()
       .getUndoableEditReceiver()
       .getUndoManager()
       .undo();
   // Exclude the plug-in's activity from the undo history [Jon Aquino]
   reportNothingToUndoYet(context);
   context.getWorkbenchFrame().getToolBar().updateEnabledState();
   return true;
 }
  public void initialize(PlugInContext context) throws Exception {

    FeatureInstaller featureInstaller = new FeatureInstaller(context.getWorkbenchContext());

    featureInstaller.addMainMenuItem(
        this,
        new String[] {MenuNames.EDIT, "CoordSys"},
        AppContext.getApplicationContext().getI18nString(this.getName()),
        false,
        null,
        this.createEnableCheck(context.getWorkbenchContext()));

    JPopupMenu layerNamePopupMenu =
        context.getWorkbenchContext().getIWorkbench().getGuiComponent().getLayerNamePopupMenu();
    featureInstaller.addPopupMenuItem(
        layerNamePopupMenu,
        this,
        AppContext.getApplicationContext().getI18nString(this.getName()) + "...",
        false,
        null,
        this.createEnableCheck(context.getWorkbenchContext()));
  }
Beispiel #14
0
  public void initialize(PlugInContext context) throws Exception {
    Locale loc = I18N.getLocaleAsObject();
    ResourceBundle bundle =
        ResourceBundle.getBundle(
            "com.geopista.ui.plugin.routeenginetools.tsp.language.RouteEngine_TSPi18n",
            loc,
            this.getClass().getClassLoader());
    I18N.plugInsResourceBundle.put("tsp", bundle);

    GeopistaNetworkEditingPlugIn geopistaNetworkEditingPlugIn =
        (GeopistaNetworkEditingPlugIn)
            (context.getWorkbenchContext().getBlackboard().get(GeopistaNetworkEditingPlugIn.KEY));
    geopistaNetworkEditingPlugIn.addAditionalPlugIn(this);
  }
  @Override
  public boolean execute(PlugInContext context) throws Exception {
    Blackboard bb = get(context.getWorkbenchContext());
    WorkbenchFrame wbframe = context.getWorkbenchFrame();

    String fileName = (String) bb.get("ArcMapStylePlugin.filename");

    File am2sld = findArcMap2SLD(wbframe, bb);
    if (am2sld == null) {
      return false;
    }

    ProcessBuilder pb = new ProcessBuilder(am2sld.toString());
    pb.start().waitFor(); // unfortunately, the code seems to always be
    // zero

    showMessageDialog(
        wbframe,
        get(
            "org.openjump.core.ui.plugin.style.ImportArcMapStylePlugIn.Must-Select-Location-Of-SLD"),
        get("org.openjump.core.ui.plugin.style.ImportSLDPlugIn.Question"),
        INFORMATION_MESSAGE);

    JFileChooser chooser = new JFileChooser();

    if (fileName != null) {
      chooser.setCurrentDirectory(new File(fileName).getParentFile());
    }

    int res = chooser.showOpenDialog(context.getWorkbenchFrame());
    if (res == APPROVE_OPTION) {
      File f = chooser.getSelectedFile();
      if (!f.exists()) {
        return false;
      }
      bb.put("ArcMapStylePlugin.filename", f.getAbsoluteFile().toString());

      DocumentBuilderFactory dbf = newInstance();
      dbf.setNamespaceAware(true);
      Document doc = dbf.newDocumentBuilder().parse(f);

      importSLD(doc, context);
    }

    return false;
  }
  @Override
  public void initialize(PlugInContext context) throws Exception {
    EnableCheckFactory enableCheckFactory = new EnableCheckFactory(context.getWorkbenchContext());

    EnableCheck enableCheck =
        new MultiEnableCheck()
            .add(enableCheckFactory.createWindowWithLayerManagerMustBeActiveCheck())
            .add(
                enableCheckFactory.createExactlyNLayerablesMustBeSelectedCheck(1, Layerable.class));

    context
        .getFeatureInstaller()
        .addMainMenuItem(
            this,
            new String[] {LAYER},
            get("org.openjump.core.ui.plugin.style.ImportArcMapStylePlugIn.name"),
            false,
            null,
            enableCheck);
  }
  public void initialize(PlugInContext context) throws Exception {
    System.out.println("loader:" + I18N.getInstance().getClass().getClassLoader());
    Locale loc = Locale.getDefault();

    ResourceBundle bundle2 =
        ResourceBundle.getBundle("language.AddMrSID", loc, this.getClass().getClassLoader());

    I18N.plugInsResourceBundle.put(this.getName(), bundle2);
    // I18N.setPlugInRessource(this.getName(),"language.AddMrSID");

    String msg = I18N.get(this.getName(), "AddMrSIDLayer");

    //    context.getFeatureInstaller().addMainMenuItem(this,
    //        new String[] { MenuNames.LAYER,
    //        		I18N.get(this.getName(),"ImageCoverage")}, msg, false, null, null);
    context
        .getFeatureInstaller()
        .addLayerNameViewMenuItem(this, new String[] {MenuNames.LAYER, "ImageCoverage"}, msg);

    context
        .getFeatureInstaller()
        .addPopupMenuItem(
            context.getWorkbenchContext().getIWorkbench().getGuiComponent().getCategoryPopupMenu(),
            this,
            I18N.get(this.getName(), "AddMrSIDLayer"),
            false,
            null,
            null);
    String dirBase = aplicacion.getPath("dirBase");
    File empty = new File(dirBase);
    String sep = File.separator;
    WORKING_DIR = empty.getAbsoluteFile().getParent() + sep;
    ETC_PATH = WORKING_DIR + "etc" + sep;
    TMP_PATH = WORKING_DIR + "tmp" + sep;
    MRSIDDECODE = ETC_PATH + "mrsiddecode.exe";
    MRSIDINFO = ETC_PATH + "mrsidinfo.exe";
    System.out.println("MrSID-etc:" + ETC_PATH);
  }
  /**
   * this method is called on the startup by JUMP/OpenJUMP. We set here the menu entry for calling
   * the function.
   */
  public void initialize(PlugInContext context) throws Exception {

    sideBarText =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.descriptiontext");
    CLASSIFIER =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.Select-classification-method");
    T2 =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.Number-of-classes");
    CLAYER = GenericNames.SELECT_LAYER;
    ATTRIBUTE = GenericNames.SELECT_ATTRIBUTE;
    OPTIMIZEWITHKMEANS =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.Optimize-with-k-means");
    PROCESSNULLASZERO =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.Process-null-as-zero");
    sClassbreaks =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.class-breaks");
    sDatapoints =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.data-points");
    sCount = I18N.get("org.openjump.core.ui.plugin.tools.statistics.CreateHistogramPlugIn.count");
    sHistogram =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.CreateHistogramPlugIn.Histogram-Plot");
    sCalculateBreaks =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.Calculating-Breaks");
    sDisplayBreaks =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.Displaying-Breaks");
    sClassifying =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.classifying");
    sAddingField =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.create-output-field");
    sName =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.Classify-Attribute");
    sWarning =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.Error-during-classification");
    sNotEnoughValuesWarning =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.Not-enough-values");
    sWrongDataType =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.CreateBarPlotPlugIn.Wrong-datatype-of-chosen-attribute");
    sNoAttributeChoosen =
        I18N.get(
            "org.openjump.core.ui.plugin.tools.statistics.ClassifyAttributesPlugin.No-attribute-choosen");

    FeatureInstaller featureInstaller = new FeatureInstaller(context.getWorkbenchContext());
    featureInstaller.addMainMenuItem(
        this, // exe
        // new String[] {MenuNames.TOOLS, MenuNames.TOOLS_ANALYSIS},     //menu path
        new String[] {MenuNames.TOOLS, MenuNames.STATISTICS},
        this.sName + "...", // name methode .getName recieved by AbstractPlugIn
        false, // checkbox
        null, // icon
        createEnableCheck(context.getWorkbenchContext())); // enable check   	
  }
Beispiel #19
0
 /** Este metodo es llamado por el Workbench cuando está cargando los plugines del sistema. */
 public void initialize(PlugInContext context) throws Exception {
   addFileDataSourceQueryChoosers(
       new DxfReader(), context.getWorkbenchContext(), "GEOPISTA dxf", Dxf.class);
 }
  public boolean execute(PlugInContext context) throws Exception {
    // Don't make this plug-in undoable -- it's a lot of data to store in memory [Jon Aquino]
    context.getLayerManager().getUndoableEditReceiver().reportIrreversibleChange();

    CoordinateSystem destination =
        (CoordinateSystem)
            JOptionPane.showInputDialog(
                (Component) context.getWorkbenchGuiComponent(),
                AppContext.getApplicationContext().getI18nString("SelectCoordinateReferenceSystem"),
                AppContext.getApplicationContext().getI18nString("CoordinateReferenceSystem"),
                JOptionPane.PLAIN_MESSAGE,
                null,
                new ArrayList(
                        CoordinateSystemRegistry.instance(
                                context.getWorkbenchContext().getBlackboard())
                            .getCoordinateSystems())
                    .toArray(),
                context.getLayerManager().getCoordinateSystem());

    if (destination == null) {
      return false;
    }

    if (context.getLayerManager().getCoordinateSystem() == destination) {
      return true;
    }

    if (Reprojector.instance()
        .wouldChangeValues(context.getLayerManager().getCoordinateSystem(), destination)) {
      // Two-phase commit [Jon Aquino]
      ArrayList transactions = new ArrayList();

      for (Iterator i = context.getLayerManager().iterator(); i.hasNext(); ) {
        Layer layer = (Layer) i.next();
        EditTransaction transaction =
            new EditTransaction(
                layer.getFeatureCollectionWrapper().getFeatures(),
                getName(),
                layer,
                isRollingBackInvalidEdits(context),
                false,
                context.getLayerViewPanel());

        for (int j = 0; j < transaction.size(); j++) {
          Reprojector.instance()
              .reproject(
                  transaction.getGeometry(j),
                  context.getLayerManager().getCoordinateSystem(),
                  destination);
        }

        transactions.add(transaction);
      }

      EditTransaction.commit(transactions);
    }
    // cambia

    for (Iterator i = context.getLayerManager().iterator(); i.hasNext(); ) {
      Layer layer = (Layer) i.next();
      layer.getFeatureCollectionWrapper().getFeatureSchema().setCoordinateSystem(destination);
      DataSourceQuery dsq = layer.getDataSourceQuery();
      if (dsq != null)
        dsq.getDataSource()
            .getProperties()
            .put(DataSource.COORDINATE_SYSTEM_KEY, destination.getName());
    }

    context.getLayerManager().setCoordinateSystem(destination);

    if (context.getLayerViewPanel() != null) {
      context.getLayerViewPanel().getViewport().zoomToFullExtent();
    }

    return true;
  }
  public boolean execute(PlugInContext context) throws Exception {
    LineString a = null;
    List capasVisibles =
        context.getWorkbenchContext().getLayerNamePanel().getLayerManager().getVisibleLayers(true);

    context.getLayerViewPanel().getLayerManager().getVisibleLayers(true);
    context.getLayerNamePanel().getLayerManager().getVisibleLayers(false);

    Iterator capasVisiblesIter = capasVisibles.iterator();
    boolean cancelWhile = false;

    final LockManager lockManager =
        (LockManager)
            context
                .getActiveTaskComponent()
                .getLayerViewPanel()
                .getBlackboard()
                .get(LockManager.LOCK_MANAGER_KEY);

    while (capasVisiblesIter.hasNext()) {
      Layer capaActual = (Layer) capasVisiblesIter.next();
      Collection featuresSeleccionadas =
          context
              .getWorkbenchContext()
              .getLayerViewPanel()
              .getSelectionManager()
              .getFeaturesWithSelectedItems(capaActual);

      // Almacenamos en este ArrayList el resultado de la operacion de
      // bloqueo

      Iterator featuresSeleccionadasIter = featuresSeleccionadas.iterator();
      while (featuresSeleccionadasIter.hasNext()) {
        if (cancelWhile == true) {
          if (JOptionPane.showConfirmDialog(
                  (Component) context.getWorkbenchGuiComponent(),
                  aplicacion.getI18nString("GeopistaFeatureSchemaPlugIn.RestoFeatures"),
                  aplicacion.getI18nString("GeopistaFeatureSchemaPlugIn.EditarMultiplesEntidades"),
                  JOptionPane.YES_NO_OPTION)
              == JOptionPane.NO_OPTION) return false;
          else cancelWhile = false;
        }

        localFeature = (Feature) featuresSeleccionadasIter.next();
        String systemId = ((GeopistaFeature) localFeature).getSystemId();
        final ArrayList lockResultaArrayList = new ArrayList();
        // capa de sistema. La feature debe bloquearse
        if (capaActual instanceof GeopistaLayer
            && !((GeopistaLayer) capaActual).isLocal()
            && !((GeopistaLayer) capaActual).isExtracted()
            && capaActual.isEditable()
            && systemId != null
            && !((GeopistaFeature) localFeature).isTempID()
            && !systemId.equals("")) {

          final TaskMonitorDialog progressDialog =
              new TaskMonitorDialog(aplicacion.getMainFrame(), context.getErrorHandler());

          progressDialog.setTitle(aplicacion.getI18nString("LockFeatures"));
          progressDialog.addComponentListener(
              new ComponentAdapter() {
                public void componentShown(ComponentEvent e) {

                  // Wait for the dialog to appear before starting the
                  // task. Otherwise
                  // the task might possibly finish before the dialog
                  // appeared and the
                  // dialog would never close. [Jon Aquino]
                  new Thread(
                          new Runnable() {
                            public void run() {

                              try {

                                Integer lockID =
                                    lockManager.lockFeature(localFeature, progressDialog);
                                lockResultaArrayList.add(lockID);
                              } catch (Exception e) {

                              } finally {
                                progressDialog.setVisible(false);
                              }
                            }
                          })
                      .start();
                }
              });
          GUIUtil.centreOnWindow(progressDialog);
          progressDialog.setVisible(true);
        }

        FeatureDialog featureDialog =
            new FeatureDialog(
                GeopistaFunctionUtils.getFrame(context.getWorkbenchGuiComponent()),
                "Atributos",
                true,
                localFeature,
                context.getWorkbenchContext().getLayerViewPanel(),
                capaActual);

        Integer tempLockID = null;
        Iterator lockResultaArrayListIter = lockResultaArrayList.iterator();
        if (lockResultaArrayListIter.hasNext()) {
          tempLockID = (Integer) lockResultaArrayListIter.next();
        }
        final Integer lockID = tempLockID;

        try {

          ImageIcon icon = IconLoader.icon("logo_geopista.png");

          featureDialog.setSideBarImage(null);
        } catch (NullPointerException e) {
          e.printStackTrace();
        }

        if (capaActual instanceof GeopistaLayer) {
          String extendedForm = ((GeopistaLayer) capaActual).getFieldExtendedForm();
          if (extendedForm == null) extendedForm = "";
          if (!extendedForm.equals("")) {

            featureDialog.setExtendedForm(extendedForm);
          }
        }

        featureDialog.buildDialog();
        if ((capaActual instanceof GeopistaLayer
                && (((GeopistaLayer) capaActual).isLocal()
                    || ((GeopistaLayer) capaActual).isExtracted())
                && !capaActual.isEditable())
            || (lockID == null
                && capaActual instanceof GeopistaLayer
                && !((GeopistaLayer) capaActual).isLocal()
                && !((GeopistaLayer) capaActual).isExtracted()
                && !capaActual.isEditable()
                && systemId != null
                && !((GeopistaFeature) localFeature).isTempID()
                && !systemId.equals(""))) {
          featureDialog.setLock();
        }
        featureDialog.setVisible(true);

        // solo para GeopistaLayer

        if (featureDialog.wasOKPressed()) {
          if (capaActual.isEditable()) {

            if (capaActual instanceof GeopistaLayer
                && !((GeopistaLayer) capaActual).isLocal()
                && lockID == null) continue;
            // obtenemos la feature con los cambios introducidos por
            // el usuario
            clonefeature = featureDialog.getModifiedFeature();
            // Actualiza los parámetros
            execute(
                new UndoableCommand(getName()) {

                  public void execute() {

                    localFeature.setAttributes(clonefeature.getAttributes());
                  }

                  public void unexecute() {
                    ((GeopistaFeature) clonefeature).setFireDirtyEvents(false);
                    clonefeature.setAttributes(localFeature.getAttributes());
                    ((GeopistaFeature) clonefeature).setFireDirtyEvents(true);
                  }
                },
                context);
          }

        } else {
          // el usuario ha pedido cancelar la edición
          cancelWhile = true;
        }

        if (lockID != null) {
          final TaskMonitorDialog progressDialogFinal =
              new TaskMonitorDialog(aplicacion.getMainFrame(), context.getErrorHandler());

          progressDialogFinal.setTitle(aplicacion.getI18nString("UnlockFeatures"));
          progressDialogFinal.addComponentListener(
              new ComponentAdapter() {
                public void componentShown(ComponentEvent e) {

                  // Wait for the dialog to appear before starting
                  // the
                  // task. Otherwise
                  // the task might possibly finish before the
                  // dialog
                  // appeared and the
                  // dialog would never close. [Jon Aquino]
                  new Thread(
                          new Runnable() {
                            public void run() {

                              try {

                                lockManager.unlockFeaturesByLockId(lockID, progressDialogFinal);
                              } catch (Exception e) {

                              } finally {
                                progressDialogFinal.setVisible(false);
                              }
                            }
                          })
                      .start();
                }
              });
          GUIUtil.centreOnWindow(progressDialogFinal);
          progressDialogFinal.setVisible(true);
        }
      }
    }

    return false;
  }
Beispiel #22
0
  public boolean execute(PlugInContext context) throws Exception {
    if (context.getLayerViewPanel() == null) return false;
    this.networkMgr = NetworkModuleUtilWorkbench.getNetworkManager(context);
    configProperties = new CalcRutaConfigFileReaderWriter();
    if (configProperties.getRedesNames() == null) {
      context
          .getLayerViewPanel()
          .getContext()
          .warnUser(
              I18N.get("calcruta", "routeengine.calcularruta.errormessage.emptyconfiguration"));
      return false;
    }
    this.context = context;
    nodesInfo = new HashMap<Integer, VirtualNodeInfo>();
    configuatorNetworks = new HashMap<String, Network>();

    nodesFeatureCol = AddNewLayerPlugIn.createBlankFeatureCollection();
    nodesFeatureCol.getFeatureSchema().addAttribute("nodeId", AttributeType.INTEGER);

    if (context.getLayerManager().getLayer("Puntos para TSP") != null) {
      context.getLayerManager().remove(sourcePointLayer);
    }

    sourcePointLayer = context.addLayer("Puntos TSP", "Puntos para TSP", nodesFeatureCol);

    //		LabelStyle labelStyle = new LabelStyle();
    //		labelStyle.setAttribute("nodeId");
    //		labelStyle.setColor(Color.black);
    //		labelStyle.setScaling(false);
    //		labelStyle.setEnabled(true);
    //		sourcePointLayer.addStyle(labelStyle);

    if (networkMgr == null) {
      context.getLayerViewPanel().getContext().warnUser("Error en el NetworkManager.");
      return false;
    }

    if (networkMgr.getNetworks().isEmpty()) {
      context
          .getLayerViewPanel()
          .getContext()
          .warnUser("No hay redes cargadas en el NetworkManager");
      return false;
    }

    if (configProperties.getRedesNames().length <= 0) {
      context
          .getLayerViewPanel()
          .getContext()
          .warnUser("Error en la configuracion. Inicie el configurador de rutas");
    }

    String redes[] = configProperties.getRedesNames();
    for (int i = 0; i < redes.length; i++) {
      configuatorNetworks.put(
          redes[i], ((LocalGISNetworkManager) networkMgr).getAllNetworks().get(redes[i]));
    }
    for (int m = 0; m < configuatorNetworks.values().size(); m++) {
      if (configuatorNetworks.values().toArray()[m] == null) {
        context
            .getLayerViewPanel()
            .getContext()
            .warnUser("Error en la configuracion. Inicie el configurador de rutas");
        return false;
      }
    }

    ToolboxDialog toolbox = new ToolboxDialog(context.getWorkbenchContext());
    //		toolbox.add();
    //
    //		RouteEngineDrawPointTool.createCursor(IconLoader.icon("bandera.gif").getImage());
    context
        .getLayerViewPanel()
        .setCurrentCursorTool(RouteEngineTSPDrawPointTool.create(toolbox.getContext()));

    return false;
  }
 public void initialize(PlugInContext context) throws Exception {
   // [Michael Michaud 2007-03-23]
   // Moves MenuNames.TOOLS/MenuNames.TOOLS_PROGRAMMING to MenuNames.CUSTOMIZE
   createMainMenuItem(new String[] {MenuNames.CUSTOMIZE}, null, context.getWorkbenchContext());
 }