Example usage for java.beans PropertyChangeListener PropertyChangeListener

List of usage examples for java.beans PropertyChangeListener PropertyChangeListener

Introduction

In this page you can find the example usage for java.beans PropertyChangeListener PropertyChangeListener.

Prototype

PropertyChangeListener

Source Link

Usage

From source file:org.zaproxy.zap.extension.exportreport.export.ExportReport.java

public void generateReport(ViewDelegate view, ExtensionExportReport extension) {
    FileList list = extension.getFileList();
    try {/*from ww  w.  j a v a  2s.c om*/
        if (fc == null) {
            fc = generateWriteableFileChooser(list);
            fc.addPropertyChangeListener(WritableFileChooser.FILE_FILTER_CHANGED_PROPERTY,
                    new PropertyChangeListener() {
                        @Override
                        public void propertyChange(PropertyChangeEvent evt) {
                            ReportFilter filter = (ReportFilter) evt.getNewValue();
                            String extension = (filter.getExtensionByDescription(filter.getDescription())
                                    .length() == 0 ? ""
                                            : "." + filter.getExtensionByDescription(filter.getDescription()));
                            fc.setSelectedFile(new File(extension));
                        }
                    });
        }

        int rc = fc.showSaveDialog(View.getSingleton().getMainFrame());

        boolean valid = false;
        String fileExtension = "";
        while (rc == WritableFileChooser.APPROVE_OPTION && !valid) {
            fileExtension = list.compareExtension(fc.getSelectedFile().getName());
            if (fileExtension.length() > 0) {
                valid = true;
            }
            if (!valid) {
                // Determine in v2.0 which method to use for display of
                // error messages based on feedback.
                // JOptionPane.showMessageDialog(null,
                // "The file " + fc.getSelectedFile() + " is not a valid
                // destination file.", "Open Error",
                // JOptionPane.ERROR_MESSAGE);
                view.showWarningDialog(Constant.messages
                        .getString("exportreport.message.error.file.destination", fc.getSelectedFile()));
                rc = fc.showSaveDialog(View.getSingleton().getMainFrame());
            }
        }

        if (rc == WritableFileChooser.APPROVE_OPTION && valid) {
            task = new Task(view, extension, fileExtension, fc.getSelectedFile());
            task.execute();
        }

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        view.showWarningDialog(Constant.messages.getString("exportreport.message.error.exception"));
    }
}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaToolsDlg.java

/**
 * //from   w  w  w .  j  a va2  s.  c  om
 */
private void importSchema(final boolean doLocalization) {
    FileDialog fileDlg = new FileDialog((Dialog) null);
    fileDlg.setTitle(getResourceString(doLocalization ? SL_CHS_LOC : SL_CHS_IMP));
    UIHelper.centerAndShow(fileDlg);

    String fileName = fileDlg.getFile();
    if (StringUtils.isNotEmpty(fileName)) {
        String title = getResourceString(doLocalization ? "SL_L10N_SCHEMA" : "SL_IMPORT_SCHEMA");

        final File file = new File(fileDlg.getDirectory() + File.separator + fileName);
        final SimpleGlassPane glassPane = new SimpleGlassPane(title, 18);
        glassPane.setBarHeight(12);
        glassPane.setFillColor(new Color(0, 0, 0, 85));

        setGlassPane(glassPane);
        glassPane.setVisible(true);

        SwingWorker<Integer, Integer> importWorker = new SwingWorker<Integer, Integer>() {
            private boolean isOK = false;

            @Override
            protected Integer doInBackground() throws Exception {
                DataProviderSessionIFace localSession = null;
                try {
                    localSession = DataProviderFactory.getInstance().createSession();

                    localSession.beginTransaction();

                    BuildSampleDatabase bsd = new BuildSampleDatabase();

                    Discipline discipline = localSession.get(Discipline.class,
                            AppContextMgr.getInstance().getClassObject(Discipline.class).getId());

                    isOK = bsd.loadSchemaLocalization(discipline, schemaType, DBTableIdMgr.getInstance(), null, //catFmtName,
                            null, //accFmtName,
                            doLocalization ? UpdateType.eLocalize : UpdateType.eImport, // isDoingUpdate
                            file, // external file
                            glassPane, localSession);
                    if (isOK) {
                        localSession.commit();
                    } else {
                        localSession.rollback();
                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(BuildSampleDatabase.class, ex);

                } finally {
                    if (localSession != null) {
                        localSession.close();
                    }
                }

                return null;
            }

            @Override
            protected void done() {
                super.done();

                glassPane.setVisible(false);

                if (isOK) {
                    UIRegistry.showLocalizedMsg("Specify.ABT_EXIT");
                    CommandDispatcher.dispatch(new CommandAction("App", "AppReqExit"));
                }
            }
        };
        importWorker.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(final PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("progress")) {
                    glassPane.setProgress((Integer) evt.getNewValue());
                }
            }
        });
        importWorker.execute();
    }
}

From source file:org.zkoss.ganttz.LeftTasksTreeRow.java

@Override
public void doAfterCompose(Component component) throws Exception {
    super.doAfterCompose(component);
    findComponents((Treerow) component);
    registerTextboxesListeners();/*from w  w  w  .j ava2s  . c o  m*/
    updateComponents();
    task.addFundamentalPropertiesChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            updateComponents();
        }
    });

}

From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java

