List of usage examples for javax.swing Timer stop
public void stop()
Timer
, causing it to stop sending action events to its listeners. From source file:nz.govt.natlib.ndha.manualdeposit.CMSSearchResults.java
@SuppressWarnings("serial") private void formWindowOpened(java.awt.event.WindowEvent evt) { // NOPMD try {//from ww w . j av a 2 s . c o m theFormControl = new FormControl(this, theSettingsPath); } catch (Exception ex) { LOG.error("Error loading form parameters", ex); } if (theFormControl != null) { final Action updateDividersAction = new AbstractAction() { public void actionPerformed(final ActionEvent e) { Timer t = (Timer) e.getSource(); t.stop(); splitMain.setDividerLocation(theFormControl.getExtra(SPLIT_NAME, 320)); splitMain.repaint(); for (int i = 0; i < tblResults.getColumnModel().getColumnCount(); i++) { TableColumn col = tblResults.getColumnModel().getColumn(i); String colName = "Col" + i; int width = theFormControl.getExtra(colName, 150); col.setPreferredWidth(width); col.setWidth(width); } } }; new Timer(200, updateDividersAction).start(); } thePresenter.showResults(); }
From source file:nz.govt.natlib.ndha.manualdeposit.dialogs.About.java
@SuppressWarnings("serial") private void formComponentResized(java.awt.event.ComponentEvent evt) { paintImage();//from w w w. j ava2s . c om Action updateDividersAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { Timer t = (Timer) e.getSource(); t.stop(); paintImage(); repaint(); } }; new Timer(200, updateDividersAction).start(); }
From source file:nz.govt.natlib.ndha.manualdeposit.jobmanagement.JobQueueManagement.java
private void checkSipStatus() { LOG.debug("Start checkSipStatus"); for (int i = jobQueueDeposited.size() - 1; i >= 0; i--) { final UploadJob job = jobQueueDeposited.get(i); job.checkSipStatus();/*w w w .j av a 2s .c om*/ } for (int i = jobQueueAwaitingCleanup.size() - 1; i >= 0; i--) { final UploadJob job = jobQueueAwaitingCleanup.get(i); job.checkForCleanup(); } final Action checkSipStatusAction = new AbstractAction() { private static final long serialVersionUID = -8315654343127184873L; public void actionPerformed(final ActionEvent e) { Timer t = (Timer) e.getSource(); t.stop(); checkSipStatus(); } }; new Timer(theAppProperties.getApplicationData().getSipStatusRefreshInterval(), checkSipStatusAction) .start(); LOG.debug("End checkSipStatus"); }
From source file:nz.govt.natlib.ndha.manualdeposit.jobmanagement.UploadJob.java
private void checkDigestStatus() { printDebugInfo("Check digest status"); if (theDigest == null) { return;//from w w w . java 2s .com } if (theDigest.getFinished()) { isCopyFinished = true; boolean allSucceeded = true; StringBuilder errorMessage = new StringBuilder(); errorMessage.append("The following files were not copied successfully:"); for (ChecksumDigest.FileStatus status : theDigest.getFileStatii()) { if (!status.getFileCopyIsIdentical()) { allSucceeded = false; errorMessage.append("\n"); errorMessage.append(status.getFSO().getFullPath()); } } if (allSucceeded) { for (ChecksumDigest.FileStatus status : theDigest.getFileStatii()) { FileSystemObject fso = status.getFSO(); fso.setFile(fso.getDestinationFile()); } } else { for (FileStatus status : theDigest.getFileStatii()) { File parent = status.getFSO().getDestinationFile().getParentFile(); LOG.debug("Deleting file " + status.getFSO().getDestinationFile().getAbsolutePath()); status.getFSO().getDestinationFile().delete(); FileUtils.deleteEmptyDirectoryRecursive(parent); } } if (theJobState == JobState.Requested) { theJobState = JobState.Pending; } saveJob(false); if (allSucceeded) { for (ChecksumDigest.FileStatus status : theDigest.getFileStatii()) { if (status.getFileCopyIsIdentical()) { FileSystemObject fso = status.getFSO(); fso.setFile(fso.getDestinationFile()); } else { allSucceeded = false; errorMessage.append("\n"); errorMessage.append(status.getFSO().getFullPath()); } } } else { jobDetailStatus = errorMessage.toString(); } } else { Action checkDigestStatusAction = new AbstractAction() { private static final long serialVersionUID = 5562669711772031634L; public void actionPerformed(ActionEvent e) { Timer t = (Timer) e.getSource(); t.stop(); checkDigestStatus(); } }; new Timer(500, checkDigestStatusAction).start(); } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
@SuppressWarnings("serial") public void setupScreen(final AppProperties appProperties, final String settingsPath) throws Exception { LOG.debug("setupScreen"); this.setJMenuBar(mnuMain); theSettingsPath = settingsPath;/*from ww w . j ava 2 s . co m*/ LOG.debug("setupScreen, setting provenance event presenter"); theAppProperties = appProperties; theUserGroupData = theAppProperties.getUserData().getUser(theAppProperties.getLoggedOnUser()) .getUserGroupData(); final boolean searchVisible = (theUserGroupData.isIncludeCMS2Search() || theUserGroupData.isIncludeCMS1Search() || theUserGroupData.isIncludeProducerList() || theUserGroupData.isIncludeNoCMSOption()); pnlCmsReference.setVisible(searchVisible); mnuViewShowSearch.setVisible(searchVisible); if (theUserGroupData.isIncludeCMS2Search()) { rbnCMS2.setSelected(true); } else if (theUserGroupData.isIncludeCMS1Search()) { rbnCMS1.setSelected(true); } else if (theUserGroupData.isIncludeProducerList()) { rbnStaffMediated.setSelected(true); } else if (theUserGroupData.isIncludeNoCMSOption()) { rbnNoCmsRef.setSelected(true); } rbnCMS2.setVisible(theUserGroupData.isIncludeCMS2Search()); rbnCMS1.setVisible(theUserGroupData.isIncludeCMS1Search()); rbnNoCmsRef.setVisible(theUserGroupData.isIncludeNoCMSOption()); rbnStaffMediated.setVisible(theUserGroupData.isIncludeProducerList()); rbnCMS1.setText(theAppProperties.getApplicationData().getCMS1Label()); rbnCMS2.setText(theAppProperties.getApplicationData().getCMS2Label()); if (theUserGroupData.isIncludeCMS2Search()) { rbnCMS2.setSelected(true); } else { if (theUserGroupData.isIncludeCMS1Search()) { rbnCMS1.setSelected(true); } else { rbnNoCmsRef.setSelected(true); } } setTitle(title + theAppProperties.getAppVersion()); ClassLoader cLoader = Thread.currentThread().getContextClassLoader(); java.net.URL imageURL = cLoader.getResource("Indigo_logo_64x64.jpg"); setIconImage(Toolkit.getDefaultToolkit().getImage(imageURL)); LOG.debug("setupScreen, setting FormControl"); try { theFormControl = new FormControl(this, theSettingsPath); fixBackwardsCompatibility(); } catch (Exception ex) { LOG.error("Error loading form parameters", ex); } LOG.debug("setupScreen, adding handlers"); depositPresenter.addHandlers(treeFileSystem, treeEntities, treeStructMap, cmbSelectTemplate, cmbSelectStructTemplate, cmbSortBy, cmbFixityType, tblDetail, tblJobQueueRunning, tblJobQueuePending, tblJobQueueFailed, tblJobQueueDeposited, tblJobQueueComplete, mnuFileFavourites, lstProducers, lstMaterialFlow); LOG.debug("setupScreen, handlers added"); checkButtons(); setCMSDetails(); setHotKeyVisibility(); depositPresenter.checkForInitialLoadScreenSizes(theFormControl, splitAddIE, SPLIT_IE_ATTR, splitMain, SPLIT_MAIN_ATTR, splitMainDetail, SPLIT_MAIN_DETAIL_ATTR, splitMainRight, SPLIT_MAIN_RIGHT_ATTR); final Action updateDividersAction = new AbstractAction() { public void actionPerformed(final ActionEvent e) { Timer t = (Timer) e.getSource(); t.stop(); splitAddIE.setDividerLocation(theFormControl.getExtra(SPLIT_IE_ATTR, 175)); splitMain.setDividerLocation(theFormControl.getExtra(SPLIT_MAIN_ATTR, 200)); splitMainDetail.setDividerLocation(theFormControl.getExtra(SPLIT_MAIN_DETAIL_ATTR, 200)); splitMainRight.setDividerLocation(theFormControl.getExtra(SPLIT_MAIN_RIGHT_ATTR, 200)); splitMain.repaint(); splitMainDetail.repaint(); splitMainRight.repaint(); TableColumn col = tblDetail.getColumnModel().getColumn(0); col.setPreferredWidth(theFormControl.getExtra(META_DATA_COL_1_ATTR, 200)); col = tblDetail.getColumnModel().getColumn(1); col.setPreferredWidth(theFormControl.getExtra(META_DATA_COL_2_ATTR, 200)); MultiSplitLayout layout = mspJobQueue.getMultiSplitLayout(); layout.setFloatingDividers(false); MultiSplitLayout.Split model = (MultiSplitLayout.Split) layout.getModel(); MultiSplitLayout.Divider divider = (MultiSplitLayout.Divider) model.getChildren().get(1); Rectangle bounds = divider.getBounds(); int top = theFormControl.getExtra(JOB_QUEUE_DIVIDER_1_ATTR, bounds.y); bounds.y = top; divider.setBounds(bounds); theOldHeight1 = top; divider = (MultiSplitLayout.Divider) model.getChildren().get(3); bounds = divider.getBounds(); top = theFormControl.getExtra(JOB_QUEUE_DIVIDER_2_ATTR, bounds.y); bounds.y = top; divider.setBounds(bounds); theOldHeight2 = top; divider = (MultiSplitLayout.Divider) model.getChildren().get(5); bounds = divider.getBounds(); top = theFormControl.getExtra(JOB_QUEUE_DIVIDER_3_ATTR, bounds.y); bounds.y = top; divider.setBounds(bounds); theOldHeight3 = top; divider = (MultiSplitLayout.Divider) model.getChildren().get(7); bounds = divider.getBounds(); top = theFormControl.getExtra(JOB_QUEUE_DIVIDER_4_ATTR, bounds.y); bounds.y = top; divider.setBounds(bounds); theOldHeight4 = top; } }; new Timer(200, updateDividersAction).start(); final PersonalSettings personalSettings = theAppProperties.getApplicationData().getPersonalSettings(); theStandardFont = personalSettings.getStandardFont(); final SortBy sortBy = personalSettings.getSortFilesBy(); for (int i = 0; i < cmbSortBy.getItemCount(); i++) { final SortBy item = (SortBy) cmbSortBy.getItemAt(i); if (item.equals(sortBy)) { cmbSortBy.setSelectedIndex(i); break; } } setJobQueuePanes(); LOG.debug("setupScreen, end"); addHotKeyListener(this); }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
@SuppressWarnings("serial") private void stopEditingTree() { treeFileSystem.stopEditing();/* w w w .ja v a2s. com*/ Action stopEditingAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { Timer t = (Timer) e.getSource(); t.stop(); try { treeFileSystem.stopEditing(); } catch (Exception ex) { } } }; new Timer(100, stopEditingAction).start(); }
From source file:org.datacleaner.windows.FileTransferProgressWindow.java
public void setFinished(String filename) { final int index = getIndex(filename); final String doneText = "Done!"; _infoLabels[index].setText(doneText); for (int i = 0; i < _infoLabels.length; i++) { if (!doneText.equals(_infoLabels[i].getText())) { // return if not all files have transfered return; }/*from w w w . j av a2s. com*/ } final Timer timer = new Timer(1500, null); final ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FileTransferProgressWindow.this.dispose(); timer.stop(); } }; timer.addActionListener(listener); timer.start(); }
From source file:pipeline.GUI_utils.ListOfPointsView.java
@SuppressWarnings("unchecked") private void checkForDirtiness() { while (!closed) { boolean assumeTableStructureChanged = false; boolean copyOfDirty = false; synchronized (dirty) { try { while (!dirty.get() && !closed) dirty.wait();//from w w w . j a va 2 s . c o m } catch (InterruptedException e) { if (closed || frame == null) break; } copyOfDirty = dirty.get(); dirty.set(false); assumeTableStructureChanged = tableStructurePossiblyChanged; tableStructurePossiblyChanged = false; } if (copyOfDirty && !(closed || frame == null)) { Component previousGlassPane = frame.getGlassPane(); final Timer timer = new Timer(2_000, null); timer.setInitialDelay(4_000); final Action t = new AbstractAction() { private static final long serialVersionUID = 1L; private boolean high; private boolean firstRun = true; @Override public void actionPerformed(ActionEvent action) { if (frame == null || !frame.isVisible()) { // The user might have closed the window; just exit timer.stop(); return; } if (firstRun) { firstRun = false; frame.setGlassPane(g); g.setBounds(table.getBounds()); g.setVisible(true); } g.setAlpha(high ? 200 : 100); // table.setBackground(high?darkGrey:lightGrey); high = !high; g.repaint(); } }; timer.addActionListener(t); timer.start(); IPluginIOList<T> localPointsCopy = null; boolean filterUpdating = false; synchronized (dataCopySemaphore) { localPointsCopy = (IPluginIOList<T>) pointsCopy.duplicateStructure(); localPointsCopy.addAllAndLink(pointsCopy); if ((modelEvent != null) && (modelEvent.eventType == PipelineTableModelEvent.FILTER_ADJUSTING)) filterUpdating = true; } silenceUpdates.incrementAndGet(); try { if (assumeTableStructureChanged) { setupTableModel(localPointsCopy); updateColumnDescriptions(); } updateExpr4jModel(); // Now read the values computed by expr4j and update the result to display (but keep the formula), // only for user-defined columns updateComputedCells(); if (!assumeTableStructureChanged) { // Reset filter range because if any new user values are generated the rows // might automatically be filtered out, which is very confusing for the user if (!filterUpdating) table.resetFilterRanges(false); } points.fireValueChanged(false, false); final boolean copyOfAssumeTableStructureChanged = assumeTableStructureChanged; SwingUtilities.invokeLater(() -> { timer.stop(); g.setVisible(false); frame.setGlassPane(previousGlassPane); synchronized (modelSemaphore) { silenceUpdates.incrementAndGet(); try { table.setBackground(Color.WHITE); if (copyOfAssumeTableStructureChanged) { // tableModel.fireTableStructureChanged(); // Not necessary because already indirectly triggered above } else { final ListSelectionModel saveRowSelection, saveColumnSelection; try { saveRowSelection = (ListSelectionModel) ((DefaultListSelectionModel) table .getSelectionModel()).clone(); saveColumnSelection = (ListSelectionModel) ((DefaultListSelectionModel) table .getColumnModel().getSelectionModel()).clone(); } catch (Exception e) { throw new RuntimeException(e); } tableModel.fireTableDataChanged(); Utils.log("Resetting selection", LogLevel.DEBUG); table.setSelectionModel(saveRowSelection); table.getColumnModel().setSelectionModel(saveColumnSelection); } } finally { silenceUpdates.decrementAndGet(); } frame.repaint();// For glass pane } }); } catch (Exception e) { Utils.log("Exception: " + e, LogLevel.WARNING); dirty.set(false); } finally { silenceUpdates.decrementAndGet(); } } } }