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:phex.gui.tabs.library.SharedFilesTableModel.java

@EventTopicSubscriber(topic = PhexEventTopics.Share_Update)
public void onShareUpdateEvent(String topic, Object event) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            fireTableDataChanged();/*from w  w w. ja  v  a 2 s . co m*/
        }
    });
}

From source file:jgnash.ui.report.compiled.IncomeExpensePieChart.java

private void setChartCursor(final ChartPanel chartPanel, final ChartEntity e, final Point point) {
    lastPoint = point;//w w w . ja va  2s  .  co  m

    EventQueue.invokeLater(new Runnable() {

        ChartEntity entity = e;

        @Override
        public void run() {
            if (entity == null && point != null) {
                entity = chartPanel.getEntityForPoint(lastPoint.x, lastPoint.y);
            }
            Account parent = currentAccount;
            if (entity instanceof PieSectionEntity) {
                // change cursor if section is interesting
                Account a = (Account) ((PieSectionEntity) entity).getSectionKey();
                if (a.getChildCount() > 0 && a != parent) {
                    chartPanel.setCursor(ZOOM_IN);
                } else {
                    chartPanel.setCursor(Cursor.getDefaultCursor());
                }
                return;
            } else if (entity == null && parent != null) {
                parent = parent.getParent();
                if (parent != null && !(parent instanceof RootAccount)) {
                    chartPanel.setCursor(ZOOM_OUT);
                    return;
                }
            }
            chartPanel.setCursor(Cursor.getDefaultCursor());
        }
    });
}

From source file:ca.uhn.hl7v2.testpanel.ui.editor.Hl7V2MessageEditorPanel.java

/**
 * Create the panel./*  w w  w  . ja va 2s . c o  m*/
 */
