List of usage examples for javax.swing JOptionPane YES_NO_OPTION
int YES_NO_OPTION
To view the source code for javax.swing JOptionPane YES_NO_OPTION.
Click Source Link
showConfirmDialog
. From source file:userInteface.Patient.ManageVitalSignsJPanel.java
private void deleteVitalSignJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteVitalSignJButtonActionPerformed // TODO add your handling code here: int selectedRow = viewPatientsJTable.getSelectedRow(); if (selectedRow < 0) { JOptionPane.showMessageDialog(this, "Please select a row from table."); return;// w w w . ja v a2 s . c om } Person person = (Person) viewPatientsJTable.getValueAt(selectedRow, 0); Patient patient = person.getPatient(); if (patient == null) { JOptionPane.showMessageDialog(this, "Patient not created, Please create Patient first.", "Error", JOptionPane.ERROR_MESSAGE); return; } selectedRow = viewVitalSignsJTable.getSelectedRow(); if (selectedRow < 0) { JOptionPane.showMessageDialog(this, "Please select a row from table.", "Error", JOptionPane.INFORMATION_MESSAGE); return; } VitalSign vitalSign = (VitalSign) viewVitalSignsJTable.getValueAt(selectedRow, 0); int flag = JOptionPane.showConfirmDialog(this, "Are you sure want to remove?", "Warning", JOptionPane.YES_NO_OPTION); if (flag == 0) { patient.getVitalSignHistory().deleteVitalSign(vitalSign); refreshVialSigns(); } }
From source file:com.proyecto.vista.MantenimientoEmpleado.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = Controlador.ELIMINAR;//from ww w. java2 s .c o m if (tblempleado.getSelectedRow() != -1) { Integer codigo = tblempleado.getSelectedRow(); Empleado empleado = empleadoControlador.buscarPorId(lista.get(codigo).getDni()); if (empleado != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Empleado?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblempleado.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Empleado empleado2 = lista.get(filas[0]); lista.remove(empleado2); empleadoControlador.setSeleccionado(empleado2); empleadoControlador.accion(accion); } if (empleadoControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Empleado eliminado correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Empleado no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Empleado no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Empleado", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
private JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); JMenuItem mItem = null;/* ww w . j av a2 s.c om*/ String urlString; URL url; //============================================================================================ // File Menu //============================================================================================ JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); menuBar.add(fileMenu); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-new.png"; url = this.getClass().getResource(urlString); ImageIcon iconNew = new ImageIcon(url, "New"); mItem = new JMenuItem(new NewTextFileAction("New", iconNew)); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-open.png"; url = this.getClass().getResource(urlString); ImageIcon iconOpen = new ImageIcon(url, "Open"); mItem = new JMenuItem(new OpenFileAction("Open...", iconOpen, new Integer(KeyEvent.VK_A))); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save.png"; url = this.getClass().getResource(urlString); ImageIcon iconSave = new ImageIcon(url, "Save"); mItem = new JMenuItem(new SaveAction("Save", iconSave, new Integer(KeyEvent.VK_S))); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save-as.png"; url = this.getClass().getResource(urlString); ImageIcon iconSaveAs = new ImageIcon(url, "Save As"); mItem = new JMenuItem(new SaveAsAction("Save As...", iconSaveAs)); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/status/folder-visiting.png"; url = this.getClass().getResource(urlString); ImageIcon iconClose = new ImageIcon(url, "Close All Tabs"); mItem = new JMenuItem(new CloseAllTabsAction("Close All Tabs...", iconClose, new Integer(KeyEvent.VK_C))); fileMenu.add(mItem); fileMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-print.png"; url = this.getClass().getResource(urlString); ImageIcon iconPrint = new ImageIcon(url, "Print"); mItem = new JMenuItem(new PrintAction("Print...", iconPrint)); fileMenu.add(mItem); fileMenu.addSeparator(); // exit menu item urlString = "/org/tango-project/tango-icon-theme/16x16/actions/system-log-out.png"; url = this.getClass().getResource(urlString); ImageIcon iconExit = new ImageIcon(url, "Exit"); mItem = new JMenuItem(new ExitAction("Exit", iconExit)); fileMenu.add(mItem); //============================================================================================ // Edit Menu //============================================================================================ JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-cut.png"; url = this.getClass().getResource(urlString); ImageIcon iconCut = new ImageIcon(url, "Cut"); mItem = new JMenuItem(new DefaultEditorKit.CutAction()); mItem.setText("Cut"); mItem.setIcon(iconCut); mItem.setMnemonic(KeyEvent.VK_X); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-copy.png"; url = this.getClass().getResource(urlString); ImageIcon iconCopy = new ImageIcon(url, "Copy"); mItem = new JMenuItem(new DefaultEditorKit.CopyAction()); mItem.setText("Copy"); mItem.setIcon(iconCopy); mItem.setMnemonic(KeyEvent.VK_C); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-paste.png"; url = this.getClass().getResource(urlString); ImageIcon iconPaste = new ImageIcon(url, "Paste"); mItem = new JMenuItem(new DefaultEditorKit.PasteAction()); mItem.setText("Paste"); mItem.setIcon(iconPaste); mItem.setMnemonic(KeyEvent.VK_V); editMenu.add(mItem); editMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-undo.png"; url = this.getClass().getResource(urlString); ImageIcon iconUndo = new ImageIcon(url, "Undo"); mItem = new JMenuItem(new UndoAction("Undo", iconUndo, new Integer(KeyEvent.VK_Z))); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-redo.png"; url = this.getClass().getResource(urlString); ImageIcon iconRedo = new ImageIcon(url, "Redo"); mItem = new JMenuItem(new RedoAction("Redo", iconRedo, new Integer(KeyEvent.VK_Y))); editMenu.add(mItem); editMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/categories/preferences-system.png"; url = this.getClass().getResource(urlString); ImageIcon iconView = new ImageIcon(url, "Preferences"); mItem = new JMenuItem("Preferences"); mItem.setIcon(iconView); mItem.setToolTipText("Edit jMetrik preferences"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JmetrikPreferencesManager prefs = new JmetrikPreferencesManager(); prefs.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); prefs.addPropertyChangeListener(statusBar.getStatusListener()); JmetrikPreferencesDialog propDialog = new JmetrikPreferencesDialog(Jmetrik.this, prefs); // propDialog.loadPreferences(); propDialog.setVisible(true); } }); editMenu.setMnemonic('e'); editMenu.add(mItem); menuBar.add(editMenu); //============================================================================================ // Log Menu //============================================================================================ JMenu logMenu = new JMenu("Log"); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-properties.png"; url = this.getClass().getResource(urlString); ImageIcon iconLog = new ImageIcon(url, "View Log"); mItem = new JMenuItem(new ViewLogAction("View Log", iconLog)); logMenu.setMnemonic('l'); logMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/mimetypes/text-x-generic.png"; url = this.getClass().getResource(urlString); ImageIcon iconCommand = new ImageIcon(url, "Script Log"); mItem = new JMenuItem(new ViewScriptLogAction("Script Log", iconCommand)); logMenu.setMnemonic('c'); logMenu.add(mItem); menuBar.add(logMenu); //============================================================================================ // Manage Menu //============================================================================================ JMenu manageMenu = new JMenu("Manage"); manageMenu.setMnemonic('m'); mItem = new JMenuItem("New Database...");//create db mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NewDatabaseDialog newDatabaseDialog = new NewDatabaseDialog(Jmetrik.this); newDatabaseDialog.setVisible(true); if (newDatabaseDialog.canRun()) { if (workspace == null) { // workspace = new Workspace(workspaceTree, tabbedPane, dataTable, variableTable); workspace = new Workspace(workspaceList, tabbedPane, dataTable, variableTable); workspace.addPropertyChangeListener(statusBar.getStatusListener()); workspace.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); } workspace.runProcess(newDatabaseDialog.getCommand()); // workspace.createDatabase(newDatabaseDialog.getCommand()); } } }); manageMenu.add(mItem); mItem = new JMenuItem("Open Database..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OpenDatabaseDialog openDbDialog = new OpenDatabaseDialog(Jmetrik.this, "Open"); JList l = openDbDialog.getDatabaseList(); workspace.setDatabaseListModel(l); openDbDialog.setVisible(true); if (openDbDialog.canRun()) { openWorkspace(openDbDialog.getDatabaseName()); } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDelete = new ImageIcon(url, "Delete"); mItem = new JMenuItem("Delete Database..."); mItem.setIcon(iconDelete); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OpenDatabaseDialog selectDialog = new OpenDatabaseDialog(Jmetrik.this, "Delete"); JList l = selectDialog.getDatabaseList(); workspace.setDatabaseListModel(l); selectDialog.setVisible(true); if (selectDialog.canRun()) { int answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete " + selectDialog.getDatabaseName() + " and all of its contents? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.YES_OPTION) { DatabaseCommand command = new DatabaseCommand(); DatabaseName dbName = new DatabaseName(selectDialog.getDatabaseName()); command.getFreeOption("name").add(dbName.getName()); command.getSelectOneOption("action").setSelected("delete-db"); DatabaseName currentDb = workspace.getDatabaseName(); if (currentDb.getName().equals(dbName.getName())) { JOptionPane.showMessageDialog(Jmetrik.this, "You cannot delete the current database.\n" + "Close the database before attempting to delete it.", "Database Delete Error", JOptionPane.WARNING_MESSAGE); } else { workspace.runProcess(command); } } } } }); manageMenu.add(mItem); manageMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/apps/accessories-text-editor.png"; url = this.getClass().getResource(urlString); ImageIcon iconDesc = new ImageIcon(url, "Descriptions"); mItem = new JMenuItem("Table Descriptions..."); mItem.setIcon(iconDesc); mItem.addActionListener(new TableDescriptionActionListener()); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/list-add.png"; url = this.getClass().getResource(urlString); ImageIcon iconImport = new ImageIcon(url, "Import"); mItem = new JMenuItem("Import Data..."); mItem.setIcon(iconImport); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (workspace.databaseOpened()) { ImportDialog importDialog = new ImportDialog(Jmetrik.this, workspace.getDatabaseName(), importExportPath); importDialog.setVisible(true); if (importDialog.canRun()) { importExportPath = importDialog.getCurrentDirectory(); workspace.runProcess(importDialog.getCommand()); } } else { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before importing data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/format-indent-less.png"; url = this.getClass().getResource(urlString); ImageIcon iconExport = new ImageIcon(url, "Export"); mItem = new JMenuItem("Export Data..."); mItem.setIcon(iconExport); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (!workspace.databaseOpened()) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before exporting data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } else if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must select a table in the workspace list. \n " + "Select a table to continue the export.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else { ExportDataDialog exportDialog = new ExportDataDialog(Jmetrik.this, workspace.getDatabaseName(), tableName, importExportPath); if (exportDialog.canRun()) { importExportPath = exportDialog.getCurrentDirectory(); workspace.runProcess(exportDialog.getCommand()); } } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDeleteTable = new ImageIcon(url, "Delete"); mItem = new JMenuItem("Delete Table..."); mItem.setIcon(iconDeleteTable); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (workspace.databaseOpened()) { DeleteTableDialog deleteDialog = new DeleteTableDialog(Jmetrik.this, workspace.getDatabaseName(), (SortedListModel<DataTableName>) workspaceList.getModel()); deleteDialog.setVisible(true); if (deleteDialog.canRun()) { int nSelected = deleteDialog.getNumberOfSelectedTables(); int answer = JOptionPane.NO_OPTION; if (nSelected > 1) { answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete these " + nSelected + " tables? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } else { ArrayList<DataTableName> dList = deleteDialog.getSelectedTables(); answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete the table " + dList.get(0).getTableName() + "? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } if (answer == JOptionPane.YES_OPTION) { workspace.runProcess(deleteDialog.getCommand()); } } } else { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before deleting a table.", "No Open Database", JOptionPane.ERROR_MESSAGE); } } }); manageMenu.add(mItem); manageMenu.addSeparator(); SubsetCasesProcess subsetCasesProcess = new SubsetCasesProcess(); subsetCasesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList); SubsetVariablesProcess subsetVariablesProcess = new SubsetVariablesProcess(); subsetVariablesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDeleteVariables = new ImageIcon(url, "Delete Variables"); mItem = new JMenuItem("Delete Variables..."); mItem.setIcon(iconDeleteVariables); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (!workspace.databaseOpened()) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before subsetting data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } else if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must select a table in the workspace list. \n " + "Select a table to continue.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else if (workspace.tableOpen()) { DeleteVariableDialog deleteVariableDialog = new DeleteVariableDialog(Jmetrik.this, workspace.getDatabaseName(), workspace.getCurrentDataTable(), workspace.getVariables()); deleteVariableDialog.setVisible(true); if (deleteVariableDialog.canRun()) { int nSelected = deleteVariableDialog.getNumberOfSelectedVariables(); int answer = JOptionPane.NO_OPTION; if (nSelected > 1) { answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete these " + nSelected + " variables? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Variables", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } else { VariableAttributes v = deleteVariableDialog.getSelectedVariable(); answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete the variable " + v.getName().toString() + "? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } if (answer == JOptionPane.YES_OPTION) { workspace.runProcess(deleteVariableDialog.getCommand()); } } } } }); manageMenu.add(mItem); menuBar.add(manageMenu); //============================================================================================ // Transform Menu //============================================================================================ JMenu transformMenu = new JMenu("Transform"); transformMenu.setMnemonic('t'); BasicScoringProcess basicScoringProcess = new BasicScoringProcess(); basicScoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); ScoringProcess scoringProcess = new ScoringProcess(); scoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); transformMenu.addSeparator(); RankingProcess rankingProcess = new RankingProcess(); rankingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); TestScalingProcess testScalingProcess = new TestScalingProcess(); testScalingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); LinearTransformationProcess linearTransformationProcess = new LinearTransformationProcess(); linearTransformationProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); transformMenu.addSeparator(); IrtLinkingProcess irtLinkingProcess = new IrtLinkingProcess(); irtLinkingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); IrtEquatingProcess irtEquatingProcess = new IrtEquatingProcess(); irtEquatingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); menuBar.add(transformMenu); //============================================================================================ // Analyze Menu //============================================================================================ JMenu analyzeMenu = new JMenu("Analyze"); analyzeMenu.setMnemonic('a'); FrequencyProcess frequencyProcess = new FrequencyProcess(); frequencyProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); DescriptiveProcess descriptiveProcess = new DescriptiveProcess(); descriptiveProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); CorrelationProcess correlationProcess = new CorrelationProcess(); correlationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); analyzeMenu.addSeparator(); ItemAnalysisProcess itemAnalysisProcess = new ItemAnalysisProcess(); itemAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); CmhProcess cmhProcess = new CmhProcess(); cmhProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); analyzeMenu.addSeparator(); RaschAnalysisProcess raschAnalysisProcess = new RaschAnalysisProcess(); raschAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); IrtItemCalibrationProcess irtItemCalibrationProcess = new IrtItemCalibrationProcess(); irtItemCalibrationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); IrtPersonScoringProcess irtPersonScoringProcess = new IrtPersonScoringProcess(); irtPersonScoringProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); menuBar.add(analyzeMenu); //============================================================================================ // Graph Menu //============================================================================================ JMenu graphMenu = new JMenu("Graph"); graphMenu.setMnemonic('g'); BarChartProcess barchartProcess = new BarChartProcess(); barchartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); PieChartProcess piechartProcess = new PieChartProcess(); piechartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); graphMenu.addSeparator(); HistogramProcess histogramProcess = new HistogramProcess(); histogramProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); DensityProcess densityProcess = new DensityProcess(); densityProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); LineChartProcess lineChartProcess = new LineChartProcess(); lineChartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); ScatterplotProcess scatterplotProcess = new ScatterplotProcess(); scatterplotProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); graphMenu.addSeparator(); NonparametricCurveProcess nonparametricCurveProcess = new NonparametricCurveProcess(); nonparametricCurveProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); mItem = new JMenuItem("Irt Plot..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database and select a table. \n " + "Select a table to continue scoring.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else { if (irtPlotDialog == null && workspace.tableOpen()) { //Note that starting this dialog is different because variables //names must be obtained from the rows of a table. DatabaseAccessObject dao = workspace.getDatabaseFactory().getDatabaseAccessObject(); try { ArrayList<VariableAttributes> tempVar = dao.getVariableAttributesFromColumn( workspace.getConnection(), workspace.getCurrentDataTable(), new VariableName("name")); irtPlotDialog = new IrtPlotDialog(Jmetrik.this, workspace.getDatabaseName(), tableName, tempVar, (SortedListModel<DataTableName>) workspaceList.getModel()); } catch (SQLException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } } if (irtPlotDialog != null) irtPlotDialog.setVisible(true); } if (irtPlotDialog != null && irtPlotDialog.canRun()) { workspace.runProcess(irtPlotDialog.getCommand()); } } }); graphMenu.add(mItem); ItemMapProcess itemMapProcess = new ItemMapProcess(); itemMapProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); menuBar.add(graphMenu); //============================================================================================ // Command Menu //============================================================================================ JMenu commandMenu = new JMenu("Commands"); commandMenu.setMnemonic('c'); mItem = new JMenuItem("Run command"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JScrollPane pain = (JScrollPane) tabbedPane.getSelectedComponent(); JViewport vp = pain.getViewport(); Component c = vp.getComponent(0); if (c instanceof JmetrikTextFile) { JmetrikTab tempTab = (JmetrikTab) tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()); JmetrikTextFile textFile = (JmetrikTextFile) c; workspace.runFromSyntax(textFile.getText()); } } }); commandMenu.add(mItem); mItem = new JMenuItem("Stop command"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //add something } }); mItem.setEnabled(false); commandMenu.add(mItem); mItem = new JMenuItem("Command Reference..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //add something } }); mItem.setEnabled(false); commandMenu.add(mItem); menuBar.add(commandMenu); //============================================================================================ // Help Menu //============================================================================================ JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('h'); mItem = new JMenuItem("Quick Start Guide"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Desktop deskTop = Desktop.getDesktop(); try { URI uri = new URI("http://www.itemanalysis.com/quick-start-guide.php"); deskTop.browse(uri); } catch (URISyntaxException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } catch (IOException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } } }); helpMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/apps/help-browser.png"; url = this.getClass().getResource(urlString); ImageIcon iconAbout = new ImageIcon(url, "About"); mItem = new JMenuItem("About"); mItem.setIcon(iconAbout); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JmetrikAboutDialog aboutDialog = new JmetrikAboutDialog(Jmetrik.this, APP_NAME, VERSION, AUTHOR, RELEASE_DATE, COPYRIGHT_YEAR, BETA_VERSION); aboutDialog.setVisible(true); } }); helpMenu.add(mItem); menuBar.add(helpMenu); return menuBar; }
From source file:Main.Interface_Main.java
/** * Creates new form Interface_Main//from w w w . j a va2 s.c o m * Populates the com port combo box * Init the graphs for Current, Voltage, and Wattage */ public Interface_Main() { initComponents(); btnStop.setEnabled(false); btnStart.setEnabled(false); btnThreshold.setEnabled(false); sldScreen.setEnabled(false); btnReset.setEnabled(false); spnRefSpd.setEnabled(false); Image im = null; try { im = ImageIO.read(getClass().getResource("/faviconbot2edit.png")); setIconImage(im); } catch (IOException ex) { } //Version check to notify user and update title bar. Double newVer = checkVersion('A'); if (newVer > appVersion) { JOptionPane.showMessageDialog(this, "Update available! Visit: http://github.com/friedcircuits", "Update", JOptionPane.INFORMATION_MESSAGE); jlblVer.setVisible(false); appTitle = appTitle + " - New Version: " + newVer.toString(); jlblVer.setText(appTitle); } else { jlblVer.setText(appTitle); } cmbPort.removeAllItems(); ArrayList portNames = listPorts(); for (int i = 0; i < portNames.size(); i++) { cmbPort.addItem(portNames.get(i)); } cmbBaud.setSelectedIndex(7); this.seriesCurrent = new TimeSeries("Time1", Millisecond.class); this.seriesCurrentMax = new TimeSeries("Time", Millisecond.class); this.seriesCurrentMin = new TimeSeries("Time", Millisecond.class); final TimeSeriesCollection dataset = new TimeSeriesCollection(this.seriesCurrent); dataset.addSeries(seriesCurrentMax); dataset.addSeries(seriesCurrentMin); JFreeChart chart = createChartCurrent(dataset); ChartPanel chartPanel = new ChartPanel(chart); //chartPanel.setPreferredSize(new Dimension(100, 260)); //size according to my window chartPanel.setMouseWheelEnabled(true); plCurrent.add(chartPanel, BorderLayout.CENTER); plCurrent.validate(); this.seriesVolt = new TimeSeries("Time", Millisecond.class); this.seriesVoltMax = new TimeSeries("Time", Millisecond.class); this.seriesVoltMin = new TimeSeries("Time", Millisecond.class); final TimeSeriesCollection datasetVolt = new TimeSeriesCollection(this.seriesVolt); datasetVolt.addSeries(seriesVoltMax); datasetVolt.addSeries(seriesVoltMin); JFreeChart chartVolt = createChartVolt(datasetVolt); ChartPanel chartPanelVolt = new ChartPanel(chartVolt); //chartPanelVolt.setPreferredSize(new Dimension(400, 260)); //size according to my window chartPanelVolt.setMouseWheelEnabled(true); plVoltage.add(chartPanelVolt, BorderLayout.CENTER); plVoltage.validate(); this.seriesWatt = new TimeSeries("Time", Millisecond.class); final TimeSeriesCollection datasetWatt = new TimeSeriesCollection(this.seriesWatt); JFreeChart chartWatt = createChartWatt(datasetWatt); ChartPanel chartPanelWatt = new ChartPanel(chartWatt); //chartPanelWatt.setPreferredSize(new Dimension(400, 260)); //size according to my window chartPanelWatt.setMouseWheelEnabled(true); plWattage.add(chartPanelWatt, BorderLayout.CENTER); plWattage.validate(); this.seriesDm = new TimeSeries("Time", Millisecond.class); final TimeSeriesCollection datasetDm = new TimeSeriesCollection(this.seriesDm); JFreeChart chartDm = createChartDm(datasetDm); ChartPanel chartPanelDm = new ChartPanel(chartDm); //chartPanelWatt.setPreferredSize(new Dimension(400, 260)); //size according to my window chartPanelDm.setMouseWheelEnabled(true); plmWh.add(chartPanelDm, BorderLayout.CENTER); plmWh.validate(); this.seriesDp = new TimeSeries("Time", Millisecond.class); final TimeSeriesCollection datasetDp = new TimeSeriesCollection(this.seriesDp); JFreeChart chartDp = createChartDp(datasetDp); ChartPanel chartPanelDp = new ChartPanel(chartDp); //chartPanelWatt.setPreferredSize(new Dimension(400, 260)); //size according to my window chartPanelDp.setMouseWheelEnabled(true); plmAh.add(chartPanelDp, BorderLayout.CENTER); plmAh.validate(); if (cmbPort.getItemCount() > 0) { btnStart.setEnabled(true); lblStatus.setText("Select COM Port and Baud Rate."); } else lblStatus.setText("No serial port found."); System.out.println(cmbPort.getItemCount()); File f = new File(logTmpFile); if (f.exists()) { int reply = JOptionPane.showConfirmDialog(this, "Data temp file exists, resume? (No deletes file)", "Resume?", JOptionPane.YES_NO_OPTION); if (reply == JOptionPane.NO_OPTION) { try { f.delete(); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Unable to delete"); JOptionPane.showMessageDialog(this, e); } } } else { JOptionPane.showMessageDialog(this, "New session", "Session", JOptionPane.INFORMATION_MESSAGE); } System.out.println(f.getAbsolutePath()); }
From source file:jeplus.gui.EPlusEditorPanel.java
private void cmdLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdLoadActionPerformed // Confirm save before open another file if (this.isContentChanged()) { int ans = JOptionPane.showConfirmDialog(this, "The contents of " + CurrentFileName + " has been modified. Would you like to save the changes first?", "Confirm saving ...", JOptionPane.YES_NO_OPTION); if (ans == JOptionPane.YES_OPTION) { saveFileContent(this.CurrentFileName, rsTextArea.getText()); }/*from w w w. j a v a 2 s . c om*/ } // Select a file to open if (FC.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { CurrentFileName = FC.getSelectedFile().getPath(); String name = FC.getSelectedFile().getName(); // Open idf/imf file rsTextArea.setText(getFileContent(CurrentFileName)); setContentChanged(false); this.Title = name; notifyContentChange(false); } }
From source file:org.csa.rstb.dat.toolviews.HaAlphaPlotPanel.java
@Override protected boolean checkDataToClipboardCopy() { final int warnLimit = 2000; final int excelLimit = 65536; final int numNonEmptyBins = getNumNonEmptyBins(); if (numNonEmptyBins > warnLimit) { String excelNote = ""; if (numNonEmptyBins > excelLimit - 100) { excelNote = "Note that e.g., Microsoft Excel 2002 only supports a total of " + excelLimit + " rows in a sheet.\n"; /*I18N*/ }//from w ww. j a va2s . c o m final String message = MessageFormat.format("This scatter plot contains {0} non-empty bins.\n" + "For each bin, a text data row containing an x, y and z value will be created.\n" + "{1}\nPress ''Yes'' if you really want to copy this amount of data to the system clipboard.\n", numNonEmptyBins, excelNote); final int status = JOptionPane.showConfirmDialog(this, message, /*I18N*/ "Copy Data to Clipboard", /*I18N*/ JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (status != JOptionPane.YES_OPTION) { return false; } } return true; }
From source file:net.pms.newgui.NavigationShareTab.java
private void initSimpleComponents(CellConstraints cc) { // Thumbnail seeking position seekpos = new JTextField("" + configuration.getThumbnailSeekPos()); seekpos.addKeyListener(new KeyAdapter() { @Override/*w w w .ja v a 2 s .c o m*/ public void keyReleased(KeyEvent e) { try { int ab = Integer.parseInt(seekpos.getText()); configuration.setThumbnailSeekPos(ab); if (configuration.getUseCache()) { PMS.get().getDatabase().init(true); } } catch (NumberFormatException nfe) { LOGGER.debug("Could not parse thumbnail seek position from \"" + seekpos.getText() + "\""); } } }); if (configuration.isThumbnailGenerationEnabled()) { seekpos.setEnabled(true); } else { seekpos.setEnabled(false); } // Generate thumbnails thumbgenCheckBox = new JCheckBox(Messages.getString("NetworkTab.2"), configuration.isThumbnailGenerationEnabled()); thumbgenCheckBox.setContentAreaFilled(false); thumbgenCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setThumbnailGenerationEnabled((e.getStateChange() == ItemEvent.SELECTED)); seekpos.setEnabled(configuration.isThumbnailGenerationEnabled()); mplayer_thumb.setEnabled(configuration.isThumbnailGenerationEnabled()); } }); // Use MPlayer for video thumbnails mplayer_thumb = new JCheckBox(Messages.getString("FoldTab.14"), configuration.isUseMplayerForVideoThumbs()); mplayer_thumb.setToolTipText(Messages.getString("FoldTab.61")); mplayer_thumb.setContentAreaFilled(false); mplayer_thumb.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setUseMplayerForVideoThumbs((e.getStateChange() == ItemEvent.SELECTED)); } }); if (configuration.isThumbnailGenerationEnabled()) { mplayer_thumb.setEnabled(true); } else { mplayer_thumb.setEnabled(false); } // DVD ISO thumbnails dvdiso_thumb = new JCheckBox(Messages.getString("FoldTab.19"), configuration.isDvdIsoThumbnails()); dvdiso_thumb.setContentAreaFilled(false); dvdiso_thumb.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setDvdIsoThumbnails((e.getStateChange() == ItemEvent.SELECTED)); } }); // Image thumbnails image_thumb = new JCheckBox(Messages.getString("FoldTab.21"), configuration.getImageThumbnailsEnabled()); image_thumb.setContentAreaFilled(false); image_thumb.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setImageThumbnailsEnabled((e.getStateChange() == ItemEvent.SELECTED)); } }); // Audio thumbnails import final KeyedComboBoxModel<CoverSupplier, String> thumbKCBM = new KeyedComboBoxModel<>( new CoverSupplier[] { CoverSupplier.NONE, CoverSupplier.COVER_ART_ARCHIVE }, new String[] { Messages.getString("FoldTab.35"), Messages.getString("FoldTab.73") }); audiothumbnail = new JComboBox<>(thumbKCBM); audiothumbnail.setEditable(false); thumbKCBM.setSelectedKey(configuration.getAudioThumbnailMethod()); audiothumbnail.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setAudioThumbnailMethod(thumbKCBM.getSelectedKey()); LOGGER.info("Setting {} {}", Messages.getRootString("FoldTab.26"), thumbKCBM.getSelectedValue()); } } }); // Alternate video cover art folder defaultThumbFolder = new JTextField(configuration.getAlternateThumbFolder()); defaultThumbFolder.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { configuration.setAlternateThumbFolder(defaultThumbFolder.getText()); } }); // Alternate video cover art folder button select = new CustomJButton("..."); select.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser; try { chooser = new JFileChooser(); } catch (Exception ee) { chooser = new JFileChooser(new RestrictedFileSystemView()); } chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString("FoldTab.28")); if (returnVal == JFileChooser.APPROVE_OPTION) { defaultThumbFolder.setText(chooser.getSelectedFile().getAbsolutePath()); configuration.setAlternateThumbFolder(chooser.getSelectedFile().getAbsolutePath()); } } }); // Show Server Settings folder isShowFolderServerSettings = new JCheckBox(Messages.getString("FoldTab.ShowServerSettingsFolder"), configuration.isShowServerSettingsFolder()); isShowFolderServerSettings.setContentAreaFilled(false); isShowFolderServerSettings.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setShowServerSettingsFolder((e.getStateChange() == ItemEvent.SELECTED)); } }); // Show #--TRANSCODE--# folder isShowFolderTranscode = new JCheckBox(Messages.getString("FoldTab.ShowTranscodeFolder"), configuration.isShowTranscodeFolder()); isShowFolderTranscode.setContentAreaFilled(false); isShowFolderTranscode.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setShowTranscodeFolder((e.getStateChange() == ItemEvent.SELECTED)); } }); // Show Media Library folder isShowFolderMediaLibrary = new JCheckBox(Messages.getString("FoldTab.ShowMediaLibraryFolder"), configuration.isShowMediaLibraryFolder()); isShowFolderMediaLibrary.setContentAreaFilled(false); isShowFolderMediaLibrary.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setShowMediaLibraryFolder((e.getStateChange() == ItemEvent.SELECTED)); } }); // Browse compressed archives archive = new JCheckBox(Messages.getString("NetworkTab.1"), configuration.isArchiveBrowsing()); archive.setContentAreaFilled(false); archive.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setArchiveBrowsing(e.getStateChange() == ItemEvent.SELECTED); } }); // Enable the Media Library cacheenable = new JCheckBox(Messages.getString("NetworkTab.EnableMediaLibrary"), configuration.getUseCache()); cacheenable.setToolTipText(Messages.getString("FoldTab.ShowMediaLibraryFolderTooltip")); cacheenable.setContentAreaFilled(false); cacheenable.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setUseCache((e.getStateChange() == ItemEvent.SELECTED)); cachereset.setEnabled(configuration.getUseCache()); setScanLibraryEnabled(configuration.getUseCache()); } }); // Reset cache cachereset = new CustomJButton(Messages.getString("NetworkTab.EmptyMediaLibrary")); cachereset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int option = JOptionPane.showConfirmDialog(looksFrame, Messages.getString("NetworkTab.MediaLibraryEmptiedExceptFullyPlayed") + "\n" + Messages.getString("NetworkTab.19"), Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { PMS.get().getDatabase().init(true); } } }); cachereset.setEnabled(configuration.getUseCache()); // Hide file extensions hideextensions = new JCheckBox(Messages.getString("FoldTab.5"), configuration.isHideExtensions()); hideextensions.setContentAreaFilled(false); if (configuration.isPrettifyFilenames()) { hideextensions.setEnabled(false); } hideextensions.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setHideExtensions((e.getStateChange() == ItemEvent.SELECTED)); } }); // Hide transcoding engine names hideengines = new JCheckBox(Messages.getString("FoldTab.8"), configuration.isHideEngineNames()); hideengines.setToolTipText(Messages.getString("FoldTab.46")); hideengines.setContentAreaFilled(false); hideengines.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setHideEngineNames((e.getStateChange() == ItemEvent.SELECTED)); } }); // Hide empty folders hideemptyfolders = new JCheckBox(Messages.getString("FoldTab.31"), configuration.isHideEmptyFolders()); hideemptyfolders.setToolTipText(Messages.getString("FoldTab.59")); hideemptyfolders.setContentAreaFilled(false); hideemptyfolders.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setHideEmptyFolders((e.getStateChange() == ItemEvent.SELECTED)); } }); // Show iTunes library itunes = new JCheckBox(Messages.getString("FoldTab.30"), configuration.isShowItunesLibrary()); itunes.setToolTipText(Messages.getString("FoldTab.47")); itunes.setContentAreaFilled(false); if (!(Platform.isMac() || Platform.isWindows())) { itunes.setEnabled(false); } itunes.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setShowItunesLibrary((e.getStateChange() == ItemEvent.SELECTED)); } }); // Show iPhoto library iphoto = new JCheckBox(Messages.getString("FoldTab.29"), configuration.isShowIphotoLibrary()); iphoto.setContentAreaFilled(false); if (!Platform.isMac()) { iphoto.setEnabled(false); } iphoto.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setShowIphotoLibrary((e.getStateChange() == ItemEvent.SELECTED)); } }); // Show aperture library aperture = new JCheckBox(Messages.getString("FoldTab.34"), configuration.isShowApertureLibrary()); aperture.setContentAreaFilled(false); if (!Platform.isMac()) { aperture.setEnabled(false); } aperture.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setShowApertureLibrary((e.getStateChange() == ItemEvent.SELECTED)); } }); // File order final KeyedComboBoxModel<Integer, String> kcbm = new KeyedComboBoxModel<>( new Integer[] { UMSUtils.SORT_LOC_SENS, // alphabetical UMSUtils.SORT_LOC_NAT, // natural sort UMSUtils.SORT_INS_ASCII, // ASCIIbetical UMSUtils.SORT_MOD_NEW, // newest first UMSUtils.SORT_MOD_OLD, // oldest first UMSUtils.SORT_RANDOM, // random UMSUtils.SORT_NO_SORT // no sorting }, new String[] { Messages.getString("FoldTab.15"), Messages.getString("FoldTab.22"), Messages.getString("FoldTab.20"), Messages.getString("FoldTab.16"), Messages.getString("FoldTab.17"), Messages.getString("FoldTab.58"), Messages.getString("FoldTab.62") }); sortmethod = new JComboBox<>(kcbm); sortmethod.setEditable(false); kcbm.setSelectedKey(configuration.getSortMethod(null)); sortmethod.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setSortMethod(kcbm.getSelectedKey()); LOGGER.info("Setting {} {}", Messages.getRootString("FoldTab.18"), kcbm.getSelectedValue()); } } }); // Ignore the word "the" while sorting ignorethewordthe = new JCheckBox(Messages.getString("FoldTab.39"), configuration.isIgnoreTheWordAandThe()); ignorethewordthe.setToolTipText(Messages.getString("FoldTab.44")); ignorethewordthe.setContentAreaFilled(false); ignorethewordthe.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setIgnoreTheWordAandThe((e.getStateChange() == ItemEvent.SELECTED)); } }); atzLimit = new JTextField("" + configuration.getATZLimit()); atzLimit.setToolTipText(Messages.getString("FoldTab.49")); atzLimit.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { try { int ab = Integer.parseInt(atzLimit.getText()); configuration.setATZLimit(ab); } catch (NumberFormatException nfe) { LOGGER.debug("Could not parse ATZ limit from \"" + atzLimit.getText() + "\""); LOGGER.debug("The full error was: " + nfe); } } }); isShowFolderLiveSubtitles = new JCheckBox(Messages.getString("FoldTab.ShowLiveSubtitlesFolder"), configuration.isShowLiveSubtitlesFolder()); isShowFolderLiveSubtitles.setContentAreaFilled(false); isShowFolderLiveSubtitles.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setShowLiveSubtitlesFolder((e.getStateChange() == ItemEvent.SELECTED)); } }); prettifyfilenames = new JCheckBox(Messages.getString("FoldTab.43"), configuration.isPrettifyFilenames()); prettifyfilenames.setToolTipText(Messages.getString("FoldTab.45")); prettifyfilenames.setContentAreaFilled(false); prettifyfilenames.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setPrettifyFilenames((e.getStateChange() == ItemEvent.SELECTED)); hideextensions.setEnabled((e.getStateChange() != ItemEvent.SELECTED)); episodeTitles.setEnabled((e.getStateChange() == ItemEvent.SELECTED)); } }); episodeTitles = new JCheckBox(Messages.getString("FoldTab.74"), configuration.isUseInfoFromIMDb()); episodeTitles.setToolTipText(Messages.getString("FoldTab.64")); episodeTitles.setContentAreaFilled(false); if (!configuration.isPrettifyFilenames()) { episodeTitles.setEnabled(false); } episodeTitles.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setUseInfoFromIMDb((e.getStateChange() == ItemEvent.SELECTED)); } }); isShowFolderNewMedia = new JCheckBox(Messages.getString("FoldTab.ShowNewMediaFolder"), configuration.isShowNewMediaFolder()); isShowFolderNewMedia.setToolTipText(Messages.getString("FoldTab.66")); isShowFolderNewMedia.setContentAreaFilled(false); isShowFolderNewMedia.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setShowNewMediaFolder((e.getStateChange() == ItemEvent.SELECTED)); } }); resume = new JCheckBox(Messages.getString("NetworkTab.68"), configuration.isResumeEnabled()); resume.setToolTipText(Messages.getString("NetworkTab.69")); resume.setContentAreaFilled(false); resume.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setResume((e.getStateChange() == ItemEvent.SELECTED)); } }); isShowFolderRecentlyPlayed = new JCheckBox(Messages.getString("FoldTab.ShowRecentlyPlayedFolder"), configuration.isShowRecentlyPlayedFolder()); isShowFolderRecentlyPlayed.setContentAreaFilled(false); isShowFolderRecentlyPlayed.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setShowRecentlyPlayedFolder((e.getStateChange() == ItemEvent.SELECTED)); } }); // Fully played action final KeyedComboBoxModel<FullyPlayedAction, String> fullyPlayedActionModel = new KeyedComboBoxModel<>( new FullyPlayedAction[] { FullyPlayedAction.NO_ACTION, FullyPlayedAction.MARK, FullyPlayedAction.HIDE_VIDEO, FullyPlayedAction.MOVE_FOLDER, FullyPlayedAction.MOVE_TRASH }, new String[] { Messages.getString("FoldTab.67"), Messages.getString("FoldTab.68"), Messages.getString("FoldTab.69"), Messages.getString("FoldTab.70"), Messages.getString("FoldTab.71") }); fullyPlayedAction = new JComboBox<>(fullyPlayedActionModel); fullyPlayedAction.setEditable(false); fullyPlayedActionModel.setSelectedKey(configuration.getFullyPlayedAction()); fullyPlayedAction.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setFullyPlayedAction(fullyPlayedActionModel.getSelectedKey()); fullyPlayedOutputDirectory .setEnabled(fullyPlayedActionModel.getSelectedKey() == FullyPlayedAction.MOVE_FOLDER); selectFullyPlayedOutputDirectory .setEnabled(fullyPlayedActionModel.getSelectedKey() == FullyPlayedAction.MOVE_FOLDER); if (configuration.getUseCache() && fullyPlayedActionModel.getSelectedKey() == FullyPlayedAction.NO_ACTION) { PMS.get().getDatabase().init(true); } } } }); // Watched video output directory fullyPlayedOutputDirectory = new JTextField(configuration.getFullyPlayedOutputDirectory()); fullyPlayedOutputDirectory.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { configuration.setFullyPlayedOutputDirectory(fullyPlayedOutputDirectory.getText()); } }); fullyPlayedOutputDirectory .setEnabled(configuration.getFullyPlayedAction() == FullyPlayedAction.MOVE_FOLDER); // Watched video output directory selection button selectFullyPlayedOutputDirectory = new CustomJButton("..."); selectFullyPlayedOutputDirectory.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser; try { chooser = new JFileChooser(); } catch (Exception ee) { chooser = new JFileChooser(new RestrictedFileSystemView()); } chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString("FoldTab.28")); if (returnVal == JFileChooser.APPROVE_OPTION) { fullyPlayedOutputDirectory.setText(chooser.getSelectedFile().getAbsolutePath()); configuration.setFullyPlayedOutputDirectory(chooser.getSelectedFile().getAbsolutePath()); } } }); selectFullyPlayedOutputDirectory .setEnabled(configuration.getFullyPlayedAction() == FullyPlayedAction.MOVE_FOLDER); }
From source file:AltiConsole.AltiConsoleMainScreen.java
/** * Starting point for the altimeter console application. * /*www. j a v a2s. co m*/ * @param args * ignored. */ public static void main(final String[] args) { initializeL10n(); final Translator trans = Application.getTranslator(); Splash.init(); // "Altimeter console" final AltiConsoleMainScreen alticonsole = new AltiConsoleMainScreen( trans.get("AltiConsoleMainScreen.Title")); Image icone; URL myURL; myURL = AltiConsoleMainScreen.class.getResource("/pix/bear_altimeters-small.png"); if (myURL == null) myURL = AltiConsoleMainScreen.class.getResource("/bear_altimeters-small.png"); icone = Toolkit.getDefaultToolkit().getImage(myURL); if (icone == null) { icone = Toolkit.getDefaultToolkit() .getImage(AltiConsoleMainScreen.class.getResource("/bear_altimeters-small.png")); } alticonsole.pack(); alticonsole.setIconImage(icone); alticonsole.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); alticonsole.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent windowEvent) { System.out.println("exit and disconnecting\n"); if (JOptionPane.showConfirmDialog(alticonsole, trans.get("AltiConsoleMainScreen.ClosingWindow"), trans.get("AltiConsoleMainScreen.ReallyClosing"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { alticonsole.DisconnectFromAlti(); System.exit(0); } } }); RefineryUtilities.centerFrameOnScreen(alticonsole); alticonsole.setVisible(true); }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java
/** * Constructs the MessageFilter (this.filter) based on the current form selections *//*ww w. ja va2 s .c o m*/ private boolean generateMessageFilter() { messageFilter = new MessageFilter(); // set start/end date try { messageFilter.setStartDate(getCalendar(mirthDatePicker1, mirthTimePicker1)); Calendar endCalendar = getCalendar(mirthDatePicker2, mirthTimePicker2); if (endCalendar != null && !mirthTimePicker2.isEnabled()) { // If the end time picker is disabled, it will be set to 00:00:00 of the day provided. // Since our query is using <= instead of <, we add one day and then subtract a millisecond // in order to set the time to the last millisecond of the day we want to search on endCalendar.add(Calendar.DATE, 1); endCalendar.add(Calendar.MILLISECOND, -1); } messageFilter.setEndDate(endCalendar); } catch (ParseException e) { parent.alertError(parent, "Invalid date."); return false; } Calendar startDate = messageFilter.getStartDate(); Calendar endDate = messageFilter.getEndDate(); if (startDate != null && endDate != null && startDate.getTimeInMillis() > endDate.getTimeInMillis()) { parent.alertError(parent, "Start date cannot be after the end date."); return false; } // Set text search String textSearch = StringUtils.trim(textSearchField.getText()); if (textSearch.length() > 0) { messageFilter.setTextSearch(textSearch); List<String> textSearchMetaDataColumns = new ArrayList<String>(); for (MetaDataColumn metaDataColumn : getMetaDataColumns()) { if (metaDataColumn.getType() == MetaDataColumnType.STRING) { textSearchMetaDataColumns.add(metaDataColumn.getName()); } } messageFilter.setTextSearchMetaDataColumns(textSearchMetaDataColumns); } if (regexTextSearchCheckBox.isSelected()) { messageFilter.setTextSearchRegex(true); } // set status Set<Status> statuses = new HashSet<Status>(); if (statusBoxReceived.isSelected()) { statuses.add(Status.RECEIVED); } if (statusBoxTransformed.isSelected()) { statuses.add(Status.TRANSFORMED); } if (statusBoxFiltered.isSelected()) { statuses.add(Status.FILTERED); } if (statusBoxSent.isSelected()) { statuses.add(Status.SENT); } if (statusBoxError.isSelected()) { statuses.add(Status.ERROR); } if (statusBoxQueued.isSelected()) { statuses.add(Status.QUEUED); } if (!statuses.isEmpty()) { messageFilter.setStatuses(statuses); } if (StringUtils.isNotEmpty(textSearch) && Preferences.userNodeForPackage(Mirth.class).getBoolean("textSearchWarning", true)) { JCheckBox dontShowTextSearchWarningCheckBox = new JCheckBox( "Don't show this message again in the future"); String textSearchWarning = "<html>Text searching may take a long time, depending on the amount of messages being searched.<br/>Are you sure you want to proceed?</html>"; String textRegexSearchWarning = "<html>Regular expression pattern matching may take a long time and be a costly operation, depending on the amount of messages being searched.<br/>Are you sure you want to proceed?</html>"; String searchWarning = (regexTextSearchCheckBox.isSelected()) ? textRegexSearchWarning : textSearchWarning; Object[] params = new Object[] { searchWarning, dontShowTextSearchWarningCheckBox }; int result = JOptionPane.showConfirmDialog(this, params, "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); Preferences.userNodeForPackage(Mirth.class).putBoolean("textSearchWarning", !dontShowTextSearchWarningCheckBox.isSelected()); if (result != JOptionPane.YES_OPTION) { return false; } } advancedSearchPopup.applySelectionsToFilter(messageFilter); selectedMetaDataIds = messageFilter.getIncludedMetaDataIds(); if (messageFilter.getMaxMessageId() == null) { try { Long maxMessageId = parent.mirthClient.getMaxMessageId(channelId); messageFilter.setMaxMessageId(maxMessageId); } catch (ClientException e) { parent.alertThrowable(parent, e); return false; } } return true; }
From source file:serial.ChartFromSerial.java
public void hardRefresh() { portNames = SerialPort.getCommPorts(); while (portNames.length == 0) { buttonsOff();//from w w w . j a v a 2s . c om if (JOptionPane.showConfirmDialog(rootPane, "No connected devices found.\nWould you like to refresh?", "Could not connect to any devices.", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.NO_OPTION) { return; } else { portNames = SerialPort.getCommPorts(); } } portList_jCombo.removeAllItems(); for (SerialPort portName : portNames) { portList_jCombo.addItem(portName.getSystemPortName()); } defaultButtonStates(); if (chosenPort != null) { chosenPort.closePort(); } }