private void initUI() {
    setLayout(new GridBagLayout());

    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    components = new ArrayList<JComponent>();
    checks = new ArrayList<JCheckBox>();

    int size = paramList.size();
    boolean shouldExpand = false;
    boolean needScroll = false;
    for (int i = 0; i < size; i++) {
        final int pos = i;
        final QueryParameter param = paramList.get(i);
        if (param.isHidden()) {
            components.add(null);/* www .  j ava  2  s. c  om*/
            checks.add(null);
            initHiddenParameterValues(param);
            continue;
        }
        String source = param.getSource();
        String defaultSource = param.getDefaultSource();

        if ((defaultSource != null) && !defaultSource.trim().equals("")) {
            try {
                param.setDefaultSourceValues(Globals.getDBViewer().getDefaultSourceValues(con, param));
            } catch (NextSqlException e) {
                Show.error(e);
            }
        }

        final JComponent component;
        int anchor = GridBagConstraints.WEST;
        double y = 0.0;
        int expand = GridBagConstraints.HORIZONTAL;
        if ((source != null) && !source.equals("")) {
            List<IdName> values = new ArrayList<IdName>();
            try {
                if (param.isManualSource()) {
                    if (!param.isDependent()) {
                        values = Globals.getDBViewer().getValues(con, source, true, param.getOrderBy());
                    }
                } else {
                    int index = source.indexOf(".");
                    int index2 = source.lastIndexOf(".");
                    String tableName = source.substring(0, index);
                    String columnName;
                    String shownColumnName = null;
                    if (index == index2) {
                        columnName = source.substring(index + 1);
                    } else {
                        columnName = source.substring(index + 1, index2);
                        shownColumnName = source.substring(index2 + 1);
                    }
                    values = Globals.getDBViewer().getColumnValues(con, param.getSchema(), tableName,
                            columnName, shownColumnName, param.getOrderBy());
                }
            } catch (NextSqlException e) {
                error = true;
                Show.error(e);
            } catch (InvalidSqlException e) {
                String m = I18NSupport.getString("source.dialog.valid");
                Show.info(m + " : \"select <exp1> , <exp2> from ...\"");
            }
            if (param.getSelection().equals(ParameterEditPanel.SINGLE_SELECTION)) {
                component = new JComboBox();
                final JComboBox combo = (JComboBox) component;
                combo.setRenderer(new IdNameRenderer());
                combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --");
                for (int j = 0, len = values.size(); j < len; j++) {
                    combo.addItem(values.get(j));
                }

                combo.addItemListener(new ItemListener() {
                    public void itemStateChanged(ItemEvent e) {
                        if (e.getStateChange() == ItemEvent.SELECTED) {
                            IdName in = null;
                            if (combo.getSelectedIndex() > 0) {
                                in = (IdName) combo.getSelectedItem();
                            }
                            parameterSelection(pos, in);
                        }
                    }
                });
                AutoCompleteDecorator.decorate(combo);
                needScroll = false;
            } else {
                anchor = GridBagConstraints.NORTHWEST;
                y = 1.0;
                expand = GridBagConstraints.BOTH;

                DefaultListModel model = new DefaultListModel();
                for (int j = 0, len = values.size(); j < len; j++) {
                    model.addElement(values.get(j));
                }
                List srcList = Arrays.asList(model.toArray());
                component = new ListSelectionPanel(srcList, new ArrayList(), "", "", true, false) {
                    protected void onAdd() {
                        selection();
                    }

                    protected void onRemove() {
                        selection();
                    }

                    // needed for saved parameters on rerun
                    protected void onSetRight() {
                        selection();
                    }

                    private void selection() {
                        if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) {
                            Object[] values = getDestinationElements().toArray();
                            if (values.length == 0) {
                                values = new Object[] { ParameterUtil.NULL };
                            }
                            parameterSelection(pos, values);
                        }
                    }
                };
                ((ListSelectionPanel) component).setListSize(scrListDim);
                ((ListSelectionPanel) component).setRenderer(new IdNameRenderer(),
                        new IdNameComparator(param.getOrderBy()));

                shouldExpand = true;
            }

        } else {
            if (param.getSelection().equals(QueryParameter.MULTIPLE_SELECTION)) {
                anchor = GridBagConstraints.NORTHWEST;
                y = 1.0;
                expand = GridBagConstraints.BOTH;
                ;
                component = new ListAddPanel(param) {
                    protected void onAdd() {
                        selection();
                    }

                    protected void onRemove() {
                        selection();
                    }

                    private void selection() {
                        if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) {
                            Object[] values = getElements().toArray();
                            parameterSelection(pos, values);
                        }
                    }
                };
            } else {
                needScroll = false;
                if (param.getValueClassName().equals("java.util.Date")) {
                    component = new JXDatePicker();
                    ((JXDatePicker) component).addPropertyChangeListener(new PropertyChangeListener() {
                        public void propertyChange(PropertyChangeEvent e) {
                            if ("date".equals(e.getPropertyName())) {
                                parameterSelection(pos, ((JXDatePicker) component).getDate());
                            }
                        }
                    });
                    // hack to fix bug with big popup button
                    JButton popupButton = (JButton) component.getComponent(1);
                    //popupButton.setMargin(new Insets(2, 2, 2, 2));
                    popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY));
                } else if (param.getValueClassName().equals("java.sql.Timestamp")
                        || param.getValueClassName().equals("java.sql.Time")) {
                    component = new JDateTimePicker() {
                        protected void onChange() {
                            parameterSelection(pos, getDate());
                        }
                    };
                    // hack to fix bug with big popup button
                    JButton popupButton = (JButton) (((JDateTimePicker) component).getDatePicker())
                            .getComponent(1);
                    //popupButton.setMargin(new Insets(2, 2, 2, 2));
                    popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY));
                } else if (param.getValueClassName().equals("java.lang.Boolean")) {
                    component = new JCheckBox();
                    ((JCheckBox) component).addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
                            boolean selected = abstractButton.getModel().isSelected();
                            parameterSelection(pos, selected);
                        }
                    });
                } else {
                    component = new JTextField(25);
                    ((JTextField) component).getDocument().addDocumentListener(new DocumentListener() {

                        @Override
                        public void changedUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        @Override
                        public void insertUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        @Override
                        public void removeUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        private void updateFromTextField(DocumentEvent e) {
                            java.awt.EventQueue.invokeLater(new Runnable() {

                                @Override
                                public void run() {
                                    Object value = null;
                                    try {
                                        if ("".equals(((JTextField) component).getText().trim())) {
                                            value = null;
                                        } else {
                                            value = ParameterUtil.getParameterValueFromString(
                                                    param.getValueClassName(),
                                                    ((JTextField) component).getText());
                                        }
                                        parameterSelection(pos, value);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                        LOG.error(e.getMessage(), e);
                                    }
                                }
                            });
                        }
                    });
                }
            }
        }
        components.add(component);
        final JCheckBox cb = new JCheckBox(I18NSupport.getString("run.parameter.ignore"));
        checks.add(cb);

        final JLabel label = new JLabel(getRuntimeParameterName(param));
        panel.add(label, new GridBagConstraints(0, i, 1, 1, 0.0, 0.0, anchor, GridBagConstraints.NONE,
                new Insets(5, 5, 5, 5), 0, 0));
        final JComponent addComponent;
        if (needScroll) {
            JScrollPane scr = new JScrollPane(component, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scr.setPreferredSize(listDim);
            addComponent = scr;
        } else {
            addComponent = component;
        }
        panel.add(addComponent, new GridBagConstraints(1, i, 1, 1, 1.0, y, GridBagConstraints.WEST, expand,
                new Insets(5, 0, 5, 5), 0, 0));
        int checkAnchor = GridBagConstraints.WEST;
        if ((addComponent instanceof JScrollPane) || (addComponent instanceof ListSelectionPanel)) {
            checkAnchor = GridBagConstraints.NORTHWEST;
        }

        if (Globals.getParametersIgnore()) {
            panel.add(cb, new GridBagConstraints(2, i, 1, 1, 0.0, 0.0, checkAnchor, GridBagConstraints.NONE,
                    new Insets(5, 0, 5, 5), 0, 0));
        }

        cb.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                if (cb.isSelected()) {
                    if (addComponent instanceof JScrollPane) {
                        component.setEnabled(false);
                    }
                    label.setEnabled(false);
                    addComponent.setEnabled(false);
                    param.setIgnore(true);
                } else {
                    if (addComponent instanceof JScrollPane) {
                        component.setEnabled(true);
                    }
                    label.setEnabled(true);
                    addComponent.setEnabled(true);
                    param.setIgnore(false);
                }
            }
        });
    }

    // populate hidden dependent parameters (this will be done if a parameter depends only on a single hidden parameter)
    // if a parameter depends on a hidden parameter and other parameters, it cannot be populated here
    for (int i = 0; i < size; i++) {
        final QueryParameter param = paramList.get(i);
        if (param.isHidden()) {
            populateDependentParameters(param, false);
        }
    }

    if (!shouldExpand) {
        panel.add(new JLabel(), new GridBagConstraints(0, size, 3, 1, 1.0, 1.0, GridBagConstraints.WEST,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    }

    JScrollPane scrPanel = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrPanel.setPreferredSize(scrDim);
    scrPanel.setMinimumSize(scrDim);

    add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0), 0, 0));
    setParameterValues(parametersValues);
    setParameterIgnore(parametersIgnore);
}

