Example usage for java.awt EventQueue invokeLater

List of usage examples for java.awt EventQueue invokeLater

Introduction

In this page you can find the example usage for java.awt EventQueue invokeLater.

Prototype

public static void invokeLater(Runnable runnable) 

Source Link

Document

Causes runnable to have its run method called in the #isDispatchThread dispatch thread of Toolkit#getSystemEventQueue the system EventQueue .

Usage

From source file:org.apache.log4j.chainsaw.LogUI.java

/**
 * Allow Chainsaw v2 to be ran in-process (configured as a ChainsawAppender)
 * NOTE: Closing Chainsaw will NOT stop the application generating the events.
 * @param appender// w w  w .j  a v a 2s.  c  om
 *
 */
public void activateViewer(ChainsawAppender appender) {

    if (OSXIntegration.IS_OSX) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
    }

    LogManager.setRepositorySelector(new RepositorySelector() {

        public LoggerRepository getLoggerRepository() {
            return repositoryExImpl;
        }
    }, repositorySelectorGuard);

    //if Chainsaw is launched as an appender, ensure the root logger level is TRACE
    LogManager.getRootLogger().setLevel(Level.TRACE);

    final ApplicationPreferenceModel model = new ApplicationPreferenceModel();
    SettingsManager.getInstance().configure(new ApplicationPreferenceModelSaver(model));

    cyclicBufferSize = model.getCyclicBufferSize();

    handler = new ChainsawAppenderHandler(appender);
    handler.addEventBatchListener(new NewTabEventBatchReceiver());

    logger = LogManager.getLogger(LogUI.class);

    setShutdownAction(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
        }
    });

    applicationPreferenceModel = new ApplicationPreferenceModel();

    SettingsManager.getInstance().configure(new ApplicationPreferenceModelSaver(model));

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            loadLookAndFeelUsingPluginClassLoader(model.getLookAndFeelClassName());
            createChainsawGUI(model, null);
            getApplicationPreferenceModel().apply(model);
            activateViewer();
        }
    });
}

From source file:com.atlassian.theplugin.idea.config.ProjectConfigurationComponent.java

public static void fireDirectClickedServerPopup(final Project project, final String serverUrl,
        final ServerType serverType, final Runnable runnable) {
    /*      final Color BACKGROUND_COLOR = new Color(255, 255, 200);
            //from   w ww .jav a 2  s  . c  om
          StringBuilder sb = new StringBuilder("Server <i>" + serverUrl + "</i> not found in configuration<br>");
          sb.append("<br>Click on this notification to open configuration panel and add this server");
            
          JEditorPane content = new JEditorPane();
          content.setEditable(false);
          content.setContentType("text/html");
          content.setEditorKit(new ClasspathHTMLEditorKit());
          content.setText("<html>" + Constants.BODY_WITH_STYLE + sb.toString() + "</body></html>");
          content.setBackground(BACKGROUND_COLOR);
          content.addHyperlinkListener(new GenericHyperlinkListener());
            
          content.addMouseListener(new MouseAdapter() {
             @Override
             public void mouseClicked(MouseEvent e) {
    if (ProjectConfigurationComponent.addDirectClickedServer(project, serverUrl, serverType)) {
       EventQueue.invokeLater(runnable);
    }
             }
          });
            
          IdeaVersionFacade.getInstance().fireNotification(
    project,
    new JScrollPane(content),
    content.getText(),
    "/icons/crucible-blue-16.png",
    IdeaVersionFacade.OperationStatus.INFO,
    BACKGROUND_COLOR);*/

    if (Messages.showYesNoDialog(
            "Server " + serverUrl + " not found in configuration,\ndo you want to "
                    + "open configuration panel and add this server?",
            "Server not found", Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) {
        if (ProjectConfigurationComponent.addDirectClickedServer(project, serverUrl, serverType)) {
            EventQueue.invokeLater(runnable);
        }
    }
}

From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java

private void changeListTableRow() {
    if (model != null && model.getEntity() != null && model.getEntity().getRawListColumns() != null) {
        final int index = listColumnTable.getSelectedRow();
        if (index < 0)
            return;
        TaskHelper.runInNonEDT(new Callable<Void>() {
            public Void call() throws Exception {
                List<ListColumn> list = model.getEntity().getRawListColumns();
                if (index < list.size()) {
                    final ListColumn lc = list.get(index);
                    EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            ModelHelper.simpleGetAndComplexSet(lc, TableView.this, ModelValueCategory.List);
                        }/*from  w w w  .  j  ava2  s.com*/
                    });
                }
                return null;
            }
        });
    }
}

