Example usage for javax.swing JOptionPane showInputDialog

List of usage examples for javax.swing JOptionPane showInputDialog

Introduction

In this page you can find the example usage for javax.swing JOptionPane showInputDialog.

Prototype

public static String showInputDialog(Component parentComponent, Object message) throws HeadlessException 

Source Link

Document

Shows a question-message dialog requesting input from the user parented to parentComponent.

Usage

From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Creates dialogs in which the user can change the percentages of
 * process instances to be counted as fast-slow-normal baed on their
 * throughput time./*from w  w  w. j a v a  2s . co  m*/
 * It also adjusts the process metrics to these percentages.
 */
private void changeProcessPercentages() {
    //Create a dialog in which the user can fill in the percentage of
    //cases that is to be counted as 'fast'
    String perc = JOptionPane.showInputDialog(this,
            "Enter the percentage of cases that is to be" + " counted as 'fast': ");
    if (perc != null) {
        try {
            fastestProcessPercentage = Double.parseDouble(perc);
            if (fastestProcessPercentage < 0 || fastestProcessPercentage > 100) {
                fastestProcessPercentage = 0;
            }
        } catch (Exception e) {
            Message.add("Exception: " + e.toString(), 2);
            fastestProcessPercentage = 0;
        }
        //Create a dialog in which the user can fill in the percentage of
        //cases that is to be counted as 'slow'
        String perc2 = JOptionPane.showInputDialog(this,
                "Enter the percentage of cases that is to be counted" + " as 'slow': ");
        if (perc2 != null) {
            //Cancel button was not pushed
            try {
                slowestProcessPercentage = Double.parseDouble(perc2);
                if (slowestProcessPercentage < 0 || slowestProcessPercentage > 100
                        || (slowestProcessPercentage + fastestProcessPercentage) > 100) {
                    slowestProcessPercentage = 0;
                }
            } catch (Exception e) {
                Message.add("Exception: " + e.toString(), 2);
                slowestProcessPercentage = 0;
            }
        }
        //display the process metrics (based on the selected instances)
        displayProcessMetrics(getSelectedInstances());
    }
}

From source file:org.sikuli.script.SikuliScript.java

public static String input(String msg, String preset) {
    return (String) JOptionPane.showInputDialog(msg, preset);
}

From source file:org.tinymediamanager.ui.settings.ExternalServicesSettingsPanel.java