public Hl7V2MessageEditorPanel(final Controller theController) {
    setBorder(null);
    myController = theController;

    ButtonGroup encGrp = new ButtonGroup();
    setLayout(new BorderLayout(0, 0));

    mysplitPane = new JSplitPane();
    mysplitPane.setResizeWeight(0.5);
    mysplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    add(mysplitPane);

    mysplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent theEvt) {
            double ratio = (double) mysplitPane.getDividerLocation() / mysplitPane.getHeight();
            ourLog.debug("Resizing split to ratio: {}", ratio);
            Prefs.getInstance().setHl7EditorSplit(ratio);
        }
    });

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            mysplitPane.setDividerLocation(Prefs.getInstance().getHl7EditorSplit());
        }
    });

    messageEditorContainerPanel = new JPanel();
    messageEditorContainerPanel.setBorder(null);
    mysplitPane.setRightComponent(messageEditorContainerPanel);
    messageEditorContainerPanel.setLayout(new BorderLayout(0, 0));

    myMessageEditor = new JEditorPane();
    Highlighter h = new UnderlineHighlighter();
    myMessageEditor.setHighlighter(h);
    // myMessageEditor.setFont(Prefs.getHl7EditorFont());
    myMessageEditor.setSelectedTextColor(Color.black);

    myMessageEditor.setCaret(new EditorCaret());

    myMessageScrollPane = new JScrollPane(myMessageEditor);
    messageEditorContainerPanel.add(myMessageScrollPane);

    JToolBar toolBar = new JToolBar();
    messageEditorContainerPanel.add(toolBar, BorderLayout.NORTH);
    toolBar.setFloatable(false);
    toolBar.setRollover(true);

    myFollowToggle = new JToggleButton("Follow");
    myFollowToggle.setToolTipText("Keep the message tree (above) and the message editor (below) in sync");
    myFollowToggle.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            theController.setMessageEditorInFollowMode(myFollowToggle.isSelected());
        }
    });
    myFollowToggle.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/updown.png")));
    myFollowToggle.setSelected(theController.isMessageEditorInFollowMode());
    toolBar.add(myFollowToggle);

    myhorizontalStrut = Box.createHorizontalStrut(20);
    toolBar.add(myhorizontalStrut);

    mylabel_4 = new JLabel("Encoding");
    toolBar.add(mylabel_4);

    myRdbtnEr7 = new JRadioButton("ER7");
    myRdbtnEr7.setMargin(new Insets(1, 2, 0, 1));
    toolBar.add(myRdbtnEr7);

    myRdbtnXml = new JRadioButton("XML");
    myRdbtnXml.setMargin(new Insets(1, 5, 0, 1));
    toolBar.add(myRdbtnXml);
    encGrp.add(myRdbtnEr7);
    encGrp.add(myRdbtnXml);

    treeContainerPanel = new JPanel();
    mysplitPane.setLeftComponent(treeContainerPanel);
    treeContainerPanel.setLayout(new BorderLayout(0, 0));

    mySpinnerIconOn = new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/spinner.gif"));
    mySpinnerIconOff = new ImageIcon();

    myTreePanel = new Hl7V2MessageTree(theController);
    myTreePanel.setWorkingListener(new IWorkingListener() {

        public void startedWorking() {
            mySpinner.setText("");
            mySpinner.setIcon(mySpinnerIconOn);
            mySpinnerIconOn.setImageObserver(mySpinner);
        }

        public void finishedWorking(String theStatus) {
            mySpinner.setText(theStatus);

            mySpinner.setIcon(mySpinnerIconOff);
            mySpinnerIconOn.setImageObserver(null);
        }
    });
    myTreeScrollPane = new JScrollPane(myTreePanel);

    myTopTabBar = new JTabbedPane();
    treeContainerPanel.add(myTopTabBar);
    myTopTabBar.setBorder(null);

    JPanel treeContainer = new JPanel();
    treeContainer.setLayout(new BorderLayout(0, 0));
    treeContainer.add(myTreeScrollPane);

    myTopTabBar.add("Message Tree", treeContainer);

    mytoolBar_1 = new JToolBar();
    mytoolBar_1.setFloatable(false);
    treeContainer.add(mytoolBar_1, BorderLayout.NORTH);

    mylabel_3 = new JLabel("Show");
    mytoolBar_1.add(mylabel_3);

    myShowCombo = new JComboBox();
    mytoolBar_1.add(myShowCombo);
    myShowCombo.setPreferredSize(new Dimension(130, 27));
    myShowCombo.setMinimumSize(new Dimension(130, 27));
    myShowCombo.setMaximumSize(new Dimension(130, 32767));

    collapseAllButton = new JButton();
    collapseAllButton.setBorderPainted(false);
    collapseAllButton.addMouseListener(new HoverButtonMouseAdapter(collapseAllButton));
    collapseAllButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myTreePanel.collapseAll();
        }
    });
    collapseAllButton.setToolTipText("Collapse All");
    collapseAllButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/collapse_all.png")));
    mytoolBar_1.add(collapseAllButton);

    expandAllButton = new JButton();
    expandAllButton.setBorderPainted(false);
    expandAllButton.addMouseListener(new HoverButtonMouseAdapter(expandAllButton));
    expandAllButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myTreePanel.expandAll();
        }
    });
    expandAllButton.setToolTipText("Expand All");
    expandAllButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/expand_all.png")));
    mytoolBar_1.add(expandAllButton);

    myhorizontalGlue = Box.createHorizontalGlue();
    mytoolBar_1.add(myhorizontalGlue);

    mySpinner = new JButton("");
    mySpinner.setForeground(Color.DARK_GRAY);
    mySpinner.setHorizontalAlignment(SwingConstants.RIGHT);
    mySpinner.setMaximumSize(new Dimension(200, 15));
    mySpinner.setPreferredSize(new Dimension(200, 15));
    mySpinner.setMinimumSize(new Dimension(200, 15));
    mySpinner.setBorderPainted(false);
    mySpinner.setSize(new Dimension(16, 16));
    mytoolBar_1.add(mySpinner);
    myProfileComboboxModel = new ProfileComboModel();

    myTablesComboModel = new TablesComboModel(myController);

    mytoolBar = new JToolBar();
    mytoolBar.setFloatable(false);
    mytoolBar.setRollover(true);
    treeContainerPanel.add(mytoolBar, BorderLayout.NORTH);

    myOutboundInterfaceCombo = new JComboBox();
    myOutboundInterfaceComboModel = new DefaultComboBoxModel();

    mylabel_1 = new JLabel("Send");
    mytoolBar.add(mylabel_1);
    myOutboundInterfaceCombo.setModel(myOutboundInterfaceComboModel);
    myOutboundInterfaceCombo.setMaximumSize(new Dimension(200, 32767));
    mytoolBar.add(myOutboundInterfaceCombo);

    mySendButton = new JButton("Send");
    mySendButton.addMouseListener(new HoverButtonMouseAdapter(mySendButton));
    mySendButton.setBorderPainted(false);
    mySendButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // int selectedIndex =
            // myOutboundInterfaceComboModel.getIndexOf(myOutboundInterfaceComboModel.getSelectedItem());
            int selectedIndex = myOutboundInterfaceCombo.getSelectedIndex();
            OutboundConnection connection = myController.getOutboundConnectionList().getConnections()
                    .get(selectedIndex);
            activateSendingActivityTabForConnection(connection);
            myController.sendMessages(connection, myMessage,
                    mySendingActivityTable.provideTransmissionCallback());
        }
    });

    myhorizontalStrut_2 = Box.createHorizontalStrut(20);
    myhorizontalStrut_2.setPreferredSize(new Dimension(2, 0));
    myhorizontalStrut_2.setMinimumSize(new Dimension(2, 0));
    myhorizontalStrut_2.setMaximumSize(new Dimension(2, 32767));
    mytoolBar.add(myhorizontalStrut_2);

    mySendOptionsButton = new JButton("Options");
    mySendOptionsButton.setBorderPainted(false);
    final HoverButtonMouseAdapter sendOptionsHoverAdaptor = new HoverButtonMouseAdapter(mySendOptionsButton);
    mySendOptionsButton.addMouseListener(sendOptionsHoverAdaptor);
    mySendOptionsButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/sendoptions.png")));
    mytoolBar.add(mySendOptionsButton);
    mySendOptionsButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent theE) {
            if (mySendOptionsPopupDialog != null) {
                mySendOptionsPopupDialog.doHide();
                mySendOptionsPopupDialog = null;
                return;
            }
            mySendOptionsPopupDialog = new SendOptionsPopupDialog(Hl7V2MessageEditorPanel.this, myMessage,
                    mySendOptionsButton, sendOptionsHoverAdaptor);
            Point los = mySendOptionsButton.getLocationOnScreen();
            mySendOptionsPopupDialog.setLocation(los.x, los.y + mySendOptionsButton.getHeight());
            mySendOptionsPopupDialog.setVisible(true);
        }
    });

    mySendButton.setIcon(new ImageIcon(
            Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/button_execute.png")));
    mytoolBar.add(mySendButton);

    myhorizontalStrut_1 = Box.createHorizontalStrut(20);
    mytoolBar.add(myhorizontalStrut_1);

    mylabel_2 = new JLabel("Validate");
    mytoolBar.add(mylabel_2);

    myProfileCombobox = new JComboBox();
    mytoolBar.add(myProfileCombobox);
    myProfileCombobox.setPreferredSize(new Dimension(200, 27));
    myProfileCombobox.setMinimumSize(new Dimension(200, 27));
    myProfileCombobox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (myHandlingProfileComboboxChange) {
                return;
            }

            myHandlingProfileComboboxChange = true;
            try {
                if (myProfileCombobox.getSelectedIndex() == 0) {
                    myMessage.setValidationContext(null);
                } else if (myProfileCombobox.getSelectedIndex() == 1) {
                    myMessage.setValidationContext(new DefaultValidation());
                } else if (myProfileCombobox.getSelectedIndex() > 0) {
                    ProfileGroup profile = myProfileComboboxModel.myProfileGroups
                            .get(myProfileCombobox.getSelectedIndex());
                    myMessage.setRuntimeProfile(profile);

                    // } else if (myProfileCombobox.getSelectedItem() ==
                    // ProfileComboModel.APPLY_CONFORMANCE_PROFILE) {
                    // IOkCancelCallback<Void> callback = new
                    // IOkCancelCallback<Void>() {
                    // public void ok(Void theArg) {
                    // myProfileComboboxModel.update();
                    // }
                    //
                    // public void cancel(Void theArg) {
                    // myProfileCombobox.setSelectedIndex(0);
                    // }
                    // };
                    // myController.chooseAndLoadConformanceProfileForMessage(myMessage,
                    // callback);
                }
            } catch (ProfileException e2) {
                ourLog.error("Failed to load profile", e2);
            } finally {
                myHandlingProfileComboboxChange = false;
            }
        }
    });
    myProfileCombobox.setMaximumSize(new Dimension(300, 32767));
    myProfileCombobox.setModel(myProfileComboboxModel);

    myhorizontalStrut_4 = Box.createHorizontalStrut(20);
    myhorizontalStrut_4.setPreferredSize(new Dimension(2, 0));
    myhorizontalStrut_4.setMinimumSize(new Dimension(2, 0));
    myhorizontalStrut_4.setMaximumSize(new Dimension(2, 32767));
    mytoolBar.add(myhorizontalStrut_4);

    // mySendingPanel = new JPanel();
    // mySendingPanel.setBorder(null);
    // myTopTabBar.addTab("Sending", null, mySendingPanel, null);
    // mySendingPanel.setLayout(new BorderLayout(0, 0));

    mySendingActivityTable = new ActivityTable();
    mySendingActivityTable.setController(myController);
    myTopTabBar.addTab("Sending", null, mySendingActivityTable, null);

    // mySendingPanelScrollPanel = new JScrollPane();
    // mySendingPanelScrollPanel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    // mySendingPanelScrollPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    // mySendingPanelScrollPanel.setColumnHeaderView(mySendingActivityTable);
    //
    // mySendingPanel.add(mySendingPanelScrollPanel, BorderLayout.CENTER);

    bottomPanel = new JPanel();
    bottomPanel.setPreferredSize(new Dimension(10, 20));
    bottomPanel.setMinimumSize(new Dimension(10, 20));
    add(bottomPanel, BorderLayout.SOUTH);
    GridBagLayout gbl_bottomPanel = new GridBagLayout();
    gbl_bottomPanel.columnWidths = new int[] { 98, 74, 0 };
    gbl_bottomPanel.rowHeights = new int[] { 16, 0 };
    gbl_bottomPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gbl_bottomPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    bottomPanel.setLayout(gbl_bottomPanel);

    mylabel = new JLabel("Terser Path:");
    mylabel.setHorizontalTextPosition(SwingConstants.LEFT);
    mylabel.setHorizontalAlignment(SwingConstants.LEFT);
    GridBagConstraints gbc_label = new GridBagConstraints();
    gbc_label.fill = GridBagConstraints.VERTICAL;
    gbc_label.weighty = 1.0;
    gbc_label.anchor = GridBagConstraints.NORTHWEST;
    gbc_label.gridx = 0;
    gbc_label.gridy = 0;
    bottomPanel.add(mylabel, gbc_label);

    myTerserPathTextField = new JLabel();
    myTerserPathTextField.setForeground(Color.BLUE);
    myTerserPathTextField.setFont(new Font("Lucida Console", Font.PLAIN, 13));
    myTerserPathTextField.setBorder(null);
    myTerserPathTextField.setBackground(SystemColor.control);
    myTerserPathTextField.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (StringUtils.isNotEmpty(myTerserPathTextField.getText())) {
                myTerserPathPopupMenu.show(myTerserPathTextField, 0, 0);
            }
        }
    });

    GridBagConstraints gbc_TerserPathTextField = new GridBagConstraints();
    gbc_TerserPathTextField.weightx = 1.0;
    gbc_TerserPathTextField.fill = GridBagConstraints.HORIZONTAL;
    gbc_TerserPathTextField.gridx = 1;
    gbc_TerserPathTextField.gridy = 0;
    bottomPanel.add(myTerserPathTextField, gbc_TerserPathTextField);

    initLocal();

}