From source file:org.docear.plugin.core.CoreConfiguration.java

protected void initMode(final ModeController modeController) {
    WorkspaceController.replaceAction(new DocearAddRepositoryPathAction());
    WorkspaceController.replaceAction(new DocearRemoveRepositoryPathAction());
    WorkspaceController.replaceAction(new DocearRemoveRepositoryPathRibbonAction());
    WorkspaceController.replaceAction(new DocearLibraryOpenLocation());
    WorkspaceController.replaceAction(new DocearNewProjectAction());
    WorkspaceController.replaceAction(new DocearLibraryNewMindmap());

    final DocearMaximizeMapHandler maximizeMapHandler = DocearMaximizeMapHandler.installMode(modeController);
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            OneTouchCollapseResizer resizer = OneTouchCollapseResizer.findResizerFor(
                    modeController.getUserInputListenerFactory().getRibbonBuilder().getRibbonRootComponent());
            if (resizer == null) {
                EventQueue.invokeLater(this);
                return;
            }/*  w w w .  j  a v  a 2s  . com*/
            maximizeMapHandler.addCollapsableResizer(resizer);
            maximizeMapHandler.addCollapsableResizer(getNotePanelResizer());
            maximizeMapHandler.addCollapsableResizer(getFBarResizer());
            maximizeMapHandler.addCollapsableResizer(getIconBarResizer());
            maximizeMapHandler.addCollapsableResizer(getStatusLineResizer());
        }
    });

    DocearProjectLoader docearProjectLoader = new DocearProjectLoader();
    WorkspaceController.getModeExtension(modeController).setProjectLoader(docearProjectLoader);
    AWorkspaceModeExtension modeExt = WorkspaceController.getModeExtension(modeController);
    final IWorkspaceView view = modeExt.getView();
    if (view != null) {
        view.getTransferHandler().registerNodeDropHandler(FolderTypeLibraryNode.class,
                new VirtualFolderDropHandler());
        view.getTransferHandler().registerNodeDropHandler(LiteratureRepositoryPathNode.class,
                new FileFolderDropHandler());
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                OneTouchCollapseResizer resizer = OneTouchCollapseResizer.findResizerFor(view.getComponent());
                if (resizer == null) {
                    EventQueue.invokeLater(this);
                    return;
                }
                maximizeMapHandler.addCollapsableResizer(resizer);
            }
        });

    }

    DocearController.getController().getDocearEventLogger().appendToLog(this,
            DocearLogEvent.APPLICATION_STARTED);
    Toolkit.getDefaultToolkit();
    DocearController.getController().getDocearEventLogger().appendToLog(this,
            DocearLogEvent.OS_OPERATING_SYSTEM, System.getProperty("os.name"));
    DocearController.getController().getDocearEventLogger().appendToLog(this, DocearLogEvent.OS_LANGUAGE_CODE,
            System.getProperty("user.language"));
    DocearController.getController().getDocearEventLogger().appendToLog(this, DocearLogEvent.OS_COUNTRY_CODE,
            System.getProperty("user.country"));
    DocearController.getController().getDocearEventLogger().appendToLog(this, DocearLogEvent.OS_TIME_ZONE,
            System.getProperty("user.timezone"));
    DocearController.getController().getDocearEventLogger().appendToLog(this,
            DocearLogEvent.OS_SCREEN_RESOLUTION, Toolkit.getDefaultToolkit().getScreenSize().toString());

    MapVersionInterpreter.addMapVersionInterpreter(new MapVersionInterpreter("Docear", 1, "docear", false,
            false, "Docear", "url", null, new org.freeplane.features.url.IMapConverter() {
                public void convert(NodeModel root) throws MapConversionException {
                    final MapModel mapModel = root.getMap();
                    DocearMapModelExtension docearMapModel = mapModel
                            .getExtension(DocearMapModelExtension.class);
                    if (docearMapModel == null) {
                        DocearMapModelController.setModelWithCurrentVersion(mapModel);
                    }
                }
            }));

    // set up context menu for workspace

    addPluginDefaults(Controller.getCurrentController());
    addMenus(modeController);

    registerListeners(modeController);

    replaceFreeplaneStringsAndActions(modeController);

    DocearMapModelController.install(new DocearMapModelController(modeController));

    setDocearMapWriter(modeController);

    registerController(modeController);
    UrlManager.getController().setLastCurrentDir(URIUtils
            .getAbsoluteFile(WorkspaceController.getModeExtension(modeController).getDefaultProjectHome()));
}