public ExternalServicesSettingsPanel() {
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));
    {/*  w  w w  . jav  a 2s .  co m*/
        JPanel panelTrakttv = new JPanel();
        panelTrakttv.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.trakttv"),
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        add(panelTrakttv, "2, 2, fill, fill");
        panelTrakttv.setLayout(new FormLayout(
                new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                        FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(25dlu;default)"),
                        FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, }));

        final JLabel lblTraktStatus = new JLabel(""); //$NON-NLS-1$
        panelTrakttv.add(lblTraktStatus, "2, 2, 5, 1");

        JButton btnGetTraktPin = new JButton(BUNDLE.getString("Settings.trakt.getpin")); //$NON-NLS-1$
        panelTrakttv.add(btnGetTraktPin, "2, 4");

        JButton btnTestTraktConnection = new JButton(BUNDLE.getString("Settings.trakt.testconnection")); //$NON-NLS-1$
        panelTrakttv.add(btnTestTraktConnection, "4, 4");

        if (!Globals.isDonator()) {
            btnGetTraktPin.setEnabled(false);
            btnTestTraktConnection.setEnabled(false);

            String msg = "<html><body>" + BUNDLE.getString("tmm.donatorfunction.hint") + "</body></html>"; //$NON-NLS-1$
            JLabel lblTraktDonator = new JLabel(msg);
            lblTraktDonator.setForeground(Color.RED);
            panelTrakttv.add(lblTraktDonator, "2, 8, 3, 1, default, default");
        } else {
            if (StringUtils.isNoneBlank(Globals.settings.getTraktAccessToken(),
                    Globals.settings.getTraktRefreshToken())) {
                lblTraktStatus.setText(BUNDLE.getString("Settings.trakt.status.good")); //$NON-NLS-1$
            } else {
                lblTraktStatus.setText(BUNDLE.getString("Settings.trakt.status.bad")); //$NON-NLS-1$
            }
            btnGetTraktPin.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    // open the pin url in a browser
                    try {
                        TmmUIHelper.browseUrl("https://trakt.tv/pin/799");
                    } catch (Exception e1) {
                        // browser could not be opened, show a dialog box
                        JOptionPane.showMessageDialog(MainWindow.getFrame(),
                                BUNDLE.getString("Settings.trakt.getpin.fallback"), //$NON-NLS-1$
                                BUNDLE.getString("Settings.trakt.getpin"), JOptionPane.INFORMATION_MESSAGE);
                    }

                    // let the user insert the pin
                    String pin = JOptionPane.showInputDialog(MainWindow.getFrame(),
                            BUNDLE.getString("Settings.trakt.getpin.entercode")); //$NON-NLS-1$

                    // try to get the tokens
                    String accessToken = "";
                    String refreshToken = "";
                    try {
                        Map<String, String> tokens = TraktTv.authenticateViaPin(pin);
                        accessToken = tokens.get("accessToken") == null ? "" : tokens.get("accessToken");
                        refreshToken = tokens.get("refreshToken") == null ? "" : tokens.get("refreshToken");
                    } catch (Exception e1) {
                    }

                    Globals.settings.setTraktAccessToken(accessToken);
                    Globals.settings.setTraktRefreshToken(refreshToken);

                    if (StringUtils.isNoneBlank(Globals.settings.getTraktAccessToken(),
                            Globals.settings.getTraktRefreshToken())) {
                        lblTraktStatus.setText(BUNDLE.getString("Settings.trakt.status.good")); //$NON-NLS-1$
                    } else {
                        JOptionPane.showMessageDialog(MainWindow.getFrame(),
                                BUNDLE.getString("Settings.trakt.getpin.problem"),
                                BUNDLE.getString("Settings.trakt.getpin"), JOptionPane.ERROR_MESSAGE);//$NON-NLS-1$
                        lblTraktStatus.setText(BUNDLE.getString("Settings.trakt.status.bad")); //$NON-NLS-1$
                    }
                }
            });
            btnTestTraktConnection.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        TraktTv.refreshAccessToken();
                        JOptionPane.showMessageDialog(MainWindow.getFrame(),
                                BUNDLE.getString("Settings.trakt.testconnection.good"),
                                BUNDLE.getString("Settings.trakt.testconnection"), JOptionPane.ERROR_MESSAGE);//$NON-NLS-1$
                    } catch (Exception e1) {
                        JOptionPane.showMessageDialog(MainWindow.getFrame(),
                                BUNDLE.getString("Settings.trakt.testconnection.bad"),
                                BUNDLE.getString("Settings.trakt.testconnection"), JOptionPane.ERROR_MESSAGE);//$NON-NLS-1$
                    }
                }
            });
        }
    }
    initDataBindings();

}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

private void alertIndicatorNew() {
    String projectName = null;/*from   w  w  w  .j a  v a2  s . co m*/

    while (true) {
        projectName = JOptionPane.showInputDialog(this,
                MessagesBundle.getString("info_message_enter_new_alert_indicator_name"));

        if (projectName == null) {
            return;
        }

        projectName = projectName.trim();

        if (projectName.length() == 0) {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_you_need_to_specific_alert_indicator_name"),
                    MessagesBundle.getString("warning_title_you_need_to_specific_alert_indicator_name"),
                    JOptionPane.WARNING_MESSAGE);
            continue;
        }

        if (this.alertIndicatorProjectManager.contains(projectName)) {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_already_an_alert_indicator_with_same_name"),
                    MessagesBundle.getString("warning_title_already_an_alert_indicator_with_same_name"),
                    JOptionPane.WARNING_MESSAGE);
            continue;
        }

        IndicatorDefaultDrawing newDrawing = (IndicatorDefaultDrawing) createDrawing();
        if (this.alertIndicatorProjectManager.addProject(newDrawing, projectName)) {
            this.syncJListWithIndicatorProjectManager(this.jList1, this.alertIndicatorProjectManager);
            // Select on the newly created project.
            this.jList1.setSelectedValue(projectName, true);
            return;
        } else {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_invalid_alert_indicator_name"),
                    MessagesBundle.getString("warning_title_invalid_alert_indicator_name"),
                    JOptionPane.WARNING_MESSAGE);
            continue;
        }
    }
}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