From source file:org.zaproxy.zap.GuiBootstrap.java

/**
 * Initialises the {@code Control} and does post {@code View} initialisations.
 *
 * @throws Exception if an error occurs during initialisation
 * @see Control//  w ww. j  a  v  a 2s . c o  m
 * @see View
 */
private void initControlAndPostViewInit() throws Exception {
    Control.initSingletonWithView(getControlOverrides());

    final Control control = Control.getSingleton();
    final View view = View.getSingleton();

    EventQueue.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            view.postInit();
            view.getMainFrame().setVisible(true);

            boolean createNewSession = true;
            if (getArgs().isEnabled(CommandLine.SESSION) && getArgs().isEnabled(CommandLine.NEW_SESSION)) {
                view.showWarningDialog(Constant.messages.getString("start.gui.cmdline.invalid.session.options",
                        CommandLine.SESSION, CommandLine.NEW_SESSION, Constant.getZapHome()));

            } else if (getArgs().isEnabled(CommandLine.SESSION)) {
                Path sessionPath = SessionUtils.getSessionPath(getArgs().getArgument(CommandLine.SESSION));
                if (!Files.exists(sessionPath)) {
                    view.showWarningDialog(Constant.messages
                            .getString("start.gui.cmdline.session.does.not.exist", Constant.getZapHome()));

                } else {
                    createNewSession = !control.getMenuFileControl()
                            .openSession(sessionPath.toAbsolutePath().toString());
                }

            } else if (getArgs().isEnabled(CommandLine.NEW_SESSION)) {
                Path sessionPath = SessionUtils.getSessionPath(getArgs().getArgument(CommandLine.NEW_SESSION));
                if (Files.exists(sessionPath)) {
                    view.showWarningDialog(Constant.messages
                            .getString("start.gui.cmdline.newsession.already.exist", Constant.getZapHome()));

                } else {
                    createNewSession = !control.getMenuFileControl()
                            .newSession(sessionPath.toAbsolutePath().toString());
                }
            }
            view.hideSplashScreen();

            if (createNewSession) {
                try {
                    control.getMenuFileControl().newSession(false);
                } catch (Exception e) {
                    logger.error(e.getMessage(), e);
                    View.getSingleton()
                            .showWarningDialog(Constant.messages.getString("menu.file.newSession.error"));
                }
            }

        }
    });

    try {
        // Allow extensions to pick up command line args in GUI mode
        control.getExtensionLoader().hookCommandLineListener(getArgs());
        control.runCommandLine();

    } catch (final Exception e) {
        logger.error(e.getMessage(), e);
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                view.showWarningDialog(e.getMessage());
            }
        });
    }
}

