コード例 #1
0
ファイル: OptionsForm.java プロジェクト: glycerine/emacs4ij
 private boolean setServiceParameter(
     GlobalEnvironment.PropertyType type, JLabel label, JTextField textField) {
   String name = String.valueOf(type).toLowerCase();
   String startDirectory =
       StringUtil.isEmptyOrSpaces(textField.getText())
           ? System.getProperty("user.home")
           : textField.getText();
   JFileChooser fileChooser = new JFileChooser(startDirectory);
   fileChooser.setDialogTitle("Select Emacs " + name + " directory");
   fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
     String dir = fileChooser.getSelectedFile().getAbsolutePath();
     textField.setText(dir);
     if (GlobalEnvironment.testProperty(type, dir)) {
       infoLabel.setText("Emacs " + name + " directory successfully set");
       label.setForeground(Color.black);
       return true;
     } else {
       onWrongProperty(label, type);
       return false;
     }
   } else {
     if (GlobalEnvironment.isEmacsPropertyOk(type)) return true;
     onWrongProperty(label, type);
     return false;
   }
 }
コード例 #2
0
  // $$ modif from Oury
  private static JFileChooser getFileChooser(Component owner, int mode) {
    JFileChooser chooser = null;
    String last = /*Jext*/ AbstractEditorPanel.getProperty("lastdir." + mode);
    if (last == null) last = /*Jext*/ AbstractEditorPanel.getHomeDirectory();

    if (owner instanceof AbstractEditorPanel) {
      chooser = ((/*Jext*/ AbstractEditorPanel) owner).getFileChooser(mode);
      if (
      /*Jext*/ AbstractEditorPanel.getBooleanProperty("editor.dirDefaultDialog")
          && mode != SCRIPT) {
        String file =
            ((AbstractEditorPanel) owner)
                // $$ from Seb [[
                // .getTextArea()
                // $$ from Seb ]]
                .getCurrentFile();
        if (file != null) chooser.setCurrentDirectory(new File(file));
      } else chooser.setCurrentDirectory(new File(last));
    } else {
      chooser = new JFileChooser(last);
      if (mode == SAVE) chooser.setDialogType(JFileChooser.SAVE_DIALOG);
      else chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    }

    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setFileHidingEnabled(true);

    return chooser;
  }
コード例 #3
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
  /** Call this to browse for a custom gradle executor. */
  private void browseForCustomGradleExecutor() {
    File startingDirectory = new File(SystemProperties.getInstance().getUserHome());
    File currentFile = gradlePluginLord.getCustomGradleExecutor();
    if (currentFile != null) {
      startingDirectory = currentFile.getAbsoluteFile();
    } else {
      if (gradlePluginLord.getCurrentDirectory() != null) {
        startingDirectory = gradlePluginLord.getCurrentDirectory();
      }
    }

    JFileChooser chooser = new JFileChooser(startingDirectory);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(false);

    File file = null;
    if (chooser.showOpenDialog(mainPanel) == JFileChooser.APPROVE_OPTION) {
      file = chooser.getSelectedFile();
    }

    if (file != null) {
      setCustomGradleExecutor(file);
    } else { // if they canceled, and they have no custom gradle executor specified, then we must
             // clear things
      // This will reset the UI back to 'not using a custom executor'. We can't have them check the
      // field and not have a value here.
      if (gradlePluginLord.getCustomGradleExecutor() == null) {
        setCustomGradleExecutor(null);
      }
    }
  }
コード例 #4
0
 private void setupFileChooser() {
   fileChooser = new JFileChooser();
   fileChooser.setDialogTitle("Select directory to output ISArchive to...");
   fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
   fileChooser.setApproveButtonText("Output to selected directory");
   fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
 }
コード例 #5
0
ファイル: Main.java プロジェクト: GuilhermeHideki/b1lp2
  public static void main(String args[]) {

    // TODO: Use args
    if (false) {
      Parser p = new Parser();
      run(p.parse(ConfigFile));
    }

    // TODO: Use args
    if (true) {
      JFileChooser fileChooser = new JFileChooser();
      fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      fileChooser.showSaveDialog(null);
      String filepath = fileChooser.getSelectedFile().toString().replace("\\", "\\\\");
      // String filepath = "X:\\#inbox";

      List<Extension> text = new ArrayList<>();
      text.add(new ExtensionCaseInsensitive("doc"));
      text.add(new ExtensionCaseInsensitive("docx"));
      text.add(new ExtensionCaseInsensitive("pdf"));
      text.add(new ExtensionCaseInsensitive("txt"));

      run(new Folder(filepath, text));
    }
  }
