List of usage examples for java.awt EventQueue invokeLater
public static void invokeLater(Runnable runnable)
From source file:com.zigabyte.stock.stratplot.StrategyPlotter.java
/** Load stock data specified in file field. If the data is from a serialized file, uses a ProgressMonitorInputStream to show progress. Once data is loaded, sets compareHistory to first symbol in COMPARE_INDEX_SYMBOLS found in data, and sets begin/end dates to the begin/end dates of this symbol, or of the first history in the data if no compare symbol was found. Shows a dialog when either completed or an error occurs. **//* w ww . jav a 2 s . com*/ protected void loadFile() { try { // get file String filePath = this.fileField.getText().trim(); if (filePath.length() == 0) throw new IllegalArgumentException("Empty file"); File file = new File(filePath); // choose parser StockMarketHistoryFactory parser; { String fileFormat = (String) this.fileFormatCombo.getSelectedItem(); if ("Metastock".equals(fileFormat)) parser = new MetastockParser(true); else if ("Serialized".equals(fileFormat)) parser = new SerializedStockFilesParser(false); else if ("SerializedGZ".equals(fileFormat)) parser = new SerializedStockFilesParser(true); else throw new IllegalArgumentException("Unrecognized file format: " + fileFormat); } // load data using parser EventQueue.invokeLater(new Runnable() { public void run() { runButton.setEnabled(false); viewDataButton.setEnabled(false); } }); this.histories = null; // allow gc this.loadedHistoriesFile = null; if (!(parser instanceof SerializedStockFilesParser)) { this.histories = parser.loadHistory(file); } else { // use ProgressMonitorInputStream SerializedStockFilesParser serializedParser = (SerializedStockFilesParser) parser; InputStream in = new FileInputStream(file); ProgressMonitorInputStream pmIn = new ProgressMonitorInputStream(this, file.getName(), in); this.histories = serializedParser.loadHistory(pmIn); pmIn.close(); } this.loadedHistoriesFile = file; if (histories.size() > 0) { // initialize compareSymbol String compareIndexSymbol = ""; for (String spSymbol : COMPARE_INDEX_SYMBOLS) { if (histories.get(spSymbol) != null) { compareIndexSymbol = spSymbol; break; } } this.compareIndexSymbolField.setText(compareIndexSymbol); // initialize start/end fields StockHistory sampleHistory = (compareIndexSymbol.length() > 0 ? histories.get(compareIndexSymbol) : histories.get(0)); if (sampleHistory.size() > 0) { this.startDateField.setValue(sampleHistory.get(0).getDate()); this.endDateField.setValue(sampleHistory.get(sampleHistory.size() - 1).getDate()); } } // display completed dialog String msg = "Loaded " + this.histories.size() + " histories"; JOptionPane.showMessageDialog(this, msg, "Load complete", JOptionPane.INFORMATION_MESSAGE); } catch (FileNotFoundException e) { showErrorDialog(e, false); } catch (Exception e) { showErrorDialog(e); } finally { EventQueue.invokeLater(new Runnable() { public void run() { runButton.setEnabled(histories != null); viewDataButton.setEnabled(histories != null); loadFileButton.setCursor(null); // clear wait cursor } }); } }
From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java
private void afterShow(java.awt.event.ComponentEvent evt) {// GEN-FIRST:event_afterShow // table.addPropertyChangeListener("tableCellEditor", new // PropertyChangeListener() { //// ww w . j a va 2s.c o m // @Override // public void propertyChange(PropertyChangeEvent evt) { // System.out.println("1[" +evt.getPropertyName()); // System.out.println("2[" +evt.getSource()); // System.out.println("3[" +(evt.getOldValue())); // System.out.println("4[" +evt.getNewValue()); // System.out.println("5[" +table.getCellEditor()); // } // }); // table.getCellEditor().addCellEditorListener(new CellEditorListener() // { // // @Override // public void editingStopped(ChangeEvent e) { // System.out.println("stop"); // } // // @Override // public void editingCanceled(ChangeEvent e) { // System.out.println("cancel"); // } // }); tableColumnTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { changeTableRow(); } }); // 38 up; // 40 down; // 37 left; // 39 right; // 10 enter; tableColumnTable.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == 10 || keyCode == 38 || keyCode == 40) changeTableRow(); } }); listColumnTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { changeListTableRow(); } }); // 38 up; // 40 down; // 37 left; // 39 right; // 10 enter; listColumnTable.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == 10 || keyCode == 38 || keyCode == 40) changeListTableRow(); } }); p.setDividerLocation(0.5); EventQueue.invokeLater(new Runnable() { public void run() { pt.setDividerLocation(0.5); EventQueue.invokeLater(new Runnable() { public void run() { pb.setDividerLocation(0.5); } }); } }); }
From source file:org.parosproxy.paros.model.Session.java
private void refreshScope() { // log.debug("refreshScope"); if (Constant.isLowMemoryOptionSet()) { // Nothing to do return;//from w w w. ja v a 2 s.c o m } if (EventQueue.isDispatchThread()) { refreshScope((SiteNode) siteTree.getRoot()); Control.getSingleton().sessionScopeChanged(); } else { try { EventQueue.invokeLater(new Runnable() { @Override public void run() { refreshScope((SiteNode) siteTree.getRoot()); Control.getSingleton().sessionScopeChanged(); } }); } catch (Exception e) { log.error(e.getMessage(), e); } } }
From source file:org.n52.ifgicopter.spf.output.GpxOutputPlugin.java
/** * /*from ww w . j a v a2 s . c o m*/ */ protected void updateGUI() { if (this.gpx == null) return; final String t = this.gpx.xmlText(GPX_OPTIONS); EventQueue.invokeLater(new Runnable() { @Override public void run() { GpxOutputPlugin.this.textPane.setText(t); GpxOutputPlugin.this.outputFileLabel .setText("<html><b>Output file: </b>" + getGpxFilePath() + "</html>"); DefaultListModel model = (DefaultListModel) GpxOutputPlugin.this.valuesToSaveList.getModel(); // update list if (model.getSize() < GpxOutputPlugin.this.availableDataKeys.size()) { if (model.contains(NO_DATA_LIST_ELEMENT)) model.remove(model.indexOf(NO_DATA_LIST_ELEMENT)); for (String s : GpxOutputPlugin.this.availableDataKeys) { if (!model.contains(s)) { model.addElement(s); } } } } }); }
From source file:com.atlassian.theplugin.idea.jira.IssueCreateDialog.java
private void createIssueAndCloseOnSuccess(final JIRAIssueBean newIssue, final boolean openNewIssue) { Task createTask = new Task.Modal(project, "Creating Issue", false) { public void run(@NotNull final ProgressIndicator indicator) { String message;//www . java 2 s . c o m indicator.setIndeterminate(true); try { final IntelliJJiraServerFacade jiraServerFacade = IntelliJJiraServerFacade.getInstance(); final JiraIssueAdapter createdIssue = parentIssue == null ? jiraServerFacade.createIssue(jiraServerData, newIssue) : jiraServerFacade.createSubtask(jiraServerData, parentIssue, newIssue); IdeaHelper.getProjectCfgManager(project) .addProjectConfigurationListener(createdIssue.getLocalConfigurationListener()); message = "New issue created: <a href=" + createdIssue.getIssueUrl() + ">" + createdIssue.getKey() + "</a>"; issueListToolWindowPanel.setStatusInfoMessage(message, false); if (!createdIssue.usesRest() && originalEstimate.getText() != null && originalEstimate.getText().length() > 0) { // "timeoriginalestimate" JIRAActionField originalEstimateField = new JIRAActionFieldBean("timetracking", "Original Estimate"); originalEstimateField.addValue(newIssue.getOriginalEstimate()); ArrayList<JIRAActionField> fieldList = new ArrayList<JIRAActionField>(); fieldList.add(originalEstimateField); jiraServerFacade.setFields(jiraServerData, createdIssue, fieldList); message = "Original estimate updated for: <a href=" + createdIssue.getIssueUrl() + ">" + createdIssue.getKey() + "</a>"; issueListToolWindowPanel.setStatusInfoMessage(message, false); } EventQueue.invokeLater(new Runnable() { public void run() { issueListToolWindowPanel.refreshIssues(true); if (openNewIssue) { issueListToolWindowPanel.openIssue(createdIssue, false); } else { Color bg = new Color(192, 239, 192); IdeaVersionFacade.getInstance().fireNotification(project, new NotificationPopup(createdIssue, bg), null, null, IdeaVersionFacade.OperationStatus.INFO, bg); } close(0); } }); } catch (final JIRAException e) { EventQueue.invokeLater(new Runnable() { public void run() { DialogWithDetails.showExceptionDialog(project, "Failed to create new issue", e); } }); } } }; ProgressManager.getInstance().run(createTask); }
From source file:org.p_vcd.ui.VcdDialog.java
@Override public void callbackOnEnd(ProcessBase process, boolean wasSuccessful) { if (!wasSuccessful || process != this.currentSearch) return;//from w ww . ja v a 2 s .c o m this.resultDetections = ((ProcessVCD) process).getDetections(); EventQueue.invokeLater(new Runnable() { public void run() { drawDetectionResult(); } }); }
From source file:tax.MainForm.java
private void afmTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextKeyPressed String text = afmText.getText(); if (evt.getKeyCode() == KeyEvent.VK_ENTER) { if (text.length() == 9) { for (Object key : afmToName.keySet()) { if (afmToName.get(key).equals(text)) nameText.setText(key.toString()); }/*www .j a v a 2 s . c om*/ // Util.fadeInAndOut(afmText, Util.darkGreen); addRowBut.doClick(); } else if (text.length() == 0) { Util.fadeInAndOut(afmText, Color.white); nameText.setEnabled(true); nameText.requestFocus(); } else Util.fadeInAndOut(afmText, Util.darkOrange); } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown() && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE) && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) { EventQueue.invokeLater(new Runnable() { @Override public void run() { String text = afmText.getText(); int afmLength = text.length(); while (lastAFMTextLength == afmLength) { try { Thread.sleep(100); System.out.println("text: " + text); System.out.println(lastAFMTextLength + " " + afmLength); return; } catch (InterruptedException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } text = afmText.getText(); afmLength = text.length(); } try { int num = Integer.decode(text); if (afmLength > 9) { if (text.length() > 0) afmText.setText(text.substring(0, afmLength - 1)); else afmText.setText(""); return; } } catch (Exception e) { if (text.length() > 0) afmText.setText(text.substring(0, afmLength - 1)); else afmText.setText(""); return; } lastAFMTextLength = afmLength; } }); } }
From source file:net.technicpack.launcher.ui.LauncherFrame.java
@Override public void relocalize(ResourceLoader loader) { this.resources = loader; this.resources.registerResource(this); setIconImage(this.resources.getImage("icon.png")); //Wipe controls this.getContentPane().removeAll(); this.setLayout(null); //Clear references to existing controls initComponents();//from ww w. j av a2 s.c o m userChanged(userModel.getCurrentUser()); if (currentTabName != null) selectTab(currentTabName); EventQueue.invokeLater(new Runnable() { @Override public void run() { invalidate(); repaint(); } }); }
From source file:org.eclipse.titanium.graph.gui.windows.GraphEditor.java
/** * This method causes both the main graph window and the satellite view to * refresh. This method is thread safe!//from ww w . j a v a 2 s . co m */ public void refresh() { EventQueue.invokeLater(new Runnable() { @Override public void run() { drawArea.repaint(); if (satView != null) { satView.repaint(); } } }); }
From source file:net.technicpack.launcher.ui.LauncherFrame.java
@Override public void userChanged(MojangUser mojangUser) { if (mojangUser == null) this.setVisible(false); else {/*from www. ja va 2s . com*/ this.setVisible(true); userWidget.setUser(mojangUser); if (modpackSelector.getSelectedPack() != null) setupPlayButtonText(modpackSelector.getSelectedPack(), mojangUser); if (pasteWatcher == null) { pasteWatcher = new PasteWatcher(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteUpdated((Transferable) e.getSource()); } }); } modpackSelector.forceRefresh(); EventQueue.invokeLater(new Runnable() { @Override public void run() { repaint(); } }); } }