From source file:org.n52.ifgicopter.spf.input.GpxInputPlugin.java

/**
 * @return/*from   w w  w  .  jav a  2s.c o m*/
 * 
 */
private JPanel makeControlPanel() {
    if (this.controlPanel == null) {
        this.controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));

        JButton startButton = new JButton("Start");
        startButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        start();
                    }
                });
            }
        });
        this.controlPanel.add(startButton);
        JButton stopButton = new JButton("Stop");
        stopButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        stop();
                    }
                });
            }
        });
        this.controlPanel.add(stopButton);
        JButton selectFileButton = new JButton("Select GPX File");
        selectFileButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                selectGpxFileAction();
            }
        });
        this.controlPanel.add(selectFileButton);

        JLabel sleepTimeLabel = new JLabel("Time between points in seconds:");
        this.controlPanel.add(sleepTimeLabel);
        double spinnerMin = 0.5d;
        double spinnerMax = 10000.0d;
        SpinnerModel model = new SpinnerNumberModel(2.0d, spinnerMin, spinnerMax, 0.1d);
        JSpinner sleepTimeSpinner = new JSpinner(model);
        sleepTimeSpinner.setToolTipText("Select time using controls or manual input within the range of "
                + spinnerMin + " to " + spinnerMax + ".");

        sleepTimeSpinner.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                Object source = e.getSource();
                if (source instanceof JSpinner) {
                    final JSpinner spinner = (JSpinner) source;

                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            Double value = (Double) spinner.getValue();
                            value = Double.valueOf(value.doubleValue() * SECONDS_TO_MILLISECONDS);
                            setSleepTimeMillis(value.longValue());
                        }
                    });
                } else
                    getLog().warn("Unsupported ChangeEvent, need JSpinner as source: " + e);
            }
        });
        // catch text change events without loosing the focus
        // JSpinner.DefaultEditor editor = (DefaultEditor) sleepTimeSpinner.getEditor();
        // not implemented, can be done using KeyEvent, but then it hast to be checked where in the text
        // field the keystroke was etc. --> too complicated.

        this.controlPanel.add(sleepTimeSpinner);
    }

    return this.controlPanel;
}