private void moduleIndicatorNew() {
    String projectName = null;//from   ww w. ja  v a 2  s .c  o  m

    while (true) {
        projectName = JOptionPane.showInputDialog(this,
                MessagesBundle.getString("info_message_enter_new_module_indicator_name"));

        if (projectName == null) {
            return;
        }

        projectName = projectName.trim();

        if (projectName.length() == 0) {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_you_need_to_specific_module_indicator_name"),
                    MessagesBundle.getString("warning_title_you_need_to_specific_module_indicator_name"),
                    JOptionPane.WARNING_MESSAGE);
            continue;
        }

        if (this.moduleIndicatorProjectManager.contains(projectName)) {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_already_a_module_indicator_with_same_name"),
                    MessagesBundle.getString("warning_title_already_a_module_indicator_with_same_name"),
                    JOptionPane.WARNING_MESSAGE);
            continue;
        }

        IndicatorDefaultDrawing newDrawing = (IndicatorDefaultDrawing) createDrawing();
        if (this.moduleIndicatorProjectManager.addProject(newDrawing, projectName)) {
            this.syncJListWithIndicatorProjectManager(this.jList2, this.moduleIndicatorProjectManager);
            // Select on the newly created project.
            this.jList2.setSelectedValue(projectName, true);
            return;
        } else {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_invalid_module_indicator_name"),
                    MessagesBundle.getString("warning_title_invalid_module_indicator_name"),
                    JOptionPane.WARNING_MESSAGE);
            continue;
        }
    }
}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

private void _alertIndicatorSave(String projectName, boolean selectProjectAfterSave) {
    if (projectName == null) {
        // No project name selection. Prompt user to enter new project name.
        while (true) {
            projectName = JOptionPane.showInputDialog(this,
                    MessagesBundle.getString("info_message_enter_save_alert_indicator_name"));

            if (projectName == null) {
                return;
            }/*ww w .j  a va  2s  .co  m*/

            projectName = projectName.trim();

            if (projectName.length() == 0) {
                JOptionPane.showMessageDialog(this,
                        MessagesBundle.getString("warning_message_you_need_to_specific_alert_indicator_name"),
                        MessagesBundle.getString("warning_title_you_need_to_specific_alert_indicator_name"),
                        JOptionPane.WARNING_MESSAGE);
                continue;
            }

            if (alertIndicatorProjectManager.contains(projectName)) {
                JOptionPane.showMessageDialog(this,
                        MessagesBundle.getString("warning_message_already_an_alert_indicator_with_same_name"),
                        MessagesBundle.getString("warning_title_already_an_alert_indicator_with_same_name"),
                        JOptionPane.WARNING_MESSAGE);
                continue;
            }

            IndicatorDefaultDrawing drawing = (IndicatorDefaultDrawing) view.getDrawing();

            if (this.alertIndicatorProjectManager.addProject(drawing, projectName)) {
                this.syncJListWithIndicatorProjectManager(this.jList1, this.alertIndicatorProjectManager);
                final String output = MessageFormat
                        .format(MessagesBundle.getString("info_message_file_saved_template"), projectName);
                JOptionPane.showMessageDialog(this, output, MessagesBundle.getString("info_title_file_saved"),
                        JOptionPane.INFORMATION_MESSAGE);
                if (selectProjectAfterSave) {
                    this.jList1.setSelectedValue(projectName, true);
                }
                return;
            } else {
                JOptionPane.showMessageDialog(this,
                        MessagesBundle.getString("warning_message_invalid_alert_indicator_name"),
                        MessagesBundle.getString("warning_title_invalid_alert_indicator_name"),
                        JOptionPane.WARNING_MESSAGE);
                continue;
            }
        }
    } else {
        // projectName is selected by user.
        final IndicatorDefaultDrawing drawing = (IndicatorDefaultDrawing) view.getDrawing();
        if (alertIndicatorProjectManager.addProject(drawing, projectName)) {
            // Just to ensure list cell renderer will be triggered.
            this.syncJListWithIndicatorProjectManager(this.jList1, this.alertIndicatorProjectManager);
            final String output = MessageFormat
                    .format(MessagesBundle.getString("info_message_file_saved_template"), projectName);
            JOptionPane.showMessageDialog(this, output, MessagesBundle.getString("info_title_file_saved"),
                    JOptionPane.INFORMATION_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_invalid_alert_indicator_name"),
                    MessagesBundle.getString("warning_title_invalid_alert_indicator_name"),
                    JOptionPane.WARNING_MESSAGE);
        }
    }
}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

