List of usage examples for javax.swing JOptionPane showOptionDialog
@SuppressWarnings("deprecation") public static int showOptionDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initialValue) throws HeadlessException
initialValue
parameter and the number of choices is determined by the optionType
parameter. From source file:org.qcc.modules.learningpalette.OptionsPlugin.LearningPalettePanel.java
private void deleteSelectedItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteSelectedItemActionPerformed if (selectedPaletteItem != null) { Object[] options = { "Yes", "No" }; int n = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(this), "This will delete the selected palette item permanently.\n" + "Are you sure you wish to continue?", "Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);// w ww .jav a 2s .c o m if (n != 0) { return; } //Step 1: Remove palette item from the combo box String fileName = selectedPaletteItem.getFileName(); pItemCombo.removeItem(selectedPaletteItem); //Step 2: Delete the file if necessary if (fileName != null && fileName.equals("") == false) { String saveDirectory = System.getProperty("user.dir") + "\\LearningPaletteXML"; //Make the directory if necessary File folder = new File(saveDirectory); if (!folder.exists()) { if (folder.mkdir()) { System.out.println("Directory is created!"); } else { System.out.println("Failed to create directory!"); } } File fileToDelete = null; File[] listOfFiles = folder.listFiles(); for (File file : listOfFiles) { if (file.isFile()) { if (file.getName().equals(fileName)) { fileToDelete = file; } } } if (fileToDelete != null) { fileToDelete.delete(); } } //Step 3: call loadPaletteItems("") //Cleanup the form itemNameText.setText(""); descriptionText.setText(""); customizerReplace.setText(""); customizerLabel.setText(""); customizerList.removeAll(); loadPaletteItems(""); } }
From source file:org.sikuli.ide.SikuliIDE.java
private int askForSaveAll(String typ) { //TODO I18N/* w ww . ja v a 2 s .c o m*/ String warn = "Some scripts are not saved yet!"; String title = SikuliIDEI18N._I("dlgAskCloseTab"); String[] options = new String[3]; options[WARNING_DO_NOTHING] = typ + " immediately"; options[WARNING_ACCEPTED] = "Save all and " + typ; options[WARNING_CANCEL] = SikuliIDEI18N._I("cancel"); int ret = JOptionPane.showOptionDialog(this, warn, title, 0, JOptionPane.WARNING_MESSAGE, null, options, options[2]); if (ret == WARNING_CANCEL || ret == JOptionPane.CLOSED_OPTION) { return -1; } return ret; }
From source file:org.sikuli.ide.SikuliIDE.java
public void showExtensionsFrame() { // String warn = "You might proceed, if you\n" // + "- have some programming skills\n" // + "- read the docs about extensions\n" // + "- know what you are doing\n\n" // + "Otherwise you should press Cancel!"; String warn = "Not available yet - click what you like ;-)"; String title = "Need your attention!"; String[] options = new String[3]; options[WARNING_DO_NOTHING] = "OK"; options[WARNING_ACCEPTED] = "Be quiet!"; options[WARNING_CANCEL] = "Cancel"; int ret = JOptionPane.showOptionDialog(this, warn, title, 0, JOptionPane.WARNING_MESSAGE, null, options, options[2]);/*from w w w .j a va 2 s . c om*/ if (ret == WARNING_CANCEL || ret == JOptionPane.CLOSED_OPTION) { return; } if (ret == WARNING_ACCEPTED) { //TODO set prefs to be quiet on extensions warning } ; ExtensionManagerFrame extmg = ExtensionManagerFrame.getInstance(); if (extmg != null) { extmg.setVisible(true); } }
From source file:org.sleeksnap.updater.Updater.java
/** * Check for updates/*from ww w . j a v a2 s . com*/ */ public boolean checkUpdate(final UpdaterReleaseType type, final boolean prompt) { // Check for an update. try { logger.info("Checking for updates..."); final String data = HttpUtil.executeGet(Application.UPDATE_URL + type.getFeedPath()); final JSONObject obj = new JSONObject(data); // Compare versions final String ver = obj.getString("version"); final String[] s = ver.split("\\."); final int major = Integer.parseInt(s[0]), minor = Integer.parseInt(s[1]), patch = Integer.parseInt(s[2]); if (major > Version.MAJOR || major == Version.MAJOR && minor > Version.MINOR || major == Version.MAJOR && minor == Version.MINOR && patch > Version.PATCH) { logger.info("A new version is available. Current version: " + Version.getVersionString() + ", new version: " + major + "." + minor + "." + patch); if (prompt) { final StringBuilder message = new StringBuilder(); message.append("There is a new version of ").append(Application.NAME).append(" available!") .append("\n"); message.append("Your version: ").append(Version.getVersionString()).append("\n"); message.append("Latest version: ").append(ver).append("\n"); message.append("Click OK to download it, or Cancel to be prompted the next time you start ") .append(Application.NAME); final int choice = JOptionPane.showOptionDialog(null, message, "Update Available", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new String[] { "OK", "Cancel" }, "OK"); if (choice == 0) { logger.info("User confirmed the update."); applyUpdate(ver, new URL(obj.getString("file"))); return true; } else { logger.info("User declined the update."); } } else { logger.info("Automatically applying update..."); applyUpdate(ver, new URL(obj.getString("file"))); return true; } } else { logger.info("No updates available."); } } catch (final JSONException e) { logger.severe("Unable to check for update due to web service error."); } catch (final IOException e) { // Unable to update e.printStackTrace(); } return false; }
From source file:org.tellervo.desktop.bulkdataentry.command.ImportSelectedElementsCommand.java
/** * @see com.dmurph.mvc.control.ICommand#execute(com.dmurph.mvc.MVCEvent) */// w w w .ja v a 2s .co m @Override public void execute(MVCEvent argEvent) { BulkImportModel model = BulkImportModel.getInstance(); ElementModel emodel = model.getElementModel(); ElementTableModel tmodel = emodel.getTableModel(); ArrayList<IBulkImportSingleRowModel> selected = new ArrayList<IBulkImportSingleRowModel>(); tmodel.getSelected(selected); // here is where we verify they contain required info HashSet<String> requiredMessages = new HashSet<String>(); ArrayList<IBulkImportSingleRowModel> incompleteModels = new ArrayList<IBulkImportSingleRowModel>(); HashSet<String> definedProps = new HashSet<String>(); for (IBulkImportSingleRowModel som : selected) { definedProps.clear(); for (String s : SingleElementModel.TABLE_PROPERTIES) { if (som.getProperty(s) != null) { definedProps.add(s); } } boolean incomplete = false; // object if (!definedProps.contains(SingleElementModel.OBJECT)) { requiredMessages.add("Cannot import without a parent object."); incomplete = true; } else if (fixTempObjectCode(som)) { // There was a temp code but it is fixed now } else { requiredMessages.add("Cannot import as parent object has not been created yet"); incomplete = true; } // type if (!definedProps.contains(SingleElementModel.TYPE)) { requiredMessages.add("Element must contain a type."); incomplete = true; } // taxon if (!definedProps.contains(SingleElementModel.TAXON)) { requiredMessages.add("Element must contain a taxon."); incomplete = true; } // title if (!definedProps.contains(SingleElementModel.TITLE)) { requiredMessages.add("Element must have a title"); incomplete = true; } // lat/long if (definedProps.contains(SingleElementModel.LATITUDE) || definedProps.contains(SingleElementModel.LONGITUDE)) { if (!definedProps.contains(SingleElementModel.LATITUDE) || !definedProps.contains(SingleElementModel.LONGITUDE)) { requiredMessages .add("If coordinates are specified then both latitude and longitude are required"); incomplete = true; } else { String attempt = som.getProperty(SingleElementModel.LATITUDE).toString().trim(); try { Double lat = Double.parseDouble(attempt); if (lat > -90 || lat < 90) { requiredMessages.add("Latitude must be between -90 and 90"); incomplete = true; } } catch (NumberFormatException e) { requiredMessages.add("Cannot parse '" + attempt + "' into a number."); incomplete = true; } attempt = som.getProperty(SingleElementModel.LONGITUDE).toString().trim(); try { Double lng = Double.parseDouble(attempt); if (lng > -180 || lng < 180) { requiredMessages.add("Longitude must be between -180 and 180"); incomplete = true; } } catch (NumberFormatException e) { requiredMessages.add("Cannot parse '" + attempt + "' into a number."); incomplete = true; } } } if (definedProps.contains(SingleElementModel.HEIGHT) || definedProps.contains(SingleElementModel.WIDTH) || definedProps.contains(SingleElementModel.DEPTH) || definedProps.contains(SingleElementModel.DIAMETER)) { if (!definedProps.contains(SingleElementModel.UNIT)) { requiredMessages.add("Units must be specified when dimensions are included"); incomplete = true; } if ((definedProps.contains(SingleElementModel.HEIGHT) && definedProps.contains(SingleElementModel.DIAMETER) && !definedProps.contains(SingleElementModel.WIDTH) && !definedProps.contains(SingleElementModel.DEPTH))) { // h+diam but not width or depth } else if ((definedProps.contains(SingleElementModel.HEIGHT) && definedProps.contains(SingleElementModel.WIDTH) && definedProps.contains(SingleElementModel.DEPTH) && !definedProps.contains(SingleElementModel.DIAMETER))) { // h+w+d but not diam } else { requiredMessages.add( "When dimensions are included they must be: height/width/depth or height/diameter."); incomplete = true; } } if (incomplete) { incompleteModels.add(som); } } if (!incompleteModels.isEmpty()) { StringBuilder message = new StringBuilder(); message.append("Please correct the following errors:\n"); message.append(StringUtils.join(requiredMessages.toArray(), "\n")); Alert.message(model.getMainView(), "Importing Errors", message.toString()); return; } // now we actually create the models int i = -1; boolean hideErrorMessage = false; for (IBulkImportSingleRowModel srm : selected) { i++; SingleElementModel som = (SingleElementModel) srm; TridasElement origElement = new TridasElement(); if (!som.isDirty()) { System.out.println("Element isn't dirty, not saving/updating: " + som.getProperty(SingleElementModel.TITLE).toString()); } som.populateToTridasElement(origElement); Object o = som.getProperty(SingleElementModel.OBJECT); TridasObject parentObject = null; if (o instanceof TridasObjectOrPlaceholder) { parentObject = ((TridasObjectOrPlaceholder) o).getTridasObject(); } else if (o instanceof TridasObject) { parentObject = (TridasObject) o; } EntityResource<TridasElement> resource; if (origElement.getIdentifier() != null) { resource = new EntityResource<TridasElement>(origElement, TellervoRequestType.UPDATE, TridasElement.class); } else { resource = new EntityResource<TridasElement>(origElement, parentObject, TridasElement.class); } // set up a dialog... Window parentWindow = SwingUtilities.getWindowAncestor(model.getMainView()); TellervoResourceAccessDialog dialog = new TellervoResourceAccessDialog(parentWindow, resource, i, selected.size()); resource.query(); dialog.setVisible(true); if (!dialog.isSuccessful()) { if (hideErrorMessage) { continue; } else if (i < selected.size() - 1) { // More records remain Object[] options = { "Yes", "Yes, but hide further messages", "No" }; int result = JOptionPane.showOptionDialog(BulkImportModel.getInstance().getMainView(), //parent I18n.getText("error.savingChanges") + ":" + System.lineSeparator() + // message dialog.getFailException().getLocalizedMessage() + System.lineSeparator() + System.lineSeparator() + "Would you like to continue importing the remaining records?", I18n.getText("error"), // title JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]); if (result == JOptionPane.NO_OPTION) { hideErrorMessage = true; continue; } else if (result == JOptionPane.YES_OPTION) { continue; } else { break; } } else { JOptionPane.showMessageDialog(BulkImportModel.getInstance().getMainView(), //parent I18n.getText("error.savingChanges") + ":" + System.lineSeparator() + // message dialog.getFailException().getLocalizedMessage(), I18n.getText("error"), // title JOptionPane.ERROR_MESSAGE); //option break; } } som.populateFromTridasElement(resource.getAssociatedResult()); som.setDirty(false); tmodel.setSelected(som, false); // add to imported list or update existing if (origElement.getIdentifier() != null) { TridasElement found = null; for (TridasElement tox : model.getElementModel().getImportedList()) { if (tox.getIdentifier().getValue().equals(origElement.getIdentifier().getValue())) { found = tox; break; } } if (found == null) { log.warn( "Error updating model. Couldn't find the object in the model to update so adding to imported list."); model.getElementModel().getImportedList().add(resource.getAssociatedResult()); } else { resource.getAssociatedResult().copyTo(found); } } else { model.getElementModel().getImportedList().add(resource.getAssociatedResult()); } } // // // finally, update the combo boxes in the table to the new options // DynamicJComboBoxEvent event = new DynamicJComboBoxEvent(emodel.getImportedDynamicComboBoxKey(), emodel.getImportedListStrings()); // event.dispatch(); tmodel.fireTableDataChanged(); }
From source file:org.tinymediamanager.ui.MainWindow.java
public void closeTmmAndStart(ProcessBuilder pb) { int confirm = JOptionPane.YES_OPTION; // if there are some threads running, display exit confirmation if (TmmTaskManager.getInstance().poolRunning()) { confirm = JOptionPane.showOptionDialog(null, BUNDLE.getString("tmm.exit.runningtasks"), BUNDLE.getString("tmm.exit.confirmation"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); // $NON-NLS-1$ }/*from w w w. ja va 2s .c om*/ if (confirm == JOptionPane.YES_OPTION) { LOGGER.info("bye bye"); try { Utils.trackEvent("shutdown"); // send shutdown signal TmmTaskManager.getInstance().shutdown(); // save unsaved settings Globals.settings.saveSettings(); // hard kill TmmTaskManager.getInstance().shutdownNow(); // close database connection TmmModuleManager.getInstance().shutDown(); } catch (Exception ex) { LOGGER.warn("", ex); } dispose(); // spawn our process if (pb != null) { try { LOGGER.info("Going to execute: " + pb.command()); pb.start(); } catch (IOException e) { LOGGER.error("Cannot spawn process:", e); } } System.exit(0); // calling the method is a must } }
From source file:org.tinymediamanager.ui.movies.settings.MovieSettingsPanel.java
/** * Instantiates a new movie settings panel. *//* ww w. ja v a2s . c o m*/ public MovieSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), 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.LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); JPanel panelGeneral = new JPanel(); panelGeneral.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.general"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelGeneral, "2, 2, fill, fill"); panelGeneral.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_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, 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, })); JLabel lblVisiblecolumns = new JLabel(BUNDLE.getString("Settings.movie.visiblecolumns")); //$NON-NLS-1$ panelGeneral.add(lblVisiblecolumns, "2, 2, right, default"); chckbxYear = new JCheckBox(BUNDLE.getString("metatag.year")); //$NON-NLS-1$ panelGeneral.add(chckbxYear, "4, 2"); chckbxRating = new JCheckBox(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$ panelGeneral.add(chckbxRating, "6, 2"); chckbxNfo = new JCheckBox(BUNDLE.getString("metatag.nfo")); //$NON-NLS-1$ panelGeneral.add(chckbxNfo, "8, 2"); chckbxMetadata = new JCheckBox(BUNDLE.getString("tmm.metadata")); //$NON-NLS-1$ panelGeneral.add(chckbxMetadata, "10, 2"); chckbxDateAdded = new JCheckBox(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ panelGeneral.add(chckbxDateAdded, "12, 2"); chckbxImages = new JCheckBox(BUNDLE.getString("metatag.images")); //$NON-NLS-1$ panelGeneral.add(chckbxImages, "4, 4"); chckbxTrailer = new JCheckBox(BUNDLE.getString("metatag.trailer")); //$NON-NLS-1$ panelGeneral.add(chckbxTrailer, "6, 4"); chckbxSubtitles = new JCheckBox(BUNDLE.getString("metatag.subtitles")); //$NON-NLS-1$ panelGeneral.add(chckbxSubtitles, "8, 4"); chckbxWatched = new JCheckBox(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ panelGeneral.add(chckbxWatched, "10, 4"); JLabel lblSaveUiFilter = new JLabel(BUNDLE.getString("Settings.movie.persistuifilter")); //$NON-NLS-1$ panelGeneral.add(lblSaveUiFilter, "2, 6, right, default"); chckbxSaveUiFilter = new JCheckBox(""); panelGeneral.add(chckbxSaveUiFilter, "4, 6"); JSeparator separator_4 = new JSeparator(); panelGeneral.add(separator_4, "2, 8, 11, 1"); JLabel lblImageCache = new JLabel(BUNDLE.getString("Settings.imagecacheimport")); panelGeneral.add(lblImageCache, "2, 10, right, default"); chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecacheimporthint")); //$NON-NLS-1$ TmmFontHelper.changeFont(chckbxImageCache, 0.833); panelGeneral.add(chckbxImageCache, "4, 10, 7, 1"); JLabel lblRuntimeFromMedia = new JLabel(BUNDLE.getString("Settings.runtimefrommediafile")); panelGeneral.add(lblRuntimeFromMedia, "2, 12, right, default"); chckbxRuntimeFromMf = new JCheckBox(""); panelGeneral.add(chckbxRuntimeFromMf, "4, 12"); JSeparator separator = new JSeparator(); panelGeneral.add(separator, "2, 14, 11, 1"); final JLabel lblAutomaticRename = new JLabel(BUNDLE.getString("Settings.movie.automaticrename")); //$NON-NLS-1$ panelGeneral.add(lblAutomaticRename, "2, 16, right, default"); chckbxRename = new JCheckBox(BUNDLE.getString("Settings.movie.automaticrename.desc")); //$NON-NLS-1$ panelGeneral.add(chckbxRename, "4, 16, 7, 1"); JLabel lblTraktTv = new JLabel(BUNDLE.getString("Settings.trakt"));//$NON-NLS-1$ panelGeneral.add(lblTraktTv, "2, 18"); chckbxTraktTv = new JCheckBox(""); panelGeneral.add(chckbxTraktTv, "4, 18"); JButton btnClearTraktTvMovies = new JButton(BUNDLE.getString("Settings.trakt.clearmovies"));//$NON-NLS-1$ btnClearTraktTvMovies.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int confirm = JOptionPane.showOptionDialog(null, BUNDLE.getString("Settings.trakt.clearmovies.hint"), BUNDLE.getString("Settings.trakt.clearmovies"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.YES_OPTION) { TmmTask task = new ClearTraktTvTask(true, false); TmmTaskManager.getInstance().addUnnamedTask(task); } } }); panelGeneral.add(btnClearTraktTvMovies, "6, 18, 3, 1, left, default"); JPanel panelMovieDataSources = new JPanel(); panelMovieDataSources.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.datasource"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMovieDataSources, "2, 4, 3, 1, fill, fill"); panelMovieDataSources.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow(2)"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("100px:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblDataSource = new JLabel(BUNDLE.getString("Settings.source")); //$NON-NLS-1$ panelMovieDataSources.add(lblDataSource, "2, 2, 5, 1"); JLabel lblIngore = new JLabel(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$ panelMovieDataSources.add(lblIngore, "12, 2"); JScrollPane scrollPaneDataSources = new JScrollPane(); panelMovieDataSources.add(scrollPaneDataSources, "2, 4, 5, 1, fill, fill"); listDataSources = new JList<>(); scrollPaneDataSources.setViewportView(listDataSources); JPanel panelMovieSourcesButtons = new JPanel(); panelMovieDataSources.add(panelMovieSourcesButtons, "8, 4, fill, top"); panelMovieSourcesButtons .setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAdd = new JButton(IconManager.LIST_ADD); btnAdd.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAdd.setMargin(new Insets(2, 2, 2, 2)); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.datasource.folderchooser")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addMovieDataSources(file.toAbsolutePath().toString()); } } }); panelMovieSourcesButtons.add(btnAdd, "1, 1, fill, top"); JButton btnRemove = new JButton(IconManager.LIST_REMOVE); btnRemove.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemove.setMargin(new Insets(2, 2, 2, 2)); btnRemove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listDataSources.getSelectedIndex(); if (row != -1) { // nothing selected String path = MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource().get(row); String[] choices = { BUNDLE.getString("Button.continue"), BUNDLE.getString("Button.abort") }; //$NON-NLS-1$ int decision = JOptionPane.showOptionDialog(null, String.format(BUNDLE.getString("Settings.movie.datasource.remove.info"), path), BUNDLE.getString("Settings.datasource.remove"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, choices, BUNDLE.getString("Button.abort")); //$NON-NLS-1$ if (decision == 0) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); MovieModuleManager.MOVIE_SETTINGS.removeMovieDataSources(path); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } } }); panelMovieSourcesButtons.add(btnRemove, "1, 3, fill, top"); JScrollPane scrollPaneIgnore = new JScrollPane(); panelMovieDataSources.add(scrollPaneIgnore, "12, 4, fill, fill"); listIgnore = new JList<>(); scrollPaneIgnore.setViewportView(listIgnore); JPanel panelIgnoreButtons = new JPanel(); panelMovieDataSources.add(panelIgnoreButtons, "14, 4, fill, fill"); panelIgnoreButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAddIgnore = new JButton(IconManager.LIST_ADD); btnAddIgnore.setToolTipText(BUNDLE.getString("Settings.addignore")); //$NON-NLS-1$ btnAddIgnore.setMargin(new Insets(2, 2, 2, 2)); btnAddIgnore.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addMovieSkipFolder(file.toAbsolutePath().toString()); } } }); panelIgnoreButtons.add(btnAddIgnore, "1, 1"); JButton btnRemoveIgnore = new JButton(IconManager.LIST_REMOVE); btnRemoveIgnore.setToolTipText(BUNDLE.getString("Settings.removeignore")); //$NON-NLS-1$ btnRemoveIgnore.setMargin(new Insets(2, 2, 2, 2)); btnRemoveIgnore.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = listIgnore.getSelectedIndex(); if (row != -1) { // nothing selected String ingore = settings.getMovieSkipFolders().get(row); settings.removeMovieSkipFolder(ingore); } } }); panelIgnoreButtons.add(btnRemoveIgnore, "1, 3"); JPanel panel = new JPanel(); panelMovieDataSources.add(panel, "2, 8, 13, 1, fill, fill"); panel.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20dlu"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblNfoFormat = new JLabel(BUNDLE.getString("Settings.nfoFormat")); panel.add(lblNfoFormat, "1, 1, right, default"); cbNfoFormat = new JComboBox(MovieConnectors.values()); panel.add(cbNfoFormat, "3, 1, fill, default"); JLabel lblNfoFileNaming = new JLabel(BUNDLE.getString("Settings.nofFileNaming")); //$NON-NLS-1$ panel.add(lblNfoFileNaming, "7, 1, right, default"); cbMovieNfoFilename1 = new JCheckBox(BUNDLE.getString("Settings.moviefilename") + ".nfo"); //$NON-NLS-1$ panel.add(cbMovieNfoFilename1, "9, 1"); cbMovieNfoFilename2 = new JCheckBox("movie.nfo"); panel.add(cbMovieNfoFilename2, "9, 2"); cbMovieNfoFilename2.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); cbMovieNfoFilename3 = new JCheckBox(BUNDLE.getString("Settings.nfo.discstyle")); //$NON-NLS-1$ panel.add(cbMovieNfoFilename3, "9, 3"); cbMovieNfoFilename3.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); final JLabel lblCertificationStyle = new JLabel(BUNDLE.getString("Settings.certificationformat")); //$NON-NLS-1$ panel.add(lblCertificationStyle, "1, 5, right, default"); cbCertificationStyle = new JComboBox(); panel.add(cbCertificationStyle, "3, 5, 7, 1, fill, default"); JPanel panelBadWords = new JPanel(); panelBadWords.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.badwords"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelBadWords, "4, 2, fill, fill"); panelBadWords.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JTextPane txtpntBadWordsHint = new JTextPane(); txtpntBadWordsHint.setBackground(UIManager.getColor("Panel.background")); txtpntBadWordsHint.setText(BUNDLE.getString("Settings.movie.badwords.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(txtpntBadWordsHint, 0.833); panelBadWords.add(txtpntBadWordsHint, "2, 2, 3, 1, fill, default"); JScrollPane scpBadWords = new JScrollPane(); panelBadWords.add(scpBadWords, "2, 4, fill, fill"); listBadWords = new JList<>(); scpBadWords.setViewportView(listBadWords); JButton btnRemoveBadWord = new JButton(IconManager.LIST_REMOVE); btnRemoveBadWord.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemoveBadWord.setMargin(new Insets(2, 2, 2, 2)); btnRemoveBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listBadWords.getSelectedIndex(); if (row != -1) { String badWord = MovieModuleManager.MOVIE_SETTINGS.getBadWords().get(row); MovieModuleManager.MOVIE_SETTINGS.removeBadWord(badWord); } } }); panelBadWords.add(btnRemoveBadWord, "4, 4, default, bottom"); tfAddBadword = new JTextField(); tfAddBadword.setColumns(10); panelBadWords.add(tfAddBadword, "2, 6, fill, default"); JButton btnAddBadWord = new JButton(IconManager.LIST_ADD); btnAddBadWord.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAddBadWord.setMargin(new Insets(2, 2, 2, 2)); btnAddBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtils.isNotEmpty(tfAddBadword.getText())) { MovieModuleManager.MOVIE_SETTINGS.addBadWord(tfAddBadword.getText()); tfAddBadword.setText(""); } } }); panelBadWords.add(btnAddBadWord, "4, 6"); initDataBindings(); { // NFO filenames List<MovieNfoNaming> movieNfoFilenames = settings.getMovieNfoFilenames(); if (movieNfoFilenames.contains(MovieNfoNaming.FILENAME_NFO)) { cbMovieNfoFilename1.setSelected(true); } if (movieNfoFilenames.contains(MovieNfoNaming.MOVIE_NFO)) { cbMovieNfoFilename2.setSelected(true); } if (movieNfoFilenames.contains(MovieNfoNaming.DISC_NFO)) { cbMovieNfoFilename3.setSelected(true); } if (!Globals.isDonator()) { chckbxTraktTv.setSelected(false); chckbxTraktTv.setEnabled(false); btnClearTraktTvMovies.setEnabled(false); } // set default certification style cbNfoFormat.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (cbNfoFormat.getSelectedItem() == MovieConnectors.MP) { for (int i = 0; i < cbCertificationStyle.getItemCount(); i++) { CertificationStyleWrapper wrapper = cbCertificationStyle.getItemAt(i); if (wrapper.style == CertificationStyle.TECHNICAL) { cbCertificationStyle.setSelectedItem(wrapper); break; } } } else if (cbNfoFormat.getSelectedItem() == MovieConnectors.XBMC || cbNfoFormat.getSelectedItem() == MovieConnectors.KODI) { for (int i = 0; i < cbCertificationStyle.getItemCount(); i++) { CertificationStyleWrapper wrapper = cbCertificationStyle.getItemAt(i); if (wrapper.style == CertificationStyle.LARGE) { cbCertificationStyle.setSelectedItem(wrapper); break; } } } } }); // certification examples for (CertificationStyle style : CertificationStyle.values()) { CertificationStyleWrapper wrapper = new CertificationStyleWrapper(); wrapper.style = style; cbCertificationStyle.addItem(wrapper); if (style == settings.getMovieCertificationStyle()) { cbCertificationStyle.setSelectedItem(wrapper); } } cbCertificationStyle.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); // item listener cbMovieNfoFilename1.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); } }
From source file:org.tinymediamanager.ui.tvshows.settings.TvShowSettingsPanel.java
/** * Instantiates a new tv show settings panel. *///from w w w. ja v a 2 s . c o m public TvShowSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow(3)"), })); JPanel panelGeneral = new JPanel(); panelGeneral.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.general"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelGeneral, "2, 2, fill, fill"); panelGeneral.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, 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, })); lblImageCache = new JLabel(BUNDLE.getString("Settings.imagecacheimport")); panelGeneral.add(lblImageCache, "2, 2"); chckbxImageCache = new JCheckBox(""); panelGeneral.add(chckbxImageCache, "4, 2"); lblImageCacheHint = new JLabel(BUNDLE.getString("Settings.imagecacheimporthint")); //$NON-NLS-1$ panelGeneral.add(lblImageCacheHint, "6, 2, 3, 1"); TmmFontHelper.changeFont(lblImageCacheHint, 0.833); final JSeparator separator = new JSeparator(); panelGeneral.add(separator, "2, 4, 7, 1"); JLabel lblTraktTv = new JLabel(BUNDLE.getString("Settings.trakt"));//$NON-NLS-1$ panelGeneral.add(lblTraktTv, "2, 6"); chckbxTraktTv = new JCheckBox(""); panelGeneral.add(chckbxTraktTv, "4, 6"); btnClearTraktTvShows = new JButton(BUNDLE.getString("Settings.trakt.cleartvshows"));//$NON-NLS-1$ btnClearTraktTvShows.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int confirm = JOptionPane.showOptionDialog(null, BUNDLE.getString("Settings.trakt.cleartvshows.hint"), BUNDLE.getString("Settings.trakt.cleartvshows"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.YES_OPTION) { TmmTask task = new ClearTraktTvTask(false, true); TmmTaskManager.getInstance().addUnnamedTask(task); } } }); panelGeneral.add(btnClearTraktTvShows, "6, 6"); JPanel panelBadWords = new JPanel(); panelBadWords.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.tvshow.badwords"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelBadWords, "4, 2, fill, fill"); panelBadWords.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JTextPane txtpntBadWordsHint = new JTextPane(); txtpntBadWordsHint.setBackground(UIManager.getColor("Panel.background")); txtpntBadWordsHint.setText(BUNDLE.getString("Settings.tvshow.badwords.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(txtpntBadWordsHint, 0.833); panelBadWords.add(txtpntBadWordsHint, "2, 2, 3, 1, fill, default"); JScrollPane scpBadWords = new JScrollPane(); panelBadWords.add(scpBadWords, "2, 4, fill, fill"); listBadWords = new JList<>(); scpBadWords.setViewportView(listBadWords); JButton btnRemoveBadWord = new JButton(IconManager.LIST_REMOVE); btnRemoveBadWord.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemoveBadWord.setMargin(new Insets(2, 2, 2, 2)); btnRemoveBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listBadWords.getSelectedIndex(); if (row != -1) { String badWord = TvShowModuleManager.SETTINGS.getBadWords().get(row); TvShowModuleManager.SETTINGS.removeBadWord(badWord); } } }); panelBadWords.add(btnRemoveBadWord, "4, 4, default, bottom"); tfAddBadword = new JTextField(); tfAddBadword.setColumns(10); panelBadWords.add(tfAddBadword, "2, 6, fill, default"); JButton btnAddBadWord = new JButton(IconManager.LIST_ADD); btnAddBadWord.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAddBadWord.setMargin(new Insets(2, 2, 2, 2)); btnAddBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtils.isNotEmpty(tfAddBadword.getText())) { TvShowModuleManager.SETTINGS.addBadWord(tfAddBadword.getText()); tfAddBadword.setText(""); } } }); panelBadWords.add(btnAddBadWord, "4, 6"); { JPanel panelTvShowDataSources = new JPanel(); panelTvShowDataSources.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.tvshowdatasource"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelTvShowDataSources, "2, 4, 3, 1, fill, top"); panelTvShowDataSources.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("50dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow(2)"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("160px:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblDataSource = new JLabel(BUNDLE.getString("Settings.source")); //$NON-NLS-1$ panelTvShowDataSources.add(lblDataSource, "2, 2, 5, 1"); JLabel lblSkipFolders = new JLabel(BUNDLE.getString("Settings.ignore"));//$NON-NLS-1$ panelTvShowDataSources.add(lblSkipFolders, "12, 2, 3, 1"); JScrollPane scrollPaneDatasource = new JScrollPane(); panelTvShowDataSources.add(scrollPaneDatasource, "2, 4, 5, 1, fill, fill"); listDatasources = new JList<>(); scrollPaneDatasource.setViewportView(listDatasources); JPanel panelTvShowSourcesButtons = new JPanel(); panelTvShowDataSources.add(panelTvShowSourcesButtons, "8, 4, default, top"); panelTvShowSourcesButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAdd = new JButton(IconManager.LIST_ADD); btnAdd.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAdd.setMargin(new Insets(2, 2, 2, 2)); btnAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper .selectDirectory(BUNDLE.getString("Settings.tvshowdatasource.folderchooser")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addTvShowDataSources(file.toAbsolutePath().toString()); } } }); panelTvShowSourcesButtons.add(btnAdd, "1, 1, fill, top"); JButton btnRemove = new JButton(IconManager.LIST_REMOVE); btnRemove.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemove.setMargin(new Insets(2, 2, 2, 2)); btnRemove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listDatasources.getSelectedIndex(); if (row != -1) { // nothing selected String path = settings.getTvShowDataSource().get(row); String[] choices = { BUNDLE.getString("Button.continue"), //$NON-NLS-1$ BUNDLE.getString("Button.abort") }; int decision = JOptionPane.showOptionDialog(null, String.format(BUNDLE.getString("Settings.tvshowdatasource.remove.info"), path), BUNDLE.getString("Settings.datasource.remove"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, choices, BUNDLE.getString("Button.abort")); //$NON-NLS-1$ if (decision == 0) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); settings.removeTvShowDataSources(path); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } } }); panelTvShowSourcesButtons.add(btnRemove, "1, 3, fill, top"); JScrollPane scrollPane = new JScrollPane(); panelTvShowDataSources.add(scrollPane, "12, 4, fill, fill"); listExclude = new JList<>(); scrollPane.setViewportView(listExclude); JPanel panelSkipFolderButtons = new JPanel(); panelTvShowDataSources.add(panelSkipFolderButtons, "14, 4, fill, fill"); panelSkipFolderButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAddSkipFolder = new JButton(IconManager.LIST_ADD); btnAddSkipFolder.setToolTipText(BUNDLE.getString("Settings.addignore")); //$NON-NLS-1$ btnAddSkipFolder.setMargin(new Insets(2, 2, 2, 2)); btnAddSkipFolder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addTvShowSkipFolder(file.toAbsolutePath().toString()); } } }); panelSkipFolderButtons.add(btnAddSkipFolder, "1, 1"); JButton btnRemoveSkipFolder = new JButton(IconManager.LIST_REMOVE); btnRemoveSkipFolder.setToolTipText(BUNDLE.getString("Settings.removeignore")); //$NON-NLS-1$ btnRemoveSkipFolder.setMargin(new Insets(2, 2, 2, 2)); btnRemoveSkipFolder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = listExclude.getSelectedIndex(); if (row != -1) { // nothing selected String ingore = settings.getTvShowSkipFolders().get(row); settings.removeTvShowSkipFolder(ingore); } } }); panelSkipFolderButtons.add(btnRemoveSkipFolder, "1, 3"); JLabel lblDvdOrder = new JLabel(BUNDLE.getString("Settings.dvdorder")); //$NON-NLS-1$ panelTvShowDataSources.add(lblDvdOrder, "2, 6, right, default"); cbDvdOrder = new JCheckBox(""); panelTvShowDataSources.add(cbDvdOrder, "4, 6"); } initDataBindings(); if (!Globals.isDonator()) { chckbxTraktTv.setSelected(false); chckbxTraktTv.setEnabled(false); btnClearTraktTvShows.setEnabled(false); } }
From source file:org.tmpotter.ui.ActionHandler.java
/** * Save project as specified filename.// w ww. j av a 2s . co m */ private void saveProjectAs() { File outFile = new File(modelMediator.getProjectName().concat(".tmpx")); try { boolean save = false; boolean cancel = false; while (!save && !cancel) { final JFileChooser fc = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("TMX File", "tmpx"); fc.setFileFilter(filter); boolean nameOfUser = false; while (!nameOfUser) { fc.setLocation(230, 300); fc.setCurrentDirectory(RuntimePreferences.getUserHome()); fc.setDialogTitle(getString("DLG.SAVEAS")); fc.setMultiSelectionEnabled(false); fc.setSelectedFile(outFile); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); RuntimePreferences.setUserHome(fc.getCurrentDirectory()); int returnVal; returnVal = fc.showSaveDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { outFile = fc.getSelectedFile(); if (!outFile.getName().endsWith(".tmpx")) { outFile = new File(outFile.getName().concat(".tmpx")); } nameOfUser = true; } else { nameOfUser = true; cancel = true; } } int selected; if (nameOfUser && !cancel) { if (outFile.exists()) { final Object[] options = { getString("BTN.SAVE"), getString("BTN.CANCEL") }; selected = JOptionPane.showOptionDialog(parent, getString("MSG.FILE_EXISTS"), getString("MSG.WARNING"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (selected == 0) { save = true; } } else { save = true; } } } if (save) { cleanTmData(); ProjectProperties prop = modelMediator.getProjectProperties(); prop.setFilePathProject(outFile); TmxpWriter.writeTmxp(prop, tmData.getDocumentOriginal(), tmData.getDocumentTranslation()); } } catch (Exception ex) { JOptionPane.showMessageDialog(parent, JOptionPane.ERROR_MESSAGE); } }
From source file:org.tridas.io.gui.control.config.ConfigController.java
public void setInputFormat(MVCEvent argEvent) { ConfigEvent event = (ConfigEvent) argEvent; model.setReaderDefaults(null);// w w w .j a v a2s . c om String xls = org.tridas.io.I18n.getText("excelmatrix.about.shortName"); String odf = org.tridas.io.I18n.getText("odfmatrix.about.shortName"); String csv = org.tridas.io.I18n.getText("csv.about.shortName"); // If this is a matrix format then we may need to warn users that it's // not magical if ((event.getValue().equals(xls) || event.getValue().equals(odf) || event.getValue().equals(csv)) && model.warnedAboutMatrixStyle == false && TricycleModelLocator.getInstance().isWarnAboutMatrixStyle()) { Object[] options = { I18n.getText("view.popup.dontWarnAgain"), "OK" }; int n = JOptionPane.showOptionDialog(null, WordUtils.wrap(I18n.getText("view.popup.warnAboutMatrixStyle"), 60), I18n.getText("view.popup.spreadsheetFiles"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]); if (n == 0) { TricycleModelLocator.getInstance().setWarnAboutMatrixStyle(false); } model.warnedAboutMatrixStyle = true; } FileListModel fmodel = TricycleModelLocator.getInstance().getFileListModel(); fmodel.setInputFormat(event.getValue()); }