From source file:ca.uhn.hl7v2.testpanel.ui.ActivityDetailsCellRenderer.java

private void renderInfo(final JTable theTable, Object theValue, final int theRow) {
    if (theValue instanceof ActivityInfoError) {
        setForeground(Color.red);
    } else {//from  w w w  . j  a v a 2  s  .c o  m
        setForeground(Color.black);
    }

    String message = ((ActivityInfo) theValue).getMessage();
    setText(message);
    // setText(text);

    setFont(myVarWidthFont);

    if (theTable.getRowHeight(theRow) != theTable.getRowHeight()) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                theTable.setRowHeight(theRow, theTable.getRowHeight());
            }
        });
    }
}

From source file:org.n52.ifgicopter.spf.input.LastDataPostgisInputPlugin.java

@Override
protected JMenu makeMenu() {
    if (this.menu == null) {
        this.menu = new JMenu();
        JMenuItem start = new JMenuItem("Start");
        start.addActionListener(new ActionListener() {

            @Override//from w w  w .  j a v  a  2s.  c o  m
            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);
    }

    return this.menu;
}

From source file:org.parosproxy.paros.control.MenuFileControl.java

public boolean newSession(String fileName) {
    final Object[] created = { Boolean.TRUE };
    waitMessageDialog = view//from  ww  w.  j  a  v a2s.  c  om
            .getWaitMessageDialog(Constant.messages.getString("menu.file.newSession.wait.dialogue"));
    control.newSession(fileName, new SessionListener() {

        @Override
        public void sessionSnapshot(Exception e) {
        }

        @Override
        public void sessionSaved(final Exception e) {
            if (EventQueue.isDispatchThread()) {
                if (e == null) {
                    view.getSiteTreePanel().getTreeSite().setModel(model.getSession().getSiteTree());
                } else {
                    view.showWarningDialog(Constant.messages.getString("menu.file.newSession.error"));
                    log.error("Error creating session file " + model.getSession().getFileName(), e);
                    created[0] = Boolean.FALSE;
                }

                if (waitMessageDialog != null) {
                    waitMessageDialog.setVisible(false);
                    waitMessageDialog = null;
                }
            } else {
                EventQueue.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        sessionSaved(e);
                    }
                });
            }
        }

        @Override
        public void sessionOpened(File file, Exception e) {
        }
    });

    waitMessageDialog.setVisible(true);
    return created[0] == Boolean.TRUE;
}