private void _moduleIndicatorSave(String projectName, boolean selectProjectAfterSave) {
    if (projectName == null) {
        while (true) {
            projectName = JOptionPane.showInputDialog(this,
                    MessagesBundle.getString("info_message_enter_save_module_indicator_name"));

            if (projectName == null) {
                return;
            }/*from  w w w .  ja v a2 s .com*/

            projectName = projectName.trim();

            if (projectName.length() == 0) {
                JOptionPane.showMessageDialog(this,
                        MessagesBundle.getString("warning_message_you_need_to_specific_module_indicator_name"),
                        MessagesBundle.getString("warning_title_you_need_to_specific_module_indicator_name"),
                        JOptionPane.WARNING_MESSAGE);
                continue;
            }

            if (moduleIndicatorProjectManager.contains(projectName)) {
                JOptionPane.showMessageDialog(this,
                        MessagesBundle.getString("warning_message_already_a_module_indicator_with_same_name"),
                        MessagesBundle.getString("warning_title_already_a_module_indicator_with_same_name"),
                        JOptionPane.WARNING_MESSAGE);
                continue;
            }

            IndicatorDefaultDrawing drawing = (IndicatorDefaultDrawing) view.getDrawing();

            if (this.moduleIndicatorProjectManager.addProject(drawing, projectName)) {
                this.syncJListWithIndicatorProjectManager(this.jList2, this.moduleIndicatorProjectManager);
                final String output = MessageFormat
                        .format(MessagesBundle.getString("info_message_file_saved_template"), projectName);
                JOptionPane.showMessageDialog(this, output, MessagesBundle.getString("info_title_file_saved"),
                        JOptionPane.INFORMATION_MESSAGE);
                if (selectProjectAfterSave) {
                    this.jList2.setSelectedValue(projectName, true);
                }
                return;
            } else {
                JOptionPane.showMessageDialog(this,
                        MessagesBundle.getString("warning_message_invalid_module_indicator_name"),
                        MessagesBundle.getString("warning_title_invalid_module_indicator_name"),
                        JOptionPane.WARNING_MESSAGE);
                continue;
            }
        }
    } else {
        // projectName is selected by user.
        final IndicatorDefaultDrawing drawing = (IndicatorDefaultDrawing) view.getDrawing();
        if (this.moduleIndicatorProjectManager.addProject(drawing, projectName)) {
            // Just to ensure list cell renderer will be triggered.
            this.syncJListWithIndicatorProjectManager(this.jList2, this.moduleIndicatorProjectManager);
            final String output = MessageFormat
                    .format(MessagesBundle.getString("info_message_file_saved_template"), projectName);
            JOptionPane.showMessageDialog(this, output, MessagesBundle.getString("info_title_file_saved"),
                    JOptionPane.INFORMATION_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_invalid_module_indicator_name"),
                    MessagesBundle.getString("warning_title_invalid_module_indicator_name"),
                    JOptionPane.WARNING_MESSAGE);
        }
    }
}

