List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:edu.ku.brc.specify.extras.FixSQLString.java
/** * /*from w w w . j a v a 2s .c o m*/ */ private void fixFromTextToSQL() { String srcStr = srcTA.getText(); srcStr = StringUtils.replace(srcStr, "\"", ""); srcStr = StringUtils.replace(srcStr, "+", ""); srcStr = StringUtils.replace(srcStr, ";", ""); while (srcStr.contains(" INNER")) { srcStr = StringUtils.replace(srcStr, " INNER", " INNER"); } while (srcStr.contains(" LEFT")) { srcStr = StringUtils.replace(srcStr, " LEFT", " LEFT"); } while (srcStr.contains(" WHERE")) { srcStr = StringUtils.replace(srcStr, " WHERE", " WHERE"); } while (srcStr.contains("\n")) { srcStr = StringUtils.replace(srcStr, " \n", ""); } dstTA.setText(srcStr); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dstTA.requestFocus(); dstTA.selectAll(); UIHelper.setTextToClipboard(dstTA.getText()); } }); }
From source file:com.frostwire.gui.library.DeviceDiscoveryClerk.java
private void handleDeviceAlive(InetAddress address, final Device device) { device.setTimestamp(System.currentTimeMillis()); //LOG.info("Device Alive: " + device); SwingUtilities.invokeLater(new Runnable() { public void run() { LibraryMediator.instance().handleDeviceAlive(device); }/* w ww .ja v a 2s . com*/ }); }
From source file:lu.lippmann.cdb.graph.GraphUtil.java
/** * Import decision tree in editor !/*from www . j a v a2s .c om*/ */ public static DecisionTree importDecisionTreeInEditor(final DecisionTree dt, final Instances dataSet, final ApplicationContext applicationContext, final EventPublisher eventPublisher, final CommandDispatcher commandDispatcher) { final CGraph graph = buildNewCGraphWithFRLayout(dataSet, dt.getGraphWithOperations()); ((GraphWithOperations) graph.getInternalGraph()).setWorkingUser(applicationContext.getUser()); applicationContext.setCadralGraph(graph); System.out.println("Publishing graph : " + applicationContext.getCadralGraph()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { eventPublisher.publish(new GraphReloadedEvent(false)); commandDispatcher.dispatch(new EnableAllMenusCommand()); commandDispatcher.dispatch(new SelectAllCommand()); commandDispatcher.dispatch(new ClusterGraphCommand()); commandDispatcher.dispatch(new DeselectAllCommand()); commandDispatcher.dispatch(new AutoFitCommand()); commandDispatcher.dispatch(new ClickViewModeCommand(ViewMode.Edit)); } }); return dt; }
From source file:i18nplugin.TranslatorEditor.java
private void createGui() { setLayout(new FormLayout("fill:min:grow", "fill:min:grow, pref")); CellConstraints cc = new CellConstraints(); // Top//from www . ja v a 2s .c o m PanelBuilder topPanel = new PanelBuilder(new FormLayout("fill:10dlu:grow", "pref, 5dlu, fill:pref:grow")); topPanel.setBorder(Borders.DLU4_BORDER); topPanel.addSeparator(mLocalizer.msg("original", "Original text"), cc.xy(1, 1)); mOriginal = new JTextArea(); mOriginal.setWrapStyleWord(false); mOriginal.setEditable(false); topPanel.add(new JScrollPane(mOriginal), cc.xy(1, 3)); // Bottom PanelBuilder bottomPanel = new PanelBuilder( new FormLayout("fill:10dlu:grow", "pref, 5dlu, fill:pref:grow")); bottomPanel.setBorder(Borders.DLU4_BORDER); bottomPanel.addSeparator(mLocalizer.msg("translation", "Translation"), cc.xy(1, 1)); mTranslation = new JTextArea(); mTranslation.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { updateState(); } public void insertUpdate(DocumentEvent e) { updateState(); } public void removeUpdate(DocumentEvent e) { updateState(); } }); mOriginal.setBackground(mTranslation.getBackground()); mOriginal.setForeground(mTranslation.getForeground()); bottomPanel.add(new JScrollPane(mTranslation), cc.xy(1, 3)); // Splitpane final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setBorder(null); split.setTopComponent(topPanel.getPanel()); split.setBottomComponent(bottomPanel.getPanel()); SwingUtilities.invokeLater(new Runnable() { public void run() { split.setDividerLocation(0.5); } }); add(split, cc.xy(1, 1)); // translation state PanelBuilder panel = new PanelBuilder(new FormLayout("pref, 2dlu, fill:10dlu:grow", "pref, 3dlu, pref")); panel.setBorder(Borders.DLU4_BORDER); panel.addSeparator(mLocalizer.msg("state", "State"), cc.xyw(1, 1, 3)); mIcon = new JLabel(); panel.add(mIcon, cc.xy(1, 3)); mState = new JLabel("-"); panel.add(mState, cc.xy(3, 3)); add(panel.getPanel(), cc.xy(1, 2)); }
From source file:cool.pandora.modeller.ui.handlers.base.SaveBagHandler.java
@Override public void execute() { final DefaultBag bag = bagView.getBag(); try {//from w w w . ja va 2 s . c o m final BagFactory bagFactory = new BagFactory(); final Writer bagWriter = getWriter(bagFactory, bag); /* * else if (mode == DefaultBag.TAR_MODE) { * bagWriter = new TarWriter(bagFactory); * } else if (mode == DefaultBag.TAR_GZ_MODE) { * bagWriter = new TarGzWriter(bagFactory); * } else if (mode == DefaultBag.TAR_BZ2_MODE) { * bagWriter = new TarBz2Writer(bagFactory); * } */ if (bagWriter != null) { bagWriter.addProgressListener(bagView.task); bagView.longRunningProcess = bagWriter; messages = bag.write(bagWriter); if (messages != null && !messages.trim().isEmpty()) { BagView.showWarningErrorDialog("Warning - bag not saved", "Problem saving " + "bag:\n" + messages); } else { BagView.showWarningErrorDialog("Bag saved", "Bag saved successfully.\n"); } } else { BagView.showWarningErrorDialog("Warning - bag not saved", "Could not get writer " + "for bag"); } SwingUtilities.invokeLater(() -> { final DefaultBag bag1 = bagView.getBag(); if (bag1.isSerialized()) { if (clearAfterSaving) { BagView.statusBarEnd(); bagView.clearBagHandler.clearExistingBag(); setClearAfterSaving(false); } else { if (bag1.isValidateOnSave()) { bagView.validateBagHandler.validateBag(); } BagView.statusBarEnd(); final File bagFile = bag1.getBagFile(); log.info("BagView.openExistingBag: {}", bagFile); bagView.openBagHandler.openExistingBag(bagFile); bagView.updateSaveBag(); } } else { ApplicationContextUtil.addConsoleMessage(messages); bagView.updateManifestPane(); } }); } finally { bagView.task.done(); BagView.statusBarEnd(); } }
From source file:LiveParenMatcher.java
public void removeUpdate_2(DocumentEvent de) { // print some debugging information before matching the parens ElementIterator iter = new ElementIterator(de.getDocument()); for (Element elem = iter.first(); elem != null; elem = iter.next()) { DocumentEvent.ElementChange change = de.getChange(elem); if (change != null) { // null means there was no change in elem System.out.println("Element " + elem.getName() + " (depth " + iter.depth() + ") changed its children: " + change.getChildrenRemoved().length + " children removed, " + change.getChildrenAdded().length + " children added.\n"); }//from ww w .j a v a 2 s . c o m } SwingUtilities.invokeLater(this); // will call run() }
From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateTreeTableCellEditor.java
@Override public boolean stopCellEditing() { String value = (String) getCellEditorValue(); boolean valid = StringUtils.isNotBlank(value) && value.length() <= 255; if (valid) {//from www . jav a 2 s. c om int selectedRow = parent.getTreeTable().getSelectedRow(); if (selectedRow >= 0) { TreePath selectedPath = parent.getTreeTable().getPathForRow(selectedRow); if (selectedPath != null) { TreeTableNode selectedNode = (TreeTableNode) selectedPath.getLastPathComponent(); if (selectedNode instanceof CodeTemplateLibraryTreeTableNode) { for (Enumeration<? extends MutableTreeTableNode> libraries = ((MutableTreeTableNode) parent .getFullModel().getRoot()).children(); libraries.hasMoreElements();) { if (((CodeTemplateLibraryTreeTableNode) libraries.nextElement()).getLibrary().getName() .equals(value)) { valid = false; break; } } } else { CodeTemplateLibraryTreeTableNode libraryNode = (CodeTemplateLibraryTreeTableNode) selectedNode .getParent(); for (Enumeration<? extends MutableTreeTableNode> codeTemplates = libraryNode .children(); codeTemplates.hasMoreElements();) { CodeTemplateTreeTableNode codeTemplateNode = (CodeTemplateTreeTableNode) codeTemplates .nextElement(); if (codeTemplateNode.getCodeTemplate().getName().equals(value)) { valid = false; break; } } } } } } if (valid) { parent.setSaveEnabled(true); TreePath selectedPath = parent.getTreeTable().getTreeSelectionModel().getSelectionPath(); if (selectedPath != null && selectedPath.getLastPathComponent() instanceof CodeTemplateLibraryTreeTableNode) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { parent.updateLibrariesComboBox(); } }); } } else { super.cancelCellEditing(); } return super.stopCellEditing(); }
From source file:edu.ku.brc.specify.plugins.imgproc.ImageProcessorPanel.java
/** * /*from w ww . j a va2 s . co m*/ */ public void createUI() { Dimension s = new Dimension(350, 350); setSize(s); setPreferredSize(s); setBackground(Color.WHITE); for (String imgNm : procImgNames) { procObjs.add(new ProcessObject(imgNm)); } circle = IconManager.getIcon("ip_circle"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doProcLayout(); step = -1; doNextStep(); } }); }
From source file:MainGUI.java
private void bkgPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_bkgPanelMouseClicked for (CButton c : ((BKGPanel) bkgPanel).getButtons()) { if (c.isContained(evt.getX(), evt.getY())) { if (c.text.equals("Play")) { final MainGUI main = this; SwingUtilities.invokeLater(new Runnable() { @Override// w w w . j a v a 2 s. co m public void run() { QuestionGUI gui = new QuestionGUI(main, Question.generateQuestionSet(main.getDifficulty(), 20), username); gui.setVisible(true); } }); } else if (c.text.equals("Check Stats")) { try { if (stats != null && stats.isValid()) { return; } stats = new UserHistoryGUI(username); stats.setVisible(true); } catch (ParseException e) { e.printStackTrace(); } } else if (c.text.equals("Options")) { opt.setVisible(true); } else if (c.text.equals("Facebook Connect")) { } } } }
From source file:burp.BurpExtender.java
@Override public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks) { // keep a reference to our callbacks object this.callbacks = callbacks; callbacks.registerContextMenuFactory(new ContextMenuFactory(this, callbacks)); // set our extension name callbacks.setExtensionName("Code Dx"); for (int i = 0; i < refreshSpinner.length; i++) refreshSpinner[i] = new ImageIcon(BurpExtender.class.getResource("/" + i + ".png")); // create our UI SwingUtilities.invokeLater(new Runnable() { @Override//from w w w . j ava 2 s .c o m public void run() { pane = new JScrollPane(createMainPanel()); refreshAnimation = new ButtonAnimationThread(projectRefresh, refreshSpinner); callbacks.customizeUiComponent(pane); // add the custom tab to Burp's UI callbacks.addSuiteTab(BurpExtender.this); // add listener to update projects list when Code Dx tab selected Component parent = pane.getParent(); if (parent instanceof JTabbedPane) { final JTabbedPane tabs = (JTabbedPane) parent; final ChangeListener tabChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { if (pane == tabs.getSelectedComponent() && !updating && !"".equals(serverUrl.getText()) && !"".equals(apiKey.getText())) { Thread updateThread = new Thread() { public void run() { updateTargets(); updateProjects(true); } }; updateThread.start(); } else if (pane != tabs.getSelectedComponent()) { NameValuePair project = getProject(); if (project != null) callbacks.saveExtensionSetting(BurpExtender.PROJECT_KEY, project.getValue()); } } }; tabs.addChangeListener(tabChangeListener); //Remove the change listener when the extension is unloaded callbacks.registerExtensionStateListener(new IExtensionStateListener() { @Override public void extensionUnloaded() { tabs.removeChangeListener(tabChangeListener); } }); } } }); }