List of usage examples for javax.swing JFileChooser DIRECTORIES_ONLY
int DIRECTORIES_ONLY
To view the source code for javax.swing JFileChooser DIRECTORIES_ONLY.
Click Source Link
From source file:carolina.pegaLatLong.LatLong.java
private void geraCsv(List<InformacaoGerada> gerados) throws IOException { JFileChooser escolha = new JFileChooser(); escolha.setAcceptAllFileFilterUsed(false); escolha.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int i = escolha.showSaveDialog(null); if (i != 1) { System.err.println(escolha.getSelectedFile().getPath() + "\\teste.txt"); String caminho = escolha.getSelectedFile().getPath(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(caminho + "\\teste.csv"), StandardCharsets.ISO_8859_1)); //FileWriter arquivo = new FileWriter(caminho + "\\teste.csv"); //PrintWriter writer = new PrintWriter(arquivo); writer.write("Endereco;Latitude;Longitude"); writer.newLine();//from www . j av a 2s. c o m gerados.stream().forEach((gerado) -> { try { System.err.println(gerado.getEnderecoFormatado() + ";" + gerado.getLatitude() + ";" + gerado.getLongitude() + "\n"); writer.write(gerado.getEnderecoFormatado() + ";" + gerado.getLatitude() + ";" + gerado.getLongitude()); writer.newLine(); } catch (IOException ex) { System.err.println("Erro"); } }); writer.close(); JOptionPane.showMessageDialog(null, "Finalizado!"); } }
From source file:modmanager.MainWindow.java
private void changeModDirMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_changeModDirMenuItemActionPerformed {//GEN-HEADEREND:event_changeModDirMenuItemActionPerformed modificationDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); modificationDirectoryChooser.setDialogTitle("Choose modification directory"); if (modificationDirectoryChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { modifications.setModificationDirectory(modificationDirectoryChooser.getSelectedFile()); }/*from ww w .java 2s . c o m*/ }
From source file:de.codesourcery.jasm16.ide.ui.views.WorkspaceExplorer.java
protected JPopupMenu createPopupMenu(final WorkspaceTreeNode selectedNode) { final JPopupMenu popup = new JPopupMenu(); int openProjects = 0; int closedProjects = 0; for (IAssemblyProject p : workspace.getAllProjects()) { if (p.isOpen()) { openProjects++;// w ww . j a v a2s.c o m } else { closedProjects++; } } // open debugger final IAssemblyProject project = getProject(selectedNode); if (project != null) { if (project.isOpen()) { addMenuEntry(popup, "Close project", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { workspace.closeProject(project); } }); } else { addMenuEntry(popup, "Open project", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { workspace.openProject(project); } }); } addMenuEntry(popup, "Build project", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { project.getProjectBuilder().build(); } catch (Exception ex) { LOG.error("Failed to build " + project, ex); UIUtils.showErrorDialog(null, "Building project '" + project.getName() + "' failed", "Building the project failed: " + ex.getMessage(), ex); } } }); if (project.getProjectBuilder() == null) { throw new RuntimeException("Internal error, project " + project.getName() + " has no builder ??"); } final IResource executable = project.getProjectBuilder().getExecutable(); if (executable != null) { addMenuEntry(popup, "Open in debugger", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { openDebugPerspective(project, executable, perspectivesManager); } catch (IOException e1) { LOG.error( "Failed to open debug perspective for " + project + " , resource " + executable, e1); } } }); } } if (canCreateFileIn(selectedNode)) { addMenuEntry(popup, "New source file...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { createNewSourceFile(selectedNode); } catch (IOException e1) { LOG.error("actionPerformed(): ", e1); } } }); } addMenuEntry(popup, "New project...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { createNewProject(); } catch (Exception e1) { LOG.error("actionPerformed(): ", e1); UIUtils.showErrorDialog(panel, "Failed to create project", "Project creation failed: " + e1.getMessage()); } } }); if (selectedNode != null) { addMenuEntry(popup, "Delete...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteResource(selectedNode); } }); } addMenuEntry(popup, "Refresh", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { refreshWorkspace(project); } }); addMenuEntry(popup, "Import existing project...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser fc = new JFileChooser(workspace.getBaseDirectory()); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); final int returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { final File directory = fc.getSelectedFile(); try { workspace.importProject(directory); } catch (Exception e1) { UIUtils.showErrorDialog(null, "Failed to import project", "Error while importing project: " + e1.getMessage()); } } } }); if (project != null) { addMenuEntry(popup, "Project properties...", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ProjectConfigurationView view = (ProjectConfigurationView) getViewContainer() .getViewByID(ProjectConfigurationView.ID); if (view == null) { view = new ProjectConfigurationView() { @Override protected void onSave() { apply(project.getConfiguration()); try { project.getConfiguration().save(); } catch (IOException e) { UIUtils.showErrorDialog(null, "Error", "Failed to save project options", e); } finally { getViewContainer().disposeView(this); } } @Override protected void onCancel() { getViewContainer().disposeView(this); } }; getViewContainer().addView(view); } view.setProject(project); view.getViewContainer().toFront(view); } }); } if (closedProjects > 0) { addMenuEntry(popup, "Open ALL projects", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openAllProjects(); } }); } if (openProjects > 0) { addMenuEntry(popup, "Close ALL projects", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeAllProjects(); } }); } return popup; }
From source file:com.orange.atk.graphAnalyser.LectureJATKResult.java
/** * add all graph from a directory/*www .j a v a2 s . c om*/ * */ private void openDirectoryAction(ActionEvent evt) { ConfigFile configFile = null; String JATKpath = Platform.getInstance().getJATKPath(); String pathihmconfig = JATKpath + Platform.FILE_SEPARATOR + "log" + Platform.FILE_SEPARATOR + "ConfigIHM.cfg"; File ihmconfig = new File(pathihmconfig); configFile = new ConfigFile(ihmconfig); //get a value from confile String Scriptpath = getvalueconfigfile(pathihmconfig, "path_READGRAPH"); //open JfileChooser final JFileChooser fc = new JFileChooser(Scriptpath); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(jMenu1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); Scriptpath = file.getAbsolutePath(); if (Scriptpath != null) configFile.setOption("path_READGRAPH", Scriptpath); configFile.saveConfigFile(); //clean graph cleanlistElement(); analyzerGraphs.createMyDataset(file.getPath()); mapPerfGraph = analyzerGraphs.getMapPerfGraph(); mapAction = analyzerGraphs.getMapAction(); addPerformanceslist(); addMarkerlist(); //Add listener on list of graph and markers setListenerMarkerGraph(); //Crosshair Value Renderer et model setRendererandModelSeries(); } }
From source file:de.quadrillenschule.azocamsyncd.gui.ConfigurationWizardJFrame.java
private void localStorageDirjButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_localStorageDirjButton1ActionPerformed boolean success = false; JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.setSelectedFile(new File(gp.getProperty(CamSyncProperties.LOCALSTORAGE_PATH))); if (jfc.showDialog(jPanel1, "Choose as local directory") == JFileChooser.APPROVE_OPTION) { File f = new File(jfc.getSelectedFile().getAbsolutePath(), "azocamsynctest"); success = f.mkdir();/*ww w . ja va2 s .c o m*/ success = f.delete(); gp.setProperty(CamSyncProperties.LOCALSTORAGE_PATH, jfc.getSelectedFile().getAbsolutePath()); } if (success) { JOptionPane.showMessageDialog(rootPane, "You've setup the path for incoming files.\nAll configuration steps are performed now.\n Let's start the service!", "Success!", JOptionPane.INFORMATION_MESSAGE); step2jCheckBox.setSelected(true); step2jCheckBox.setText("Success"); this.setVisible(false); } else { JOptionPane.showConfirmDialog(rootPane, "This directory cannot read &write. Please choose another one.", "Local storage directory not working", JOptionPane.WARNING_MESSAGE); } }
From source file:coreferenceresolver.gui.MainGUI.java
private void markupBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_markupBtnActionPerformed JFileChooser inputFileChooser = new JFileChooser(defaulPath); inputFileChooser.setDialogTitle("Choose where your markup file saved"); inputFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (inputFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { String[] inputFilePath = inputFilePathTF.getText().split("\\\\"); String inputFileName = inputFilePath[inputFilePath.length - 1]; markupFilePathTF.setText(inputFileChooser.getSelectedFile().getAbsolutePath() + File.separator + inputFileName + ".markup"); noteTF.setText("Markup waiting ..."); new Thread(new Runnable() { @Override/*from w w w . java2s .c o m*/ public void run() { try { MarkupMain.markup(inputFilePathTF.getText(), markupFilePathTF.getText()); noteTF.setText("Markup done!"); String folderPathOpen = markupFilePathTF.getText().substring(0, markupFilePathTF.getText().lastIndexOf(File.separatorChar)); Desktop.getDesktop().open(new File(folderPathOpen)); } catch (IOException ex) { Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex); } } }).start(); } else { return; } }
From source file:marytts.tools.voiceimport.DatabaseImportMain.java
private static File determineVoiceBuildingDir(String[] args) { // Determine the voice building directory in the following order: // 1. System property "user.dir" // 2. First command line argument // 3. current directory // 4. Prompt user via gui. // Do a sanity check -- do they exist, do they have a wav/ subdirectory? String voiceBuildingDir = null; Vector<String> candidates = new Vector<String>(); candidates.add(System.getProperty("user.dir")); if (args.length > 0) candidates.add(args[0]);// w ww . j a v a2 s .co m candidates.add("."); // current directory for (String dir : candidates) { if (dir != null && new File(dir).isDirectory() && new File(dir + "/wav").isDirectory()) { voiceBuildingDir = dir; break; } } if (voiceBuildingDir == null) { // need to ask user JFrame window = new JFrame("This is the Frames's Title Bar!"); JFileChooser fc = new JFileChooser(); fc.setDialogTitle("Choose Voice Building Directory"); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); System.out.println("Opening GUI....... "); //outDir.setText(file.getAbsolutePath()); //System.exit(0); int returnVal = fc.showOpenDialog(window); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); if (file != null) voiceBuildingDir = file.getAbsolutePath(); } } System.setProperty("user.dir", voiceBuildingDir); if (voiceBuildingDir != null) { return new File(voiceBuildingDir); } else { return null; } }
From source file:at.tuwien.ifs.somtoolbox.apps.viewer.controls.ClusteringControl.java
public void init() { maxCluster = state.growingLayer.getXSize() * state.growingLayer.getYSize(); spinnerNoCluster = new JSpinner(new SpinnerNumberModel(1, 1, maxCluster, 1)); spinnerNoCluster.addChangeListener(new ChangeListener() { @Override/* w w w. jav a2 s . co m*/ public void stateChanged(ChangeEvent e) { numClusters = (Integer) ((JSpinner) e.getSource()).getValue(); SortedMap<Integer, ClusterElementsStorage> m = mapPane.getMap().getCurrentClusteringTree() .getAllClusteringElements(); if (m.containsKey(numClusters)) { st = m.get(numClusters).sticky; } else { st = false; } sticky.setSelected(st); redrawClustering(); } }); JPanel clusterPanel = UiUtils.makeBorderedPanel(new FlowLayout(FlowLayout.LEFT, 10, 0), "Clusters"); sticky.setToolTipText( "Marks this number of clusters as sticky for a certain leve; the next set of clusters will have a smaller boundary"); sticky.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { st = sticky.isSelected(); SortedMap<Integer, ClusterElementsStorage> m = mapPane.getMap().getCurrentClusteringTree() .getAllClusteringElements(); if (m.containsKey(numClusters)) { ClusterElementsStorage c = m.get(numClusters); c.sticky = st; // System.out.println("test"); // ((ClusterElementsStorageNode)m.get(numClusters)).sticky = st; redrawClustering(); } } }); colorCluster = new JCheckBox("colour", state.colorClusters); colorCluster.setToolTipText("Fill the clusters in colours"); colorCluster.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { state.colorClusters = colorCluster.isSelected(); // TODO: Palette anzeigen (?) redrawClustering(); } }); UiUtils.fillPanel(clusterPanel, new JLabel("#"), spinnerNoCluster, sticky, colorCluster); getContentPane().add(clusterPanel, c.nextRow()); dendogramPanel = UiUtils.makeBorderedPanel(new GridLayout(0, 1), "Dendogram"); getContentPane().add(dendogramPanel, c.nextRow()); JPanel numLabelPanel = UiUtils.makeBorderedPanel(new GridBagLayout(), "Labels"); GridBagConstraintsIFS gcLabels = new GridBagConstraintsIFS(); labelSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1)); labelSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { numLabels = (Integer) ((JSpinner) e.getSource()).getValue(); state.clusterWithLabels = numLabels; redrawClustering(); } }); this.showValues = new JCheckBox("values", state.labelsWithValues); this.showValues.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { state.labelsWithValues = showValues.isSelected(); redrawClustering(); } }); int start = new Double((1 - state.clusterByValue) * 100).intValue(); valueQe = new JSlider(0, 100, start); valueQe.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int byValue = ((JSlider) e.getSource()).getValue(); state.clusterByValue = 1 - byValue / 100; redrawClustering(); } }); numLabelPanel.add(new JLabel("# Labels"), gcLabels); numLabelPanel.add(labelSpinner, gcLabels.nextCol()); numLabelPanel.add(showValues, gcLabels.nextCol()); numLabelPanel.add(valueQe, gcLabels.nextRow().setGridWidth(3).setFill(GridBagConstraints.HORIZONTAL)); getContentPane().add(numLabelPanel, c.nextRow()); Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); labelTable.put(0, new JLabel("by Value")); labelTable.put(100, new JLabel("by Qe")); valueQe.setToolTipText("Method how to select representative labels - by QE, or the attribute values"); valueQe.setLabelTable(labelTable); valueQe.setPaintLabels(true); final JComboBox initialisationBox = new JComboBox(KMeans.InitType.values()); initialisationBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object o = mapPane.getMap().getClusteringTreeBuilder(); if (o instanceof KMeansTreeBuilder) { ((KMeansTreeBuilder) o).reInit((KMeans.InitType) initialisationBox.getSelectedItem()); // FIXME: is this call needed? mapPane.getMap().getCurrentClusteringTree().getAllClusteringElements(); redrawClustering(); } } }); getContentPane().add(UiUtils.fillPanel(kmeansInitialisationPanel, new JLabel("k-Means initialisation"), initialisationBox), c.nextRow()); JPanel borderPanel = new TitledCollapsiblePanel("Border", new GridLayout(1, 4), true); JSpinner borderSpinner = new JSpinner( new SpinnerNumberModel(ClusteringTree.INITIAL_BORDER_WIDTH_MAGNIFICATION_FACTOR, 0.1, 5, 0.1)); borderSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { state.clusterBorderWidthMagnificationFactor = ((Double) ((JSpinner) e.getSource()).getValue()) .floatValue(); redrawClustering(); } }); borderPanel.add(new JLabel("width")); borderPanel.add(borderSpinner); borderPanel.add(new JLabel("colour")); buttonColour = new JButton(""); buttonColour.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new ClusterBoderColorChooser(state.parentFrame, state.clusterBorderColour, ClusteringControl.this); } }); buttonColour.setBackground(state.clusterBorderColour); borderPanel.add(buttonColour); getContentPane().add(borderPanel, c.nextRow()); JPanel evaluationPanel = new TitledCollapsiblePanel("Cluster Evaluation", new GridLayout(3, 2), true); evaluationPanel.add(new JLabel("quality measure")); qualityMeasureButton = new JButton(); qualityMeasureButton.setText("ent/pur calc"); qualityMeasureButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("doing entropy here"); ClusteringTree clusteringTree = state.mapPNode.getClusteringTree(); if (clusteringTree == null) { // we have not clustered yet return; } // System.out.println(clusteringTree.getChildrenCount()); // FIXME put this in a method and call it on numcluster.change() SOMLibClassInformation classInfo = state.inputDataObjects.getClassInfo(); ArrayList<ClusterNode> clusters = clusteringTree.getNodesAtLevel(numClusters); System.out.println(clusters.size()); // EntropyMeasure.computeEntropy(clusters, classInfo); EntropyAndPurityCalculator eapc = new EntropyAndPurityCalculator(clusters, classInfo); // FIXME round first entropyLabel.setText(String.valueOf(eapc.getEntropy())); purityLabel.setText(String.valueOf(eapc.getPurity())); } }); evaluationPanel.add(qualityMeasureButton); GridBagConstraintsIFS gcEval = new GridBagConstraintsIFS(); evaluationPanel.add(new JLabel("entropy"), gcEval); evaluationPanel.add(new JLabel("purity"), gcEval.nextCol()); entropyLabel = new JLabel("n/a"); purityLabel = new JLabel("n/a"); evaluationPanel.add(entropyLabel, gcEval.nextRow()); evaluationPanel.add(purityLabel, gcEval.nextCol()); getContentPane().add(evaluationPanel, c.nextRow()); JPanel panelButtons = new JPanel(new GridLayout(1, 4)); JButton saveButton = new JButton("Save"); saveButton.setFont(smallFont); saveButton.setMargin(SMALL_INSETS); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser; if (state.fileChooser.getSelectedFile() != null) { fileChooser = new JFileChooser(state.fileChooser.getSelectedFile().getPath()); } else { fileChooser = new JFileChooser(); } fileChooser.addChoosableFileFilter(clusteringFilter); fileChooser.addChoosableFileFilter(xmlFilter); File filePath = ExportUtils.getFilePath(ClusteringControl.this, fileChooser, "Save Clustering and Labels"); if (filePath != null) { if (xmlFilter.accept(filePath)) { LabelXmlUtils.saveLabelsToFile(state.mapPNode, filePath); } else { try { FileOutputStream fos = new FileOutputStream(filePath); GZIPOutputStream gzipOs = new GZIPOutputStream(fos); PObjectOutputStream oos = new PObjectOutputStream(gzipOs); oos.writeObjectTree(mapPane.getMap().getCurrentClusteringTree()); oos.writeObjectTree(mapPane.getMap().getManualLabels()); oos.writeInt(state.clusterWithLabels); oos.writeBoolean(state.labelsWithValues); oos.writeDouble(state.clusterByValue); oos.writeObject(spinnerNoCluster.getValue()); oos.close(); } catch (Exception ex) { ex.printStackTrace(); } } // keep the selected path for future references state.fileChooser.setSelectedFile(filePath.getParentFile()); } } }); panelButtons.add(saveButton); JButton loadButton = new JButton("Load"); loadButton.setFont(smallFont); loadButton.setMargin(SMALL_INSETS); loadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = getFileChooser(); fileChooser.setName("Open Clustering"); fileChooser.addChoosableFileFilter(xmlFilter); fileChooser.addChoosableFileFilter(clusteringFilter); int returnVal = fileChooser.showDialog(ClusteringControl.this, "Open"); if (returnVal == JFileChooser.APPROVE_OPTION) { File filePath = fileChooser.getSelectedFile(); if (xmlFilter.accept(filePath)) { PNode restoredLabels = null; try { restoredLabels = LabelXmlUtils.restoreLabelsFromFile(fileChooser.getSelectedFile()); PNode manual = state.mapPNode.getManualLabels(); ArrayList<PNode> tmp = new ArrayList<PNode>(); for (ListIterator<?> iter = restoredLabels.getChildrenIterator(); iter.hasNext();) { PNode element = (PNode) iter.next(); tmp.add(element); } manual.addChildren(tmp); Logger.getLogger("at.tuwien.ifs.somtoolbox") .info("Successfully loaded cluster labels."); } catch (Exception e1) { e1.printStackTrace(); Logger.getLogger("at.tuwien.ifs.somtoolbox") .info("Error loading cluster labels: " + e1.getMessage()); } } else { try { FileInputStream fis = new FileInputStream(filePath); GZIPInputStream gzipIs = new GZIPInputStream(fis); ObjectInputStream ois = new ObjectInputStream(gzipIs); ClusteringTree tree = (ClusteringTree) ois.readObject(); PNode manual = (PNode) ois.readObject(); PNode all = mapPane.getMap().getManualLabels(); ArrayList<PNode> tmp = new ArrayList<PNode>(); for (ListIterator<?> iter = manual.getChildrenIterator(); iter.hasNext();) { PNode element = (PNode) iter.next(); tmp.add(element); } all.addChildren(tmp); state.clusterWithLabels = ois.readInt(); labelSpinner.setValue(state.clusterWithLabels); state.labelsWithValues = ois.readBoolean(); showValues.setSelected(state.labelsWithValues); state.clusterByValue = ois.readDouble(); valueQe.setValue(new Double((1 - state.clusterByValue) * 100).intValue()); mapPane.getMap().buildTree(tree); spinnerNoCluster.setValue(ois.readObject()); ois.close(); Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Successfully loaded clustering."); } catch (Exception ex) { ex.printStackTrace(); Logger.getLogger("at.tuwien.ifs.somtoolbox") .info("Error loading clustering: " + ex.getMessage()); } } // keep the selected path for future references state.fileChooser.setSelectedFile(filePath.getParentFile()); } } }); panelButtons.add(loadButton); JButton exportImages = new JButton("Export"); exportImages.setFont(smallFont); exportImages.setMargin(SMALL_INSETS); exportImages.setToolTipText("Export labels as images (not yet working)"); exportImages.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); if (CommonSOMViewerStateData.fileNamePrefix != null && !CommonSOMViewerStateData.fileNamePrefix.equals("")) { fileChooser.setCurrentDirectory(new File(CommonSOMViewerStateData.fileNamePrefix)); } else { fileChooser.setCurrentDirectory(state.getFileChooser().getCurrentDirectory()); } fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (fileChooser.getSelectedFile() != null) { // reusing the dialog fileChooser.setSelectedFile(null); } fileChooser.setName("Choose path"); int returnVal = fileChooser.showDialog(ClusteringControl.this, "Choose path"); if (returnVal == JFileChooser.APPROVE_OPTION) { // save images String path = fileChooser.getSelectedFile().getAbsolutePath(); Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Writing label images to " + path); } } }); panelButtons.add(exportImages); JButton deleteManual = new JButton("Delete"); deleteManual.setFont(smallFont); deleteManual.setMargin(SMALL_INSETS); deleteManual.setToolTipText("Delete manually added labels."); deleteManual.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { state.mapPNode.getManualLabels().removeAllChildren(); Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Manual Labels deleted."); } }); panelButtons.add(deleteManual); c.anchor = GridBagConstraints.NORTH; this.getContentPane().add(panelButtons, c.nextRow()); this.setVisible(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:br.upe.ecomp.dosa.view.wizard.WizardAction.java
@Override protected void fileBrowseButtonActionPerformed(ActionEvent evt) { JFileChooser fileopen = new JFileChooser(); fileopen.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int ret = fileopen.showDialog(this, "Open file"); if (ret == JFileChooser.APPROVE_OPTION) { fileLocationTextField.setText(fileopen.getSelectedFile().toString()); }// w w w .j av a2s. com }