From source file:pl.otros.logview.gui.LogViewPanel.java

public LogViewPanel(final LogDataTableModel dataTableModel, TableColumns[] visibleColumns,
        final OtrosApplication otrosApplication) {
    super();// w  w  w  .  j av a2s  .c  o m
    this.dataTableModel = dataTableModel;
    this.otrosApplication = otrosApplication;
    this.statusObserver = otrosApplication.getStatusObserver();
    configuration = otrosApplication.getConfiguration();

    AllPluginables allPluginable = AllPluginables.getInstance();
    markersContainer = allPluginable.getMarkersContainser();
    markersContainer.addListener(new MarkersMenuReloader());
    logFiltersContainer = allPluginable.getLogFiltersContainer();
    messageColorizersContainer = allPluginable.getMessageColorizers();
    messageFormattersContainer = allPluginable.getMessageFormatters();
    selectedMessageColorizersContainer = new PluginableElementsContainer<MessageColorizer>();
    selectedMessageFormattersContainer = new PluginableElementsContainer<MessageFormatter>();
    for (MessageColorizer messageColorizer : messageColorizersContainer.getElements()) {
        selectedMessageColorizersContainer.addElement(messageColorizer);
    }
    for (MessageFormatter messageFormatter : messageFormattersContainer.getElements()) {
        selectedMessageFormattersContainer.addElement(messageFormatter);
    }
    messageColorizersContainer.addListener(
            new SynchronizePluginableContainerListener<MessageColorizer>(selectedMessageColorizersContainer));
    messageFormattersContainer.addListener(
            new SynchronizePluginableContainerListener<MessageFormatter>(selectedMessageFormattersContainer));

    menuLabelFont = new JLabel().getFont().deriveFont(Font.BOLD);
    filtersPanel = new JPanel();
    logsTablePanel = new JPanel();
    logsMarkersPanel = new JPanel();
    leftPanel = new JPanel(new MigLayout());
    logDetailTextArea = new JTextPane();
    logDetailTextArea.setEditable(false);
    MouseAdapter locationInfo = new LocationClickMouseAdapter(otrosApplication, logDetailTextArea);
    logDetailTextArea.addMouseMotionListener(locationInfo);
    logDetailTextArea.addMouseListener(locationInfo);
    logDetailTextArea.setBorder(BorderFactory.createTitledBorder("Details"));
    logDetailWithRulerScrollPane = RulerBarHelper.wrapTextComponent(logDetailTextArea);
    table = new JTableWith2RowHighliting(dataTableModel);

    // Initialize default column visible before creating context menu
    table.setColumnControlVisible(true);
    final ColumnControlButton columnControlButton = new ColumnControlButton(table) {

        @Override
        public void togglePopup() {
            populatePopup();
            super.togglePopup();
        }

        @Override
        protected List<Action> getAdditionalActions() {
            final List<Action> additionalActions = super.getAdditionalActions();
            final AbstractAction saveLayout = new AbstractAction("Save current to new column layout",
                    Icons.DISK) {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {
                    String newLayoutName = JOptionPane.showInputDialog(table, "New Layout name");
                    if (newLayoutName == null) {
                        return;
                    }
                    newLayoutName = newLayoutName.trim();
                    LOGGER.info(String.format("Saving New column layout '%s'", newLayoutName));
                    ArrayList<String> visibleColNames = new ArrayList<String>();
                    for (TableColumn tc : table.getColumns()) {
                        Object o = tc.getIdentifier();
                        if (!(o instanceof TableColumns)) {
                            LOGGER.severe("TableColumn identifier of unexpected type: "
                                    + tc.getIdentifier().getClass().getName());
                            LOGGER.warning("Throw up a pop-up");
                            return;
                        }
                        TableColumns tcs = (TableColumns) o;
                        visibleColNames.add(tcs.getName());
                    }
                    ColumnLayout columnLayout = new ColumnLayout(newLayoutName, visibleColNames);
                    final List<ColumnLayout> columnLayouts = LogTableFormatConfigView
                            .loadColumnLayouts(configuration);
                    columnLayouts.add(columnLayout);
                    LogTableFormatConfigView.saveColumnLayouts(columnLayouts, configuration);
                    populatePopup();
                }
            };
            additionalActions.add(saveLayout);

            final List<ColumnLayout> columnLayoutNames = LogTableFormatConfigView
                    .loadColumnLayouts(configuration);
            for (final ColumnLayout columnLayout : columnLayoutNames) {
                final String name = columnLayout.getName();
                final AbstractAction applyColumnLayout = new ApplyColumnLayoutAction(name, Icons.EDIT_COLUMNS,
                        columnLayout, table);
                additionalActions.add(applyColumnLayout);
            }
            return additionalActions;
        }
    };
    table.setColumnControl(columnControlButton);

    List<TableColumn> columns = table.getColumns(true);
    for (int i = 0; i < columns.size(); i++) {
        columns.get(i).setIdentifier(TableColumns.getColumnById(i));
    }
    for (TableColumn tableColumn : columns) {
        table.getColumnExt(tableColumn.getIdentifier()).setVisible(false);
    }
    for (TableColumns tableColumns : visibleColumns) {
        table.getColumnExt(tableColumns).setVisible(true);
    }

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    updateColumnsSize();
    table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
    final Renderers renderers = Renderers.getInstance(otrosApplication);
    table.setDefaultRenderer(String.class, new TableMarkDecoratorRenderer(renderers.getStringRenderer()));
    table.setDefaultRenderer(Object.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Object.class)));
    table.setDefaultRenderer(Integer.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Object.class)));
    table.setDefaultRenderer(Level.class, new TableMarkDecoratorRenderer(renderers.getLevelRenderer()));
    table.setDefaultRenderer(Date.class, new TableMarkDecoratorRenderer(renderers.getDateRenderer()));
    final TimeDeltaRenderer timeDeltaRenderer = new TimeDeltaRenderer();
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent listSelectionEvent) {
            final int[] selectedRows = table.getSelectedRows();
            if (selectedRows.length > 0) {
                final int selectedRow = selectedRows[selectedRows.length - 1];
                final Date selectedDate = dataTableModel.getLogData(table.convertRowIndexToModel(selectedRow))
                        .getDate();
                timeDeltaRenderer.setSelectedTimestamp(selectedDate);
                table.repaint();
            }
        }
    });
    table.setDefaultRenderer(TimeDelta.class, new TableMarkDecoratorRenderer(timeDeltaRenderer));

    ((EventSource) configuration.getConfiguration()).addConfigurationListener(new ConfigurationListener() {
        @Override
        public void configurationChanged(ConfigurationEvent ce) {
            if (ce.getType() == AbstractConfiguration.EVENT_SET_PROPERTY && !ce.isBeforeUpdate()) {
                if (ce.getPropertyName().equals(ConfKeys.LOG_TABLE_FORMAT_DATE_FORMAT)) {
                    table.setDefaultRenderer(Date.class, new TableMarkDecoratorRenderer(new DateRenderer(
                            configuration.getString(ConfKeys.LOG_TABLE_FORMAT_DATE_FORMAT, "HH:mm:ss.SSS"))));
                    updateTimeColumnSize();
                } else if (ce.getPropertyName().equals(ConfKeys.LOG_TABLE_FORMAT_LEVEL_RENDERER)) {
                    table.setDefaultRenderer(Level.class,
                            new TableMarkDecoratorRenderer(new LevelRenderer(configuration.get(
                                    LevelRenderer.Mode.class, ConfKeys.LOG_TABLE_FORMAT_LEVEL_RENDERER,
                                    LevelRenderer.Mode.IconsOnly))));
                    updateLevelColumnSize();
                }
            }
        }
    });

    table.setDefaultRenderer(Boolean.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Boolean.class)));
    table.setDefaultRenderer(Note.class, new TableMarkDecoratorRenderer(new NoteRenderer()));
    table.setDefaultRenderer(MarkerColors.class, new TableMarkDecoratorRenderer(new MarkTableRenderer()));
    table.setDefaultEditor(Note.class, new NoteTableEditor());
    table.setDefaultEditor(MarkerColors.class, new MarkTableEditor(otrosApplication));
    table.setDefaultRenderer(ClassWrapper.class,
            new TableMarkDecoratorRenderer(renderers.getClassWrapperRenderer()));
    sorter = new TableRowSorter<LogDataTableModel>(dataTableModel);
    for (int i = 0; i < dataTableModel.getColumnCount(); i++) {
        sorter.setSortable(i, false);
    }
    sorter.setSortable(TableColumns.ID.getColumn(), true);
    sorter.setSortable(TableColumns.TIME.getColumn(), true);
    table.setRowSorter(sorter);

    messageDetailListener = new MessageDetailListener(this, dateFormat, selectedMessageFormattersContainer,
            selectedMessageColorizersContainer);
    table.getSelectionModel().addListSelectionListener(messageDetailListener);
    dataTableModel.addNoteObserver(messageDetailListener);

    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            boolean hasFocus = otrosApplication.getApplicationJFrame().isFocused();
            final boolean enabled = otrosApplication.getConfiguration()
                    .getBoolean(ConfKeys.JUMP_TO_CODE_AUTO_JUMP_ENABLED, false);
            if (hasFocus && enabled && !e.getValueIsAdjusting()) {
                try {
                    final LogData logData = dataTableModel
                            .getLogData(table.convertRowIndexToModel(e.getFirstIndex()));
                    LocationInfo li = new LocationInfo(logData.getClazz(), logData.getMethod(),
                            logData.getFile(), Integer.valueOf(logData.getLine()));
                    final JumpToCodeService jumpToCodeService = otrosApplication.getServices()
                            .getJumpToCodeService();
                    final boolean ideAvailable = jumpToCodeService.isIdeAvailable();
                    if (ideAvailable) {
                        LOGGER.fine("Jumping to " + li);
                        jumpToCodeService.jump(li);
                    }
                } catch (Exception e1) {
                    LOGGER.warning("Can't perform jump to code " + e1.getMessage());
                }

            }
        }
    });

    notes = new JTextArea();
    notes.setEditable(false);
    NoteObserver allNotesObserver = new AllNotesTextAreaObserver(notes);
    dataTableModel.addNoteObserver(allNotesObserver);

    addFiltersGUIsToPanel(filtersPanel);
    logsTablePanel.setLayout(new BorderLayout());
    logsTablePanel.add(new JScrollPane(table));
    JPanel messageDetailsPanel = new JPanel(new BorderLayout());
    messageDetailToolbar = new JToolBar("MessageDetail");
    messageDetailsPanel.add(messageDetailToolbar, BorderLayout.NORTH);
    messageDetailsPanel.add(logDetailWithRulerScrollPane);
    initMessageDetailsToolbar();

    jTabbedPane = new JTabbedPane();
    jTabbedPane.add("Message detail", messageDetailsPanel);
    jTabbedPane.add("All notes", new JScrollPane(notes));

    leftPanel.add(filtersPanel, "wrap, growx");
    leftPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "wrap,growx");
    leftPanel.add(logsMarkersPanel, "wrap,growx");

    JSplitPane splitPaneLogsTableAndDetails = new JSplitPane(JSplitPane.VERTICAL_SPLIT, logsTablePanel,
            jTabbedPane);
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftPanel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED),
            splitPaneLogsTableAndDetails);
    splitPane.setOneTouchExpandable(true);
    this.setLayout(new BorderLayout());
    this.add(splitPane);

    splitPaneLogsTableAndDetails.setDividerLocation(0.5d);
    splitPaneLogsTableAndDetails.setOneTouchExpandable(true);
    splitPane.setDividerLocation(leftPanel.getPreferredSize().width + 10);

    PopupListener popupListener = new PopupListener(new Callable<JPopupMenu>() {
        @Override
        public JPopupMenu call() throws Exception {
            return initTableContextMenu();
        }
    });
    table.addMouseListener(popupListener);
    table.addKeyListener(popupListener);

    PopupListener popupListenerMessageDetailMenu = new PopupListener(new Callable<JPopupMenu>() {
        @Override
        public JPopupMenu call() throws Exception {
            return initMessageDetailPopupMenu();
        }
    });
    logDetailTextArea.addMouseListener(popupListenerMessageDetailMenu);
    logDetailTextArea.addKeyListener(popupListenerMessageDetailMenu);

    dataTableModel.notifyAllNoteObservers(new NoteEvent(EventType.CLEAR, dataTableModel, null, 0));

    table.addKeyListener(new MarkRowBySpaceKeyListener(otrosApplication));
    initAcceptConditions();
}