From source file:de.huxhorn.lilith.swing.ViewActions.java

public ViewActions(MainFrame mainFrame) {
    this.mainFrame = mainFrame;

    containerChangeListener = new ChangeListener() {
        /**//from w  w w  .  ja  va  2s. c o  m
         * Invoked when the target of the listener has changed its state.
         *
         * @param e a ChangeEvent object
         */
        public void stateChanged(ChangeEvent e) {
            updateActions();
        }
    };

    containerPropertyChangeListener = new PropertyChangeListener() {

        /**
         * This method gets called when a bound property is changed.
         *
         * @param evt A PropertyChangeEvent object describing the event source
         *            and the property that has changed.
         */

        public void propertyChange(PropertyChangeEvent evt) {
            if (ViewContainer.SELECTED_EVENT_PROPERTY_NAME.equals(evt.getPropertyName())) {
                setEventWrapper((EventWrapper) evt.getNewValue());
            }

        }
    };

    keyStrokeActionMapping = new HashMap<KeyStroke, CopyToClipboardAction>();
    // ##### Menu Actions #####
    // File
    OpenMenuAction openMenuAction = new OpenMenuAction();
    clearRecentFilesAction = new ClearRecentFilesAction();
    OpenInactiveLogMenuAction openInactiveLogMenuAction = new OpenInactiveLogMenuAction();
    ImportMenuAction importMenuAction = new ImportMenuAction();
    exportMenuAction = new ExportMenuAction();
    CleanAllInactiveLogsMenuAction cleanAllInactiveLogsMenuAction = new CleanAllInactiveLogsMenuAction();
    preferencesMenuAction = new PreferencesMenuAction();
    ExitMenuAction exitMenuAction = new ExitMenuAction();

    // Edit
    showUnfilteredEventAction = new ShowUnfilteredEventAction();
    gotoSourceAction = new GotoSourceAction();
    copySelectionAction = new CopySelectionAction();
    copyEventAction = new CopyToClipboardAction(new EventFormatter());
    copyLoggingActions = new ArrayList<CopyToClipboardAction>();
    copyLoggingActions.add(new CopyToClipboardAction(new EventJsonFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new EventXmlFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingMessageFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingMessagePatternFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingLoggerNameFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingThrowableFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingCallStackFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingCallLocationFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingMarkerFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingMdcFormatter()));
    copyLoggingActions.add(new CopyToClipboardAction(new LoggingNdcFormatter()));
    copyAccessActions = new ArrayList<CopyToClipboardAction>();
    copyAccessActions.add(new CopyToClipboardAction(new AccessUriFormatter()));

    prepareClipboardActions(copyLoggingActions, keyStrokeActionMapping);
    prepareClipboardActions(copyAccessActions, keyStrokeActionMapping);

    // Search
    findMenuAction = new FindMenuAction();
    findPreviousAction = new FindPreviousAction();
    findNextAction = new FindNextAction();
    findPreviousActiveAction = new FindPreviousActiveAction();
    findNextActiveAction = new FindNextActiveAction();
    resetFindAction = new ResetFindAction();

    // View
    scrollToBottomMenuAction = new ScrollToBottomMenuAction();
    pauseMenuAction = new PauseMenuAction();
    clearMenuAction = new ClearMenuAction();
    attachMenuAction = new AttachMenuAction();
    disconnectMenuAction = new DisconnectMenuAction();

    focusMessageAction = new FocusMessageAction();
    focusEventsAction = new FocusEventsAction();

    //statisticsMenuAction = new StatisticsMenuAction();
    editSourceNameMenuAction = new EditSourceNameMenuAction();
    saveLayoutAction = new SaveLayoutAction();
    resetLayoutAction = new ResetLayoutAction();
    saveConditionMenuAction = new SaveConditionMenuAction();

    zoomInMenuAction = new ZoomInMenuAction();
    zoomOutMenuAction = new ZoomOutMenuAction();
    resetZoomMenuAction = new ResetZoomMenuAction();

    previousTabAction = new PreviousTabAction();
    nextTabAction = new NextTabAction();
    closeFilterAction = new CloseFilterAction();
    closeOtherFiltersAction = new CloseOtherFiltersAction();
    closeAllFiltersAction = new CloseAllFiltersAction();

    // Window
    ShowTaskManagerAction showTaskManagerAction = new ShowTaskManagerAction();
    closeAllAction = new CloseAllAction();
    closeOtherAction = new CloseOtherAction();
    minimizeAllAction = new MinimizeAllAction();
    minimizeAllOtherAction = new MinimizeAllOtherAction();
    removeInactiveAction = new RemoveInactiveAction();
    //clearAndRemoveInactiveAction=new ClearAndRemoveInactiveAction();

    // Help
    KeyboardHelpAction keyboardHelpAction = new KeyboardHelpAction();
    ShowLoveMenuAction showLoveMenuAction = new ShowLoveMenuAction();
    TipOfTheDayAction tipOfTheDayAction = new TipOfTheDayAction();
    DebugAction debugAction = new DebugAction();
    aboutAction = new AboutAction();
    CheckForUpdateAction checkForUpdateAction = new CheckForUpdateAction();
    TroubleshootingAction troubleshootingAction = new TroubleshootingAction();

    // ##### ToolBar Actions #####
    scrollToBottomToolBarAction = new ScrollToBottomToolBarAction();
    pauseToolBarAction = new PauseToolBarAction();
    clearToolBarAction = new ClearToolBarAction();
    findToolBarAction = new FindToolBarAction();
    //statisticsToolBarAction = new StatisticsToolBarAction();
    attachToolBarAction = new AttachToolBarAction();
    disconnectToolBarAction = new DisconnectToolBarAction();

    showTaskManagerItem = new JMenuItem(showTaskManagerAction);
    closeAllItem = new JMenuItem(closeAllAction);
    closeAllOtherItem = new JMenuItem(closeOtherAction);
    minimizeAllItem = new JMenuItem(minimizeAllAction);
    minimizeAllOtherItem = new JMenuItem(minimizeAllOtherAction);
    removeInactiveItem = new JMenuItem(removeInactiveAction);
    //clearAndRemoveInactiveItem = new JMenuItem(clearAndRemoveInactiveAction);

    toolbar = new JToolBar(SwingConstants.HORIZONTAL);
    toolbar.setFloatable(false);

    scrollToBottomButton = new JToggleButton(scrollToBottomToolBarAction);
    toolbar.add(scrollToBottomButton);

    JButton pauseButton = new JButton(pauseToolBarAction);
    toolbar.add(pauseButton);

    JButton clearButton = new JButton(clearToolBarAction);
    toolbar.add(clearButton);

    JButton findButton = new JButton(findToolBarAction);
    toolbar.add(findButton);

    JButton disconnectButton = new JButton(disconnectToolBarAction);
    toolbar.add(disconnectButton);

    toolbar.addSeparator();

    //JButton statisticsButton = new JButton(statisticsToolBarAction);
    //toolbar.add(statisticsButton);
    //toolbar.addSeparator();

    JButton attachButton = new JButton(attachToolBarAction);
    toolbar.add(attachButton);

    toolbar.addSeparator();

    PreferencesToolBarAction preferencesToolBarAction = new PreferencesToolBarAction();
    JButton preferencesButton = new JButton(preferencesToolBarAction);
    toolbar.add(preferencesButton);

    toolbar.addSeparator();

    ShowLoveToolbarAction showLoveToolbarAction = new ShowLoveToolbarAction();
    JButton showLoveButton = new JButton(showLoveToolbarAction);
    toolbar.add(showLoveButton);

    recentFilesMenu = new JMenu("Recent Files");

    Application app = mainFrame.getApplication();

    menubar = new JMenuBar();

    // File
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('f');
    fileMenu.add(openMenuAction);
    fileMenu.add(recentFilesMenu);
    fileMenu.add(openInactiveLogMenuAction);
    fileMenu.add(cleanAllInactiveLogsMenuAction);
    fileMenu.add(importMenuAction);
    fileMenu.add(exportMenuAction);
    if (!app.isMac()) {
        fileMenu.addSeparator();
        fileMenu.add(preferencesMenuAction);
        fileMenu.addSeparator();
        fileMenu.add(exitMenuAction);
    }

    // Edit
    editMenu = new JMenu("Edit");
    editMenu.setMnemonic('e');
    editMenu.add(copySelectionAction);
    editMenu.addSeparator();
    editMenu.add(copyEventAction);
    editMenu.addSeparator();
    for (CopyToClipboardAction current : copyLoggingActions) {
        editMenu.add(current);
    }
    editMenu.addSeparator();
    for (CopyToClipboardAction current : copyAccessActions) {
        editMenu.add(current);
    }
    editMenu.addSeparator();
    customCopyMenu = new JMenu("Custom copy");
    customCopyPopupMenu = new JMenu("Custom copy");
    editMenu.add(customCopyMenu);
    editMenu.addSeparator();
    PasteStackTraceElementAction pasteStackTraceElementAction = new PasteStackTraceElementAction();
    editMenu.add(pasteStackTraceElementAction);

    // Search
    searchMenu = new JMenu("Search");
    searchMenu.setMnemonic('s');
    searchMenu.add(findMenuAction);
    searchMenu.add(resetFindAction);
    searchMenu.add(findPreviousAction);
    searchMenu.add(findNextAction);
    searchMenu.add(findPreviousActiveAction);
    searchMenu.add(findNextActiveAction);
    searchMenu.addSeparator();
    searchMenu.add(saveConditionMenuAction);
    searchMenu.addSeparator();

    focusMenu = new FocusMenu(mainFrame.getApplicationPreferences());
    excludeMenu = new ExcludeMenu(mainFrame.getApplicationPreferences());
    searchMenu.add(focusMenu);
    searchMenu.add(excludeMenu);

    // View
    viewMenu = new JMenu("View");
    viewMenu.setMnemonic('v');
    viewMenu.add(scrollToBottomMenuAction);
    viewMenu.add(pauseMenuAction);
    viewMenu.add(clearMenuAction);
    viewMenu.add(attachMenuAction);
    viewMenu.add(disconnectMenuAction);
    viewMenu.add(focusEventsAction);
    viewMenu.add(focusMessageAction);
    //viewMenu.add(statisticsMenuAction);
    viewMenu.add(editSourceNameMenuAction);
    viewMenu.addSeparator();
    viewMenu.add(zoomInMenuAction);
    viewMenu.add(zoomOutMenuAction);
    viewMenu.add(resetZoomMenuAction);
    viewMenu.addSeparator();
    JMenu layoutMenu = new JMenu("Layout");
    columnsMenu = new JMenu("Columns");
    layoutMenu.add(columnsMenu);
    layoutMenu.addSeparator();
    layoutMenu.add(saveLayoutAction);
    layoutMenu.add(resetLayoutAction);
    viewMenu.add(layoutMenu);
    viewMenu.addSeparator();
    viewMenu.add(previousTabAction);
    viewMenu.add(nextTabAction);
    viewMenu.addSeparator();
    viewMenu.add(closeFilterAction);
    viewMenu.add(closeOtherFiltersAction);
    viewMenu.add(closeAllFiltersAction);

    // Window
    windowMenu = new JMenu("Window");
    windowMenu.setMnemonic('w');

    // Help
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic('h');

    helpMenu.add(keyboardHelpAction);
    helpMenu.add(showLoveMenuAction);
    helpMenu.add(tipOfTheDayAction);
    helpMenu.add(checkForUpdateAction);
    helpMenu.add(troubleshootingAction);
    helpMenu.addSeparator();
    helpMenu.add(debugAction);
    if (!app.isMac()) {
        helpMenu.addSeparator();
        helpMenu.add(aboutAction);
    }

    menubar.add(fileMenu);
    menubar.add(editMenu);
    menubar.add(searchMenu);
    menubar.add(viewMenu);
    menubar.add(windowMenu);
    menubar.add(helpMenu);

    updateWindowMenu();
    updateRecentFiles();
    updateActions();
}