コード例 #6
0
  private void initComponent() {
    // Create the logger first, because the action listeners
    // need to refer to it.
    logger = new JTextArea(8, 50);
    logger.setMargin(new Insets(5, 5, 5, 5));
    logger.setEditable(false);

    JScrollPane logScrollPane = new JScrollPane(logger);

    // Create a file chooser
    fc = new JFileChooser();
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    // Create the open button.  We use the image from the JLF
    // Graphics Repository (but we extracted it from the jar).
    openButton = new JButton("Chose NetBeans ...", createImageIcon("images/open.gif"));
    openButton.addActionListener(GuiFriendlizerApp.this);

    // Create the save button.  We use the image from the JLF
    // Graphics Repository (but we extracted it from the jar).
    patchButton = new JButton("Do Patch", createImageIcon("images/patch.gif"));
    patchButton.addActionListener(GuiFriendlizerApp.this);
    patchButton.setEnabled(false);

    // For layout purposes, put the buttons in a separate panel
    JPanel buttonPanel = new JPanel(); // use FlowLayout
    buttonPanel.add(openButton);
    buttonPanel.add(patchButton);

    // Add the buttons and the logger to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(logScrollPane, BorderLayout.CENTER);
  }
コード例 #7
0
  private static void assertChooser() {
    if (fc == null) {
      fc = new JFileChooser();
      Box ab = new Box(BoxLayout.Y_AXIS);
      ab.add(afap = new AudioFormatAccessoryPanel("Sample format"));
      ab.add(sap = new SaveAccessoryPanel(null));
      fc.setAccessory(ab);
      fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      fc.setFileFilter(
          new FileFilter() {
            public boolean accept(File f) {
              return f.isDirectory() && !f.equals(Zoeos.getZoeosLocalDir());
            }

            public String getDescription() {
              return "Directories";
            }
          });
      fc.setAcceptAllFileFilterUsed(false);
    }
    try {
      fc.setCurrentDirectory(new File(ZPREF_lastDir.getValue()));
    } catch (Exception e) {
    }
  }
コード例 #8
0
 private void selFolder() {
   // selects a single folder, then makes table uneditable other than launch, sel res folder and
   // cancel, gui table different, just shows folder
   final JFileChooser fc = new JFileChooser(currentPath);
   fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   int result = fc.showOpenDialog(FrontEnd.this);
   dir = fc.getSelectedFile();
   switch (result) {
     case JFileChooser.APPROVE_OPTION:
       dirImp = dir.toString();
       dtm.getDataVector().removeAllElements();
       dtm.fireTableDataChanged();
       curRow = 0;
       addRow();
       dtm.setValueAt(
           "You have chosen the folder '" + dirImp.substring(67) + "' and all of its subfolders.",
           0,
           0);
       dtm.setValueAt(dirImp.substring(67), 0, 1);
       if (table.getRowCount() > 0) {
         openF.setEnabled(false);
         openFo.setEnabled(false);
         selFo.setEnabled(false);
         canF.setEnabled(true);
       }
       selFoFl = 1;
     case JFileChooser.CANCEL_OPTION:
       break;
   }
 }
