@Override public ProgressVisitor subProcess(int i) { return new H2GISProgressMonitor(progressMonitor.startTask(i)); }
@Override public void run(ProgressMonitor pm) { try(Connection connection = dataSource.getConnection(); Statement st = connection.createStatement()) { pm.addPropertyChangeListener(ProgressMonitor.PROP_CANCEL, EventHandler.create(PropertyChangeListener.class, st, "cancel")); connection.setAutoCommit(false); ProgressMonitor dropPm = pm.startTask(tableToDelete.length); for (String resource : tableToDelete) { TableLocation tableLocation = TableLocation.parse(resource, JDBCUtilities.isH2DataBase(connection.getMetaData())); try { LOGGER.info(String.format("drop table %s", tableLocation)); st.execute(String.format("drop table %s", tableLocation)); } catch (SQLException ex) { LOGGER.error(I18N.tr("Cannot remove the source {0}", resource), ex); connection.rollback(); connection.setAutoCommit(true); return; } dropPm.endTask(); } connection.commit(); SwingUtilities.invokeAndWait(this); } catch (SQLException ex) { LOGGER.error(I18N.trc("Tables are database tables, drop means delete tables", "Cannot drop the tables"), ex); } catch (InvocationTargetException | InterruptedException ex) { LOGGER.trace(ex.getLocalizedMessage(), ex); } }
ProgressMonitor insertProgress = pm.startTask(selectedRows.size());
private void cachePrimaryKey(ProgressMonitor pm) throws SQLException { ProgressMonitor cachePm = pm.startTask(getRowCount()); if(rowPk == null) { rowPk = new DualHashBidiMap<>(); } else { rowPk.clear(); } try(Connection connection = dataSource.getConnection(); Statement st = connection.createStatement()) { PropertyChangeListener listener = EventHandler.create(PropertyChangeListener.class, st, "cancel"); pm.addPropertyChangeListener(ProgressMonitor.PROP_CANCEL, listener); st.setFetchSize(fetchSize); connection.setAutoCommit(false); // Use postgre cursor try(ResultSet rs = st.executeQuery("SELECT "+pk_name+" FROM "+location+" "+ orderBy)) { // Cache the primary key values int pkRowId = 0; while (rs.next()) { pkRowId++; rowPk.put(pkRowId, rs.getLong(1)); cachePm.endTask(); } } finally { pm.removePropertyChangeListener(listener); } } catch (SQLException ex) { throw new IllegalArgumentException(ex); } }
@Override public void run() { // Update the table values List<Integer> ranges = nextViewSelection.getValueRanges(); Iterator<Integer> intervals = ranges.iterator(); try { table.getSelectionModel().setValueIsAdjusting(true); table.clearSelection(); ProgressMonitor swingPm = pm.startTask("Apply filter", ranges.size()); while (intervals.hasNext()) { int begin = intervals.next(); int end = intervals.next(); table.addRowSelectionInterval(begin, end); swingPm.endTask(); if (swingPm.isCancelled()) { return; } } } finally { table.getSelectionModel().setValueIsAdjusting(false); } if(!nextViewSelection.isEmpty()) { scrollToRow(nextViewSelection.first(), table); } } });
@Override public void run(ProgressMonitor progress) { long t1 = System.currentTimeMillis(); ProgressMonitor pm = progress.startTask(I18N.tr("Execute SQL Request"), panel.getScriptPanel().getLineCount()); try(Connection connection = ds.getConnection()) { try(Statement st = connection.createStatement()) { st.setQueryTimeout(timeOut); // If the user clicks on cancel, cancel the execution pm.addPropertyChangeListener(ProgressMonitor.PROP_CANCEL , EventHandler.create(PropertyChangeListener.class, st, "cancel")); if(splitterFactory != null) { parseAndExecuteScript(pm, st); } else { st.execute(panel.getScriptPanel().getText().trim()); } } } catch (SQLException ex) { LOGGER.error(ex.getLocalizedMessage(), ex); } long t2 = System.currentTimeMillis(); double lastExecTime = ((t2 - t1) / 1000.0); String message = I18N.tr("OVERALL EXECUTION TIME: {0} seconds",lastExecTime); LOGGER.info(message); showPanelMessage(message); } }
@Override public void run(ProgressMonitor pm) { long deb = System.currentTimeMillis(); try(Connection connection = dataManager.getDataSource().getConnection()) { ProgressMonitor filePm = pm.startTask(files.size()); boolean isH2 = JDBCUtilities.isH2DataBase(connection.getMetaData()); for(File file : files) { String ext = FilenameUtils.getExtension(file.getName()); DriverFunction driverFunction = driverFunctionContainer.getImportDriverFromExt(ext, driverType); if(driverFunction != null) { TableLocation tableName = new TableLocation("","",dataManager.findUniqueTableName( TableLocation.capsIdentifier(FileUtils.getNameFromURI(file.toURI()), isH2))); driverFunction.importFile(connection, tableName.toString() ,file, new H2GISProgressMonitor(filePm)); } else { LOGGER.error(I18N.tr("No driver found for {0} extension", ext)); } } } catch (SQLException ex) { LOGGER.error(I18N.tr("Cannot import the file"), ex); // Print additional information while((ex = ex.getNextException()) != null) { LOGGER.error(ex.getLocalizedMessage()); } } catch (IOException ex) { LOGGER.error(I18N.tr("Cannot import the file"), ex); } LOGGER.info(I18N.tr("Importation done in {0} sec", (System.currentTimeMillis() - deb) / 1000d)); catalog.refreshSourceList(); } }
int pkIndex = JDBCUtilities.getIntegerPrimaryKey(connection, tableLocation.toString()); if (pkIndex > 0) { ProgressMonitor jobProgress = progressMonitor.startTask(2); ProgressMonitor cacheProgress = jobProgress.startTask(I18N.tr("Cache primary key values"), rowCount); Map<Long, Integer> pkValueToRowId = new HashMap<>(rowCount); int rowId=0; ProgressMonitor sortProgress = jobProgress.startTask(I18N.tr("Read sorted keys"), rowCount); try(ResultSet rs = st.executeQuery("select "+pkFieldName+" from "+table+" ORDER BY "+columnName+desc)) { while(rs.next()) { ProgressMonitor jobProgress = progressMonitor.startTask(2); ProgressMonitor cacheProgress = jobProgress.startTask(I18N.tr("Cache table values"), rowCount); Comparable[] cache = new Comparable[rowCount]; try(ResultSet rs = st.executeQuery("select "+columnName+" from "+table)) { ProgressMonitor sortProgress = jobProgress.startTask(I18N.tr("Sort table values"), rowCount); Comparator<Integer> comparator = new SortValueCachedComparator(cache); if (!ascending) {
listener); try (ResultSet rs = st.executeQuery(String.format("SELECT %s FROM %s",columnName, tableName ))) { ProgressMonitor fetchProgress = pm.startTask(rowNum.size()); while(rs.next() && !pm.isCancelled()) { if(rowNum.contains(rs.getRow())) {
@Override public void run(ProgressMonitor progress) { ProgressMonitor pm = progress.startTask(editableList.length); ILayer dropLayer = mapContext.getLayerModel(); int i=0; for(EditableElement eElement : editableList) { if(eElement instanceof EditableSource) { try { EditableSource edit = (EditableSource) eElement; dropLayer.addLayer(mapContext.createLayer(edit.getTableReference())); } catch (LayerException e) { //This layer can not be inserted, we continue to the next layer GUILOGGER.warn(I18N.tr("Unable to create and drop the layer"),e); } } else if(eElement instanceof MapElement) { final MapElement mapElement = (MapElement)eElement; mapElement.open(pm); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { editorManager.openEditable(mapElement); } }); return; } } }
int n = 0; pm.progressTo(50); pm.startTask(CREATE_CLASSIF , 100); U lp = (getLegend()).getFallbackParameters(); MappedLegend<K,U> newRL = getEmptyAnalysis();
private void runFilter(ProgressMonitor progress) { final ProgressMonitor pm = progress.startTask(getTaskName(), 3); ProgressMonitor viewUpdate = pm.startTask(I18N.tr("Read filter"), rowCount); for(int viewId=0;viewId<rowCount;viewId++) { if(activeFilter.isSelected(table.getRowSorter().convertRowIndexToModel(viewId), source)) {
rowSet.beforeFirst(); int rowId = 0; ProgressMonitor progressMonitor = pm.startTask(rowSet.getRowCount()); if (params.getColumnId() != -1) { while(rowSet.next()) {
ProgressMonitor progressInfo = parentProgress.startTask(I18N.tr("Loading Workspace.."),100); MainContext.initConsoleLogger(debugMode);
ProgressMonitor rulesProgress = pm.startTask(rList.size()); for (Rule r : rList) { beginLayer(r.getName()); rowSetProgress = rulesProgress.startTask("Drawing " + layer.getName() + " (Rule " + r.getName() + ")", ((ReadRowSet) rs).getFilteredRowCount()); } else { rowSetProgress = rulesProgress.startTask("Drawing " + layer.getName() + " (Rule " + r.getName() + ")", 1);
int n = 0; pm.progressTo(50); pm.startTask(CREATE_CLASSIF, 100); for(String s : set){ newRL.put(s, lp);
pm = new NullProgressMonitor(); } else { pm = progressMonitor.startTask(numLayers);
private void initialize(ProgressMonitor parentProgress) { ProgressMonitor progress = parentProgress.startTask(I18N.tr("Loading the main window"), 100); makeMainFrame(); progress.endTask();