From source file:ome.formats.importer.gui.FileQueueHandler.java

/**
 * Retrieve the file chooser's selected reader then iterate over
 * each of our supplied containers filtering out those whose format
 * do not match those of the selected reader.
 * /*  w  ww  .j a  v  a  2  s  .c o  m*/
 * @param allContainers List of ImporterContainers
 */
private void handleFiles(List<ImportContainer> allContainers) {
    FileFilter selectedFilter = fileChooser.getFileFilter();
    IFormatReader selectedReader = null;

    if (selectedFilter instanceof FormatFileFilter) {
        log.debug("Selected file filter: " + selectedFilter);
        selectedReader = ((FormatFileFilter) selectedFilter).getReader();
    }

    List<ImportContainer> containers = new ArrayList<ImportContainer>();
    for (ImportContainer ic : allContainers) {
        if (selectedReader == null) {
            // The user selected "All supported file types"
            containers = allContainers;
            break;
        }
        String a = selectedReader.getFormat();
        String b = ic.getReader();
        if (a.equals(b) || b == null) {
            containers.add(ic);
        } else {
            log.debug(String.format("Skipping %s (%s != %s)", ic.getFile().getAbsoluteFile(), a, b));
        }
    }

    Boolean spw = spwOrNull(containers);

    if (containers.size() == 0 && !candidatesFormatException) {
        final JOptionPane optionPane = new JOptionPane("\nNo importable files found in this selection.",
                JOptionPane.WARNING_MESSAGE);
        final JDialog errorDialog = new JDialog(viewer, "No Importable Files Found", true);
        errorDialog.setContentPane(optionPane);

        optionPane.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
                String prop = e.getPropertyName();

                if (errorDialog.isVisible() && (e.getSource() == optionPane)
                        && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                    errorDialog.dispose();
                }
            }
        });

        errorDialog.toFront();
        errorDialog.pack();
        errorDialog.setLocationRelativeTo(viewer);
        errorDialog.setVisible(true);
    }

    if (candidatesFormatException) {
        viewer.candidateErrorsCollected(viewer);
        candidatesFormatException = false;
    }

    if (spw == null) {
        addEnabled(true);
        containers.clear();
        return; // Invalid containers.
    }

    if (getOMEROMetadataStoreClient() != null && spw.booleanValue()) {
        addEnabled(true);
        SPWDialog dialog = new SPWDialog(config, viewer, "Screen Import", true, getOMEROMetadataStoreClient());
        if (dialog.cancelled == true || dialog.screen == null)
            return;
        for (ImportContainer ic : containers) {
            ic.setTarget(dialog.screen);
            String title = dialog.screen.getName().getValue();
            addFileToQueue(ic, title, false, 0);
        }

        qTable.centerOnRow(qTable.getQueue().getRowCount() - 1);
        qTable.importBtn.requestFocus();

    } else if (getOMEROMetadataStoreClient() != null) {
        addEnabled(true);
        ImportDialog dialog = new ImportDialog(config, viewer, "Image Import", true,
                getOMEROMetadataStoreClient());
        if (dialog.cancelled == true || dialog.dataset == null)
            return;

        Double[] pixelSizes = new Double[] { dialog.pixelSizeX, dialog.pixelSizeY, dialog.pixelSizeZ };
        Boolean useFullPath = config.useFullPath.get();
        if (dialog.useCustomNamingChkBox.isSelected() == false)
            useFullPath = null; //use the default bio-formats naming

        for (ImportContainer ic : containers) {
            ic.setTarget(dialog.dataset);
            ic.setUserPixels(pixelSizes);
            ic.setArchive(dialog.archiveImage.isSelected());
            String title = "";
            if (dialog.project.getId() != null) {
                ic.setProjectID(dialog.project.getId().getValue());
                title = dialog.project.getName().getValue() + " / " + dialog.dataset.getName().getValue();
            } else {
                title = "none / " + dialog.dataset.getName().getValue();
            }

            addFileToQueue(ic, title, useFullPath, config.numOfDirectories.get());
        }

        qTable.centerOnRow(qTable.getQueue().getRowCount() - 1);
        qTable.importBtn.requestFocus();
    } else {
        addEnabled(true);
        JOptionPane.showMessageDialog(viewer,
                "Due to an error the application is unable to \n"
                        + "retrieve an OMEROMetadataStore and cannot continue."
                        + "The most likely cause for this error is that you"
                        + "are not logged in. Please try to login again.");
    }
}