From source file:net.sf.nmedit.jsynth.clavia.nordmodular.NordModular.java

public void syncSettings() {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            syncSettingsImmediatelly();/*ww  w  .j  ava  2  s . c om*/
        }
    });
}

From source file:org.n52.ifgicopter.spf.output.GpxOutputPlugin.java

/**
 * /* w w  w .jav  a2  s.co m*/
 */
protected void selectGpxFileAction() {
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            JFileChooser fc = new JFileChooser();
            fc.setDialogTitle("Select GPX File");
            fc.setFileFilter(new FileFilter() {

                @Override
                public boolean accept(File f) {
                    if (f.getName().toLowerCase().endsWith("gpx") || f.getName().toLowerCase().endsWith("xml"))
                        return true;
                    if (f.isDirectory())
                        return true;

                    return false;
                }

                @Override
                public String getDescription() {
                    return "GPX file";
                }
            });

            File gpxfile = new File(getGpxFilePath());
            if (gpxfile.isFile()) {
                fc.setCurrentDirectory(gpxfile.getParentFile());
            }

            int returnVal = fc.showOpenDialog(getUserInterface().getGui());

            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                if (!file.getName().endsWith(".gpx") || !file.getName().endsWith(".xml"))
                    setGpxFilePath(file.getAbsolutePath() + ".gpx");
                else
                    setGpxFilePath(file.getAbsolutePath());
            } else {
                log.debug("Open command cancelled by user.");
            }

            fc = null;
        }
    });
}

From source file:tax.MainForm.java

private void priceTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_priceTextKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        if (!priceText.getText().equals("")) {
            Util.fadeInAndOut(priceText, Util.darkGreen);

            afmText.setEnabled(true);/*from   www.  j  a v  a2 s  .  c  o m*/
            afmText.requestFocus();
        } else
            Util.fadeInAndOut(priceText, 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 = priceText.getText();
                int priceLength = text.length();

                while (lastPriceTextLength == priceLength) {
                    try {
                        Thread.sleep(100);
                        System.out.println("text: " + text);
                        System.out.println(lastPriceTextLength + " " + priceLength);
                        return;
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    text = priceText.getText();
                    priceLength = text.length();
                }

                //                    if (text.charAt(priceLength - 1) == '\u002c')
                //                        priceText.setText(text.substring(0, priceLength - 1) + ".");

                try {
                    Double.parseDouble(text);
                } catch (Exception e) {
                    if (text.length() > 0) {
                        //                            System.out.println(text.charAt(priceLength - 1));
                        priceText.setText(text.substring(0, priceLength - 1));
                    } else
                        priceText.setText("");
                    return;
                }
                lastPriceTextLength = priceLength;
            }

        });
    }
}

From source file:org.isatools.isacreatorconfigurator.ontologyconfigurationtool.OntologyConfigUI.java