From source file:org.shaman.rpg.editor.dialog.DialogVisualElement.java

private void setupVisuals() {
    isInsideSetupVisuals = true;//  w w  w . j av  a  2 s .  co m
    LOG.info("setup visuals");
    contentPanel.removeAll();
    commandPanels.clear();
    //load dialog
    dialog = obj.load();
    if (dialog == null) {
        contentPanel.add(new JLabel("unable to load the dialog"));
        isInsideSetupVisuals = false;
        return;
    }
    EditableProperties editableProperties = null;
    try {
        editableProperties = obj.getResourceBundle();
    } catch (IOException ex) {
        LOG.log(Level.WARNING, "unable to load properties file", ex);
    }
    //set header
    nameTextField.getDocument().removeUndoableEditListener(undoRedo);
    nameTextField.setText(dialog.getName());
    nameTextField.getDocument().addUndoableEditListener(undoRedo);
    String[] persons = dialog.getPersonList();
    @SuppressWarnings("unchecked")
    DefaultListModel<String> listModel = (DefaultListModel<String>) personsList.getModel();
    listModel.clear();
    listModel.ensureCapacity(persons.length);
    for (String p : persons) {
        listModel.addElement(p);
    }
    personsList.clearSelection();

    //set commands
    for (Command c : dialog.getCommands()) {
        CommandPanel p = null;
        if (c instanceof TextType) {
            p = new TextTypePanel();
        } else if (c instanceof StopType) {
            p = new StopTypePanel();
        } else if (c instanceof SetvarType) {
            p = new SetVarTypePanel();
        } else if (c instanceof AddvarType) {
            p = new AddVarTypePanel();
        } else if (c instanceof IfType) {
            p = new IfTypePanel();
        } else if (c instanceof LabelType) {
            p = new LabelTypePanel();
        } else if (c instanceof GotoType) {
            p = new GotoTypePanel();
        } else if (c instanceof QuestionType) {
            p = new QuestionTypePanel();
        } else {
            LOG.info("unknown command: " + c);
            continue;
        }
        p.setVisualElement(this);
        p.setDialog(dialog);
        p.setCommand(c);
        if (editableProperties != null) {
            p.updateResourceBundle(editableProperties, false);
        }
        p.setUndoRedo(undoRedo);
        contentPanel.add(p);
        commandPanels.add(p);
    }
    repaint();
    recursiveValidate(contentPanel);
    repaint();
    recursiveValidate(contentPanel);
    EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            recursiveValidate(contentPanel);
            contentPanel.repaint();
        }
    });
    isInsideSetupVisuals = false;
}