From source file:org.usfirst.frc.team2084.neuralnetwork.HeadingNeuralNetworkTrainer.java

private void trainNetwork() {
    if (!training) {

        // Set training flag and disable button
        training = true;//from   w  w  w .ja  v  a  2s  . c om
        trainButton.setEnabled(false);

        final ProgressMonitor progressMonitor = new ProgressMonitor(frame, "Training Network...", "", 0, 100);
        progressMonitor.setMillisToDecideToPopup(100);
        progressMonitor.setMillisToPopup(400);

        @SuppressWarnings("unchecked")
        final ArrayList<XYDataItem> data = new ArrayList<>(outputGraphDataSeries.getItems());

        final int maxProgress = iterations * data.size();

        final SwingWorker<Void, Void> trainingWorker = new SwingWorker<Void, Void>() {

            @Override
            protected Void doInBackground() throws Exception {
                // Reset the neural network to default values
                synchronized (this) {
                    network.reset();
                    network.setEta(eta);
                    network.setMomentum(momentum);
                }

                outer: for (int j = 0; j < iterations; j++) {
                    for (int i = 0; i < data.size(); i++) {
                        if (!isCancelled()) {
                            XYDataItem d = data.get(i);
                            double error = convertAngleToInput(d.getXValue());
                            double output = d.getYValue();
                            synchronized (this) {
                                network.feedForward(error);
                                network.backPropagation(output);
                            }
                            int jl = j;
                            int il = i;
                            int progress = (int) (((float) (data.size() * jl + il + 1) / maxProgress) * 100);
                            setProgress(progress);
                        } else {
                            break outer;
                        }
                    }
                }

                displayNetwork();
                return null;
            }

            @Override
            protected void done() {
                training = false;
                trainButton.setEnabled(true);
                progressMonitor.close();
            }
        };
        trainingWorker.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("progress")) {
                    progressMonitor.setProgress((int) evt.getNewValue());
                }
                if (progressMonitor.isCanceled()) {
                    trainingWorker.cancel(true);
                }
            }
        });
        trainingWorker.execute();
    }
}