コード例 #9
0
ファイル: CaptureReplay.java プロジェクト: easilyBaffled/435
  // Add a test case to testBox and tests array.
  private void addTest() {

    // Set up the frame for the file chooser.
    final JFrame appframe = new JFrame("Select Application");
    appframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Container contentPane = appframe.getContentPane();
    JFileChooser fileChooser = new JFileChooser(".");

    // Only let you select directories and add chooser to pane.
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    contentPane.add(fileChooser, BorderLayout.CENTER);

    // Make a new action listener for the file chooser.
    ActionListener actionListener =
        new ActionListener() {

          public void actionPerformed(ActionEvent actionEvent) {

            // Get the information to check if the file chosen is valid.
            JFileChooser theFileChooser = (JFileChooser) actionEvent.getSource();
            String command = actionEvent.getActionCommand();

            // If the user cancels selecting a program.
            if (command.equals(JFileChooser.CANCEL_SELECTION)) {
              appframe.setVisible(false);
              appframe.dispose();
              return;
            }

            // If the file chosen is valid.
            if (command.equals(JFileChooser.APPROVE_SELECTION)) {
              // Retrieve the selected file and ask for the main class name.
              File f = theFileChooser.getSelectedFile();

              // Obtain the file URL.
              String fileURL = null;
              fileURL = f.getAbsolutePath();

              // Add a checkbox to the testing check pane.
              JCheckBox newTest = new JCheckBox(fileURL, true);
              testBox.setEditable(true);
              testBox.add(newTest);
              testBox.repaint();
              testBox.setEditable(false);
              // Add the test to the list of tests.
              tests.add(newTest);

              // Make the file chooser disappear.
              appframe.setVisible(false);
              appframe.dispose();
            }
          }
        };

    // Add the action listener created above to file chooser, display it.
    fileChooser.addActionListener(actionListener);
    appframe.pack();
    appframe.setVisible(true);
  }
コード例 #10
0
ファイル: Step2Panel.java プロジェクト: ambro2/popeye
  public void actionPerformed(ActionEvent e) {
    Object sender = e.getSource();
    /*
       if (sender == addButton)
       {
          if (project != null)
          {
            if (dirChooser != null)
            {
              dirChooser.setDialogTitle( "add a file" ) ;
              dirChooser.setFileSelectionMode( JFileChooser.FILES_ONLY) ;
              if ( dirChooser.showOpenDialog( this ) == JFileChooser.APPROVE_OPTION )
              {
                addFile( dirChooser.getSelectedFile() ) ;
              }
            }
            else System.out.println( "no chooser" ) ;
          }
          else System.out.println( "no project" ) ;
       }
       else if (sender == removeButton)
       {
         int row = table.getSelectedRow() ;

         if (project != null)
         {
           TProjectData data = project.getProjectData() ;
           TProjectFileList list = data.getAvailableLangs() ;

           TLanguageFile file = list.getData(row) ;

           list.removeLanguageVersion(file) ;

           if (list.getSize() < 1)
           {
             removeButton.setEnabled(false);
           }

           model.fireTableDataChanged();
         }

       }
       else if (sender == rescanButton)
       {

       }
       else
    */
    if (sender == this.baseButton) {
      //      dirChooser.setProjectFileFilter( (String) typeCombo.getSelectedItem() );
      dirChooser.setDialogTitle("select a base file");
      dirChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      if (dirChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        setBaseFile(dirChooser.getSelectedFile());
        rescan();
      }
    }
  }
コード例 #11
0
ファイル: StatisticsPanel.java プロジェクト: 166MMX/lilith
  private void createUI() {
    ShowMaxAction showMaxAction = new ShowMaxAction();
    showMaxCheckBox = new JCheckBox(showMaxAction);
    showMaxCheckBox.setOpaque(false);
    showMaxCheckBox.setSelected(true);
    saveFileChooser = new JFileChooser();
    saveFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    FileFilter pngFileFilter = new PngFileFilter();
    saveFileChooser.setFileFilter(pngFileFilter);
    graphImageFactories =
        new GraphImageProducer[] {
          new TwentyMinutesProducer(mainFrame),
          new TwoHoursProducer(mainFrame),
          new TenHoursProducer(mainFrame),
          new OneDayProducer(mainFrame),
          new SevenDaysProducer(mainFrame),
          new ThirtyDaysProducer(mainFrame),
          new NinetyDaysProducer(mainFrame),
          new OneYearProducer(mainFrame),
        };

    JPanel graphPanel = new JPanel(new GridLayout(1, 1));
    graphLabel = new JLabel();
    graphPanel.add(graphLabel);

    setLayout(new BorderLayout());
    add(graphPanel, BorderLayout.CENTER);
    timerangeComboBox =
        new JComboBox(
            new Object[] {
              "20 minutes",
              "2 hours",
              "10 hours",
              "1 day",
              "7 days",
              "30 days",
              "90 days",
              "1 year",
            });
    timerangeComboBox.addActionListener(new TimerangeActionListener());

    sourcesComboBox = new JComboBox();
    sourcesComboBox.addActionListener(new SourcesActionListener());

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    toolbar.add(new JLabel("Source: "));
    toolbar.add(sourcesComboBox);
    toolbar.addSeparator();
    toolbar.add(new JLabel("Timerange: "));
    toolbar.add(timerangeComboBox);
    toolbar.add(showMaxCheckBox);
    toolbar.addSeparator();
    toolbar.add(new JButton(new SaveAction()));
    add(toolbar, BorderLayout.NORTH);
    setSelectedGraph(0);
  }
