List of usage examples for javax.swing JOptionPane showInputDialog
@SuppressWarnings("deprecation") public static Object showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue) throws HeadlessException
From source file:lu.fisch.moenagade.model.Project.java
public BloxsClass renameEntity(Entity entity) { String name = entity.getName(); boolean result; do {//from w ww .j a v a2 s .c o m name = (String) JOptionPane.showInputDialog(frame, "Please enter the entitie's name.", "Rename entity", JOptionPane.PLAIN_MESSAGE, null, null, name); if (name == null) return null; result = true; // check if name is OK Matcher matcher = Pattern.compile("^[a-zA-Z_$][a-zA-Z_$0-9]*$").matcher(name); boolean found = matcher.find(); if (!found) { result = false; JOptionPane.showMessageDialog(frame, "Please chose a valid name.", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); } // check if name is unique else if (entities.containsKey(name)) { result = false; JOptionPane.showMessageDialog(frame, "This name is not unique.", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); } // check internal name else if (name.trim().equals("Entity")) { result = false; JOptionPane.showMessageDialog(frame, "The name \"Entity\" is already internaly\nused and thus not allowed!", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); } else if (name.charAt(0) != name.toUpperCase().charAt(0)) { result = false; JOptionPane.showMessageDialog(frame, "The name should start with a capital letter.", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); } else { // send refresh refresh(new Change(null, -1, "rename.entity", entity.getName(), name)); // switch entities.remove(entity.getName()); entities.put(name, entity); // rename file (if present) File fFrom = new File(directoryName + System.getProperty("file.separator") + "bloxs" + System.getProperty("file.separator") + "entities" + System.getProperty("file.separator") + entity.getName() + ".bloxs"); File fTo = new File(directoryName + System.getProperty("file.separator") + "bloxs" + System.getProperty("file.separator") + "entities" + System.getProperty("file.separator") + name + ".bloxs"); if (fFrom.exists()) fFrom.renameTo(fTo); // do the rename entity.setName(name); return entity; } } while (!result); return null; }
From source file:com.edduarte.protbox.ui.windows.RestoreFileWindow.java
private RestoreFileWindow(final PReg registry) { super();/* w w w. ja va2 s .c om*/ setLayout(null); final JTextField searchField = new JTextField(); searchField.setLayout(null); searchField.setBounds(2, 2, 301, 26); searchField.setBorder(new LineBorder(Color.lightGray)); searchField.setFont(Constants.FONT); add(searchField); final JLabel noBackupFilesLabel = new JLabel("<html>No backups files were found!<br><br>" + "<font color=\"gray\">If you think there is a problem with the<br>" + "backup system, please create an issue here:<br>" + "<a href=\"#\">https://github.com/com.edduarte/protbox/issues</a></font></html>"); noBackupFilesLabel.setLayout(null); noBackupFilesLabel.setBounds(20, 50, 300, 300); noBackupFilesLabel.setFont(Constants.FONT.deriveFont(14f)); noBackupFilesLabel.addMouseListener((OnMouseClick) e -> { String urlPath = "https://github.com/com.edduarte/protbox/issues"; try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(new URI(urlPath)); } else { if (SystemUtils.IS_OS_WINDOWS) { Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + urlPath); } else { java.util.List<String> browsers = Lists.newArrayList("firefox", "opera", "safari", "mozilla", "chrome"); for (String browser : browsers) { if (Runtime.getRuntime().exec(new String[] { "which", browser }).waitFor() == 0) { Runtime.getRuntime().exec(new String[] { browser, urlPath }); break; } } } } } catch (Exception ex) { ex.printStackTrace(); } }); DefaultMutableTreeNode rootTreeNode = registry.buildEntryTree(); final JTree tree = new JTree(rootTreeNode); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); if (rootTreeNode.getChildCount() == 0) { searchField.setEnabled(false); add(noBackupFilesLabel); } expandTree(tree); tree.setLayout(null); tree.setRootVisible(false); tree.setEditable(false); tree.setCellRenderer(new SearchableTreeCellRenderer(searchField)); searchField.addKeyListener((OnKeyReleased) e -> { // update and expand tree DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); model.nodeStructureChanged((TreeNode) model.getRoot()); expandTree(tree); }); final JScrollPane scroll = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll.setBorder(new DropShadowBorder()); scroll.setBorder(new LineBorder(Color.lightGray)); scroll.setBounds(2, 30, 334, 360); add(scroll); JLabel close = new JLabel(new ImageIcon(Constants.getAsset("close.png"))); close.setLayout(null); close.setBounds(312, 7, 18, 18); close.setFont(Constants.FONT); close.setForeground(Color.gray); close.addMouseListener((OnMouseClick) e -> dispose()); add(close); final JLabel permanentDeleteButton = new JLabel(new ImageIcon(Constants.getAsset("permanent.png"))); permanentDeleteButton.setLayout(null); permanentDeleteButton.setBounds(91, 390, 40, 39); permanentDeleteButton.setBackground(Color.black); permanentDeleteButton.setEnabled(false); permanentDeleteButton.addMouseListener((OnMouseClick) e -> { if (permanentDeleteButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (JOptionPane.showConfirmDialog(null, "Are you sure you wish to permanently delete '" + entry.realName() + "'?\nThis file and its " + "backup copies will be deleted immediately. You cannot undo this action.", "Confirm Cancel", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { registry.permanentDelete(entry); dispose(); RestoreFileWindow.getInstance(registry); } else { setVisible(true); } } }); add(permanentDeleteButton); final JLabel configBackupsButton = new JLabel(new ImageIcon(Constants.getAsset("config.png"))); configBackupsButton.setLayout(null); configBackupsButton.setBounds(134, 390, 40, 39); configBackupsButton.setBackground(Color.black); configBackupsButton.setEnabled(false); configBackupsButton.addMouseListener((OnMouseClick) e -> { if (configBackupsButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (entry instanceof PbxFile) { PbxFile pbxFile = (PbxFile) entry; JFrame frame = new JFrame("Choose backup policy"); Object option = JOptionPane.showInputDialog(frame, "Choose below the backup policy for this file:", "Choose backup", JOptionPane.QUESTION_MESSAGE, null, PbxFile.BackupPolicy.values(), pbxFile.getBackupPolicy()); if (option == null) { setVisible(true); return; } PbxFile.BackupPolicy pickedPolicy = PbxFile.BackupPolicy.valueOf(option.toString()); pbxFile.setBackupPolicy(pickedPolicy); } setVisible(true); } }); add(configBackupsButton); final JLabel restoreBackupButton = new JLabel(new ImageIcon(Constants.getAsset("restore.png"))); restoreBackupButton.setLayout(null); restoreBackupButton.setBounds(3, 390, 85, 39); restoreBackupButton.setBackground(Color.black); restoreBackupButton.setEnabled(false); restoreBackupButton.addMouseListener((OnMouseClick) e -> { if (restoreBackupButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (entry instanceof PbxFolder) { registry.restoreFolderFromEntry((PbxFolder) entry); } else if (entry instanceof PbxFile) { PbxFile pbxFile = (PbxFile) entry; java.util.List<String> snapshots = pbxFile.snapshotsToString(); if (snapshots.isEmpty()) { setVisible(true); return; } JFrame frame = new JFrame("Choose backup"); Object option = JOptionPane.showInputDialog(frame, "Choose below what backup snapshot would you like restore:", "Choose backup", JOptionPane.QUESTION_MESSAGE, null, snapshots.toArray(), snapshots.get(0)); if (option == null) { setVisible(true); return; } int pickedIndex = snapshots.indexOf(option.toString()); registry.restoreFileFromEntry((PbxFile) entry, pickedIndex); } dispose(); } }); add(restoreBackupButton); tree.addMouseListener((OnMouseClick) e -> { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node != null) { PbxEntry entry = (PbxEntry) node.getUserObject(); if ((entry instanceof PbxFolder && entry.areNativeFilesDeleted())) { permanentDeleteButton.setEnabled(true); restoreBackupButton.setEnabled(true); configBackupsButton.setEnabled(false); } else if (entry instanceof PbxFile) { permanentDeleteButton.setEnabled(true); restoreBackupButton.setEnabled(true); configBackupsButton.setEnabled(true); } else { permanentDeleteButton.setEnabled(false); restoreBackupButton.setEnabled(false); configBackupsButton.setEnabled(false); } } }); final JLabel cancel = new JLabel(new ImageIcon(Constants.getAsset("cancel.png"))); cancel.setLayout(null); cancel.setBounds(229, 390, 122, 39); cancel.setBackground(Color.black); cancel.addMouseListener((OnMouseClick) e -> dispose()); add(cancel); addWindowFocusListener(new WindowFocusListener() { private boolean gained = false; @Override public void windowGainedFocus(WindowEvent e) { gained = true; } @Override public void windowLostFocus(WindowEvent e) { if (gained) { dispose(); } } }); setSize(340, 432); setUndecorated(true); getContentPane().setBackground(Color.white); setResizable(false); getRootPane().setBorder(BorderFactory.createLineBorder(new Color(100, 100, 100))); Utils.setComponentLocationOnCenter(this); setVisible(true); }
From source file:Listeners.MyActionListener.java
public void saveAction() { if (lista.getCod() == 0) { String s = (String) JOptionPane.showInputDialog(vista, "Ponle un nombre a tu lista", "Guardar lista", JOptionPane.PLAIN_MESSAGE, null, null, ""); //If a string was returned, say so. if ((s != null) && (s.length() > 0)) { lista.setDescripcion(s);//from ww w . j a v a 2 s . c om } } addRequest(); }
From source file:com.pdk.DisassembleElfAction.java
private void showList() { Project project = NetbeansUtil.getPeterProject(); File dir = new File(project.getProjectDirectory().getPath()); Collection<File> files = FileUtils.listFiles(dir, new String[] { "o", "exe" }, true); if (files.isEmpty()) { return;/*from ww w.j ava 2s .com*/ } files.add(new File(dir.getAbsolutePath() + File.separator + "kernel/kernel")); Iterator<File> iter = files.iterator(); while (iter.hasNext()) { File file = iter.next(); String relativePath = file.getAbsolutePath().substring(dir.getAbsolutePath().length()); if (relativePath.startsWith("/toolchain/")) { iter.remove(); } } String[] arr = new String[files.size()]; iter = files.iterator(); int x = 0; while (iter.hasNext()) { File file = iter.next(); String relativePath = file.getAbsolutePath().substring(dir.getAbsolutePath().length() + 1); arr[x] = relativePath; x++; } Arrays.sort(arr, new Comparator<String>() { @Override public int compare(String o1, String o2) { if (o1.startsWith("kernel/")) { return -1; } else if (o1.startsWith("kernel/")) { return 1; } else { return o1.compareTo(o2); } } }); String file = (String) JOptionPane.showInputDialog(null, null, "Please select an elf file", JOptionPane.QUESTION_MESSAGE, null, arr, arr[0]); if (file != null) { try { Object[] options = { "Disasm", "Sections", "Cancel" }; int n = JOptionPane.showOptionDialog(null, "Please select", "Question", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); if (n == 2) { return; } String command2 = null; if (n == 0) { command2 = "i586-peter-elf-objdump -S"; } else if (n == 1) { command2 = "i586-peter-elf-readelf -S"; } if (command2 == null) { return; } final String command = "/toolchain/bin/" + command2 + " " + file; process = Runtime.getRuntime().exec(command, null, dir); InputStreamReader isr = new InputStreamReader(process.getInputStream()); final BufferedReader br = new BufferedReader(isr, 1024 * 1024 * 50); final JProgressBarDialog d = new JProgressBarDialog(new JFrame(), "i586-peter-elf-objdump -S " + file, true); d.progressBar.setIndeterminate(true); d.progressBar.setStringPainted(true); d.progressBar.setString("Updating"); d.addCancelEventListener(this); Thread longRunningThread = new Thread() { public void run() { try { lines = new StringBuilder(); String line; stop = false; while (!stop && (line = br.readLine()) != null) { d.progressBar.setString(line); lines.append(line).append("\n"); } DisassembleDialog disassembleDialog = new DisassembleDialog(); disassembleDialog.setTitle(command); if (((DefaultComboBoxModel) disassembleDialog.enhancedTextArea1.fontComboBox.getModel()) .getIndexOf("Monospaced") != -1) { disassembleDialog.enhancedTextArea1.fontComboBox.setSelectedItem("Monospaced"); } if (((DefaultComboBoxModel) disassembleDialog.enhancedTextArea1.fontComboBox.getModel()) .getIndexOf("Monospaced.plain") != -1) { disassembleDialog.enhancedTextArea1.fontComboBox .setSelectedItem("Monospaced.plain"); } disassembleDialog.enhancedTextArea1.fontComboBox.setSelectedItem("Monospaced"); disassembleDialog.enhancedTextArea1.setText(lines.toString()); disassembleDialog.setVisible(true); } catch (Exception ex) { ModuleLib.log(CommonLib.printException(ex)); } } }; d.thread = longRunningThread; d.setVisible(true); } catch (Exception ex) { ModuleLib.log(CommonLib.printException(ex)); } } }
From source file:es.emergya.ui.gis.popups.SaveGPXDialog.java
private SaveGPXDialog(final List<Layer> capas) { super("Consulta de Posiciones GPS"); setResizable(false);/* ww w .ja v a 2 s . c o m*/ setAlwaysOnTop(true); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JPanel dialogo = new JPanel(new BorderLayout()); dialogo.setBackground(Color.WHITE); dialogo.setBorder(new EmptyBorder(10, 10, 10, 10)); JPanel central = new JPanel(new FlowLayout()); central.setOpaque(false); final JTextField nombre = new JTextField(15); nombre.setEditable(false); central.add(nombre); final JButton button = new JButton("Examinar...", LogicConstants.getIcon("button_nuevo")); central.add(button); final JButton aceptar = new JButton("Guardar", LogicConstants.getIcon("button_save")); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); if (fileChooser.showSaveDialog(SaveGPXDialog.this) == JFileChooser.APPROVE_OPTION) { nombre.setText(fileChooser.getSelectedFile().getAbsolutePath()); aceptar.setEnabled(true); } } }); dialogo.add(central, BorderLayout.CENTER); JPanel botones = new JPanel(new FlowLayout()); botones.setOpaque(false); aceptar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String base_url = nombre.getText() + "_"; for (Layer layer : capas) { if (layer instanceof GpxLayer) { GpxLayer gpxLayer = (GpxLayer) layer; File f = new File(base_url + gpxLayer.name + ".gpx"); boolean sobreescribir = !f.exists(); try { while (!sobreescribir) { String original = f.getCanonicalPath(); f = checkFileOverwritten(nombre, f); sobreescribir = !f.exists() || original.equals(f.getCanonicalPath()); } } catch (NullPointerException t) { log.debug("Cancelando creacion de fichero: " + t); sobreescribir = false; } catch (Throwable t) { log.error("Error comprobando la sobreescritura", t); sobreescribir = false; } if (sobreescribir) { try { f.createNewFile(); } catch (IOException e1) { log.error(e1, e1); } if (!(f.isFile() && f.canWrite())) JOptionPane.showMessageDialog(SaveGPXDialog.this, "No tengo permiso para escribir en " + f.getAbsolutePath()); else { try { OutputStream out = new FileOutputStream(f); GpxWriter writer = new GpxWriter(out); writer.write(gpxLayer.data); out.close(); } catch (Throwable t) { log.error("Error al escribir el gpx", t); JOptionPane.showMessageDialog(SaveGPXDialog.this, "Ocurri un error al escribir en " + f.getAbsolutePath()); } } } else log.error("Por errores anteriores no se escribio el fichero"); } else log.error("Una de las capas no era gpx: " + layer.name); } SaveGPXDialog.this.dispose(); } private File checkFileOverwritten(final JTextField nombre, File f) throws Exception { String nueva = JOptionPane.showInputDialog(nombre, i18n.getString("savegpxdialog.overwrite"), "Sobreescribir archivo", JOptionPane.QUESTION_MESSAGE, null, null, f.getCanonicalPath()) .toString(); log.debug("Nueva ruta: " + nueva); return new File(nueva); } }); JButton cancelar = new JButton("Cancelar", LogicConstants.getIcon("button_cancel")); cancelar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SaveGPXDialog.this.dispose(); } }); aceptar.setEnabled(false); botones.add(aceptar); botones.add(cancelar); dialogo.add(botones, BorderLayout.SOUTH); add(dialogo); setPreferredSize(new Dimension(300, 200)); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } this.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { nombre.setText(""); nombre.repaint(); } @Override public void windowClosing(WindowEvent e) { nombre.setText(""); nombre.repaint(); } }); }
From source file:edu.harvard.i2b2.adminTool.dataModel.PatientIDConversionFactory.java
private String getKey() { String path = null;//from www. java 2 s.com String key = UserInfoBean.getInstance().getKey(); if (key == null) { if ((path = getNoteKeyDrive()) == null) { Object[] possibleValues = { "Type in the key", "Browse to find the file containing the key" }; String selectedValue = (String) JOptionPane.showInputDialog(null, "You have selected an item associated with a report\n" + "which contains protected health information.\n" + "You need a decryption key to perform this operation.\n" + "How would you like to enter the key?\n" + "(If the key is on a floppy disk, insert the disk then\n select " + "\"Browse to find the file containing the key\")", "Notes Viewer", JOptionPane.QUESTION_MESSAGE, null, possibleValues, possibleValues[0]); if (selectedValue == null) { return "Not a valid key"; } if (selectedValue.equalsIgnoreCase("Type in the key")) { key = JOptionPane.showInputDialog(this, "Please input the decryption key"); if (key == null) { return "Not a valid key"; } } else { JFileChooser chooser = new JFileChooser(); int returnVal = chooser.showOpenDialog(null); if (returnVal == JFileChooser.CANCEL_OPTION) { return "Not a valid key"; } File f = null; if (returnVal == JFileChooser.APPROVE_OPTION) { f = chooser.getSelectedFile(); System.out.println("Open this file: " + f.getAbsolutePath()); BufferedReader in = null; try { in = new BufferedReader(new FileReader(f.getAbsolutePath())); String line = null; while ((line = in.readLine()) != null) { if (line.length() > 0) { key = line.substring(line.indexOf("\"") + 1, line.lastIndexOf("\"")); } } } catch (Exception e) { e.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (Exception e) { e.printStackTrace(); } } } } } } else { System.out.println("Found key file: " + path); BufferedReader in = null; try { in = new BufferedReader(new FileReader(path)); String line = null; while ((line = in.readLine()) != null) { if (line.length() > 0) { key = line.substring(line.indexOf("\"") + 1, line.lastIndexOf("\"")); } } } catch (Exception e) { e.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (Exception e) { e.printStackTrace(); } } } } } if (key == null) { return null; } else { UserInfoBean.getInstance().setKey(key); } return key; }
From source file:net.flamefeed.ftb.modpackupdater.FileOperator.java
/** * Obtain the absolute file path for the vanilla Minecraft directory based * on which Operating System is present/* ww w .ja va 2 s .co m*/ */ private void computePathMinecraft() { final String operatingSystem = System.getProperty("os.name"); if (operatingSystem.contains("Windows") || operatingSystem.equals("Linux")) { pathMinecraft = System.getenv("appdata") + "/.minecraft"; } else if (operatingSystem.contains("Mac")) { pathMinecraft = System.getenv("appdata") + "/minecraft"; } else { pathMinecraft = System.getenv("appdata") + "/.minecraft"; pathMinecraft = JOptionPane.showInputDialog(null, "Operating system not recognised, please indicate installation path for vanilla Minecraft launcher.", "Confirm Install Path", JOptionPane.PLAIN_MESSAGE, null, null, pathMinecraft).toString(); } // Replace all \\ which might occur in Windows paths with / to make // it uniform. Sadly this requires a regex of \\, which as a string is \\\\. // Dear god. pathMinecraft = pathMinecraft.replaceAll("\\\\", "/"); // Check validity of Minecraft directory File fileMinecraft = new File(pathMinecraft); if (pathMinecraft.equals("") || (fileMinecraft.exists() && !fileMinecraft.isDirectory())) { System.err.println("Invalid Minecraft installation path"); System.err.println(pathMinecraft); JOptionPane.showMessageDialog(null, "Minecraft installation path is invalid. Installer will now terminate."); System.exit(0); } // Make sure Minecraft directory is present. Does nothing if already there. fileMinecraft.mkdir(); }
From source file:eu.europeana.sip.gui.SipCreatorGUI.java
private File getFileStoreDirectory() throws FileStoreException { File fileStore = new File(System.getProperty("user.home"), "/sip-creator-file-store"); if (fileStore.isFile()) { try {/*from w ww . j a va2 s.co m*/ List<String> lines = FileUtils.readLines(fileStore); String directory; if (lines.size() == 1) { directory = lines.get(0); } else { directory = (String) JOptionPane.showInputDialog(null, "Please choose file store", "Launch SIP-Creator", JOptionPane.PLAIN_MESSAGE, null, lines.toArray(), ""); } if (directory == null) { System.exit(0); } fileStore = new File(directory); if (fileStore.exists() && !fileStore.isDirectory()) { throw new FileStoreException( String.format("%s is not a directory", fileStore.getAbsolutePath())); } } catch (IOException e) { throw new FileStoreException("Unable to read the file " + fileStore.getAbsolutePath()); } } return fileStore; }
From source file:com.frostwire.gui.library.LibraryUtils.java
public static void createNewPlaylist(final PlaylistItem[] playlistItems, boolean starred) { if (starred) { Thread t = new Thread(new Runnable() { public void run() { Playlist playlist = LibraryMediator.getLibrary().getStarredPlaylist(); addToPlaylist(playlist, playlistItems, true, -1); GUIMediator.safeInvokeLater(new Runnable() { public void run() { DirectoryHolder dh = LibraryMediator.instance().getLibraryExplorer() .getSelectedDirectoryHolder(); if (dh instanceof StarredDirectoryHolder) { LibraryMediator.instance().getLibraryExplorer().refreshSelection(); } else { LibraryMediator.instance().getLibraryExplorer().selectStarred(); }/* www. j a v a 2s . com*/ } }); } }, "createNewPlaylist"); t.setDaemon(true); t.start(); } else { String playlistName = (String) JOptionPane.showInputDialog(GUIMediator.getAppFrame(), I18n.tr("Playlist name"), I18n.tr("Playlist name"), JOptionPane.PLAIN_MESSAGE, null, null, calculateName(playlistItems)); if (playlistName != null && playlistName.length() > 0) { final Playlist playlist = LibraryMediator.getLibrary().newPlaylist(playlistName, playlistName); Thread t = new Thread(new Runnable() { public void run() { try { playlist.save(); addToPlaylist(playlist, playlistItems); playlist.save(); GUIMediator.safeInvokeLater(new Runnable() { public void run() { LibraryMediator.instance().getLibraryPlaylists().addPlaylist(playlist); } }); } finally { asyncAddToPlaylistFinalizer(playlist); } } }, "createNewPlaylist"); t.setDaemon(true); t.start(); } } }
From source file:it.imtech.configuration.ChooseServer.java
/** * Setta il percorso del file di configurazione se la prima volta che * viene avviata l'applicazione/*from w ww . j a v a 2s . c o m*/ * * @param change Definisce se l'avvio dell'applicazione o se si vuole * modificare il percorso * @throws MalformedURLException * @throws ConfigurationException */ private XMLConfiguration setConfigurationPaths(boolean change, XMLConfiguration internalConf, ResourceBundle bundle) { URL urlConfig = null; XMLConfiguration configuration = null; try { String text = Utility.getBundleString("setconf", bundle); String title = Utility.getBundleString("setconf2", bundle); internalConf.setAutoSave(true); String n = internalConf.getString("configurl[@path]"); if (n.isEmpty()) { String s = (String) JOptionPane.showInputDialog(new Frame(), text, title, JOptionPane.PLAIN_MESSAGE, null, null, "http://phaidrastatic.cab.unipd.it/xml/config.xml"); //If a string was returned, say so. if ((s != null) && (s.length() > 0)) { internalConf.setProperty("configurl[@path]", s); urlConfig = new URL(s); } else { logger.info("File di configurazione non settato"); } } else { urlConfig = new URL(n); } if (urlConfig != null) { if (Globals.DEBUG) configuration = new XMLConfiguration(new File(Globals.JRPATH + Globals.DEBUG_XML)); else configuration = new XMLConfiguration(urlConfig); } } catch (final MalformedURLException ex) { logger.error(ex.getMessage()); JOptionPane.showMessageDialog(new Frame(), Utility.getBundleString("exc_conf_1", bundle)); } catch (final ConfigurationException ex) { logger.error(ex.getMessage()); JOptionPane.showMessageDialog(new Frame(), Utility.getBundleString("exc_conf_2", bundle)); } return configuration; }