From source file:proyectoftp.controlador.Controlador.java

private void tratarCrearDirectorio() {
    nombreDirectorio = JOptionPane.showInputDialog(vistaPrincipal, "Introduce el nombre del directrio.");
    if (nombreDirectorio != null) {
        nombreDirectorio = nombreDirectorio.trim();

        if (!nombreDirectorio.equals("")) {

            logeado = clienteFtp.conexion();

            try {

                clienteFtp.crearDirectorio(nombreDirectorio);

            } catch (IOException ex) {
                JOptionPane.showMessageDialog(vistaPrincipal,
                        "Error al crear la carpeta '" + nombreDirectorio + "'");
            }/*from w ww .  j  a  va  2s  .c om*/

            cargarListaDirectorioPrincipal();

        } else {
            JOptionPane.showMessageDialog(vistaPrincipal, "Error, no se puede crear el directrio.");
        }
    } else {
        JOptionPane.showMessageDialog(vistaPrincipal, "Error, se ha dejado el campo vacio.");
    }
}

From source file:pt.lsts.neptus.plugins.sunfish.IridiumComms.java

private void sendTextNote() {
    String note = JOptionPane.showInputDialog(getConsole(), I18n.text("Enter note to be published"));

    if (note == null || note.isEmpty())
        return;/*from   w  ww  .  j av  a2 s  .com*/

    LogBookEntry entry = new LogBookEntry();
    entry.setText(note);
    entry.setTimestampMillis(System.currentTimeMillis());
    entry.setSrc(ImcMsgManager.getManager().getLocalId().intValue());

    //(Component parentComponent, Object message, String title, int messageType, Icon icon,  Object[] selectionValues, Object initialSelectionValue)
    Object selection = JOptionPane.showInputDialog(getConsole(), "Please enter destination of this message",
            "Send Text Note", JOptionPane.QUESTION_MESSAGE, null, iridiumDestinations, "manta-1");
    if (selection == null)
        return;
    else if (selection.equals("broadcast"))
        entry.setDst(65535);
    else
        entry.setDst(IMCDefinition.getInstance().getResolver().resolve("" + selection));
    entry.setContext("Iridium logbook");
    ImcIridiumMessage msg = new ImcIridiumMessage();
    msg.setSource(ImcMsgManager.getManager().getLocalId().intValue());

    msg.setDestination(65535);
    msg.setMsg(entry);
    try {
        IridiumManager.getManager().send(msg);
        getConsole().post(Notification.success("Iridium message sent", "1 Iridium messages were sent using "
                + IridiumManager.getManager().getCurrentMessenger().getName()));
    } catch (Exception e) {
        GuiUtils.errorMessage(getConsole(), e);
    }
}