コード例 #12
0
  /** The listener method. */
  public void actionPerformed(ActionEvent event) {
    Object source = event.getSource();

    if (source == b1) // click button
    {
      try {
        String message = tf.getText();
        server.sendPrivateMessage(parent, selfIdentity, message);
        ta.append("<" + parent.getUserName() + ">: " + message + lineSeparator);
        ta.setCaretPosition(ta.getText().length());
        tf.setText("");
      } catch (RemoteException ex) {
        System.out.print("Exception encountered while sending" + " private message.");
      }
    }

    if (source == tf) // press return
    {
      try {
        String message = tf.getText();
        server.sendPrivateMessage(parent, selfIdentity, message);
        ta.append("<" + parent.getUserName() + ">: " + message + lineSeparator);
        ta.setCaretPosition(ta.getText().length());
        tf.setText("");
      } catch (RemoteException ex) {
        System.out.print("Exception encountered while sending" + " private message.");
      }
    }
    if (source == jMenuItem3) {
      JFileChooser fileChooser = new JFileChooser();

      fileChooser.setDialogTitle("Choose or create a new file to store the conversation");
      fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      fileChooser.setDoubleBuffered(true);

      fileChooser.showOpenDialog(this);

      File file = fileChooser.getSelectedFile();

      try {
        if (file != null) {

          Writer writer = new BufferedWriter(new FileWriter(file));

          writer.write(ta.getText());
          writer.flush();
          writer.close();
        }
      } catch (IOException ex) {
        System.out.println("Can't write to file. " + ex);
      }
    }
    if (source == jMenuItem4) {
      selfRemove();
      this.dispose();
    }
  }
コード例 #13
0
      public void actionPerformed(ActionEvent evt) {
        File directory = new File(field.getText());
        JFileChooser chooser = new JFileChooser(directory.getParent());
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        chooser.setSelectedFile(directory);

        if (chooser.showOpenDialog(SwingInstall.this) == JFileChooser.APPROVE_OPTION)
          field.setText(chooser.getSelectedFile().getPath());
      }
コード例 #14
0
ファイル: ChooseFile.java プロジェクト: JustinRisch/GoIP
 public static File saveFile(String ext) {
   JFileChooser fileChooser = new JFileChooser("Save as...");
   fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
   FileFilter filter = new FileNameExtensionFilter(ext, ext);
   fileChooser.setAcceptAllFileFilterUsed(false);
   fileChooser.setFileFilter(filter);
   fileChooser.showSaveDialog(null);
   return fileChooser.getSelectedFile();
 }
コード例 #15
0
ファイル: CopyWindow.java プロジェクト: schneehund/synchros
  public Path dateiAuswählen(Path neuesLaufwerk) {
    JFileChooser fc1 = new JFileChooser();
    fc1.setDialogTitle("SyncOrdner auswählen");
    fc1.setCurrentDirectory(neuesLaufwerk.toFile());
    fc1.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    if (fc1.showSaveDialog(this) == JFileChooser.APPROVE_OPTION)
      return fc1.getSelectedFile().toPath();
    else return null;
  }
コード例 #16
0
 private void showOpenFileDialog() {
   JFileChooser fileChooser = new JFileChooser();
   fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
   fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   int result = fileChooser.showSaveDialog(this);
   if (result == JFileChooser.APPROVE_OPTION) {
     File selectedFile = fileChooser.getSelectedFile();
     txtHello.setText(selectedFile.getAbsolutePath());
   }
 }