From source file:org.openconcerto.erp.core.sales.credit.component.AvoirClientSQLComponent.java

public void addViews() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();
    textNumero = new JUniqueTextField(16);
    // Champ Module
    c.gridx = 0;//from   w  ww.ja va2 s.  com
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    this.textNom = new JTextField();
    this.date = new JDate(true);

    this.date.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            fireValidChange();

        }
    });

    // Ligne 1: Numero
    this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    c.gridx++;

    DefaultGridBagConstraints.lockMinimumSize(textNumero);
    this.add(this.textNumero, c);

    // Date
    c.gridx++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel("Date", SwingConstants.RIGHT), c);
    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    this.add(this.date, c);

    // Ligne 2: Libell
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c);
    c.gridx++;
    // c.weightx = 1;
    this.add(this.textNom, c);

    // Commercial
    c.gridx++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    this.comboCommercial = new ElementComboBox();
    this.comboCommercial.setMinimumSize(this.comboCommercial.getPreferredSize());
    this.add(new JLabel(getLabelFor("ID_COMMERCIAL"), SwingConstants.RIGHT), c);
    c.gridx++;
    // c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    this.add(this.comboCommercial, c);

    this.addSQLObject(this.comboCommercial, "ID_COMMERCIAL");

    // Ligne 3: Motif
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    this.add(new JLabel(getLabelFor("MOTIF"), SwingConstants.RIGHT), c);
    c.gridx++;
    c.gridwidth = 3;
    // c.weightx = 1;

    JTextField textMotif = new JTextField();
    this.add(textMotif, c);

    // Client
    c.gridx = 0;
    c.gridy++;
    // c.weightx = 0;
    c.gridwidth = 1;
    this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c);
    c.gridx++;
    c.gridwidth = 3;
    // c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    this.add(this.comboClient, c);
    // Adresse spe
    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    // c.weightx = 0;
    c.gridwidth = 1;
    this.add(new JLabel(getLabelFor("ID_ADRESSE"), SwingConstants.RIGHT), c);

    c.gridx++;
    c.gridwidth = 3;
    // c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    this.add(this.comboAdresse, c);
    final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration
            .getInstance());

    // Contact
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    // c.weightx = 0;
    final JLabel labelContact = new JLabel(getLabelFor("ID_CONTACT"), SwingConstants.RIGHT);
    this.add(labelContact, c);

    c.gridx++;
    c.gridwidth = 3;
    // c.weightx = 1;
    c.fill = GridBagConstraints.NONE;

    this.add(selectContact, c);
    final SQLElement contactElement = getElement().getForeignElement("ID_CONTACT");
    selectContact.init(contactElement, contactElement.getComboRequest(true));
    this.addView(selectContact, "ID_CONTACT");
    this.defaultContactRowValues = new SQLRowValues(selectContact.getRequest().getPrimaryTable());
    selectContact.getAddComp().setDefaults(this.defaultContactRowValues);

    // Compte Service
    this.checkCompteServiceAuto = new JCheckBox(getLabelFor("COMPTE_SERVICE_AUTO"));
    this.addSQLObject(this.checkCompteServiceAuto, "COMPTE_SERVICE_AUTO");
    this.compteSelService = new ISQLCompteSelector();

    this.labelCompteServ = new JLabel("Compte Service");
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 1;
    // c.weightx = 0;
    this.labelCompteServ.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(this.labelCompteServ, c);

    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    // c.weightx = 1;
    this.add(this.compteSelService, c);

    this.addRequiredSQLObject(this.compteSelService, "ID_COMPTE_PCE_SERVICE");

    String valServ = DefaultNXProps.getInstance().getStringProperty("ArticleService");
    Boolean bServ = Boolean.valueOf(valServ);
    if (!bServ) {
        this.labelCompteServ.setVisible(false);
        this.compteSelService.setVisible(false);
    }

    this.checkCompteServiceAuto.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setCompteServiceVisible(!AvoirClientSQLComponent.this.checkCompteServiceAuto.isSelected());
        }
    });

    // setCompteServiceVisible(!(bServ != null && !bServ.booleanValue()));

    // Tarif
    if (this.getTable().getFieldsName().contains("ID_TARIF")) {
        // TARIF
        c.gridy++;
        c.gridx = 0;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        this.add(new JLabel("Tarif  appliquer", SwingConstants.RIGHT), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;

        c.weightx = 1;
        this.add(boxTarif, c);
        this.addView(boxTarif, "ID_TARIF");
        boxTarif.addValueListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                table.setTarif(boxTarif.getSelectedRow(), false);
            }
        });
    }

    // Table
    this.table = new AvoirItemTable();
    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.BOTH;
    c.gridheight = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weighty = 1;
    // c.weightx = 0;
    this.add(this.table, c);
    this.addView(this.table.getRowValuesTable(), "");

    // Panel du bas
    final JPanel panelBottom = getBottomPanel();
    c.gridy++;
    c.weighty = 0;
    this.add(panelBottom, c);

    // Infos

    c.gridheight = 1;
    c.gridx = 0;
    c.gridy++;
    this.add(new JLabel(getLabelFor("INFOS")), c);

    c.gridy++;
    c.fill = GridBagConstraints.BOTH;
    c.weighty = 0;
    c.gridwidth = 4;
    ITextArea infos = new ITextArea(4, 4);
    infos.setBorder(null);
    JScrollPane scrollPane = new JScrollPane(infos);
    DefaultGridBagConstraints.lockMinimumSize(scrollPane);
    this.add(scrollPane, c);

    //
    // Impression
    this.panelGestDoc = new PanelOOSQLComponent(this);
    c.fill = GridBagConstraints.NONE;
    c.gridy++;
    c.anchor = GridBagConstraints.EAST;
    this.add(panelGestDoc, c);

    this.addSQLObject(this.textNom, "NOM");
    if (getTable().contains("INFOS")) {
        this.addSQLObject(infos, "INFOS");
    }
    this.addSQLObject(this.boxAdeduire, "A_DEDUIRE");
    this.addSQLObject(textMotif, "MOTIF");
    this.addSQLObject(this.comboAdresse, "ID_ADRESSE");

    this.addRequiredSQLObject(this.textNumero, "NUMERO");
    this.addRequiredSQLObject(this.date, "DATE");
    this.addRequiredSQLObject(this.comboClient, "ID_CLIENT");

    this.boxAdeduire.addActionListener(this);

    this.comboClient.addModelListener("wantedID", this.listenerModeReglDefaut);
    this.comboClient.addModelListener("wantedID", this.changeClientListener);
    DefaultGridBagConstraints.lockMinimumSize(comboClient);
    DefaultGridBagConstraints.lockMinimumSize(this.comboAdresse);
    DefaultGridBagConstraints.lockMinimumSize(this.comboBanque);
    DefaultGridBagConstraints.lockMinimumSize(comboCommercial);

}

