コード例 #1
0
  public MostrarFINRetornoMasivo() {
    Locale loc = I18N.getLocaleAsObject();
    ResourceBundle bundle =
        ResourceBundle.getBundle(
            "com.geopista.app.catastro.intercambio.language.Importacioni18n",
            loc,
            this.getClass().getClassLoader());
    I18N.plugInsResourceBundle.put("Importacion", bundle);

    final TaskMonitorDialog progressDialog =
        new TaskMonitorDialog(application.getMainFrame(), null);

    progressDialog.setTitle(application.getI18nString("CargandoDatosIniciales"));
    progressDialog.report(application.getI18nString("CargandoDatosIniciales"));
    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 {
                          jbInit();
                        } catch (Exception e) {
                          e.printStackTrace();
                        } finally {
                          progressDialog.setVisible(false);
                        }
                      }
                    })
                .start();
          }
        });
    GUIUtil.centreOnWindow(progressDialog);
    progressDialog.setVisible(true);
  }
コード例 #2
0
  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;
  }
コード例 #3
0
  public void startApp(boolean fromInicio) {

    logger.info("Arrancando aplicacion de inventario");
    String mostrarPaginacion = System.getProperty("mostrarPaginacion");

    if ((mostrarPaginacion != null) && (mostrarPaginacion.equals("true"))) {
      com.geopista.app.inventario.Constantes.MOSTRAR_PAGINACION = true;
    }
    this.fromInicio = fromInicio;
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    aplicacion = (AppContext) AppContext.getApplicationContext();
    aplicacion.setMainFrame(this);
    blackboard = aplicacion.getBlackboard();
    try {
      initLookAndFeel();
    } catch (Exception e) {
    }
    try {
      SplashWindow splashWindow = showSplash();
      initComponents();
      configureApp();
      setExtendedState(JFrame.MAXIMIZED_BOTH);
      ClassLoader cl = this.getClass().getClassLoader();
      java.awt.Image img =
          java.awt.Toolkit.getDefaultToolkit()
              .getImage(cl.getResource(CConstantesPaths.IMAGE_PATH + "geopista.gif"));
      setIconImage(img);
      setVisible(true);
      desktopPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      /** deshabilitamos la barra de tareas */
      try {
        com.geopista.app.inventario.UtilidadesComponentes.inicializar();
        com.geopista.app.inventario.UtilidadesComponentes.setEnabled(false, this);
      } catch (Exception e) {
        logger.error(e.toString());
        e.printStackTrace();
      }

      if (splashWindow != null) splashWindow.setVisible(false);
      // ******************
      // Mostramos la pantalla de autenticación del usuario.
      // ******************
      // --------NUEVO-------------->
      //            if(SSOAuthManager.isSSOActive()){
      // 				com.geopista.protocol.CConstantesComando.servletLicenciasUrl =
      // AppContext.getApplicationContext().getString(SSOConstants.SSO_SERVER_URL)+"CServletLicencias";
      //                com.geopista.protocol.CConstantesComando.loginLicenciasUrl =
      // AppContext.getApplicationContext().getString(SSOConstants.SSO_SERVER_URL);
      //                com.geopista.protocol.CConstantesComando.adminCartografiaUrl =
      // AppContext.getApplicationContext().getString(SSOConstants.SSO_SERVER_URL);
      //       	  	}
      SSOAuthManager.ssoAuthManager(aplicacion.getDefaultProfile());
      if (!aplicacion.isOnlyLogged()) {
        // -------FIN-NUEVO----------->
        if (fromInicio) {
          if (!showAuth()) {
            dispose();
            return;
          }
        } else {
          showAuth();
        }
        // --------NUEVO-------------->
      }
      // -------FIN-NUEVO----------->
      setPolicy();

      if (!tienePermisos("Geopista.Inventario.Login")) {
        noPermApp();
        return;
      }
      if (!AppContext.seleccionarMunicipio((Frame) this)) {
        stopApp();
        return;
      }

      ConstantesRegistro.IdMunicipio = AppContext.getIdMunicipio();

      /** cargamos el municipio y la provincia */
      municipio =
          (new OperacionesAdministrador(com.geopista.protocol.CConstantesComando.loginLicenciasUrl))
              .getMunicipio(new Integer(ConstantesRegistro.IdMunicipio).toString());
      if (municipio != null) {
        Constantes.Municipio = municipio.getNombre();
        Constantes.Provincia = municipio.getProvincia();
        com.geopista.security.GeopistaPrincipal principal =
            com.geopista.security.SecurityManager.getPrincipal();
        if (principal != null)
          setTitle(
              getTitle()
                  + " - "
                  + Constantes.Municipio
                  + "-"
                  + ConstantesRegistro.IdMunicipio
                  + " ("
                  + Constantes.Provincia
                  + ") - "
                  + aplicacion.getI18NResource().getString("CAuthDialog.jLabelNombre")
                  + principal);
        com.geopista.security.SecurityManager.setIdMunicipio(
            new Integer(ConstantesRegistro.IdMunicipio).toString());
        System.setProperty("CodigoIne", municipio.getId());

        // No se si realment hay que utilizar esta llamada para inicializar el log4j
        /*
         	try{
         		URL url = getClass().getResource( "/config/log4j.ini");
         		PropertyConfigurator.configure (url);
        	//PropertyConfigurator.configureAndWatch("config" + File.separator + "log4j.ini", 3000);
        }catch(Exception e){};
        */
      }

      /** cargamos las estructuras */
      final TaskMonitorDialog progressDialog = new TaskMonitorDialog(this, null);
      progressDialog.setTitle(aplicacion.getI18nString("inventario.app.tag1"));
      progressDialog.addComponentListener(
          new ComponentAdapter() {
            public void componentShown(ComponentEvent e) {
              new Thread(
                      new Runnable() {
                        public void run() {
                          try {
                            progressDialog.report(aplicacion.getI18nString("inventario.app.tag1"));

                            while (!Estructuras.isCargada()) {

                              if (!Estructuras.isIniciada()) Estructuras.cargarEstructuras();
                              try {
                                Thread.sleep(500);
                              } catch (Exception e) {
                              }
                            }
                            logger.info("Estructuras cargadas");
                          } catch (CancelException e1) {

                          } catch (Exception e) {
                            return;
                          } finally {
                            progressDialog.setVisible(false);
                          }
                        }
                      })
                  .start();
            }
          });

      GUIUtil.centreOnWindow(progressDialog);
      progressDialog.setVisible(true);

      if (Estructuras.isCancelada()) {
        stopApp();
        return;
      }

      inventarioInternalFrame = new InventarioInternalFrame(this);
      mostrarJInternalFrame(inventarioInternalFrame);

      String mostrarMapa = System.getProperty("mostrarMapa");

      if ((mostrarMapa != null) && (mostrarMapa.equals("false"))) {
        com.geopista.app.inventario.Constantes.MOSTRAR_MAPA = false;
      }

      // AQUI SE INICIALIZA EL EDITOR
      if (com.geopista.app.inventario.Constantes.MOSTRAR_MAPA)
        if (inventarioInternalFrame.getJPanelMap() != null) {
          inventarioInternalFrame.getJPanelMap().initEditor();
        }

      addFixedPlugins();
      AppContext.showMunicipiosEntidad();
      UtilidadesComponentes.setEnabled(true, (JFrame) this);
      desktopPane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    } catch (Exception e) {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      e.printStackTrace(pw);
      System.out.println("ERROR:" + sw.toString());
      logger.error("Exception: " + sw.toString());
    }
  }