コード例 #17
0
 public void resFol() {
   final JFileChooser fc = new JFileChooser(placeS);
   fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   int result = fc.showOpenDialog(FrontEnd.this);
   dir = fc.getSelectedFile();
   switch (result) {
     case JFileChooser.APPROVE_OPTION:
       dirImp = dir.toString();
       placeS = dirImp;
   }
 }
コード例 #18
0
 private String chooseFile() {
   // 文件选择器
   JFileChooser chooser = new JFileChooser();
   chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   // 获取用户的操作结果,是确认了,还是取消了
   int choose = chooser.showOpenDialog(null);
   // 判断选择的结果
   if (choose == JFileChooser.APPROVE_OPTION) {
     return chooser.getSelectedFile().getAbsolutePath();
   }
   return "";
 }
コード例 #19
0
 private void downloadDirectoryButtonActionPerformed(ActionEvent evt) {
   JFileChooser chooser = new JFileChooser();
   chooser.setCurrentDirectory(new File(Groovesquid.getConfig().getDownloadDirectory()));
   chooser.setDialogTitle(I18n.getLocaleString("SELECT_DOWNLOAD_DIRECTORY"));
   chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   chooser.setAcceptAllFileFilterUsed(false);
   if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
     String downloadDirectory = chooser.getSelectedFile().getPath();
     Groovesquid.getConfig().setDownloadDirectory(downloadDirectory);
     downloadDirectoryTextField.setText(downloadDirectory);
   }
 }
コード例 #20
0
ファイル: OpenFileDir.java プロジェクト: NCIP/dwd
  /*
   * This function just finds and loads the file
   */
  private boolean loadFile() {
    JFileChooser fc = new JFileChooser();
    fc.setDialogTitle("Load File");

    // Choose only files, not directories
    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);

    // Start in current directory
    fc.setCurrentDirectory(new File("."));

    // Set filter for Java source files.
    fc.setFileFilter(fJavaFilter);

    // Now open chooser
    int result = fc.showOpenDialog(this);

    if (result == JFileChooser.CANCEL_OPTION) {
      // return true;
    } else if (result == JFileChooser.APPROVE_OPTION) {

      fFile = fc.getSelectedFile();
      String textFile = fFile.toString();

      if (fileNo.equalsIgnoreCase("LOAD1")) {
        UpLoadFile.filePath1.setText(textFile);
      } else if (fileNo.equalsIgnoreCase("LOAD2")) {
        UpLoadFile.filePath2.setText(textFile);
      } else if (fileNo.equalsIgnoreCase("LOAD3")) {
        VisualizationInput.originalFilePath.setText(textFile);
      } else if (fileNo.equalsIgnoreCase("LOAD4")) {
        VisualizationInput.DWDVecFilePath.setText(textFile);
      } else if (fileNo.equalsIgnoreCase("LOAD5")) {
        VisualizationInput.DWDOutputFilePath.setText(textFile);
      } else if (fileNo.equalsIgnoreCase("LOAD6")) {
        UpLoadMAGEMLFile.filePath1.setText(textFile);
      } else if (fileNo.equalsIgnoreCase("LOAD7")) {
        UpLoadMAGEMLFile.filePath2.setText(textFile);
      }

      // Get the absolute path for the file being opened
      filePath = fFile.getAbsolutePath();

      if (filePath == null) {
        // fTextField.setText (filePath);
        return false;
      }

    } else {
      return false;
    }
    return true;
  } /*End of loadFile*/
コード例 #21
0
 private String getDirName(String title, String okButton, String currentDirectory) {
   JFileChooser fileChooser = new JFileChooser();
   fileChooser.setDialogTitle(title);
   fileChooser.setApproveButtonText(okButton);
   fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
   fileChooser.setCurrentDirectory(new File(currentDirectory));
   int result = fileChooser.showOpenDialog(this);
   if (result == JFileChooser.APPROVE_OPTION) {
     File selectedFile = fileChooser.getSelectedFile();
     return selectedFile.getAbsolutePath();
   }
   return null;
 }