From source file:org.ngrinder.recorder.Recorder.java

/**
 * Initialize global message handlers.//from  w w w . j a v  a  2s. co m
 * 
 * @param tabbedPane
 *            tabbedPane
 */
protected void initMessageHandler(final TabbedPane tabbedPane) {
    final File home = recorderConfig.getHome().getDirectory();
    final MessageBus messageBusInstance = MessageBus.getInstance();
    MessageBusConnection connect = messageBusInstance.connect();
    connect.subscribe(Topics.HOME, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            Browser browser = cast(evt.getSource());
            browser.navigate(toURL(tempFile).toString());
        }
    });
    connect.subscribe(Topics.APPLICATION_CLOSE, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            proxy.stopProxy();
            frame.setExtendedState(Frame.NORMAL);
            File frameInfoFile = recorderConfig.getHome().getFile("last_frame");
            try {
                Pair<Dimension, Point> pair = Pair.of(frame.getSize(), frame.getLocation());
                String frameInfo = gson.toJson(pair);
                FileUtils.writeStringToFile(frameInfoFile, frameInfo);
            } catch (Exception e) {
                LOGGER.error("Failed to save the frame info", e);
            }

            messageBusInstance.getPublisher(Topics.PREPARE_TO_CLOSE)
                    .propertyChange(new PropertyChangeEvent(this, "PREPARE_TO_CLOSE", null, home));

            tabbedPane.disposeAllTabs();
            frame.setVisible(false);
            frame.dispose();

            System.exit(0);
        }
    });
    connect.subscribe(Topics.WINDOW_MAXIMIZE, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (frame.getExtendedState() == Frame.MAXIMIZED_BOTH) {
                frame.setExtendedState(Frame.NORMAL);
            } else {
                frame.setExtendedState(Frame.MAXIMIZED_BOTH);
            }
        }
    });

    connect.subscribe(Topics.WINDOW_MINIMIZE, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (frame.getExtendedState() == Frame.ICONIFIED) {
                frame.setExtendedState(Frame.NORMAL);
            } else {
                frame.setExtendedState(Frame.ICONIFIED);
            }
        }
    });

    connect.subscribe(Topics.SHOW_ABOUT_DIALOG, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            AboutDialog dialog = AboutDialog.getInstance(frame, recorderConfig);
            dialog.setVisible(true);
        }
    });
}