private void performTransition() {

    Thread performer = new Thread(new Runnable() {
        public void run() {
            try {
                RecommendedOntology recommendedOntology = (RecommendedOntology) selectedOntologyList
                        .getSelectedValue();

                Ontology ontology = recommendedOntology.getOntology();

                if (ontology != null) {
                    System.err.println("Got ontology: " + ontology.getOntologyAbbreviation());
                    String ontLabel = ontology.getOntologyAbbreviation() == null ? "ontology"
                            : ontology.getOntologyAbbreviation();
                    glassPane = new InfiniteProgressPanel("loading " + ontLabel + " for display...");
                    glassPane.setSize(new Dimension(getWidth(), getHeight()));
                    setGlassPane(glassPane);
                    glassPane.start();/*from   w  w w  .j  a v a2  s  . co m*/
                    validate();

                    ontologyViewContainer.removeAll();
                    if (selectedOntologies.containsKey(ontology.getOntologyDisplayLabel())) {
                        ontology.setSubsectionToQuery(selectedOntologies.get(ontology.getOntologyDisplayLabel())
                                .getBranchToSearchUnder());
                    }

                    if (OntologyUtils.getSourceOntologyPortal(ontology) == OntologyPortal.BIOPORTAL) {
                        currentlyActiveBrowser = new OntologyBrowser(ontology, bioportalClient,
                                getMaxBrowserSize());
                        configureSearchAndTermDefinitionPanel(ontology, bioportalClient);
                        ontologyViewContainer.add(currentlyActiveBrowser);
                    } else {
                        currentlyActiveBrowser = new OntologyBrowser(ontology, olsClient, getMaxBrowserSize());
                        configureSearchAndTermDefinitionPanel(ontology, olsClient);
                        ontologyViewContainer.add(currentlyActiveBrowser);
                    }

                    currentlyActiveBrowser.setPreferredSize(getMaxBrowserSize());
                    glassPane.stop();
                    OntologyConfigUI.this.validate();
                    OntologyConfigUI.this.repaint();
                } else {
                    System.err.println("ontology is null");
                }
            } catch (OutOfMemoryError oome) {
                System.err.println("We ran out of memory when trying to load the ontology");
            } finally {
                if (glassPane != null) {
                    if (glassPane.isStarted()) {
                        EventQueue.invokeLater(new Runnable() {
                            public void run() {
                                glassPane.stop();
                            }
                        });
                    }
                }
            }
        }
    });

    performer.start();
}

From source file:ca.uhn.hl7v2.testpanel.model.msg.Hl7V2MessageCollection.java

public void setHighlitedPathBasedOnRange(Range theRange) {

    final String oldValue = myHighlitedPath;

    if (theRange == null) {
        myHighlitedPath = null;//  w ww.  j a v  a 2 s .co  m
    } else {
        for (int i = 0; i < myMessageRanges.size(); i++) {
            Range range = myMessageRanges.get(i);
            if (range.contains(theRange.getStart())) {
                AbstractMessage<?> am = myMessages.get(i);
                if (am instanceof Hl7V2MessageBase) {
                    Hl7V2MessageBase messageImpl = (Hl7V2MessageBase) am;
                    messageImpl.setHighlitedPathBasedOnRange(theRange.add(-range.getStart()));
                    myHighlitedPath = i + messageImpl.getHighlitedPath();
                }
                break;
            }
        }
    } // if-else

    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            firePropertyChange(PROP_HIGHLITED_PATH, oldValue, myHighlitedPath);
            updateMessageDescription();
        }
    });

}

From source file:com.kenai.redminenb.query.RedmineQueryController.java

private void setIssueCount(final int count) {
    EventQueue.invokeLater(new Runnable() {
        @Override/* w  ww. j  a v a  2 s. c  o m*/
        public void run() {
            queryPanel.tableSummaryLabel.setText(Bundle.LBL_MatchingIssues(count));
        }
    });
}