コード例 #22
0
    /** Constructor. */
    public FileChooserCellEditor() {
      super(new JTextField());
      setClickCountToStart(CLICK_COUNT_TO_START);

      // Using a JButton as the editor component
      button = new JButton();
      button.setBackground(Color.white);
      button.setFont(button.getFont().deriveFont(Font.PLAIN));
      button.setBorder(null);

      // Dialog which will do the actual editing
      fileChooser = new JFileChooser();
      fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    }
コード例 #23
0
  public void createForm() {
    _nameLabel = new JLabel("Connection Name:");
    _usernameLabel = new JLabel("Username:"******"Password:"******"SVN URL:");
    _localLabel = new JLabel("Local Root:");

    _name = new JTextField(COLS);
    _name.setText(_workingCopy.getName());
    _username = new JTextField(COLS);
    _username.setText(_workingCopy.getUsername());
    _password = new JPasswordField(COLS);
    _password.setText(_workingCopy.getPassword());
    _url = new JTextField(COLS);
    _url.setText(_workingCopy.getUrl());

    _local = new JFileChooser();
    _local.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    _local.addActionListener(this);
    File current = new File(_workingCopy.getLocalRoot());
    _local.setSelectedFile(current);

    _error = new JLabel(" ");
    _error.setForeground(Color.red);

    _localButton = new JButton(".../" + current.getName());
    _localButton.addActionListener(this);

    _create = new JButton("Save Connection");
    _create.addActionListener(this);
    _cancel = new JButton("Cancel");
    _cancel.addActionListener(this);
    _test = new JButton("Test");
    _test.addActionListener(this);

    this.add(_nameLabel, "align right");
    this.add(_name);
    this.add(_usernameLabel, "align right");
    this.add(_username);
    this.add(_passwordLabel, "align right");
    this.add(_password);
    this.add(_urlLabel, "align right");
    this.add(_url);
    this.add(_localLabel, "align right");
    this.add(_localButton, "width 100%");
    this.add(_error, "span 2,align center");
    this.add(_cancel, "span 2, split 3, width 33%");
    this.add(_test, "width 33%");
    this.add(_create, "width 33%");
  }
コード例 #24
0
  private void showOpenFileDialog1() {
    JFileChooser fileChooser1 = new JFileChooser();
    fileChooser1.setCurrentDirectory(new File(System.getProperty("user.home")));
    fileChooser1.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser1.addChoosableFileFilter(
        new FileNameExtensionFilter("Microsoft Excel Documents", "xlsx", ".xls"));
    fileChooser1.setAcceptAllFileFilterUsed(true);
    int result1 = fileChooser1.showSaveDialog(this);

    if (result1 == JFileChooser.APPROVE_OPTION) {
      File selectedFile = fileChooser1.getSelectedFile();
      textField_1.setText(selectedFile.getAbsolutePath());
    }
  }
コード例 #25
0
  private void selectFolder() {

    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setCurrentDirectory(new File(textFolder.getText()));
    fileChooser.setDialogTitle(CAPTION_SELECT_FOLDER);
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fileChooser.setApproveButtonText("Select");
    fileChooser.setApproveButtonToolTipText(TOOL_TIP_SELECT_FOLDER);

    if (fileChooser.showOpenDialog(FileTransferServer.this) == JFileChooser.APPROVE_OPTION) {
      // Get the selected file
      String path = fileChooser.getSelectedFile().getPath() + "\\";
      textFolder.setText(path);
    }
  }
コード例 #26
0
  public void actionPerformed(ActionEvent e) {

    chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File("C:\\Program Files (x86)\\Tango04\\Dashboards\\Web"));
    chooser.setDialogTitle("Browse...");
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);

    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      textArea.setText("");
      new Exportator().startExporting(chooser.getSelectedFile().getPath(), textArea);
    } else {
      textArea.setText("No Selection");
    }
  }
コード例 #27
0
  public void actionPerformed(ActionEvent e) {
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(toolTip);
    chooser.setDialogType(dialogType);
    chooser.setFileSelectionMode(fileSelectionMode);
    chooser.setSelectedFile(new File(textField.getText()));
    chooser.setFileFilter(preferredFileFilter);

    // if the user selects APPROVE then take the text
    if (chooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
      // put the text in the text field
      String pathString = chooser.getSelectedFile().getAbsolutePath();
      textField.setText(pathString);
    }
  }