コード例 #4
0
  public MainCementerios(boolean fromInicio) {
    this.fromInicio = fromInicio;
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    aplicacion = (AppContext) AppContext.getApplicationContext();
    aplicacion.setMainFrame(this);
    blackboard = aplicacion.getBlackboard();
    try {
      initLookAndFeel();
    } catch (Exception e) {
    }
    try {
      SplashWindow splashWindow = showSplash();
      initComponents();
      configureApp();
      setExtendedState(JFrame.MAXIMIZED_BOTH);
      ClassLoader cl = this.getClass().getClassLoader();
      java.awt.Image img =
          java.awt.Toolkit.getDefaultToolkit()
              .getImage(cl.getResource(CConstantesPaths.IMAGE_PATH + "geopista.gif"));
      setIconImage(img);
      show();
      desktopPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      /** deshabilitamos la barra de tareas */
      try {
        UtilidadesComponentes.inicializar();
        UtilidadesComponentes.setEnabled(false, this);
      } catch (Exception e) {
        logger.error(e.toString());
        e.printStackTrace();
      }

      if (splashWindow != null) splashWindow.setVisible(false);
      // ******************
      // Mostramos la pantalla de autenticación del usuario.
      // ******************
      // --------NUEVO-------------->
      //            if(SSOAuthManager.isSSOActive()){
      // 				com.geopista.protocol.CConstantesComando.servletLicenciasUrl =
      // AppContext.getApplicationContext().getString(SSOConstants.SSO_SERVER_URL)+"CServletLicencias";
      //                com.geopista.protocol.CConstantesComando.loginLicenciasUrl =
      // AppContext.getApplicationContext().getString(SSOConstants.SSO_SERVER_URL);
      //                com.geopista.protocol.CConstantesComando.adminCartografiaUrl =
      // AppContext.getApplicationContext().getString(SSOConstants.SSO_SERVER_URL);
      //       	  	}
      SSOAuthManager.ssoAuthManager(aplicacion.getDefaultProfile());
      if (!aplicacion.isOnlyLogged()) {
        // -------FIN-NUEVO----------->
        if (fromInicio) {
          if (!showAuth()) {
            dispose();
            return;
          }
        } else {
          showAuth();
        }
        // --------NUEVO-------------->
      }
      // -------FIN-NUEVO----------->
      setPolicy();

      AppContext.seleccionarMunicipio((Frame) this);
      // Descomentar
      // ConstantesRegistroExp.IdMunicipio = AppContext.getIdMunicipio();

      /** cargamos las estructuras */
      final TaskMonitorDialog progressDialog = new TaskMonitorDialog(this, null);
      progressDialog.setTitle(aplicacion.getI18nString("cementerio.app.tag1"));
      progressDialog.addComponentListener(
          new ComponentAdapter() {
            public void componentShown(ComponentEvent e) {
              new Thread(
                      new Runnable() {
                        public void run() {
                          try {
                            progressDialog.report(aplicacion.getI18nString("cementerio.app.tag1"));
                            while (!Estructuras.isCargada()) {
                              if (!Estructuras.isIniciada()) Estructuras.cargarEstructuras();
                              try {
                                Thread.sleep(500);
                              } catch (Exception e) {
                              }
                            }
                          } catch (Exception e) {
                            logger.error("Error", e);
                            ErrorDialog.show(
                                AppContext.getApplicationContext().getMainFrame(),
                                "ERROR",
                                "ERROR",
                                StringUtil.stackTrace(e));
                            return;
                          } finally {
                            progressDialog.setVisible(false);
                          }
                        }
                      })
                  .start();
            }
          });

      GUIUtil.centreOnWindow(progressDialog);
      progressDialog.setVisible(true);

      CementeriosInternalFrame cementeriosInternalFrame = new CementeriosInternalFrame(this);
      mostrarJInternalFrame(cementeriosInternalFrame);
      if (cementeriosInternalFrame.getJPanelMap() != null) {
        cementeriosInternalFrame.getJPanelMap().initEditor();

        cementeriosInternalFrame
            .getCemenenerioJPanel()
            .tipoElemCementeriosJPanel
            .setEnabled(cementeriosInternalFrame.getJPanelMap().isHayCementerio());
      }

      UtilidadesComponentes.setEnabled(true, (JFrame) this);
      desktopPane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    } catch (Exception e) {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      e.printStackTrace(pw);
      System.out.println("ERROR:" + sw.toString());
      logger.error("Exception: " + sw.toString());
    }
  }
