List of usage examples for java.awt EventQueue invokeLater
public static void invokeLater(Runnable runnable)
From source file:ca.uhn.hl7v2.testpanel.ui.ActivityDetailsCellRenderer.java
private void updatePreferredHeight(final JTable theTable, final int theRow) { final int newHeight = (int) getPreferredSize().getHeight(); if (theTable.getRowHeight(theRow) != newHeight) { EventQueue.invokeLater(new Runnable() { public void run() { theTable.setRowHeight(theRow, newHeight); // theTable.getColumnModel().getColumn(2).setWidth(5000); }//from w w w . ja v a 2s . co m }); } }
From source file:ca.uhn.hl7v2.testpanel.ui.v2tree.Hl7V2MessageTree.java
void addChildren() throws InterruptedException, InvocationTargetException { if (myMessages != null && myMessages.getRuntimeProfile() != null) { myRuntimeProfileValidator = new DefaultValidator(); myRuntimeProfileValidator.setValidateChildren(false); }//from w ww.ja va 2s . co m final Set<String> openPaths = getOpenPaths(); int selectedRow = getSelectedRow(); final String selectedPath = getPathAtRow(selectedRow); if (myMessages != null) { try { addChildren(myMessages.getMessages(), myTop, ""); } catch (InterruptedException e) { ourLog.info("Interrupted during an update loop, going to schedule another pass"); myUpdaterThread.scheduleUpdate(); } catch (InvocationTargetException e) { ourLog.error("Failed up update message tree", e); } myTop.validate(); EventQueue.invokeLater(new Runnable() { public void run() { myTreeModel.nodeStructureChanged(myTop); } }); } EventQueue.invokeLater(new Runnable() { public void run() { try { mySelectionHandlingDisabled = true; ourLog.debug("Open paths are: {}", openPaths); if (openPaths.isEmpty() && myShouldOpenDefaultPaths) { ourLog.info("Opening default paths"); final AbstractLayoutCache layout = ((OutlineModel) getModel()).getLayout(); for (int row = 0; row < layout.getRowCount(); row++) { TreePath path = layout.getPathForRow(row); Object component = path.getLastPathComponent(); if (component instanceof TreeNodeMessage || component instanceof TreeNodeUnknown || component instanceof TreeNodeGroup) { expandPath(path); } } myShouldOpenDefaultPaths = false; } else { ourLog.info("Opening pre-existing paths: {} and selected path: {}", openPaths, selectedPath); expandPaths(openPaths, selectedPath); } } finally { mySelectionHandlingDisabled = false; } } }); // if (selectedRow != -1) { // getSelectionModel().setSelectionInterval(selectedRow, selectedRow); // handleNewSelectedIndex(selectedRow); // } }
From source file:org.zaproxy.zap.extension.zest.ExtensionZest.java
@Override public void optionsLoaded() { if (getView() == null || EventQueue.isDispatchThread()) { // Convert scripts loaded on start into real Zest scripts for (ScriptType type : this.getExtScript().getScriptTypes()) { for (ScriptWrapper script : this.getExtScript().getScripts(type)) { if (ZestScriptEngineFactory.NAME.equals(script.getEngineName())) { this.scriptAdded(script, false); }/* w ww.j a v a2 s .co m*/ } } } else { EventQueue.invokeLater(new Runnable() { @Override public void run() { optionsLoaded(); } }); } }
From source file:org.n52.ifgicopter.spf.input.GpxInputPlugin.java
/** * @return/*from ww w.ja v a2s . c o m*/ * */ private JMenu makeMenu() { if (this.menu == null) { this.menu = new JMenu(); JMenuItem start = new JMenuItem("Start"); start.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { start(); } }); } }); this.menu.add(start); JMenuItem stop = new JMenuItem("Stop"); stop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { stop(); } }); } }); this.menu.add(stop); this.menu.addSeparator(); JMenuItem selectFile = new JMenuItem("Select GPX File"); selectFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectGpxFileAction(); } }); this.menu.add(selectFile); this.menu.addSeparator(); } return this.menu; }
From source file:org.nuclos.client.common.Utils.java
/** * sets the input focus to a certain collectable component in a LayoutML mask. * @param eafnInitialFocus entity name and field name of the component that is to receive to focus. The entity name is * null, if the component is not in a subform. * @param clctcompprovider map of all collectable components in the layout * @param mpsubformctl map of all subformcontrollers * @param frame frame of the layout (for possible warning dialogs only) * @param bShowWarnings displays warnings for components not found for focussing * @precondition eafnInitialFocus != null *//* www. j a va 2s . co m*/ public static void setInitialComponentFocus(EntityAndFieldName eafnInitialFocus, final CollectableComponentsProvider clctcompprovider, final Map<String, ? extends SubFormController> mpsubformctl, final MainFrameTab frame, final boolean bShowWarnings) { final String sInitialFocusEntityName = eafnInitialFocus.getEntityName(); final String sInitialFocusFieldName = eafnInitialFocus.getFieldName(); // Must be invoked later, else focus is not set with compound components like LOVs EventQueue.invokeLater(new Runnable() { @Override public void run() { try { if (sInitialFocusEntityName == null) { if (sInitialFocusFieldName != null) { final Collection<CollectableComponent> collclctcomp = clctcompprovider .getCollectableComponentsFor(sInitialFocusFieldName); if (collclctcomp.isEmpty()) { if (bShowWarnings) { final String sMessage = SpringLocaleDelegate.getInstance().getMessage( "ClientUtils.1", "Das angegebene Feld f\u00fcr den initialen Fokus existiert nicht."); JOptionPane .showMessageDialog( frame, sMessage, SpringLocaleDelegate.getInstance() .getMessage("ClientUtils.2", "Hinweis"), JOptionPane.WARNING_MESSAGE); } } else { final CollectableComponent clctcomp = collclctcomp.iterator().next(); final JComponent compFocus = clctcomp.getFocusableComponent(); compFocus.requestFocusInWindow(); } } } else { final SubFormController subformctl = mpsubformctl.get(sInitialFocusEntityName); if (subformctl != null) { final SubForm.SubFormTableModel subformtblmdl = (SubForm.SubFormTableModel) subformctl .getSubForm().getJTable().getModel(); final JTable tbl = subformctl.getSubForm().getJTable(); final int iColumn = tbl.convertColumnIndexToView( subformtblmdl.findColumnByFieldName(sInitialFocusFieldName)); if (iColumn != -1) { if (subformtblmdl.getRowCount() > 0) { tbl.editCellAt(0, iColumn); Component comp = tbl.getCellEditor().getTableCellEditorComponent(tbl, tbl.getValueAt(0, iColumn), true, 0, iColumn); // Special case for multiline text editor components if (comp instanceof JScrollPane) { comp = ((JScrollPane) comp).getViewport().getView(); } comp.requestFocusInWindow(); } } else { if (bShowWarnings) { final String sMessage = SpringLocaleDelegate.getInstance().getMessage( "ClientUtils.3", "Das angegebene Feld in der Entit\u00e4t f\u00fcr den initialen Fokus existiert nicht."); JOptionPane .showMessageDialog( frame, sMessage, SpringLocaleDelegate.getInstance() .getMessage("ClientUtils.2", "Hinweis"), JOptionPane.WARNING_MESSAGE); } } } else { if (bShowWarnings) { final String sMessage = SpringLocaleDelegate.getInstance().getMessage( "ClientUtils.4", "Die angegebene Entit\u00e4t f\u00fcr den initialen Fokus existiert nicht."); JOptionPane.showMessageDialog(frame, sMessage, SpringLocaleDelegate.getInstance().getMessage("ClientUtils.2", "Hinweis"), JOptionPane.WARNING_MESSAGE); } } } } catch (Exception e) { LOG.error("setInitialComponentFocus failed: " + e, e); } } }); }
From source file:com.excilys.ebi.gatling.recorder.ui.component.RunningFrame.java
@Subscribe public void onResponseReceivedEvent(final ResponseReceivedEvent event) { EventQueue.invokeLater(new Runnable() { public void run() { if (addRequest(event.getRequest())) { if (pause != null) { events.addElement(pause.toString()); executedEvents.ensureIndexIsVisible(events.getSize() - 1); listEvents.add(pause); }// w w w . j a v a 2 s .co m lastRequest = new Date(); processRequest(event); } } }); }
From source file:org.n52.ifgicopter.spf.input.FakeInputPlugin.java
/** * //from w ww. j a v a2 s .c o m * @return */ private JMenu makeMenu() { if (this.menu == null) { this.menu = new JMenu(); JMenuItem start = new JMenuItem("Start"); start.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { start(); } }); } }); this.menu.add(start); JMenuItem stop = new JMenuItem("Stop"); stop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { stop(); } }); } }); this.menu.add(stop); this.menu.addSeparator(); } return this.menu; }
From source file:io.github.dsheirer.gui.SDRTrunk.java
/** * Toggles visibility of the broadcast channels status panel at the bottom of the controller panel *//*w w w .j a v a 2s . co m*/ private void toggleBroadcastStatusPanelVisibility() { mBroadcastStatusVisible = !mBroadcastStatusVisible; EventQueue.invokeLater(new Runnable() { @Override public void run() { if (mBroadcastStatusVisible) { mSplitPane.add(getBroadcastStatusPanel()); } else { mSplitPane.remove(getBroadcastStatusPanel()); } mMainGui.revalidate(); } }); SystemProperties.getInstance().set(PROPERTY_BROADCAST_STATUS_VISIBLE, mBroadcastStatusVisible); }
From source file:it.flavianopetrocchi.jpdfbookmarks.JPdfBookmarks.java
public void launchNewGuiInstance(String path, Bookmark bookmark) { EventQueue.invokeLater(new GuiLauncher(path, bookmark)); }
From source file:com.kenai.redminenb.query.RedmineQueryController.java
public void selectFilter(final Filter filter) { if (filter != null) { // XXX this part should be handled in the issues table - move the filtercombo and the label over int c = 0; for (RedmineIssue issue : query.getIssues()) { if (filter.accept(issue.getNode())) { c++;//from ww w . j ava2 s . c om } } final int issueCount = c; Runnable r = new Runnable() { @Override public void run() { queryPanel.filterComboBox.setSelectedItem(filter); setIssueCount(issueCount); } }; if (EventQueue.isDispatchThread()) { r.run(); } else { EventQueue.invokeLater(r); } } issueTable.setFilter(filter); }