From source file:hu.bme.mit.sette.run.Run.java

public static void stuff(String[] args) throws Exception {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    PrintStream out = System.out;

    // print settings
    System.out.println("Base directory: " + BASEDIR);
    System.out.println("Snippet directory: " + SNIPPET_DIR);
    System.out.println("Snippet project name: " + SNIPPET_PROJECT);
    System.out.println("Output directory: " + OUTPUT_DIR);

    if (ToolRegister.get(CatgTool.class) != null) {
        System.out.println("CATG directory: " + ToolRegister.get(CatgTool.class).getToolDirectory());
    }//from  w  ww  .j av a 2s  . c om
    if (ToolRegister.get(JPetTool.class) != null) {
        System.out.println("jPET executable: " + ToolRegister.get(JPetTool.class).getPetExecutable());
    }
    if (ToolRegister.get(SpfTool.class) != null) {
        System.out.println("SPF JAR: " + ToolRegister.get(SpfTool.class).getToolJAR());
    }

    System.out.println("Tools:");
    for (Tool tool : ToolRegister.toArray()) {
        System.out.println(String.format("  %s (Version: %s, Supported Java version: %s)", tool.getName(),
                tool.getVersion(), tool.getSupportedJavaVersion()));
    }

    // get scenario
    String scenario = Run.readScenario(args, in, out);
    if (scenario == null) {
        return;
    }

    switch (scenario) {
    case "exit":
        break;

    case "generator":
        new GeneratorUI(Run.createSnippetProject(true), Run.readTool(in, out)).run(in, out);
        break;

    case "runner":
        new RunnerUI(Run.createSnippetProject(true), Run.readTool(in, out)).run(in, out);
        break;

    case "parser":
        new ParserUI(Run.createSnippetProject(true), Run.readTool(in, out)).run(in, out);
        break;

    case "tests-generator":
        new TestSuiteGenerator(Run.createSnippetProject(true), OUTPUT_DIR, Run.readTool(in, out)).generate();
        break;

    case "tests-run":
        new TestSuiteRunner(Run.createSnippetProject(true), OUTPUT_DIR, Run.readTool(in, out)).analyze();
        break;

    case "snippet-browser":
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    SnippetBrowser frame = new SnippetBrowser(Run.createSnippetProject(true));
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        break;

    case "export-csv":
        out.print("Target file: ");
        String file = in.readLine();
        exportCSV(Run.createSnippetProject(true), new File(file));
        break;

    default:
        throw new UnsupportedOperationException("Scenario has not been implemented yet: " + scenario);
    }
}