public void enter() {
    Blackboard Identificadores = app.getBlackboard();
    ID_Inmueble = Integer.parseInt(Identificadores.get("IdInmueble").toString());

    // Mostramos los datos para el inmueble
    PatrimonioPostgre General = new PatrimonioPostgre();
    ArrayList Datos = General.DatosRegistro(ID_Inmueble);
    if (Datos == null) return;
    Iterator alIt = Datos.iterator();
    Iterator itControles = Registro.iterator();
    while (itControles.hasNext()) {
      try {
        JComponent comp = (JComponent) itControles.next();
        Object obj = alIt.next();
        if (comp instanceof JTextField)
          ((JTextField) comp).setText((obj != null) ? obj.toString() : "");
        if (comp instanceof JCheckBox) {
          String check = (obj != null) ? obj.toString() : "";
          if (check == "TRUE") {
            ((JCheckBox) comp).setSelected(true);
          } else {
            ((JCheckBox) comp).setSelected(false);
          }
        }
        if (comp instanceof JComboBox)
          ((JComboBox) comp).setSelectedItem((obj != null) ? obj.toString() : "");
      } catch (Exception A) {
        A.printStackTrace();
      }
    }
  }
  private static File findArcMap2SLD(WorkbenchFrame wbframe, Blackboard bb)
      throws IOException, InterruptedException {
    String arcmap2sld = (String) bb.get("ArcMapStylePlugin.toollocation");
    if (arcmap2sld == null) {
      File tmp = createTempFile("amtsldreg", null);
      ProcessBuilder pb =
          new ProcessBuilder(
              "regedit",
              "/e",
              tmp.toString(),
              "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion");
      pb.start().waitFor();
      BufferedReader in =
          new BufferedReader(new InputStreamReader(new FileInputStream(tmp), "UTF-16"));
      String s;
      while ((s = in.readLine()) != null) {
        if (s.startsWith("\"ProgramFilesDir\"=\"")) {
          s = s.split("=")[1];
          s = s.substring(1, s.length() - 1);
          arcmap2sld = s + "\\i3mainz\\ArcMap2SLD_Full_Setup\\ArcGIS_SLD_Converter.exe";
          break;
        }
      }
      in.close();
      tmp.delete();
    }

    JFileChooser chooser = new JFileChooser();

    File am2sld = arcmap2sld == null ? null : new File(arcmap2sld);
    if (am2sld == null || !am2sld.exists()) {
      showMessageDialog(
          wbframe,
          get(
              "org.openjump.core.ui.plugin.style.ImportArcMapStylePlugIn.Must-Select-Location-Of-Tool"),
          get("org.openjump.core.ui.plugin.style.ImportSLDPlugIn.Question"),
          INFORMATION_MESSAGE);
      if (arcmap2sld != null) {
        chooser.setSelectedFile(new File(arcmap2sld));
      }

      int res = chooser.showOpenDialog(wbframe);
      if (res == APPROVE_OPTION) {
        am2sld = chooser.getSelectedFile();
        if (!am2sld.exists()) {
          return null;
        }
        bb.put("ArcMapStylePlugin.toollocation", am2sld.getAbsoluteFile().toString());
      } else {
        return null;
      }
    }

    return am2sld;
  }
  public void initialize(FeatureDialogHome fd) {
    GeopistaSchema esquema = (GeopistaSchema) fd.getFeature().getSchema();

    AppContext.getApplicationContext().getBlackboard().put("featureDialog", fd);

    Object obj = fd.getFeature().getAttribute(esquema.getAttributeByColumn("id"));
    if (obj != null
        && !obj.equals("")
        && ((esquema.getGeopistalayer() != null
                && !esquema.getGeopistalayer().isExtracted()
                && !esquema.getGeopistalayer().isLocal())
            || (esquema.getGeopistalayer() == null)
                && fd.getFeature() instanceof GeopistaFeature
                && !((GeopistaFeature) fd.getFeature()).getLayer().isExtracted())) {

      String codprov = null;
      if (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codprov")) != null) {
        codprov =
            (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codprov"))).toString();
      }

      String codmunic = null;
      if (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codmunic")) != null) {
        codmunic =
            (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codmunic"))).toString();
      }

      String entidad = null;
      if (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codentidad")) != null) {
        entidad =
            (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codentidad"))).toString();
      }

      String nucleo = null;
      if (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codpoblamiento")) != null) {
        nucleo =
            (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codpoblamiento")))
                .toString();
      }

      AppContext app = (AppContext) AppContext.getApplicationContext();
      Blackboard Identificadores = app.getBlackboard();
      EdicionOperations operations = new EdicionOperations();
      Identificadores.put(
          "propiedadesnucleosencuestados1_panel",
          operations.getPanelNucleosEncuestados1EIEL(codprov, codmunic, entidad, nucleo));
      Encuestados1Panel encuestados1Panel = new Encuestados1Panel();
      encuestados1Panel.loadDataIdentificacion(codprov, codmunic, entidad, nucleo);
      encuestados1Panel.loadData();
      this.encuestados1Panel = encuestados1Panel;
      fd.addPanel(encuestados1Panel);
    }
  }
  public void initialize(FeatureDialogHome fd) {

    GeopistaSchema esquema = (GeopistaSchema) fd.getFeature().getSchema();

    Object obj = fd.getFeature().getAttribute(esquema.getAttributeByColumn("id"));
    if (obj != null
        && !obj.equals("")
        && ((esquema.getGeopistalayer() != null
                && !esquema.getGeopistalayer().isExtracted()
                && !esquema.getGeopistalayer().isLocal())
            || (esquema.getGeopistalayer() == null)
                && fd.getFeature() instanceof GeopistaFeature
                && !((GeopistaFeature) fd.getFeature()).getLayer().isExtracted())) {
      String clave = null;
      if (fd.getFeature().getAttribute(esquema.getAttributeByColumn("clave")) != null) {
        clave = (fd.getFeature().getAttribute(esquema.getAttributeByColumn("clave"))).toString();
      }

      String codprov = null;
      if (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codprov")) != null) {
        codprov =
            (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codprov"))).toString();
      }

      String codmunic = null;
      if (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codmunic")) != null) {
        codmunic =
            (fd.getFeature().getAttribute(esquema.getAttributeByColumn("codmunic"))).toString();
      }

      String orden_ca = null;
      if (fd.getFeature().getAttribute(esquema.getAttributeByColumn("orden_ca")) != null) {
        orden_ca =
            (fd.getFeature().getAttribute(esquema.getAttributeByColumn("orden_ca"))).toString();
      }

      int ID =
          Integer.parseInt(
              fd.getFeature().getAttribute(esquema.getAttributeByColumn("id")).toString());
      AppContext app = (AppContext) AppContext.getApplicationContext();
      Blackboard Identificadores = app.getBlackboard();
      Identificadores.put("ID_Captacion", ID);

      EdicionOperations operations = new EdicionOperations();
      Identificadores.put("captacion", operations.getCaptacionEIEL(ID));
      CaptacionesPanel captaciones = new CaptacionesPanel();
      captaciones.loadDataIdentificacion(clave, codprov, codmunic, orden_ca);
      captaciones.loadData();
      this.captacionesPanel = captaciones;
      fd.addPanel(captaciones);
    }
  }
 /** Called when the user presses Next on this panel */
 public void exitingToRight() throws Exception {
   // Recorremos el árbol y guardamos una lista con las capas y sus atributos seleccionados
   Map<String, List<String>> tablaCapasAtributosEscritura = new HashMap<String, List<String>>();
   if (writeableRootNodes.length > 0) {
     tablaCapasAtributosEscritura = getLayersAtributesList(writeableAtributesTree);
   }
   // guardamos los atributos seleccionados de escritura
   blackboard.put(MOBILE_WRITEABLE_LAYERS_ATRIB, tablaCapasAtributosEscritura);
   Map<String, List<String>> tablaCapasAtributosLectura = new HashMap<String, List<String>>();
   if (readableRootNodes.length > 0) {
     tablaCapasAtributosLectura = getLayersAtributesList(readableAtributesTree);
   }
   // guardamos los atributos seleccionados de escritura
   blackboard.put(MOBILE_READABLE_LAYERS_ATRIB, tablaCapasAtributosLectura);
 }
  /**
   * Retorna un árbol con las capas seleccionadas y sus atributos
   *
   * @return javax.swing.JList
   */
  private JTree getWriteableLayerTree() {
    ArrayList<GeopistaLayer> extractLayers =
        (ArrayList<GeopistaLayer>) blackboard.get(MobileExtractPanel01.MOBILE_WRITEABLE_LAYERS);
    writeableRootNodes = getRootLayerNodes(extractLayers);
    Vector rootVector =
        new NamedVector(
            I18N.get(
                MobileExtractPlugin.PluginMobileExtracti18n,
                MobilePluginI18NResource.MobileExtractPanel03_capasEdit),
            writeableRootNodes);
    JTree tree = new JTree(rootVector);
    tree.setFont(new Font(tree.getFont().getName(), Font.BOLD, tree.getFont().getSize()));
    CheckBoxNodeRenderer renderer = new CheckBoxNodeRenderer(Color.BLUE);
    tree.setCellRenderer(renderer);
    tree.setCellEditor(new CheckBoxNodeEditor(tree));
    tree.setEditable(true);

    //		DefaultMutableTreeNode root = new DefaultMutableTreeNode("Capas");
    //	    JTree tree = new JTree(root);
    //	    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    //	    DefaultMutableTreeNode chosen = null;
    //	    if(extractLayers!=null){
    //			for (int i = 0; i < extractLayers.size(); i++) {
    //				geopistaLayer = extractLayers.get(i);
    //				chosen = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
    //				if (chosen == null){
    //					chosen = root;
    //				}
    //				model.insertNodeInto(getTreeNodeFromLayer(geopistaLayer), chosen, 0);
    //			}
    //	    }

    return tree;
  }
  /** Acción realizada al pulsar el botón desasociar de la aplicación */
  private void jButtonDesasociarActionPerformed() {
    try {
      LayerOperations operaciones = new LayerOperations();

      // desasocia el dominio de la columna
      int iDeleted = operaciones.desasociarColumna(auxColumn);

      if (iDeleted > 0) {
        JOptionPane optionPane =
            new JOptionPane(
                I18N.get("GestorCapas", "general.mensaje.fin.operacion"),
                JOptionPane.INFORMATION_MESSAGE);
        JDialog dialog = optionPane.createDialog(this, "");
        dialog.show();
        Identificadores.put("DomainsModificados", true);
        jButtonAsociar.setEnabled(true);
        jButtonDesasociar.setEnabled(false);
      } else {
        JOptionPane optionPane =
            new JOptionPane(
                I18N.get("GestorCapas", "general.mensaje.error.operacion"),
                JOptionPane.ERROR_MESSAGE);
        JDialog dialog = optionPane.createDialog(this, "");
        dialog.show();
      }
      ;

      repaint();

    } catch (DataException de) {
      de.printStackTrace();
    }
  }
  /** Called when the user presses Next on this panel */
  public void exitingToRight() throws Exception {
    // ponemos en un objeto listaTablas las capas qeu se utilizan

    // DefaultListModel recuperar = (DefaultListModel) lstCapas.getModel();

    java.util.List listaTablasInformes = null;
    GeopistaObjetoInformeDatosGenerales objetoDatosGenerales =
        new GeopistaObjetoInformeDatosGenerales();
    listaTablasInformes = Arrays.asList(lstCapas.getSelectedValues());

    // Pasamos los datos al objeto
    objetoDatosGenerales.setCapas(listaTablasInformes);
    objetoDatosGenerales.setModulo((String) cmbModulos.getSelectedItem());
    objetoDatosGenerales.setTitulo(txtTituloInforme.getText());
    if (optVertical.isSelected()) {
      objetoDatosGenerales.setOrientacion(optVertical.getText());
    } else {
      objetoDatosGenerales.setOrientacion(optHorizontal.getText());
    }

    objetoDatosGenerales.setNombreFichero(txtNombreFichero.getText());
    objetoDatosGenerales.setDescripcion(txtDescripcion.getText());

    blackboardInformes.put("datosGenerales", objetoDatosGenerales);
  }
  @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;
  }
  public void enter() {
    // Recuperamos el ID_Parcela y el ID_UnidadConstruccion
    AppContext app = (AppContext) AppContext.getApplicationContext();
    Blackboard Identificadores = app.getBlackboard();
    ID_Parcela = Integer.parseInt(Identificadores.get("ID_Parcela").toString());
    // ID_Unidad= Integer.parseInt(Identificadores.get("ID_Unidad").toString());

    // Rellenamos el Listbox
    lstCons.clear();
    try {
      CatastroActualizarPostgre Cons = new CatastroActualizarPostgre();
      ArrayList Datos = Cons.Cons(ID_Parcela);
      Iterator alIt = Datos.iterator();
      while (alIt.hasNext()) {
        lstCons.addElement(alIt.next());
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#11
0
 public void okPressed() {
   blackboard.put(SnapToVerticesPolicy.ENABLED_KEY, snapToVerticesCheckBox.isSelected());
   SnapManager.setToleranceInPixels(toleranceTextField.getInteger(), blackboard);
   blackboard.put(SnapToFeaturesPolicy.ENABLED_KEY, snapToFeaturesCheckBox.isSelected());
   blackboard.put(SnapToGridPolicy.ENABLED_KEY, snapToGridCheckBox.isSelected());
   blackboard.put(SnapToGridPolicy.GRID_SIZE_KEY, Double.parseDouble(gridSizeTextField.getText()));
   blackboard.put(GridRenderer.DOTS_ENABLED_KEY, showGridDotsRadioButton.isSelected());
   blackboard.put(GridRenderer.LINES_ENABLED_KEY, showGridLinesRadioButton.isSelected());
   blackboard.put(GridRenderer.ENABLED_KEY, showGridCheckBox.isSelected());
 }
示例#12
0
  /** Acciones realizas al entrar en la pantalla */
  public void enter() {
    if (((Boolean) Identificadores.get("TablasModificadas")).booleanValue()
        && !((Boolean) Identificadores.get("TablasDominiosActualizada")).booleanValue()) {
      // Cada vez que se entra, se actualiza el arbol de tablas del sistema con
      // los posibles cambios realizados
      Identificadores.put("Tablas", null);
      Identificadores.put("Columnas", null);

      this.remove(jPanelTablas);
      jPanelTablas = new JPanelTables(TreeSelectionModel.SINGLE_TREE_SELECTION);
      jPanelTablas.setBorder(
          BorderFactory.createTitledBorder(I18N.get("GestorCapas", "tablas.arbol.titulo")));
      jPanelTablas.setBounds(new java.awt.Rectangle(5, 5, 250, 481));
      this.add(jPanelTablas);
      treeTablas = jPanelTablas.getTree();
      treeTablas.addTreeSelectionListener(this);

      // Si se modifica algo en la pantalla de tablas de base de datos, habrá
      // que actualizar la información tanto en el panel de tablasdominios como
      // en el de layers.
      Identificadores.put("TablasDominiosActualizada", true);
      if (((Boolean) Identificadores.get("LayersActualizada")).booleanValue()) {
        Identificadores.put("TablasModificadas", false);
        Identificadores.put("TablasDominiosActualizada", false);
        Identificadores.put("LayersActualizada", false);
      }
    }

    try {
      // Iniciamos la ayuda
      String helpHS = "help/catastro/gestordecapas/GestorCapasHelp_es.hs";
      ClassLoader c1 = this.getClass().getClassLoader();
      URL hsURL = HelpSet.findHelpSet(c1, helpHS);
      HelpSet hs = new HelpSet(null, hsURL);
      HelpBroker hb = hs.createHelpBroker();
      // fin de la ayuda
      hb.enableHelpKey(this, "Pestania2Dominios", hs);
    } catch (Exception excp) {
      excp.printStackTrace();
    }
  }
示例#13
0
  /*
   * Se ejecuta una vez finalizado el interfaz despues de pasar por todas las pantallas.
   * (non-Javadoc)
   * @see com.vividsolutions.jump.workbench.plugin.ThreadedPlugIn#run(com.vividsolutions.jump.task.TaskMonitor, com.vividsolutions.jump.workbench.plugin.PlugInContext)
   */
  public void run(TaskMonitor monitor, PlugInContext context) throws Exception {
    try {
      monitor.report(
          I18N.get(
              PluginMobileExtracti18n, MobilePluginI18NResource.MobileModifyPanel01_deletingProy));

      ExtractionProject eProject =
          (ExtractionProject) blackboard.get(MobileModifyPanel01.SELECTED_EXTRACT_PROJECT);

      // guardamos la informacion en base de datos
      final String sUrlPrefix =
          Constants.APLICACION.getString(UserPreferenceConstants.LOCALGIS_SERVER_URL);
      AdministradorCartografiaClient administradorCartografiaClient =
          new AdministradorCartografiaClient(
              sUrlPrefix
                  + WebAppConstants.GEOPISTA_WEBAPP_NAME
                  + ServletConstants.ADMINISTRADOR_CARTOGRAFIA_SERVLET_NAME);
      administradorCartografiaClient.deleteExtractProject(eProject);

      // Borramos los datos subidos al servidor.
      httpDeleteProject(Constants.URL_DELETE_SERVER, eProject);

      String dirBase =
          UserPreferenceStore.getUserPreference(
              UserPreferenceConstants.PREFERENCES_DATA_PATH_KEY,
              UserPreferenceConstants.DEFAULT_DATA_PATH,
              true);
      dirBase += File.separator + "maps";

      String projectName = eProject.getNombreProyecto();
      String idProyecto = eProject.getIdProyecto();

      String dirMapName = projectName + "." + idProyecto;
      File dirBaseMake = new File(dirBase, dirMapName);
      if (dirBaseMake.exists()) {
        MobileUtils.deleteDir(dirBaseMake);
        logger.info("Borrando fichero local:" + dirBaseMake);
      }

    } finally {
      // borramos la cuadrícula
      LayerManager layerManager = context.getLayerManager();
      Layer graticuleLayer = layerManager.getLayer(GraticuleCreatorEngine.getGraticuleName());
      if (graticuleLayer != null) {
        layerManager.remove(graticuleLayer);
      }
    }
  }
示例#14
0
 public void init() {
   snapToVerticesCheckBox.setSelected(blackboard.get(SnapToVerticesPolicy.ENABLED_KEY, false));
   toleranceTextField.setText("" + SnapManager.getToleranceInPixels(blackboard));
   snapToFeaturesCheckBox.setSelected(blackboard.get(SnapToFeaturesPolicy.ENABLED_KEY, false));
   snapToGridCheckBox.setSelected(blackboard.get(SnapToGridPolicy.ENABLED_KEY, false));
   gridSizeTextField.setText("" + blackboard.get(SnapToGridPolicy.GRID_SIZE_KEY, 20d));
   showGridCheckBox.setSelected(blackboard.get(GridRenderer.ENABLED_KEY, false));
   showGridDotsRadioButton.setSelected(blackboard.get(GridRenderer.DOTS_ENABLED_KEY, false));
   showGridLinesRadioButton.setSelected(blackboard.get(GridRenderer.LINES_ENABLED_KEY, true));
   updateEnabled();
 }
 /**
  * Retorna un árbol con las capas seleccionadas y sus atributos
  *
  * @return javax.swing.JList
  */
 private JTree getReadableLayerTree() {
   ArrayList<GeopistaLayer> extractLayers =
       (ArrayList<GeopistaLayer>) blackboard.get(MobileExtractPanel01.MOBILE_READABLE_LAYERS);
   readableRootNodes = getRootLayerNodes(extractLayers);
   Vector rootVector =
       new NamedVector(
           I18N.get(
               MobileExtractPlugin.PluginMobileExtracti18n,
               MobilePluginI18NResource.MobileExtractPanel03_capasLect),
           readableRootNodes);
   JTree tree = new JTree(rootVector);
   // tree.setFont(new Font(tree.getFont().getName(), Font.BOLD, tree.getFont().getSize()));
   CheckBoxNodeRenderer renderer = new CheckBoxNodeRenderer(Color.RED);
   tree.setCellRenderer(renderer);
   tree.setCellEditor(new CheckBoxNodeEditor(tree));
   tree.setEditable(true);
   return tree;
 }
示例#16
0
  /** Acción realizada al pulsar el botón de asociar de la aplicación */
  private void jButtonAsociarActionPerformed() {
    try {
      // Convierte com.geopista.protocol.administrador.dominios.Domain
      // en com.geopista.features.Domain

      int idDomain = Integer.parseInt(auxDomain.getIdDomain());
      String nombreDominio = auxDomain.getName();
      LayerOperations operaciones = new LayerOperations();
      Domain dominio = operaciones.obtenerDominioTipo(idDomain, nombreDominio);

      // asocia el dominio a la columna
      int iRes =
          operaciones.actualizarDominioColumna(
              auxColumn, dominio, Integer.parseInt(txtLevel.getText()));
      // auxColumn.setDomain(dominio);

      if (iRes > 0) {
        JOptionPane optionPane =
            new JOptionPane(
                I18N.get("GestorCapas", "general.mensaje.fin.operacion"),
                JOptionPane.INFORMATION_MESSAGE);
        JDialog dialog = optionPane.createDialog(this, "");
        dialog.show();

        Identificadores.put("DomainsModificados", true);
        jButtonDesasociar.setEnabled(true);
      } else {
        JOptionPane optionPane =
            new JOptionPane(
                I18N.get("GestorCapas", "general.mensaje.error.operacion"),
                JOptionPane.ERROR_MESSAGE);
        JDialog dialog = optionPane.createDialog(this, "");
        dialog.show();
      }

      repaint();

    } catch (DataException de) {
      de.printStackTrace();
    }
  }
  private void jbInit() throws Exception {
    this.removeAll();
    this.setLayout(new GridBagLayout());
    java.awt.GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
    gridBagConstraints1.gridx = 0;
    gridBagConstraints1.gridy = 1;
    gridBagConstraints1.weightx = 1.0;
    gridBagConstraints1.weighty = 1.0;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints1.ipadx = -21;
    gridBagConstraints1.ipady = 141;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 5, 5);
    java.awt.GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
    gridBagConstraints2.gridx = 0;
    gridBagConstraints2.gridy = 2;
    gridBagConstraints2.insets = new java.awt.Insets(5, 5, 5, 5);
    java.awt.GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
    gridBagConstraints3.gridx = 0;
    gridBagConstraints3.gridy = 3;
    gridBagConstraints3.weightx = 1.0;
    gridBagConstraints3.weighty = 1.0;
    gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints3.ipadx = -21;
    gridBagConstraints3.ipady = 141;
    gridBagConstraints3.insets = new java.awt.Insets(5, 5, 5, 5);

    java.awt.GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
    gridBagConstraints4.gridx = 0;
    gridBagConstraints4.gridy = 0;

    String projectName = (String) blackboard.get(MOBILE_PROJECT_NAME);
    JLabel extractionProjectNameLabel = new JLabel(projectName);

    this.add(extractionProjectNameLabel, gridBagConstraints4);

    this.add(getWriteableLayerScrollPane(), gridBagConstraints1);
    this.add(getReadableLayerScrollPane(), gridBagConstraints3);
    this.add(getGraticuleButton(), gridBagConstraints2);
  }
  /** Called when the user presses Next on this panel */
  public void exitingToRight() throws Exception {
    /** guardamos las celdas que tienen usuario asignado * */
    JComboBox jCombo = null;
    String idCelda;
    String idSelectedUsuario;
    HashMap<String, String> celdasUsuarios =
        new HashMap<String, String>(); // lista de usuarios asignados a la celda que es índice
    int selectedIndex;
    for (int i = 0; i < jComboList.size(); i++) {
      jCombo = jComboList.get(i);
      idCelda = jCombo.getName();
      selectedIndex = jCombo.getSelectedIndex();
      idSelectedUsuario = ComboItemGraticuleListener.SIN_ASIGNAR;
      if (selectedIndex > 0) {
        idSelectedUsuario = listaUsuariosPermisos.get(selectedIndex - 1).getId();
      }
      celdasUsuarios.put(idCelda, idSelectedUsuario);
    }

    // añadimos al clipboard el map generado
    blackboard.put(MOBILE_USERS_GRATICULES, celdasUsuarios);
  }
示例#19
0
 /** Borra lo que haya utilizado del blackboard en sus anteriores ejecuciones */
 private void emptyBlackboard() {
   blackboard.remove(MobileModifyPanel01.SELECTED_EXTRACT_PROJECT);
 }
 public void exit() {
   AppContext app = (AppContext) AppContext.getApplicationContext();
   Blackboard Identificadores = app.getBlackboard();
   Identificadores.put("ID_Construccion", ID_Construccion);
 }
  private JButton getGraticuleButton() {
    jButtonGraticule =
        new JButton(
            I18N.get(
                MobileExtractPlugin.PluginMobileExtracti18n,
                MobilePluginI18NResource.MobileExtractPanel03_crearCuadricula));

    LayerManager layerManager = context.getLayerManager();
    Layer graticuleLayer = layerManager.getLayer(GraticuleCreatorEngine.getGraticuleName());

    // si ya existe una capa cuadrícula significa que se trata de un fichero importado previamente a
    // ejecutar el asistente
    if (graticuleLayer != null) {
      jButtonGraticule.setEnabled(false);

      if (bCuadriculaCreada == true) {
        // solo ejecutamos este código una vez
        return jButtonGraticule;
      }

      FeatureCollectionWrapper graticuleCollectionWrapper =
          graticuleLayer.getFeatureCollectionWrapper();
      FeatureSchema featureSchema = graticuleCollectionWrapper.getFeatureSchema();

      // cuadriculas visionadas
      IViewport viewport = (IViewport) context.getLayerViewPanel().getViewport();
      Envelope viewEnvelope = viewport.getEnvelopeInModelCoordinates();
      List<Feature> graticuleFeatures = graticuleCollectionWrapper.query(viewEnvelope);
      // ordenamos por distancia al origen las features
      List<SortedFeature> sortedGraticuleFeatures = new ArrayList<SortedFeature>();
      Feature feature = null;
      SortedFeature sortFeat = null;
      for (Iterator iterator = graticuleFeatures.iterator(); iterator.hasNext(); ) {
        feature = (Feature) iterator.next();
        sortFeat = new SortedFeature(feature);
        sortedGraticuleFeatures.add(sortFeat);
      }
      Collections.sort(sortedGraticuleFeatures);

      // borramos el resto de cuadrículas
      graticuleCollectionWrapper.clear();
      graticuleCollectionWrapper.addAll(graticuleFeatures);
      Envelope newWrapperEnvelope = graticuleCollectionWrapper.getEnvelope();

      // zoom al envelope actual
      try {
        viewport.zoom(newWrapperEnvelope);
      } catch (NoninvertibleTransformException e) {
        log.warn("No se ha podido alcanzar el zoom " + newWrapperEnvelope);
      }

      // ajustamos la ventana al envelope de la cuadrícula
      resizeViewToEnvelope(context, newWrapperEnvelope, viewport);

      // guardamos las propiedades gráficas de la extracción
      Envelope featEnvelope =
          sortedGraticuleFeatures.get(0).getFeature().getGeometry().getEnvelopeInternal();
      Double featWidth = featEnvelope.getWidth();
      Double featHeight = featEnvelope.getHeight();
      Double minX = newWrapperEnvelope.getMinX();
      Double minY = newWrapperEnvelope.getMinY();
      Coordinate coordCorner = new Coordinate(minX, minY);
      blackboard.put(GraticuleCreatorPlugIn.SOUTHWEST_CORNER_OF_LEFT_LAYER, coordCorner);
      blackboard.put(GraticuleCreatorPlugIn.CELL_SIDE_LENGTH_X, featWidth);
      blackboard.put(GraticuleCreatorPlugIn.CELL_SIDE_LENGTH_Y, featHeight);
      Integer numCeldasAncho = (int) (newWrapperEnvelope.getWidth() / featWidth);
      Integer numCeldasAlto = (int) (newWrapperEnvelope.getHeight() / featHeight);
      blackboard.put(GraticuleCreatorPlugIn.LAYER_WIDTH_IN_CELLS, numCeldasAncho);
      blackboard.put(GraticuleCreatorPlugIn.LAYER_HEIGHT_IN_CELLS, numCeldasAlto);

      // creamos celdas para los espacios en blanco
      if (sortedGraticuleFeatures.size() < numCeldasAncho * numCeldasAlto) {
        Double curMinX = minX;
        Double curMinY = minY;
        Double fMinX = 0.0;
        GeometryFactory geoFact = new GeometryFactory();
        Feature newFeature = null;
        for (int i = 0; i < sortedGraticuleFeatures.size(); i++) {
          sortFeat = sortedGraticuleFeatures.get(i);
          feature = sortFeat.getFeature();
          fMinX = feature.getGeometry().getEnvelopeInternal().getMinX();
          if (curMinX.doubleValue() != fMinX.doubleValue()) {
            // creamos la feature
            newFeature = (Feature) feature.clone();
            Coordinate[] coordArray = {
              new Coordinate(curMinX, curMinY),
              new Coordinate(curMinX + featWidth, curMinY),
              new Coordinate(curMinX + featWidth, curMinY + featHeight),
              new Coordinate(curMinX, curMinY + featHeight),
              new Coordinate(curMinX, curMinY)
            };

            newFeature.setGeometry(
                geoFact.createPolygon(geoFact.createLinearRing(coordArray), null));
            sortedGraticuleFeatures.add(i, new SortedFeature(newFeature));
            graticuleCollectionWrapper.add(newFeature);
          }
          // para lo último
          else if ((i == sortedGraticuleFeatures.size() - 1)
              && ((minX + (featWidth * numCeldasAncho)) != (fMinX + featWidth))) {
            curMinX = fMinX + featWidth;
            newFeature = (Feature) feature.clone();
            Coordinate[] coordArray = {
              new Coordinate(curMinX, curMinY),
              new Coordinate(curMinX + featWidth, curMinY),
              new Coordinate(curMinX + featWidth, curMinY + featHeight),
              new Coordinate(curMinX, curMinY + featHeight),
              new Coordinate(curMinX, curMinY)
            };

            newFeature.setGeometry(
                geoFact.createPolygon(geoFact.createLinearRing(coordArray), null));
            sortedGraticuleFeatures.add(
                sortedGraticuleFeatures.size(), new SortedFeature(newFeature));
            graticuleCollectionWrapper.add(newFeature);
            continue;
          }

          if (((i + 1) % numCeldasAncho) != 0) {
            curMinX = curMinX + featWidth;
          } else { // ultima celda de cada fila
            curMinX = minX;
            curMinY += featHeight;
          }
        }
      }

      // añadimos el atributo cellid
      featureSchema.addAttribute(GraticuleCreatorEngine.ATR_CELL_ID, AttributeType.INTEGER);
      int k = 1;
      Object[] featAttribs = null;
      Object[] newFeatAttribs = null;
      for (Iterator iterator = sortedGraticuleFeatures.iterator(); iterator.hasNext(); k++) {
        feature = ((SortedFeature) iterator.next()).getFeature();
        featAttribs = feature.getAttributes();
        newFeatAttribs = new Object[featAttribs.length + 1];
        for (int i = 0; i < featAttribs.length; i++) {
          newFeatAttribs[i] = featAttribs[i];
        }
        newFeatAttribs[newFeatAttribs.length - 1] = k;
        feature.setAttributes(newFeatAttribs);
      }
      // pintamos el atributo en la capa
      LabelStyle labelStyle = graticuleLayer.getLabelStyle();
      labelStyle.setColor(Color.RED);
      labelStyle.setHeight(labelStyle.getHeight() * 4);
      labelStyle.setAttribute(GraticuleCreatorEngine.ATR_CELL_ID);
      labelStyle.setEnabled(true);

      // evitamos que se modifiquen las cuadrículas
      graticuleLayer.setEditable(false);
      graticuleLayer.fireAppearanceChanged();

      bCuadriculaCreada = true;
    }
    // llamada al graticulePlugin
    else {
      jButtonGraticule.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent e) {
              GraticuleCreatorPlugIn graticulePlugin = new GraticuleCreatorPlugIn();
              try {
                graticulePlugin.execute(context);
              } catch (Exception e1) {
                e1.printStackTrace();
              }
              wizardContext.inputChanged(); // indicamos que ya se puede habilitar el boton
            }
          });
    }

    return jButtonGraticule;
  }
  private void jbInit() throws Exception {
    // Leemos la conexion

    //
    //    con = getDBConnection();
    GeopistaGeneradorListadosConexionBD geopistaListados =
        new GeopistaGeneradorListadosConexionBD();

    this.setLayout(null);
    this.setSize(new Dimension(854, 500));
    jPanel1.setLayout(null);
    jPanel1.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
    lblDatosGenerales.setText(aplicacion.getI18nString("generador.app.reports.datos.generales"));
    lblModulo.setText(aplicacion.getI18nString("generador.app.reports.modulo"));
    lblCapa.setText(aplicacion.getI18nString("generador.app.reports.capa"));

    // Cargamos la lista de capas
    ArrayList capas = geopistaListados.capasGeopista();

    Iterator i = capas.iterator();
    lblDatosGenerales.setBounds(new Rectangle(135, 5, 185, 20));
    lblModulo.setBounds(new Rectangle(135, 23, 60, 25));
    lblCapa.setBounds(new Rectangle(135, 50, 45, 30));
    jPanel1.setBounds(new Rectangle(10, 15, 750, 500));
    jSeparator1.setBounds(new Rectangle(0, 135, 735, 5));
    while (i.hasNext()) {
      modeloList.addElement(i.next());
    }

    // Creamos la lista con el modelo anteriormente definido

    // --    jPanel1.setSize(new Dimension(750, 600));
    cmbModulos.setBackground(new Color(254, 255, 255));
    cmbModulos.setBounds(new Rectangle(215, 25, 520, 20));

    lstCapas.setSelectionModel(listSelectionModel1);

    lblTitulo.setText(aplicacion.getI18nString("informe.datos.seleccion.titulo.fichero"));
    lblTitulo.setBounds(new Rectangle(140, 215, 95, 15));
    txtTituloInforme.setBounds(new Rectangle(140, 230, 595, 20));

    lstCapas.addKeyListener(
        new java.awt.event.KeyAdapter() {
          public void keyReleased(java.awt.event.KeyEvent e) {
            String cadena = (String) lstCapas.getSelectedValue();
            lstCapas.ensureIndexIsVisible(lstCapas.getSelectedIndex());
            lstCapas.setSelectedValue((String) cadena, true);
          }
        });
    lstCapas.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {
            wizardContext.inputChanged();
          }

          public void mousePressed(MouseEvent e) {}

          public void mouseReleased(MouseEvent e) {}

          public void mouseEntered(MouseEvent e) {}

          {
          }

          public void mouseExited(MouseEvent e) {}
        });

    lblDescripcion.setText(aplicacion.getI18nString("generador.app.reports.descripcion.informe"));
    lblDescripcion.setBounds(new Rectangle(140, 255, 95, 20));
    txtDescripcion.setBounds(new Rectangle(140, 280, 595, 95));
    lblOrientacion.setText(aplicacion.getI18nString("generador.app.reports.orientacion.informe"));
    lblOrientacion.setBounds(new Rectangle(135, 178, 85, 25));
    lblNombreFichero.setText(aplicacion.getI18nString("generador.app.reports.nombre.fichero"));
    lblNombreFichero.setBounds(new Rectangle(135, 145, 120, 30));
    txtNombreFichero.setBounds(new Rectangle(215, 150, 520, 20));

    //    hb.enableHelpKey(this,"encabezado",hs);
    // Ponemos a mano los Módulos , prueba
    cmbModulos.addItem(
        (String) aplicacion.getI18nString("generador.app.reports.modulo.planeamiento"));
    cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.catastro"));
    cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.informacion"));
    cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.patrimonio"));
    cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.infraestructuras"));
    // Ponemos las explicaciones de las secciones
    /*  lblExplicacionDatosInformes.setText(aplicacion.getI18nString("informe.datos.generales.explicacion.comentarios"));
    txtTituloInforme.setToolTipText(aplicacion.getI18nString("informe.datos.generales.explicacion.titulo.fichero"));
    txtDescripcion.setToolTipText(aplicacion.getI18nString("informe.datos.generales.explicacion.detalle"));
    txtNombreFichero.setToolTipText(aplicacion.getI18nString("informe.datos.generales.explicacion.nombre.fichero"));
    lblUbicacion.setText(aplicacion.getI18nString("informe.datos.generales.explicacion.ubicacion"));*/

    // Ponemos a mano la horientacion
    optVertical.setText(aplicacion.getI18nString("generador.app.reports.orientacion.vertical"));
    optHorizontal.setText(aplicacion.getI18nString("generador.app.reports.orientacion.horizontal"));

    // Nuevo Listener para ver cuando cambia la caja de texto
    txtTituloInforme.addKeyListener(
        new KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {
            wizardContext.inputChanged();
          }

          public void keyReleased(KeyEvent e) {}
        });
    optVertical.setText(aplicacion.getI18nString("generador.app.reports.orientacion.vertical"));
    optVertical.setSelected(true);
    optVertical.setBounds(new Rectangle(215, 180, 125, 20));
    optVertical.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            optVertical_actionPerformed(e);
          }
        });
    optHorizontal.setText(aplicacion.getI18nString("generador.app.reports.orientacion.horizontal"));
    optHorizontal.setBounds(new Rectangle(360, 180, 135, 20));
    optHorizontal.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            optHorizontal_actionPerformed(e);
          }
        });
    jScrollPane1.setBounds(new Rectangle(215, 60, 520, 70));
    jSeparator2.setBounds(new Rectangle(5, 205, 730, 5));
    lblImagen.setBounds(new Rectangle(15, 20, 110, 490));
    lblImagen.setIcon(IconLoader.icon((String) blackboardInformes.get("tipoBanner")));
    lblImagen.setBounds(new Rectangle(15, 20, 110, 490));
    lblImagen.setBorder(BorderFactory.createLineBorder(Color.black, 1));
    lblImagen.setBorder(BorderFactory.createLineBorder(Color.black, 1));

    txtNombreFichero.addKeyListener(
        new KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {
            wizardContext.inputChanged();
          }

          public void keyReleased(KeyEvent e) {}
        });

    jScrollPane1.getViewport().add(lstCapas, null);
    jPanel1.add(jSeparator2, null);
    jPanel1.add(jScrollPane1, null);
    jPanel1.add(optHorizontal, null);
    jPanel1.add(optVertical, null);
    jPanel1.add(txtTituloInforme, null);
    jPanel1.add(lblTitulo, null);
    jPanel1.add(txtDescripcion, null);
    jPanel1.add(lblDescripcion, null);
    jPanel1.add(lblOrientacion, null);
    jPanel1.add(txtNombreFichero, null);
    jPanel1.add(lblNombreFichero, null);
    jPanel1.add(jSeparator1, null);
    jPanel1.add(lblCapa, null);
    jPanel1.add(cmbModulos, null);
    jPanel1.add(lblModulo, null);
    jPanel1.add(lblDatosGenerales, null);
    this.add(lblImagen, null);
    this.add(jPanel1, null);

    // Cargamos las capas en la lista

  }
  private JScrollPane getGraticuleCells() {
    // sacamos las cuadrículas de la rejilla
    LayerManager layerManager = context.getLayerManager();
    Layer graticuleLayer = layerManager.getLayer(GraticuleCreatorEngine.getGraticuleName());
    if (graticuleLayer != null) {
      FeatureCollectionWrapper fCollWrapper = graticuleLayer.getFeatureCollectionWrapper();
      List featList = fCollWrapper.getFeatures();
      jComboList = new ArrayList<JComboBox>();
      Feature feature = null;
      Integer cellId = null;
      JPanel jPaneCells = new JPanel();
      int cols = featList.size() / 2;
      if (featList.size() % 2 != 0) {
        cols++;
      }
      jPaneCells.setLayout(new GridLayout(cols, 2));

      //	        //capas extraídas
      //	        ArrayList<GeopistaLayer> writeableLayers = (ArrayList<GeopistaLayer>)
      // blackboard.get(MobileExtractPanel01.MOBILE_WRITEABLE_LAYERS);
      //	        ArrayList<GeopistaLayer> readableLayers = (ArrayList<GeopistaLayer>)
      // blackboard.get(MobileExtractPanel01.MOBILE_READABLE_LAYERS);
      //	        ArrayList<String> listLayersId = new ArrayList<String>();
      //	        GeopistaLayer geopistaLayer = null;
      //	        for(int i=0; i<writeableLayers.size(); i++){
      //	        	geopistaLayer = writeableLayers.get(i);
      //	        	listLayersId.add(String.valueOf(geopistaLayer.getId_LayerDataBase()));
      //	        }
      //	        for(int i=0; i<readableLayers.size(); i++){
      //	        	geopistaLayer = readableLayers.get(i);
      //	        	listLayersId.add(String.valueOf(geopistaLayer.getId_LayerDataBase()));
      //	        }

      // obtenemos el proyecto de extracción seleccionado de la pantalla anterior
      ExtractionProject eProject =
          (ExtractionProject) blackboard.get(MobileAssignCellsPanel01.SELECTED_EXTRACT_PROJECT);

      JPanel auxPanel = null;
      arrayNombresUsuarios = null;
      listaUsuariosPermisos = null;
      HashMap<String, String> usuariosAsignados = null;
      final String sUrlPrefix = Constants.APLICACION.getString("geopista.conexion.servidorurl");
      try {
        // añadimos los usuarios a los combos
        AdministradorCartografiaClient administradorCartografiaClient =
            new AdministradorCartografiaClient(
                sUrlPrefix
                    + WebAppConstants.GEOPISTA_WEBAPP_NAME
                    + ServletConstants.ADMINISTRADOR_CARTOGRAFIA_SERVLET_NAME);
        ListaUsuarios usersRealList =
            (ListaUsuarios)
                administradorCartografiaClient.getUsersPermLayers(
                    eProject.getIdExtractLayersList());
        // usuarios ya asignados
        usuariosAsignados =
            administradorCartografiaClient.getAssignCellsExtractProject(eProject.getIdProyecto());
        // usuarios con permisos sobre las capas
        Hashtable<String, Usuario> usuariosReales =
            (Hashtable<String, Usuario>) usersRealList.gethUsuarios();
        Set<String> keySetUsers = usuariosReales.keySet();
        arrayNombresUsuarios = new String[keySetUsers.size() + 1];
        arrayNombresUsuarios[0] = ComboItemGraticuleListener.SIN_ASIGNAR;
        listaUsuariosPermisos = new ArrayList<Usuario>();
        String userKey = null;
        Usuario usuario = null;
        int k = 1;
        for (Iterator iterator = keySetUsers.iterator(); iterator.hasNext(); ) {
          userKey = (String) iterator.next();
          usuario = usuariosReales.get(userKey);
          arrayNombresUsuarios[k] = usuario.getName();
          listaUsuariosPermisos.add(usuario);
          k++;
        }
      } catch (Exception e) {
        e.printStackTrace();
      }

      JComboBox jcombo = null;
      ILayerViewPanel layerViewPanel = (ILayerViewPanel) context.getLayerViewPanel();
      JLabel jLabelCelda = null;
      String cellIdStr = null;
      Map<Layer, HashSet<Feature>> visibleLayerToFeaturesInFenceMap = null;
      graticuleLayer.setVisible(false); // para quitar la cuadrícula de la intersección
      // añadimos el identificador de cada una al panel
      for (int i = 0; i < featList.size(); i++) {
        feature = (Feature) featList.get(i);
        visibleLayerToFeaturesInFenceMap =
            layerViewPanel.visibleLayerToFeaturesInFenceMap(feature.getGeometry());
        cellId = (Integer) feature.getAttribute(GraticuleCreatorEngine.ATR_CELL_ID);
        auxPanel = new JPanel();
        jLabelCelda =
            new JLabel(
                I18N.get(
                        MobileAssignCellsPlugin.PluginMobileExtracti18n,
                        MobilePluginI18NResource.MobileAssignCellsPanel02_celda)
                    + cellId);
        jcombo = new JComboBox(arrayNombresUsuarios);
        cellIdStr = String.valueOf(cellId);
        jcombo.setName(cellIdStr);

        // celdas con features o sin ellas
        if (visibleLayerToFeaturesInFenceMap == null
            || visibleLayerToFeaturesInFenceMap.size() == 0) {
          jLabelCelda.setEnabled(false);
          jcombo.setEnabled(false);
        } else {
          jLabelCelda.setForeground(Color.RED);
          jcombo.addItemListener(
              new ComboItemGraticuleListener(
                  layerViewPanel, graticuleLayer, feature, jLabelCelda, wizardContext));
          jComboList.add(jcombo);
        }

        auxPanel.add(jLabelCelda);
        auxPanel.add(jcombo);
        jPaneCells.add(auxPanel);
      }
      graticuleLayer.setVisible(true);

      // seleccionamos los usuario asignados en los combos
      if (usuariosAsignados != null && usuariosAsignados.size() != 0) {
        for (int i = 0; i < jComboList.size(); i++) {
          jcombo = jComboList.get(i);
          cellIdStr = jcombo.getName();
          if (usuariosAsignados.containsKey(cellIdStr)) {
            seleccionaUsuarioComboCelda(jcombo, usuariosAsignados.get(cellIdStr));
          }
        }
      }

      jPaneInternal = new JScrollPane();
      jPaneInternal.setViewportView(jPaneCells);
      jPaneInternal.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    }

    return jPaneInternal;
  }