From source file:org.tinymediamanager.ui.MainWindow.java

private void checkForUpdate() {
    try {/*from w w w  .  ja v  a2  s.c  om*/
        final UpdaterTask updateWorker = new UpdaterTask();

        updateWorker.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if ("state".equals(evt.getPropertyName()) && evt.getNewValue() == StateValue.DONE) {
                    try {
                        boolean update = updateWorker.get();
                        LOGGER.debug("update result was: " + update);
                        if (update) {

                            // we might need this somewhen...
                            if (updateWorker.isForcedUpdate()) {
                                LOGGER.info("Updating (forced)...");
                                closeTmmAndStart(Utils.getPBforTMMupdate());
                                return;
                            }

                            // show whatsnewdialog with the option to update
                            if (StringUtils.isNotBlank(updateWorker.getChangelog())) {
                                UpdateDialog dialog = new UpdateDialog(updateWorker.getChangelog());
                                dialog.setVisible(true);
                            } else {
                                // do the update without changelog popup

                                int answer = JOptionPane.showConfirmDialog(null,
                                        BUNDLE.getString("tmm.update.message"),
                                        BUNDLE.getString("tmm.update.title"), JOptionPane.YES_NO_OPTION);
                                if (answer == JOptionPane.OK_OPTION) {
                                    LOGGER.info("Updating...");

                                    // spawn getdown and exit TMM
                                    closeTmmAndStart(Utils.getPBforTMMupdate());
                                }
                            }
                        }
                    } catch (Exception e) {
                        LOGGER.error("Update task failed!" + e.getMessage());
                    }
                }
            }
        });

        // update task start a few secs after GUI...
        Timer timer = new Timer(5000, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                updateWorker.execute();
            }
        });
        timer.setRepeats(false);
        timer.start();
    } catch (Exception e) {
        LOGGER.error("Update task failed!" + e.getMessage());
    }
}