public boolean execute(PlugInContext context) throws Exception { reportNothingToUndoYet(context); // limpiamos lo que haya podido quedar de ejecuciones anteriores emptyBlackboard(); WizardDialog d = new WizardDialog( GeopistaUtil.getFrame(context.getWorkbenchGuiComponent()), Constants.APLICACION.getI18nString("ExtractDialogGestionar"), context.getErrorHandler()); d.init( new WizardPanel[] { new MobileModifyPanel01("MobileModifyPanel01", null, context), }); d.setSize(520, 650); d.setLocation(10, 20); d.setVisible(true); if (!d.wasFinishPressed()) { LayerManager layerManager = context.getLayerManager(); if (layerManager != null) { Layer graticuleLayer = layerManager.getLayer(GraticuleCreatorEngine.getGraticuleName()); // si existe una cuadrícula la borramos if (graticuleLayer != null) { layerManager.remove(graticuleLayer); } } return false; } 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; }
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(); } } } }