@Override public void endOfProgress() { progressMonitor.endTask(); }
@Override public void endStep() { progressMonitor.endTask(); }
@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); } }
insertSt.addBatch(); batchSize++; insertProgress.endTask(); if(batchSize >= insertBatchSize) { batchSize = 0;
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); } } });
if(rowNum.contains(rs.getRow())) { stats.addValue(rs.getDouble(columnName)); fetchProgress.endTask();
private void initialize(ProgressMonitor parentProgress) { ProgressMonitor progress = parentProgress.startTask(I18N.tr("Loading the main window"), 100); makeMainFrame(); progress.endTask(); progress.setTaskName(I18N.tr("Loading docking system and frames")); toolBarTracker = new MenuItemServiceTracker<MainWindow, ToolBarAction>(pluginFramework.getHostBundleContext(), ToolBarAction.class, dockManagerImpl, mainFrame); toolBarTracker.open(); progress.endTask(); progress.endTask(); progress.endTask(); progress.endTask(); progress.endTask(); progress.endTask(); addCoreMenu();
if(activeFilter.isSelected(table.getRowSorter().convertRowIndexToModel(viewId), source)) { nextViewSelection.add(viewId); viewUpdate.endTask(); if(pm.isCancelled()) { return;
rowSetProgress.endTask();