コード例 #28
0
  /** Show the save dialog to save the network file. */
  private void saveEvent() {
    JFileChooser fileSaver = new JFileChooser(inpFile.getParent());
    fileSaver.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileSaver.setAcceptAllFileFilterUsed(false);
    fileSaver.addChoosableFileFilter(new XLSXFilter());
    fileSaver.addChoosableFileFilter(new XMLFilter());
    fileSaver.addChoosableFileFilter(new INPFilter());

    fileSaver.showSaveDialog(frame);

    if (fileSaver.getSelectedFile() == null) return;

    Network.FileType netType = Network.FileType.INP_FILE;

    if (fileSaver.getFileFilter() instanceof XLSXFilter) {
      netType = Network.FileType.EXCEL_FILE;
    } else if (fileSaver.getFileFilter() instanceof XMLFilter) {
      netType = Network.FileType.XML_FILE;
      JOptionPane.showMessageDialog(frame, "Not supported yet !", "Error", JOptionPane.OK_OPTION);
      return;
    }

    OutputComposer compose = OutputComposer.create(netType);

    String extension = "";

    if (Utilities.getFileExtension(fileSaver.getSelectedFile().getName()).equals(""))
      switch (netType) {
        case INP_FILE:
          extension = ".inp";
          break;
        case EXCEL_FILE:
          extension = ".xlsx";
          break;
        case XML_FILE:
          extension = ".xml";
          break;
      }

    try {
      compose.composer(
          epanetNetwork, new File(fileSaver.getSelectedFile().getAbsolutePath() + extension));
    } catch (ENException e1) {
      e1.printStackTrace();
    }
  }
コード例 #29
0
ファイル: MapDialogs.java プロジェクト: Tiim/Illarion-Java
  public static Map[] showOpenMapDialog(final JFrame owner) throws IOException {
    final JFileChooser ch = new JFileChooser();
    if (config.getFile("mapLastOpenDir") != null) {
      ch.setCurrentDirectory(config.getFile("mapLastOpenDir"));
    }
    ch.setDialogType(JFileChooser.OPEN_DIALOG);
    ch.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (ch.showOpenDialog(MainFrame.getInstance()) != JFileChooser.APPROVE_OPTION) {
      return null;
    }
    final File dir = ch.getSelectedFile();
    config.set("mapLastOpenDir", dir);
    final String[] maps = dir.list(FILTER_TILES);
    for (int i = 0; i < maps.length; ++i) {
      maps[i] = maps[i].substring(0, maps[i].length() - MapIO.EXT_TILE.length());
    }
    final JDialog dialog = new JDialog(owner, Lang.getMsg("gui.chooser"));
    dialog.setModal(true);
    dialog.setLocationRelativeTo(null);
    dialog.setLayout(new BorderLayout());

    final JList list = new JList(maps);
    final JButton btn = new JButton(Lang.getMsg("gui.chooser.Ok"));

    btn.addActionListener(
        new AbstractAction() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            if (list.getSelectedValue() != null) {
              dialog.setVisible(false);
            }
          }
        });

    dialog.add(new JScrollPane(list), BorderLayout.CENTER);
    dialog.add(btn, BorderLayout.SOUTH);
    dialog.pack();
    dialog.setVisible(true);
    dialog.dispose();

    Map[] loadedMaps = new Map[list.getSelectedIndices().length];
    for (int i = 0; i < list.getSelectedIndices().length; i++) {
      loadedMaps[i] = MapIO.loadMap(dir.getPath(), (String) list.getSelectedValues()[i]);
    }
    return loadedMaps;
  }
コード例 #30
0
ファイル: SetupTab.java プロジェクト: gmercer/gradle
  /** Browses for a file using the text value from the text field as the current value. */
  private File browseForDirectory(File initialFile) {

    if (initialFile == null) {
      initialFile = SystemProperties.getInstance().getCurrentDir();
    }

    JFileChooser chooser = new JFileChooser(initialFile);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setMultiSelectionEnabled(false);

    File file = null;
    if (chooser.showOpenDialog(mainPanel) == JFileChooser.APPROVE_OPTION) {
      file = chooser.getSelectedFile();
    }

    return file;
  }