public File showDirOpenDialog(Component parent, File defaultDir) {
   if (Platform.isMacOS()) {
     System.setProperty("apple.awt.fileDialogForDirectories", "true");
     FileDialog dialog = null;
     if (parent instanceof JFrame == false && parent instanceof JDialog == false) {
       parent = ((JComponent) parent).getTopLevelAncestor();
     }
     if (parent instanceof JFrame) dialog = new FileDialog((JFrame) parent);
     else dialog = new FileDialog((JDialog) parent);
     if (defaultDir != null) dialog.setDirectory(defaultDir.getAbsolutePath());
     dialog.setVisible(true);
     if (dialog.getDirectory() == null || dialog.getFile() == null) return null;
     File file = new File(dialog.getDirectory(), dialog.getFile());
     System.setProperty("apple.awt.fileDialogForDirectories", "false");
     return file;
   } else {
     JFileChooser chooser = new JFileChooser();
     if (defaultDir != null) chooser.setCurrentDirectory(defaultDir);
     chooser.setDialogType(JFileChooser.OPEN_DIALOG);
     chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     chooser.showOpenDialog(parent);
     File file = chooser.getSelectedFile();
     return file;
   }
 }
  @Override
  public void actionPerformed(ActionEvent e) {
    Frame f = new Frame();
    FileDialog fileChooser = new FileDialog(f, "Load", FileDialog.LOAD);
    fileChooser.setVisible(true);
    File targetFile = new File(fileChooser.getDirectory() + fileChooser.getFile());

    if (fileChooser.getDirectory() == null) {
      return;
    }

    if (!targetFile.exists() || !targetFile.isFile()) {
      JOptionPane.showMessageDialog(null, "File invalid", "Error", JOptionPane.ERROR_MESSAGE);
      return;
    }

    boolean loaded = false;
    ResultOpinionExtractor resultOpinionExtractor = new ResultOpinionExtractor(targetFile);
    try {
      loaded = resultOpinionExtractor.load();
    } catch (FileNotFoundException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    if (loaded) {
      statisticView.setOpinionResult(resultOpinionExtractor);
    }
  }
示例#3
0
  private void getDiretorio() {

    try {

      FileDialog fileDialog = new FileDialog(Aplicativo.telaPrincipal, "Selecionar diretorio.");
      fileDialog.setFile("*.txt");
      fileDialog.setVisible(true);

      if (fileDialog.getDirectory() != null) {

        if (EXPORTAR == rgModo.getVlrInteger()) {
          txtDiretorio.setVlrString(fileDialog.getDirectory() + fileDialog.getFile());
          status.setString("Buscar produtos para exportação ...");
          btBuscarProdutos.setEnabled(true);
          btBuscarProdutos.requestFocus();
        } else if (IMPORTAR == rgModo.getVlrInteger()) {
          txtDiretorio.setVlrString(fileDialog.getDirectory() + fileDialog.getFile());
          status.setString("Importar produtos do arquivo " + fileDialog.getFile() + " ...");
          btImportar.setEnabled(true);
          btImportar.requestFocus();
        }
      } else {
        txtDiretorio.setVlrString("");
        btDirtorio.requestFocus();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#4
0
 public void loadROM() {
   FileDialog fileDialog = new FileDialog(this);
   fileDialog.setMode(FileDialog.LOAD);
   fileDialog.setTitle("Select a ROM to load");
   // should open last folder used, and if that doesn't exist, the folder it's running in
   final String path = PrefsSingleton.get().get("filePath", System.getProperty("user.dir", ""));
   final File startDirectory = new File(path);
   if (startDirectory.isDirectory()) {
     fileDialog.setDirectory(path);
   }
   // and if the last path used doesn't exist don't set the directory at all
   // and hopefully the jFileChooser will open somewhere usable
   // on Windows it does - on Mac probably not.
   fileDialog.setFilenameFilter(new NESFileFilter());
   boolean wasInFullScreen = false;
   if (inFullScreen) {
     wasInFullScreen = true;
     // load dialog won't show if we are in full screen, so this fixes for now.
     toggleFullScreen();
   }
   fileDialog.setVisible(true);
   if (fileDialog.getFile() != null) {
     PrefsSingleton.get().put("filePath", fileDialog.getDirectory());
     loadROM(fileDialog.getDirectory() + fileDialog.getFile());
   }
   if (wasInFullScreen) {
     toggleFullScreen();
   }
 }
示例#5
0
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand() == "Open") { // open버튼을 눌렀다면
     fdOpen.setVisible(true);
     System.out.println(fdOpen.getDirectory() + fdOpen.getFile());
   } else { // save버튼을 눌렀다면
     fdSave.setVisible(true);
     System.out.println(fdSave.getDirectory() + fdSave.getFile());
   }
 }
示例#6
0
文件: Layout.java 项目: ptrsz/nagyhf
    @Override
    public void actionPerformed(ActionEvent event) {
      String command = event.getActionCommand();
      if (command.equals("add")) {
        MultipleInputDialog inputDialog = new MultipleInputDialog();
        data.add(inputDialog.getDialogCar());

      } else if (command.equals("save")) {
        try {
          FileDialog fd = new FileDialog(Layout.this, "Válasszon egy célmappát", FileDialog.SAVE);
          fd.setVisible(true);
          String dir = fd.getDirectory();
          String filename = fd.getFile();

          FileOutputStream fileOut = new FileOutputStream(dir + filename);
          ObjectOutputStream out = new ObjectOutputStream(fileOut);
          out.writeObject(Layout.this.data);
          out.close();
          fileOut.close();
          System.out.println("save OK");
          System.out.println("Kiirva 1/1 adat " + data.get(1).getOne());

        } catch (IOException i) {
          i.printStackTrace();
        }
      } else if (command.equals("load")) {
        try {
          FileDialog fd = new FileDialog(Layout.this, "Válasszon egy célmappát", FileDialog.LOAD);
          fd.setVisible(true);
          String dir = fd.getDirectory();
          String filename = fd.getFile();

          FileInputStream fileIn = new FileInputStream(dir + filename);
          ObjectInputStream in = new ObjectInputStream(fileIn);

          Layout.this.data = (ArrayList<Car>) in.readObject();
          dataTable.repaint();

          fileIn.close();
          in.close();

          System.out.println("beolvasva");
          repaint();

          System.out.println("olvasva 1/1 adat data-ban " + data.get(1).getOne());
        } catch (IOException i) {
          i.printStackTrace();
        } catch (ClassNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      } else if (command.equals("browse")) {
        FileDialog jf = new FileDialog(Layout.this, "Choose something", FileDialog.LOAD);
        jf.setVisible(true);
      }
    }
示例#7
0
 public String rChooseFile(Rengine re, int newFile) {
   FileDialog fd =
       new FileDialog(
           f,
           (newFile == 0) ? "Select a file" : "Select a new file",
           (newFile == 0) ? FileDialog.LOAD : FileDialog.SAVE);
   fd.show();
   String res = null;
   if (fd.getDirectory() != null) res = fd.getDirectory();
   if (fd.getFile() != null) res = (res == null) ? fd.getFile() : (res + fd.getFile());
   return res;
 }
  /**
   * Open the dialog to load an file, swing based
   *
   * @return the file or null
   */
  @Override
  public File[] openDialog(final boolean multiple, final boolean folder, FileFilter filter) {

    // folder selector?
    if (folder) {
      return super.openDialog(multiple, folder, filter);
    }

    final FileDialog d = new FileDialog(new Frame(), "", FileDialog.LOAD);
    d.setVisible(true);
    if (d.getFile() != null) {
      File f = new File(d.getDirectory(), d.getFile());
      // is typ ok?
      if (folder && !f.isDirectory()) {
        f = f.getParentFile();
      }

      // file filter?
      if (filter != null && !filter.accept(f)) {
        TaskDialogs.inform(
            null,
            I18N.t("File {0} has wrong format", f.getName()),
            I18N.t(
                "Please select in the file dialog only a file, who match {0}. {1} doesn't do this.",
                filter.getDescription(), f.getAbsoluteFile()));
      }

      return new File[] {f};
    }
    return new File[] {};
  }
示例#9
0
  public static Action[] ReadProtocolbyDialog(JFrame parent) {
    // ???? ???? ??????¥á? ????
    FileDialog fileDialog = new FileDialog(parent, "Select protocol file", FileDialog.LOAD);
    fileDialog.setFile("*.txt");
    fileDialog.setVisible(true);

    String dir = fileDialog.getDirectory();
    String file = fileDialog.getFile();
    String path = dir + file;

    if (dir == null) {
      Action[] action = new Action[1];
      action[0] = new Action();
      return action;
    }

    BufferedReader in = null;
    ArrayList<String> inData = new ArrayList<String>();
    String tempData = null;

    // ????¥ê??? ??????? ?¬à?
    try {
      in = new BufferedReader(new InputStreamReader(new FileInputStream(path)));

      while ((tempData = in.readLine()) != null) {
        inData.add(tempData);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        in.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    // PCR Protocol ???????? ???
    // ?? ????? ?? ????? %PCR%, %END% ?? ????? ???
    String start = inData.get(0);
    String end = inData.get(inData.size() - 1);
    int actionCount = inData.size() - 2;
    Action[] actions = new Action[actionCount];

    if (!start.contains("%PCR%")) return null;
    if (!end.contains("%END")) return null;

    for (int i = 1; i < inData.size() - 1; i++) {
      String[] datas = inData.get(i).split("\t{1,}| {1,}");
      actions[i - 1] = new Action(file);
      int j = 0;
      for (String temp : datas) {
        actions[i - 1].set(j++, temp);
      }
    }

    if (actions[0].getLabel() != null) Save_RecentProtocol(path);

    return actions;
  }
示例#10
0
 /** Opens a save dialog box when the user selects "Save As" from the menu. */
 public void actionPerformed(ActionEvent e) {
   FileDialog chooser = new FileDialog(frame, "Use a .png or .jpg extension", FileDialog.SAVE);
   chooser.setVisible(true);
   if (chooser.getFile() != null) {
     save(chooser.getDirectory() + File.separator + chooser.getFile());
   }
 }
示例#11
0
  //    public static final String showElementTreeAction = "showElementTree";
  // -------------------------------------------------------------
  public void openFile(String currDirStr, String currFileStr) {

    if (fileDialog == null) {
      fileDialog = new FileDialog(this);
    }
    fileDialog.setMode(FileDialog.LOAD);
    if (!(currDirStr.equals(""))) {
      fileDialog.setDirectory(currDirStr);
    }
    if (!(currFileStr.equals(""))) {
      fileDialog.setFile(currFileStr);
    }
    fileDialog.show();

    String file = fileDialog.getFile(); // cancel pushed
    if (file == null) {
      return;
    }
    String directory = fileDialog.getDirectory();
    File f = new File(directory, file);
    if (f.exists()) {
      Document oldDoc = getEditor().getDocument();
      if (oldDoc != null)
        // oldDoc.removeUndoableEditListener(undoHandler);
        /*
          if (elementTreePanel != null) {
          elementTreePanel.setEditor(null);
          }
        */
        getEditor().setDocument(new PlainDocument());
      fileDialog.setTitle(file);
      Thread loader = new FileLoader(f, editor1.getDocument());
      loader.start();
    }
  }
示例#12
0
  private void getFluffImage() {
    // copied from structureTab
    FileDialog fDialog = new FileDialog(getParentFrame(), "Image Path", FileDialog.LOAD);
    fDialog.setDirectory(
        new File(ImageHelper.fluffPath).getAbsolutePath()
            + File.separatorChar
            + ImageHelper.imageMech
            + File.separatorChar);
    fDialog.setLocationRelativeTo(this);

    fDialog.setVisible(true);

    if (fDialog.getFile() != null) {
      String relativeFilePath =
          new File(fDialog.getDirectory() + fDialog.getFile()).getAbsolutePath();
      relativeFilePath =
          "."
              + File.separatorChar
              + relativeFilePath.substring(
                  new File(System.getProperty("user.dir").toString()).getAbsolutePath().length()
                      + 1);
      getAero().getFluff().setMMLImagePath(relativeFilePath);
    }
    refresh.refreshPreview();
    return;
  }
示例#13
0
 void openEffect() {
   FileDialog dialog = new FileDialog(editor, "Open Effect", FileDialog.LOAD);
   if (lastDir != null) dialog.setDirectory(lastDir);
   dialog.setVisible(true);
   final String file = dialog.getFile();
   final String dir = dialog.getDirectory();
   if (dir == null || file == null || file.trim().length() == 0) return;
   lastDir = dir;
   ParticleEffect effect = new ParticleEffect();
   try {
     effect.loadEmitters(Gdx.files.absolute(new File(dir, file).getAbsolutePath()));
     editor.effect = effect;
     emitterTableModel.getDataVector().removeAllElements();
     editor.particleData.clear();
   } catch (Exception ex) {
     System.out.println("Error loading effect: " + new File(dir, file).getAbsolutePath());
     ex.printStackTrace();
     JOptionPane.showMessageDialog(editor, "Error opening effect.");
     return;
   }
   for (ParticleEmitter emitter : effect.getEmitters()) {
     emitter.setPosition(
         editor.worldCamera.viewportWidth / 2, editor.worldCamera.viewportHeight / 2);
     emitterTableModel.addRow(new Object[] {emitter.getName(), true});
   }
   editIndex = 0;
   emitterTable.getSelectionModel().setSelectionInterval(editIndex, editIndex);
   editor.reloadRows();
 }
示例#14
0
 public static void midi(Score paramScore) {
   FileDialog localFileDialog = new FileDialog(new Frame(), "Save as a MIDI file ...", 1);
   localFileDialog.setFile("jMusic_composition.mid");
   localFileDialog.show();
   if (localFileDialog.getFile() != null) {
     midi(paramScore, localFileDialog.getDirectory() + localFileDialog.getFile());
   }
 }
示例#15
0
 public int show() {
   if (useFileDialog) {
     fileDialog.setVisible(true);
     if (fileDialog.getDirectory() == null) {
       return JFileChooser.CANCEL_OPTION;
     } else {
       PreferenceManager.getCurrent()
           .setFile(dirPreference, new File(fileDialog.getDirectory()));
       return JFileChooser.APPROVE_OPTION;
     }
   }
   int status = jfc.showDialog(getApplicationPanel(), taskName);
   if (status == JFileChooser.APPROVE_OPTION) {
     PreferenceManager.getCurrent().setFile(dirPreference, jfc.getCurrentDirectory());
   }
   return status;
 }
 // 浏览数据库日志文件按钮单击事件
 protected void do_logBrowButton_actionPerformed(ActionEvent arg0) {
   java.awt.FileDialog fd = new FileDialog(this);
   fd.setVisible(true);
   String filePath = fd.getDirectory() + fd.getFile();
   if (filePath.endsWith(".LDF")) {
     logTextField.setText(filePath);
   }
 }
  /**
   * The implementation that the other methods delegate to. This provides the caller with all
   * available options for customizing the <tt>JFileChooser</tt> instance. If a <tt>FileDialog</tt>
   * is displayed instead of a <tt>JFileChooser</tt> (on OS X, for example), most or all of these
   * options have no effect.
   *
   * @param parent the <tt>Component</tt> that should be the dialog's parent
   * @param titleKey the key for the locale-specific string to use for the file dialog title
   * @param approveKey the key for the locale-specific string to use for the approve button text
   * @param directory the directory to open the dialog to
   * @param mode the "mode" to open the <tt>JFileChooser</tt> in from the <tt>JFileChooser</tt>
   *     class, such as <tt>JFileChooser.DIRECTORIES_ONLY</tt>
   * @param option the option to look for in the return code, such as
   *     <tt>JFileChooser.APPROVE_OPTION</tt>
   * @param allowMultiSelect true if the chooser allows multiple files to be chosen
   * @param filter the <tt>FileFilter</tt> instance for customizing the files that are displayed --
   *     if this is null, no filter is used
   * @return the selected <tt>File</tt> instance, or <tt>null</tt> if a file was not selected
   *     correctly
   */
  public static List<File> getInput(
      Component parent,
      String titleKey,
      String approveKey,
      File directory,
      int mode,
      int option,
      boolean allowMultiSelect,
      final FileFilter filter) {
    if (!OSUtils.isAnyMac()) {
      JFileChooser fileChooser = getDirectoryChooser(titleKey, approveKey, directory, mode, filter);
      fileChooser.setMultiSelectionEnabled(allowMultiSelect);
      try {
        if (fileChooser.showOpenDialog(parent) != option) return null;
      } catch (NullPointerException npe) {
        // ignore NPE.  can't do anything with it ...
        return null;
      }

      if (allowMultiSelect) {
        File[] chosen = fileChooser.getSelectedFiles();
        if (chosen.length > 0) setLastInputDirectory(chosen[0]);
        return Arrays.asList(chosen);
      } else {
        File chosen = fileChooser.getSelectedFile();
        setLastInputDirectory(chosen);
        return Collections.singletonList(chosen);
      }

    } else {
      FileDialog dialog;
      if (mode == JFileChooser.DIRECTORIES_ONLY) dialog = MacUtils.getFolderDialog();
      else dialog = new FileDialog(GUIMediator.getAppFrame(), "");

      dialog.setTitle(I18n.tr(titleKey));
      if (filter != null) {
        FilenameFilter f =
            new FilenameFilter() {
              public boolean accept(File dir, String name) {
                return filter.accept(new File(dir, name));
              }
            };
        dialog.setFilenameFilter(f);
      }

      dialog.setVisible(true);
      String dirStr = dialog.getDirectory();
      String fileStr = dialog.getFile();
      if ((dirStr == null) || (fileStr == null)) return null;
      setLastInputDirectory(new File(dirStr));
      // if the filter didn't work, pretend that the person picked
      // nothing
      File f = new File(dirStr, fileStr);
      if (filter != null && !filter.accept(f)) return null;

      return Collections.singletonList(f);
    }
  }
示例#18
0
  public OpenFile() {
    b1.addActionListener(
        e -> {
          d1.setVisible(true);
          System.out.println(d1.getDirectory() + d1.getFile());
        });

    b2.addActionListener(
        e -> {
          d2.setVisible(true);
          System.out.println(d2.getDirectory() + d2.getFile());
        });

    f.add(b1);
    f.add(b2, BorderLayout.SOUTH);
    f.pack();
    f.setVisible(true);
  }
示例#19
0
  /**
   * Handles 'Save As' for a sketch.
   *
   * <p>This basically just duplicates the current sketch folder to a new location, and then calls
   * 'Save'. (needs to take the current state of the open files and save them to the new folder..
   * but not save over the old versions for the old sketch..)
   *
   * <p>Also removes the previously-generated .class and .jar files, because they can cause trouble.
   */
  public boolean saveAs() throws IOException {
    // get new name for folder
    FileDialog fd = new FileDialog(editor, "Save file as...", FileDialog.SAVE);
    if (isReadOnly()) {
      // default to the sketchbook folder
      fd.setDirectory(Base.preferences.get("sketchbook.path", null));
    } else {
      // default to the parent folder of where this was
      fd.setDirectory(folder.getParent());
    }
    fd.setFile(folder.getName());

    fd.setVisible(true);
    String newParentDir = fd.getDirectory();
    String newName = fd.getFile();

    File newFolder = new File(newParentDir);
    // user cancelled selection
    if (newName == null) return false;

    if (!newName.endsWith(".gcode")) newName = newName + ".gcode";

    // grab the contents of the current tab before saving
    // first get the contents of the editor text area
    if (current.modified) {
      current.program = editor.getText();
    }

    // save the other tabs to their new location
    for (int i = 1; i < codeCount; i++) {
      File newFile = new File(newFolder, code[i].file.getName());
      code[i].saveAs(newFile);
    }

    // save the hidden code to its new location
    for (int i = 0; i < hiddenCount; i++) {
      File newFile = new File(newFolder, hidden[i].file.getName());
      hidden[i].saveAs(newFile);
    }

    // save the main tab with its new name
    File newFile = new File(newFolder, newName);
    code[0].saveAs(newFile);

    editor.handleOpenUnchecked(
        newFile.getPath(),
        currentIndex,
        editor.textarea.getSelectionStart(),
        editor.textarea.getSelectionEnd(),
        editor.textarea.getScrollPosition());

    // Name changed, rebuild the sketch menus
    // editor.sketchbook.rebuildMenusAsync();

    // let MainWindow know that the save was successful
    return true;
  }
示例#20
0
 /**
  * Open the dialog to load an file, swing based
  *
  * @return the file or null
  */
 @Override
 public File saveDialog() {
   final FileDialog d = new FileDialog(new Frame(), "", FileDialog.SAVE);
   d.setVisible(true);
   if (d.getFile() != null) {
     return new File(d.getDirectory(), d.getFile());
   }
   return null;
 }
示例#21
0
  protected void showFileChooser() {
    File p;
    FileDialog fDlg;
    String fDir, fFile; // , fPath;
    //		int			i;
    Component win;

    for (win = this; !(win instanceof Frame); ) {
      win = SwingUtilities.getWindowAncestor(win);
      if (win == null) return;
    }

    p = getPath();
    switch (type & PathField.TYPE_BASICMASK) {
      case PathField.TYPE_INPUTFILE:
        fDlg = new FileDialog((Frame) win, dlgTxt, FileDialog.LOAD);
        break;
      case PathField.TYPE_OUTPUTFILE:
        fDlg = new FileDialog((Frame) win, dlgTxt, FileDialog.SAVE);
        break;
      case PathField.TYPE_FOLDER:
        fDlg = new FileDialog((Frame) win, dlgTxt, FileDialog.SAVE);
        // fDlg = new FolderDialog( (Frame) win, dlgTxt );
        break;
      default:
        fDlg = null;
        assert false : (type & PathField.TYPE_BASICMASK);
        break;
    }
    if (p != null) {
      fDlg.setFile(p.getName());
      fDlg.setDirectory(p.getParent());
    }
    if (filter != null) {
      fDlg.setFilenameFilter(filter);
    }
    showDialog(fDlg);
    fDir = fDlg.getDirectory();
    fFile = fDlg.getFile();

    if (((type & PathField.TYPE_BASICMASK) != PathField.TYPE_FOLDER) && (fDir == null)) {
      fDir = "";
    }

    if ((fFile != null) && (fDir != null)) {

      if ((type & PathField.TYPE_BASICMASK) == PathField.TYPE_FOLDER) {
        p = new File(fDir);
      } else {
        p = new File(fDir + fFile);
      }
      setPathAndDispatchEvent(p);
    }

    fDlg.dispose();
  }
 private static String chooseFileByFileDialog(Dialog parentDialog, String title, int mode) {
   FileDialog fileDialog = new FileDialog(parentDialog, title, mode);
   fileDialog.setVisible(true);
   String selectedFile = fileDialog.getFile();
   if (selectedFile != null) {
     return fileDialog.getDirectory() + selectedFile;
   } else {
     return null;
   }
 }
示例#23
0
 /** This method cannot be called directly. */
 @Override
 public void actionPerformed(ActionEvent e) {
   FileDialog chooser =
       new FileDialog(StdDraw.frame, "Use a .png or .jpg extension", FileDialog.SAVE);
   chooser.setVisible(true);
   String filename = chooser.getFile();
   if (filename != null) {
     StdDraw.save(chooser.getDirectory() + File.separator + chooser.getFile());
   }
 }
示例#24
0
    private void exportar() {

      if (invalidos == null) {
        return;
      }

      try {

        String localFile = null;

        FileDialog fileDialog = new FileDialog(Aplicativo.telaPrincipal, "Selecionar diretorio.");
        fileDialog.setFile("*.txt");
        fileDialog.setVisible(true);

        if (fileDialog.getDirectory() != null) {

          localFile = fileDialog.getDirectory() + fileDialog.getFile();
        }

        File file = new File(localFile);
        file.createNewFile();
        FileWriter fw = new FileWriter(file);
        BufferedWriter bw = new BufferedWriter(fw);

        for (Object[] campos : invalidos) {
          bw.write(String.valueOf(campos[0]) + ";");
          bw.write(String.valueOf(campos[2]) + ";");
          bw.write(String.valueOf(campos[1]) + ";");
          bw.write(campos[3] + "\n");
        }

        bw.flush();
        bw.close();

        Funcoes.mensagemInforma(this, "Itens inválidos salvos.");

        this.dispose();

      } catch (IOException e) {
        e.printStackTrace();
        Funcoes.mensagemErro(this, "Erro ao exportar produtos!\n" + e.getMessage(), true, con, e);
      }
    }
示例#25
0
  /** Handle ItemEvents. */
  public void itemStateChanged(ItemEvent e) {

    final String dialog_title = ResourceHandler.getMessage("template_dialog.title");

    Component target = (Component) e.getSource();

    if (target == recursiveCheckBox) {
      converter.setRecurse(recursiveCheckBox.isSelected());
    } else if (target == staticVersioningRadioButton || target == dynamicVersioningRadioButton) {
      converter.setStaticVersioning(staticVersioningRadioButton.isSelected());
    } else if (target == templateCh
        && (e.getStateChange() == e.SELECTED)) { // Process only when item is Selected

      // Get the current template selection
      String choiceStr = (String) templateCh.getSelectedItem();

      // If the user chooses 'other', display a file dialog to allow
      // them to select a template file.
      if (choiceStr.equals(TemplateFileChoice.OTHER_STR)) {
        String templatePath = null;
        FileDialog fd = new FileDialog(this, dialog_title, FileDialog.LOAD);
        fd.show();

        // Capture the path entered, if any.
        if (fd.getDirectory() != null && fd.getFile() != null) {
          templatePath = fd.getDirectory() + fd.getFile();
        }

        // If the template file is valid add it and select it.
        if (templatePath != null && setTemplateFile(templatePath)) {
          if (!templateCh.testIfInList(templatePath)) {
            templateCh.addItem(templatePath);
          }
          templateCh.select(templatePath);
        } else {
          templateCh.select(templateCh.getPreviousSelection());
        }
        fd.dispose();
      } else {
        templateCh.select(choiceStr);
      }
    }
  }
示例#26
0
 /**
  * Display a histogram of jMusic Note data in the score
  *
  * @param score the score to be displayed
  */
 public static void histogram() {
   FileDialog fd = new FileDialog(new Frame(), "Select a MIDI file to display.", FileDialog.LOAD);
   fd.show();
   String fileName = fd.getFile();
   if (fileName != null) {
     Score score = new Score();
     org.jm.util.Read.midi(score, fd.getDirectory() + fileName);
     HistogramFrame hf = new HistogramFrame(score);
   }
 }
示例#27
0
        /**
        * get the filename from the user using a file requester
        */
        private String getFileName(int mode) {
                String prompt;
                String filename;
                String pathname;
                File   file;

                // depending on load or save set the prompt                
                if (mode == FileDialog.LOAD) {
                        prompt = "Open File ";
                } else {
                        prompt = "Save File As ";
                }

                // create a file requester
                FileDialog d = new FileDialog(getJPE().getEditor(), prompt, mode);

                // set the file filter (not working on epoc it seems)
                d.setFilenameFilter(new JPEFilenameFilter());

                // set the directory to open in (not working?)
                //d.setDirectory("c:\\JPE");
                d.setDirectory(dir);

                // show requester (blocks until user is done)
                d.show();

                // optain the filename
                filename = d.getFile();

                // complete the file name by adding its path 
                pathname = d.getDirectory() + filename; 

                if (filename != null) {
                        dir = d.getDirectory();
                        getJPE().putProperty("setup","currentdir",dir);
                        // if we have a filename return it
                        return(pathname);
                } else {
                        // return null to signal a problem
                        return(null);
                }
        }
示例#28
0
 public File showFileSaveDialog(Component parent, File defaultFile) {
   FileDialog fileDialog = new FileDialog(getProjectExplorer());
   if (defaultFile != null) {
     fileDialog.setDirectory(defaultFile.getParent());
     fileDialog.setFile(defaultFile.getName());
   }
   fileDialog.setMode(FileDialog.SAVE);
   fileDialog.setVisible(true);
   String filename = fileDialog.getFile();
   return filename != null ? new File(fileDialog.getDirectory(), filename) : null;
 }
示例#29
0
 /** Opens the load MIB dialog. */
 protected void loadMib() {
   FileDialog dialog = new FileDialog(this, "Select MIB File");
   dialog.setDirectory(currentDir.getAbsolutePath());
   dialog.setVisible(true);
   String file = dialog.getFile();
   if (file != null) {
     File[] files = new File[] {new File(dialog.getDirectory(), file)};
     currentDir = files[0].getParentFile();
     descriptionArea.setText("");
     new Loader(files).start();
   }
 }
示例#30
0
  public static File FileSaveDialog(String title) {
    // Open File Dialog:
    FileDialog filedialog = new FileDialog((Frame) null, title, FileDialog.SAVE);
    filedialog.setVisible(true);
    File fileSelected = null;
    try {
      fileSelected = new File(filedialog.getDirectory(), filedialog.getFile());
    } catch (Exception e) {

    }
    return fileSelected;
  }