コード例 #5
0
  public void getMapFiles(PlugInContext pluginContext, boolean searchlocal, boolean searchremote) {
    final ArrayList localMapIds = new ArrayList();

    if (searchlocal) {
      final String rutaBase =
          aplicacion.getUserPreference(
              AppContext.PREFERENCES_DATA_PATH_KEY, AppContext.DEFAULT_DATA_PATH, true);
      ;

      // Comprobamos si existe la ruta base y en caso de que no exista la
      // creamos
      File rutaBaseFile = new File(rutaBase);
      if (!rutaBaseFile.exists()) {
        rutaBaseFile.mkdirs();
      }

      final TaskMonitorDialog progressDialog =
          new TaskMonitorDialog(aplicacion.getMainFrame(), pluginContext.getErrorHandler());
      progressDialog.allowCancellationRequests();
      progressDialog.setTitle(aplicacion.getI18nString("BuscandoMapas"));
      progressDialog.report(aplicacion.getI18nString("BuscandoMapasLocales"));
      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 {

                            ArrayList listaMap =
                                GeopistaFunctionUtils.searchDirectory(rutaBase, progressDialog);

                            Iterator Iter = listaMap.iterator();

                            while (Iter.hasNext()) {
                              GeopistaMap currentMap = (GeopistaMap) Iter.next();

                              if (!(currentMap.isExtracted()
                                  && currentMap.getIdEntidad() != AppContext.getIdEntidad())) {
                                listModel.addElement(currentMap);
                                String systemId = currentMap.getSystemId();
                                if (systemId.startsWith("e")) systemId = systemId.substring(1);
                                localMapIds.add(systemId);
                              }
                            }
                          } catch (Exception e) {

                          } finally {
                            progressDialog.setVisible(false);
                          }
                        }
                      })
                  .start();
            }
          });
      if (aplicacion.getMainFrame() == null) // sin ventana de referencia
      GUIUtil.centreOnScreen(progressDialog);
      else GUIUtil.centreOnWindow(progressDialog);
      progressDialog.setVisible(true);
    }
    if (searchremote) {
      // final String sUrlPrefix = aplicacion.getString("geopista.conexion.servidor");
      final String sUrlPrefix;
      // ------NUEVO------>
      //            if(SSOAuthManager.isSSOActive())
      //            	sUrlPrefix = aplicacion.getString(SSOConstants.SSO_SERVER_URL);
      //            else
      sUrlPrefix = aplicacion.getString("geopista.conexion.servidor");
      // ----FIN NUEVO---->
      if (aplicacion.isOnline()) {
        try {

          if (!aplicacion.isLogged()) {
            aplicacion.setProfile("Geopista");
            aplicacion.login();
          }

          if (aplicacion.isLogged()) {
            final TaskMonitorDialog progressDialog2 =
                new TaskMonitorDialog(aplicacion.getMainFrame(), pluginContext.getErrorHandler());
            progressDialog2.setTitle(aplicacion.getI18nString("BuscandoMapas"));
            progressDialog2.report(aplicacion.getI18nString("BuscandoMapasBaseDatos"));
            progressDialog2.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 {
                                  Object[] mapSystemIds = localMapIds.toArray();
                                  Arrays.sort(mapSystemIds);
                                  AdministradorCartografiaClient administradorCartografiaClient =
                                      new AdministradorCartografiaClient(
                                          sUrlPrefix + "/AdministradorCartografiaServlet");
                                  Collection lMaps =
                                      administradorCartografiaClient.getMaps(
                                          Locale.getDefault().toString());
                                  Iterator lMapsIter = lMaps.iterator();
                                  while (lMapsIter.hasNext()) {
                                    try {

                                      GeopistaMap currentMap = (GeopistaMap) lMapsIter.next();
                                      int codeIndex =
                                          Arrays.binarySearch(
                                              mapSystemIds, currentMap.getSystemId());
                                      if (codeIndex >= 0) continue;
                                      listModel.addElement(currentMap);
                                    } catch (Exception e) {
                                      e.printStackTrace();
                                    }
                                  }
                                } catch (Exception e) {

                                } finally {
                                  progressDialog2.setVisible(false);
                                }
                              }
                            })
                        .start();
                  }
                });
            if (aplicacion.getMainFrame() == null) GUIUtil.centreOnScreen(progressDialog2);
            else GUIUtil.centreOnWindow(progressDialog2);
            progressDialog2.setVisible(true);
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
コード例 #6
0
  /** Realiza el proceso de importación en cuanto se accede a esta pantalla */
  public void enteredFromLeft(Map dataMap) {
    sbMessage = new StringBuffer();
    final TaskMonitorDialog progressDialog =
        new TaskMonitorDialog(application.getMainFrame(), null);

    progressDialog.setTitle(I18N.get("Importacion", "importar.general.proceso.importando"));
    progressDialog.report(I18N.get("Importacion", "importar.general.proceso.importando"));
    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 {
                          String rutaImp =
                              (String) blackboard.get(ImportarUtils_LCGIII.FILE_TO_IMPORT);
                          notInsertedRows = 0;
                          insertedRows = 0;
                          totalRows = 0;

                          XMLReader parser = new SAXParser();
                          parser.setFeature(
                              "http://apache.org/xml/features/validation/schema", true);
                          parser.setFeature("http://xml.org/sax/features/validation", true);

                          blackboard.put("UnidadesInsertadas", new Integer(0));
                          blackboard.put("UnidadesNoInsertadas", new Integer(0));
                          blackboard.put("ListaDatosRegistro", new ArrayList());

                          Fichero fich = new Fichero();
                          fich.setIdTipoFichero(Fichero.FIN_RETORNO);

                          // Inicializar la lista total de parcelas importadas (se almacenan las
                          // ref.catastrales)
                          blackboard.put("ListaTotalFincasImportadas", new ArrayList());
                          parser.setContentHandler(
                              new FinRetornoXMLHandler(parser, progressDialog, fich, true));
                          parser.parse(rutaImp);

                          insertedRows =
                              ((Integer) blackboard.get("UnidadesInsertadas")).intValue();
                          notInsertedRows =
                              ((Integer) blackboard.get("UnidadesNoInsertadas")).intValue();
                          totalRows = insertedRows + notInsertedRows;

                          progressDialog.report(
                              I18N.get("Importacion", "importar.general.proceso.grabando"));
                          ArrayList lstDatosRegistro =
                              (ArrayList) blackboard.get("ListaDatosRegistro");

                          // Llamada a método de REGISTRO DE EXPEDIENTES
                          Iterator itRegistro = lstDatosRegistro.iterator();
                          while (itRegistro.hasNext()) {
                            Object o = itRegistro.next();
                            ArrayList lst = null;
                            if (((DatosRegistroExpedientes) o).getLstFincas() != null
                                && ((DatosRegistroExpedientes) o).getLstFincas().size() != 0)
                              lst = ((DatosRegistroExpedientes) o).getLstFincas();
                            else if (((DatosRegistroExpedientes) o).getLstBienes() != null
                                && ((DatosRegistroExpedientes) o).getLstBienes().size() != 0)
                              lst = ((DatosRegistroExpedientes) o).getLstBienes();

                            if (ConstantesRegExp.clienteCatastro != null) {
                              fich.setContenido(fileToString(new File(rutaImp)));
                              ArrayList lstExp = new ArrayList();
                              lstExp.add(
                                  ((DatosRegistroExpedientes) o)
                                      .getExpediente()
                                      .getNumeroExpediente());
                              // A crearFichero se le pasa la lista de expedientes
                              ConstantesRegExp.clienteCatastro.crearFichero(lstExp, fich);
                            }
                          }

                        } catch (Exception e) {
                          e.printStackTrace();
                        } finally {
                          progressDialog.setVisible(false);
                        }
                      }
                    })
                .start();
          }
        });
    GUIUtil.centreOnWindow(progressDialog);

    progressDialog.setVisible(true);

    printFinalMessage();

    try {
      // Iniciamos la ayuda
      String helpHS = "help/catastro/importadores/importadoresHelp_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, "FinRetorno", hs);
    } catch (Exception excp) {
      excp.printStackTrace();
    }
  }