@Override
 public void actionPerformed(ActionEvent e) {
   JFileChooser chooser = new JFileChooser();
   if (optionsPane != null) {
     chooser.setCurrentDirectory(new File(Settings.getSettings().getInstallPath()));
     chooser.setDialogTitle(choosertitle);
     chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     chooser.setAcceptAllFileFilterUsed(false);
     if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
       Logger.logInfo("getCurrentDirectory(): " + chooser.getCurrentDirectory());
       Logger.logInfo("getSelectedFile() : " + chooser.getSelectedFile());
       optionsPane.setInstallFolderText(chooser.getSelectedFile().getPath());
     } else {
       Logger.logWarn("No Selection.");
     }
   } else if (editMPD != null) {
     if (!Settings.getSettings().getLastAddPath().isEmpty()) {
       chooser.setCurrentDirectory(new File(Settings.getSettings().getLastAddPath()));
     }
     chooser.setDialogTitle("Please select the mod to install");
     chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
     chooser.setAcceptAllFileFilterUsed(true);
     if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
       File destination = new File(editMPD.folder, chooser.getSelectedFile().getName());
       if (!destination.exists()) {
         try {
           FileUtils.copyFile(chooser.getSelectedFile(), destination);
           Settings.getSettings().setLastAddPath(chooser.getSelectedFile().getPath());
           LaunchFrame.getInstance().saveSettings();
         } catch (IOException e1) {
           Logger.logError(e1.getMessage());
         }
         editMPD.updateLists();
       } else {
         ErrorUtils.tossError("File already exists, cannot add mod!");
       }
     } else {
       Logger.logWarn("No Selection.");
     }
   } else {
     chooser.setCurrentDirectory(new File(Settings.getSettings().getInstallPath()));
     chooser.setDialogTitle(choosertitle);
     chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     chooser.setAcceptAllFileFilterUsed(false);
     if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
       Logger.logInfo("getCurrentDirectory(): " + chooser.getCurrentDirectory());
       Logger.logInfo("getSelectedFile() : " + chooser.getSelectedFile());
       installDialog.setInstallFolderText(chooser.getSelectedFile().getPath());
     } else {
       Logger.logWarn("No Selection.");
     }
   }
 }
 public boolean fileChooser(boolean open, boolean onlyFiles, boolean newProject, boolean primero) {
   int option, var = 0;
   if (primero == true) {
     filechooser = new JFileChooser(Configuration.getPropiedades().getProperty("ULTIMOPATH"));
   } else {
     filechooser = new JFileChooser(FileChooserSelector.getPathSelected());
   }
   if (onlyFiles == false) {
     filechooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   } else {
     filechooser.addChoosableFileFilter(new TypeFilter());
     filechooser.setAcceptAllFileFilterUsed(false);
     filechooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
   }
   if (open == true) {
     option = filechooser.showOpenDialog(MainApplicationJFrame.getInstance());
   } else {
     option = filechooser.showSaveDialog(MainApplicationJFrame.getInstance());
   }
   if (option == JFileChooser.APPROVE_OPTION) {
     File selectedFile = filechooser.getSelectedFile();
     if (primero == true) {
       Configuration.getInstance().cambiarPath(selectedFile.getParent());
     }
     FileChooserSelector.setPathDirectorioProyecto(selectedFile.getParentFile());
     setNombreProyecto(selectedFile.getName());
     if (newProject == true) {
       BufferedReader bf = null;
       try {
         bf = new BufferedReader(new FileReader(selectedFile.getAbsolutePath()));
         while ((linea = bf.readLine()) != null && var == 0) {
           if (linea.contains("xmlns=\"")) {
             int indexBegin = linea.indexOf("xmlns=\"");
             int indexEnd = linea.indexOf("#", indexBegin);
             setNsDefecto(linea.substring(indexBegin + 7, indexEnd).concat("#"));
             var = 1;
           } else {
             setNsDefecto("http://www.owl-ontologies.com/unnamed.owl");
           }
         }
         try {
           bf.close();
         } catch (IOException ex) {
           System.out.println("No se pudo cerrar el fichero");
         }
       } catch (FileNotFoundException ex) {
       } catch (IOException ex) {
       }
     }
     FileChooserSelector.setPathSelected(selectedFile.getAbsolutePath());
     return true;
   } else return false;
 }
Beispiel #3
0
  /*
   * Lit un repertoire contenant des musiques
   * et affiche quelques infos de celles-ci
   */
  public static void testRepertoireMusique() throws Exception {

    selecteur.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    selecteur.showOpenDialog(null);
    File file = selecteur.getSelectedFile();
    MP3Collection.initDiscographie(file);

    for (int i = 0; i < MP3Collection.getDiscograhpie().size(); i++) {
      System.out.println(((Musique) MP3Collection.getDiscograhpie().get(i)).getArtist());
      System.out.println(((Musique) MP3Collection.getDiscograhpie().get(i)).getAlbum());
      System.out.println(((Musique) MP3Collection.getDiscograhpie().get(i)).getDureeEnString());
    }

    selecteur.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
  }
Beispiel #4
0
  /**
   * Make file dialog
   *
   * @param thisTitle dialog title
   * @param thisExtension file extension
   * @param thisDescription description of file type
   * @return JFileChooser
   */
  public static JFileChooser makeFileDialog(
      final String thisTitle, final String thisExtension, final String thisDescription) {
    final FileFilter thisFileFilter =
        new FileFilter() {
          private final String[] theExtensions = {thisExtension};

          @Override
          public boolean accept(final File thisFile) {
            for (final String thisExtension : this.theExtensions)
              if (thisFile.getName().toLowerCase().endsWith(thisExtension)) return true;
            return thisFile.isDirectory();
          }

          @Override
          public String getDescription() {
            return thisDescription;
          }
        };
    JFileChooser thisFileChooser;
    thisFileChooser = new JFileChooser();
    thisFileChooser.setDialogTitle(thisTitle);
    thisFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    thisFileChooser.setFileFilter(thisFileFilter);
    thisFileChooser.setCurrentDirectory(new File(System.getProperty("user.dir")));
    return thisFileChooser;
  }
Beispiel #5
0
  /**
   * Accionado quando se faz clique no botao para extrair uma directoria do ficheiro RFP.
   *
   * <p>Permite extrair uma directoria do ficheiro RFP na pasta de destino escolhida pelo
   * utilizador.
   *
   * <p>Se o objecto selecionado for uma directoria, irá então ser extraido o conteúdo dessa mesma
   * directoria.
   *
   * <p>É lançado uma excepção caso seja impossivel extrair os conteúdos da directoria selecionada.
   *
   * @param evt
   */
  private void jMenuItem11ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItem11ActionPerformed
    try {
      // verificar a seleccão
      int row = jTable1.getSelectedRow();
      Object obj = jTable1.getModel().getValueAt(row, 0);
      if (obj instanceof RFPDirectoryHeader) {
        final JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int returnVal = fc.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
          File dir = fc.getCurrentDirectory();
          File dest = fc.getSelectedFile();
          rfpFile.extractAll(((RFPDirectoryHeader) obj).getId(), dest.getPath());
        }
      } else {
        JOptionPane.showMessageDialog(
            null,
            "Impossível extrair directoria.",
            "Extrair Directoria",
            JOptionPane.ERROR_MESSAGE);
      }

    } catch (Exception ex) {
      JOptionPane.showMessageDialog(
          null, "Impossível extrair directoria.", "Extrair Directoria", JOptionPane.ERROR_MESSAGE);
    }
  } // GEN-LAST:event_jMenuItem11ActionPerformed
  private void GuardarProyectoActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_GuardarProyectoActionPerformed
    // TODO add your handling code here:
    JFileChooser selectorTAC = new JFileChooser();
    javax.swing.filechooser.FileFilter filtro = new FileNameExtensionFilter("Proyecto (.c)", "c");
    selectorTAC.setFileFilter(filtro);
    selectorTAC.setFileSelectionMode(JFileChooser.FILES_ONLY);
    selectorTAC.showOpenDialog(this);
    if (selectorTAC.getSelectedFile() != null) {
      try {
        File fileTAC = selectorTAC.getSelectedFile();
        Scanner3D sTAC = new Scanner3D(new FileReader(fileTAC));
        Parser3D pTAC = new Parser3D();
        pTAC.setScanner(sTAC);

        try {
          pTAC.parse();
          pTAC.g.ConectarNodos();
          int a = 10;
          pTAC.g.NombrePrograma = selectorTAC.getSelectedFile().getName();
          this.prueba = pTAC.g;
          this.LCargar.add(pTAC.g);
          // pTAC.g.BuscarEtiqueta("RobotdeEjemplo_main_").Ejecutar(pTAC.g,null);

          a = 1 + 1;

        } catch (Exception ex) {
          Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
        }

      } catch (FileNotFoundException ex) {
        Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
  } // GEN-LAST:event_GuardarProyectoActionPerformed
  /*
   * Handle button callbacks
   *
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   *
   */
  @Override
  public void actionPerformed(ActionEvent eventI) {

    Object source = eventI.getSource();

    if (source == null) {
      return;
    } else if (eventI.getActionCommand().equals("Browse...")) {
      // This was for a "Browse" button to locate a directory, but since
      // we're using this for filesystems and FTP, don't bother
      // Code largely taken from http://stackoverflow.com/questions/4779360/browse-for-folder-dialog
      JFileChooser fc = new JFileChooser();
      fc.setCurrentDirectory(new java.io.File("."));
      fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      int returnVal = fc.showSaveDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File selectedFolder = fc.getSelectedFile();
        try {
          outputDirTF.setText(selectedFolder.getCanonicalPath());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    } else if (eventI.getActionCommand().equals("OK")) {
      okAction();
    } else if (eventI.getActionCommand().equals("Cancel")) {
      cancelAction();
    }
  }
Beispiel #8
0
 public void browseForLog() {
   JFileChooser fc = new JFileChooser();
   fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   fc.showOpenDialog(null);
   String path = fc.getSelectedFile().getPath();
   installLogText.setText(path);
 }
Beispiel #9
0
  @Override
  public void run() {
    final Path path = this.pathOption.getValue();
    final String value;
    if (path == null) {
      value = null;
    } else {
      value = path.toString();
    }
    final JFileChooser fileChooser = new JFileChooser(value);
    final JFrame frame = new JFrame();
    fileChooser.setFileFilter(this.pathOption.filter);
    fileChooser.setDialogTitle(this.pathOption.getDescription());
    fileChooser.setFileSelectionMode(this.pathOption.selectionMode);

    try {
      final int ret = fileChooser.showOpenDialog(frame);
      if (ret == JFileChooser.APPROVE_OPTION) {
        this.pathOption.value(fileChooser.getSelectedFile());
        this.textField.setText(this.pathOption.getValue().toString());
        this.textField.setForeground(Color.BLACK);
        this.textField.setBackground(Color.WHITE);
      } else {
        this.pathOption.value((File) null);
        this.textField.setText(this.pathOption.getTooltip());
        this.textField.setForeground(Color.GRAY);
        this.textField.setBackground(Color.WHITE);
      }
    } finally {
      frame.setVisible(false);
      frame.dispose();
    }
  }
Beispiel #10
0
  /** 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);
      }
    }
  }
  private void doParcourir() {
    JFileChooser fileChooser = new JFileChooser(".");
    fileChooser.setDialogTitle(Bundle.getText("BD_ImporterProcessus_parcourir"));
    fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.setFileFilter(new FiltreFichier("dpe", Bundle.getText("DPE")));
    int res = fileChooser.showDialog(this, Bundle.getText("Valider"));
    if (res == JFileChooser.APPROVE_OPTION) {
      // Vérification si le chemin contient le nom du fichier
      nomDuFichier = null;
      if (fileChooser.getSelectedFile().isFile()) {
        cImportation.addChemin(
            fileChooser
                .getSelectedFile()
                .getAbsolutePath()
                .substring(
                    0,
                    fileChooser.getSelectedFile().getAbsolutePath().lastIndexOf(File.separator)));
        LD_Chemin.setSelectedItem(
            fileChooser
                .getSelectedFile()
                .getAbsolutePath()
                .substring(
                    0,
                    fileChooser.getSelectedFile().getAbsolutePath().lastIndexOf(File.separator)));
        nomDuFichier = fileChooser.getSelectedFile().getName();
      } else {
        cImportation.addChemin(fileChooser.getSelectedFile().getAbsolutePath());
        LD_Chemin.setSelectedItem(fileChooser.getSelectedFile().getAbsolutePath());
      }
    }

    doRechercher();
  }
Beispiel #12
0
  /**
   * Starts file chooser.
   *
   * @param dir whether it needs dir or file
   */
  protected void startFileChooser(
      final Widget paramWi, final String directory, final boolean dirOnly) {
    final Host host = getFirstConnectedHost();
    if (host == null) {
      Tools.appError("Connection to host lost.");
      return;
    }
    final VMSHardwareInfo thisClass = this;
    final JFileChooser fc =
        new JFileChooser(getLinuxDir(directory, host), getFileSystemView(host, directory)) {
          /** Serial version UID. */
          private static final long serialVersionUID = 1L;

          @Override
          public final void setCurrentDirectory(final File dir) {
            super.setCurrentDirectory(new LinuxFile(thisClass, host, dir.toString(), "d", 0, 0));
          }
        };
    fc.setBackground(ClusterBrowser.STATUS_BACKGROUND);
    fc.setDialogType(JFileChooser.CUSTOM_DIALOG);
    if (dirOnly) {
      fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    }
    fc.setDialogTitle(Tools.getString("VMSDiskInfo.FileChooserTitle") + host.getName());
    //        fc.setApproveButtonText(Tools.getString("VMSDiskInfo.Approve"));
    fc.setApproveButtonToolTipText(Tools.getString("VMSDiskInfo.Approve.ToolTip"));
    fc.putClientProperty("FileChooser.useShellFolder", Boolean.FALSE);
    final int ret =
        fc.showDialog(Tools.getGUIData().getMainFrame(), Tools.getString("VMSDiskInfo.Approve"));
    linuxFileCache.clear();
    if (ret == JFileChooser.APPROVE_OPTION && fc.getSelectedFile() != null) {
      final String name = fc.getSelectedFile().getAbsolutePath();
      paramWi.setValue(name);
    }
  }
 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;
   }
 }
  /**
   * Shows the notification.
   *
   * @param event The notification to show
   */
  public void show() {

    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int ret = fileChooser.showOpenDialog(this.engine.getGUI().getFrame());
    if (JFileChooser.APPROVE_OPTION != ret) {
      throw new WorkflowRuntimeException("Cannot proceed without valid directory");
    }
    File selectedDir = fileChooser.getSelectedFile();
    File rootDir = new File(selectedDir, "xbaya");
    deleteDir(rootDir);
    rootDir.mkdir();
    File srcDir = new File(rootDir, SRC_DIR);
    srcDir.mkdir();
    File classesDir = new File(rootDir, CLASSES_DIR);
    classesDir.mkdir();
    initSchema(rootDir, srcDir, srcDir);

    this.javaCodeTxtArea.setText(generateClass());

    this.dialog.show();
    if (this.checkBox.isSelected()) {
      deployWebservice();
    } else {
      this.compileAndRegisterJar(rootDir, srcDir, srcDir);
    }
  }
 private void AbrirProyectoActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_AbrirProyectoActionPerformed
   // TODO add your handling code here:
   JFileChooser CargarProy = new JFileChooser();
   String leerl = "", filecomplete = "";
   javax.swing.filechooser.FileFilter filtro =
       new FileNameExtensionFilter("Proyecto (.java)", "java");
   CargarProy.setFileFilter(filtro);
   CargarProy.setFileSelectionMode(JFileChooser.FILES_ONLY);
   CargarProy.showOpenDialog(this);
   if (CargarProy.getSelectedFile() != null) {
     Errores.InicializarTablaDeErrores();
     Proyecto = CargarProy.getSelectedFile();
     try {
       FileReader fr = new FileReader(Proyecto);
       BufferedReader br = new BufferedReader(fr);
       while ((leerl = br.readLine()) != null) {
         filecomplete = filecomplete + "\n" + leerl;
       }
     } catch (IOException ex) {
       Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
     }
     TextArea a = new TextArea();
     a.setEditable(true);
     a.setText(filecomplete);
     a.setEnabled(true);
     archivos.add(Proyecto);
     TAREAS.add(a);
     this.jTP.add(a);
     this.Guardados = true;
   } // GEN-LAST:event_AbrirProyectoActionPerformed
 }
  private void EliminarArchivoActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_EliminarArchivoActionPerformed
    // TODO add your handling code here:
    JFileChooser selectorTAC = new JFileChooser();
    javax.swing.filechooser.FileFilter filtro = new FileNameExtensionFilter("Proyecto (.c)", "c");
    selectorTAC.setFileFilter(filtro);
    selectorTAC.setFileSelectionMode(JFileChooser.FILES_ONLY);
    selectorTAC.showOpenDialog(this);
    if (selectorTAC.getSelectedFile() != null) {
      try {
        File fileTAC = selectorTAC.getSelectedFile();
        Scanner3D sTAC = new Scanner3D(new FileReader(fileTAC));
        Parser3D pTAC = new Parser3D();
        pTAC.setScanner(sTAC);

        try {
          pTAC.parse();
          pTAC.g.ConectarNodos();
          int a = 10;
          pTAC.g.NombrePrograma = selectorTAC.getSelectedFile().getName();
          pTAC.g.OptimizarSB();
          pTAC.g.EscribirArchivo(
              selectorTAC.getSelectedFile().getCanonicalPath(), pTAC.g.RegenerarTAC());

          a = 1 + 1;

        } catch (Exception ex) {
          Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
        }

      } catch (FileNotFoundException ex) {
        Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
  } // GEN-LAST:event_EliminarArchivoActionPerformed
Beispiel #17
0
  /**
   * Accionado quando se faz clique no botao para extrair um ficheiro.
   *
   * <p>Permite extrair o conteudo de um ficheiro selecionado pelo utilizador. A extracção só será
   * possivel caso o objecto selecionado seja um ficheiro.
   *
   * <p>É lançado uma excepção caso a extracção falhe.
   *
   * @param evt
   */
  private void jMenuItem6ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItem6ActionPerformed
    try {
      // verificar a seleccão
      int row = jTable1.getSelectedRow();
      Object obj = jTable1.getModel().getValueAt(row, 0);
      if (obj instanceof RFPFileHeader) {
        final JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int returnVal = fc.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
          File dir = fc.getCurrentDirectory();
          File dest = fc.getSelectedFile();

          if ((int) (((RFPFileHeader) obj).getFlags() & RFPBinaryFile.RFP_COMPRESSED)
              == RFPBinaryFile.RFP_COMPRESSED) {
            rfpFile.decompressFile(((RFPFileHeader) obj).getFilenameId(), dest.getPath());

          } else {
            rfpFile.extractFile(((RFPFileHeader) obj).getFilenameId(), dest.getPath());
          }
        }
      } else {
        JOptionPane.showMessageDialog(
            null,
            "Impossivel extrair ficheiro.",
            "Extração de Ficheiro",
            JOptionPane.ERROR_MESSAGE);
      }
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(
          null, "Impossivel extrair ficheiro.", "Extração de Ficheiro", JOptionPane.ERROR_MESSAGE);
    }
  } // GEN-LAST:event_jMenuItem6ActionPerformed
  void importB_actionPerformed(ActionEvent e) {
    // Fix until Sun's JVM supports more locales...
    UIManager.put("FileChooser.lookInLabelText", Local.getString("Look in:"));
    UIManager.put("FileChooser.upFolderToolTipText", Local.getString("Up One Level"));
    UIManager.put("FileChooser.newFolderToolTipText", Local.getString("Create New Folder"));
    UIManager.put("FileChooser.listViewButtonToolTipText", Local.getString("List"));
    UIManager.put("FileChooser.detailsViewButtonToolTipText", Local.getString("Details"));
    UIManager.put("FileChooser.fileNameLabelText", Local.getString("File Name:"));
    UIManager.put("FileChooser.filesOfTypeLabelText", Local.getString("Files of Type:"));
    UIManager.put("FileChooser.openButtonText", Local.getString("Open"));
    UIManager.put("FileChooser.openButtonToolTipText", Local.getString("Open selected file"));
    UIManager.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
    UIManager.put("FileChooser.cancelButtonToolTipText", Local.getString("Cancel"));

    JFileChooser chooser = new JFileChooser();
    chooser.setFileHidingEnabled(false);
    chooser.setDialogTitle(Local.getString("Insert file"));
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.addChoosableFileFilter(new AllFilesFilter(AllFilesFilter.HTML));
    chooser.setPreferredSize(new Dimension(550, 375));
    String lastSel = (String) Context.get("LAST_SELECTED_IMPORT_FILE");
    if (lastSel != null) chooser.setCurrentDirectory(new java.io.File(lastSel));
    if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) return;

    Context.put("LAST_SELECTED_IMPORT_FILE", chooser.getSelectedFile().getPath());

    File f = chooser.getSelectedFile();
    new HTMLFileImport(f, editor);
  }
Beispiel #19
0
  private void runXsltScript() {
    JFileChooser fc = new JFileChooser();
    fc.setDialogTitle("Select XSLT script");
    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    int returnVal = fc.showOpenDialog(null);
    if (returnVal == 1) {
      return;
    }
    File fXSLT = fc.getSelectedFile();

    File fXML = new File("C:/Odin/Repository/");
    boolean isDirectory = fXML.isDirectory();
    /* Code adapted from: http://blog.msbbc.co.uk/2007/06/simple-saxon-java-example.html
     * [Accessed 3rd-Sept-2010]
     */
    for (File format : fXML.listFiles()) {
      boolean isSuccessful = false;
      try {
        System.setProperty(
            "javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
        TransformerFactory tFact = TransformerFactory.newInstance();
        Transformer tf = tFact.newTransformer(new StreamSource(fXSLT));
        tf.transform(new StreamSource(format), new StreamResult(format));
        isSuccessful = true;
      } catch (TransformerException tX) {
        tX.printStackTrace();
      } finally {
        System.out.println(
            "Change of file " + format.getName() + " was successful? " + isSuccessful);
      }
    }
  }
Beispiel #20
0
 public JFileChooser getFileChooserSalvaXmlXsd() {
   fileChooser.resetChoosableFileFilters();
   fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
   fileChooser.setFileFilter(new FileNameExtensionFilter("XML, XSD ", "xml", "xsd"));
   fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
   return fileChooser;
 }
Beispiel #21
0
 /** Upload a file to the file service by selecting in another window */
 public void selectFile() {
   final JFileChooser chooser = new JFileChooser();
   chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
   final int returnVal = chooser.showOpenDialog(null);
   if (returnVal == JFileChooser.APPROVE_OPTION) {
     final File file = chooser.getSelectedFile();
     final int confirm =
         JOptionPane.showConfirmDialog(
             null,
             Language.getString("uploadConfirm", file.getName()),
             Language.getString("uploadConfirmTitle"),
             JOptionPane.YES_NO_OPTION,
             JOptionPane.WARNING_MESSAGE);
     if (confirm == JOptionPane.YES_OPTION) {
       JOptionPane.showMessageDialog(
           null,
           Language.getString("fileUploading"),
           Language.getString("fileUploadTitle"),
           JOptionPane.INFORMATION_MESSAGE);
       upload(new FileUpload(file.getAbsoluteFile()));
     } else {
       JOptionPane.showMessageDialog(
           null,
           Language.getString("fileUploadCanceled"),
           Language.getString("fileUploadTitle"),
           JOptionPane.INFORMATION_MESSAGE);
     }
   }
 }
  public ImportSQLDialog() {
    initGUI();
    setPreferredSize(new Dimension(528, 199));
    center(this);

    //		String filename = File.separator;
    String filename =
        File.separator
            + "Dokumente und Einstellungen"
            + File.separator
            + "admin"
            + File.separator
            + "workspace"
            + File.separator
            + "BusinessImpactAnalysis"
            + File.separator
            + "testdata"
            + File.separator
            + "processes";
    File currDir = new File(filename);
    fileChooser.setCurrentDirectory(currDir);
    fileChooser.setFileSelectionMode(JFileChooser.OPEN_DIALOG);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  }
Beispiel #23
0
  public void copyHistorial() {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    File desktop = new File(System.getProperty("user.home"), "Desktop");
    fileChooser.setCurrentDirectory(desktop);

    if (fileChooser.showOpenDialog(window) == JFileChooser.APPROVE_OPTION) {
      String path = fileChooser.getSelectedFile().getAbsolutePath();
      Date date = new Date(System.currentTimeMillis());
      SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
      String dateText = df.format(date);
      String name = "/historial(" + dateText + ").txt";
      PrintWriter writer = null;
      try {
        writer = new PrintWriter(path + name, "UTF-8");
      } catch (FileNotFoundException | UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      for (int i = 0; i < actionList.size(); i++) {
        writer.println(actionList.get(i).toString());
      }
      writer.close();
    } else {
      JOptionPane.showMessageDialog(
          null, "Alert", "Something has gone wrong", JOptionPane.ERROR_MESSAGE);
    }
  }
  @Override
  public void actionPerformed(ActionEvent e) {
    super.actionPerformed(e);

    super.actionPerformed(e);
    Opcat2.getGlassPane().setVisible(true);
    Opcat2.getGlassPane().start();

    try {
      JFileChooser myFileChooser = new JFileChooser();
      myFileChooser.setSelectedFile(new File(""));
      myFileChooser.resetChoosableFileFilters();
      myFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

      int retVal = myFileChooser.showOpenDialog(Opcat2.getFrame());
      if (retVal == JFileChooser.APPROVE_OPTION) {
        OpcatMCManager.getInstance()
            .doImport(
                myFileChooser.getSelectedFile(),
                entry,
                "Importing from Opcat user - " + OpcatUser.getCurrentUser().getName());
        GuiControl.getInstance().getRepository().getModelsView().repaintKeepOpen();
      }
    } catch (Exception ex) {
      OpcatLogger.logError(ex);
    }

    Opcat2.getGlassPane().setVisible(false);
    Opcat2.getGlassPane().stop();
  }
Beispiel #25
0
  /**
   * Gets called when the menu option export is called.
   *
   * @param e The action event.
   */
  public void actionPerformed(final ActionEvent e) {
    saveFile();
    if (getMenuView().hasLastFileLocation()) {
      if (!allGoalFilesExist()) {
        ScenarioEditor.getOptionPrompt()
            .showMessageDialog(null, "Warning: Some goal files are missing.");
      }
      File saveLocation = new File(getMenuView().getLastFileLocation());

      JFileChooser filechooser = getCurrentFileChooser();

      filechooser.setSelectedFile(new File(saveLocation.getName().split("\\.")[0]));
      filechooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      filechooser.setAcceptAllFileFilterUsed(false);
      filechooser.setFileFilter(FileFilters.masFilter());

      if (filechooser.showDialog(getController().getMainView(), "Export MAS project")
          == JFileChooser.APPROVE_OPTION) {
        File xmlFile = filechooser.getSelectedFile();
        exportAsMASProject(xmlFile);
      }
    } else {
      ScenarioEditor.getOptionPrompt()
          .showMessageDialog(null, "Error: Can not export an unsaved scenario.");
    }
  }
 private void btn_initdebate_selectlogoActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btn_initdebate_selectlogoActionPerformed
   // TODO add your handling code here:
   String logoPath = "";
   logoPath = BungeniEditorProperties.getEditorProperty("logoPath");
   log.debug("logo path = " + logoPath);
   String strPath = DefaultInstanceFactory.DEFAULT_INSTALLATION_PATH();
   logoPath = strPath + File.separator + logoPath.replace('/', File.separatorChar);
   log.debug("logo path new = " + logoPath);
   JFileChooser chooser = new JFileChooser();
   chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
   File fLogoPath = new File(logoPath);
   chooser.setCurrentDirectory(fLogoPath);
   int nReturnVal = chooser.showOpenDialog(this);
   if (nReturnVal == JFileChooser.APPROVE_OPTION) {
     File file = chooser.getSelectedFile();
     m_strLogoFileName = file.getName();
     m_strLogoPath = file.getAbsolutePath();
     txt_initdebate_selectlogo.setText(m_strLogoFileName);
     // This is where a real application would open the file.
     log.debug("Opening: " + file.getName() + "." + "\n");
   } else {
     log.debug("Open command cancelled by user." + "\n");
   }
 } // GEN-LAST:event_btn_initdebate_selectlogoActionPerformed
Beispiel #27
0
  public String chooseElf() {
    JFileChooser chooser = new JFileChooser(new java.io.File("."));

    FileFilter ff =
        new FileFilter() {
          public boolean accept(File f) {
            if (f.isDirectory()) return true;
            else if (f.getName().endsWith(".elf")) return true;
            else if (f.getName().endsWith(".sin")) return true;
            else return false;
          }

          public String getDescription() {
            return "*.elf *.sin";
          }
        };

    chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter());
    chooser.setFileFilter(ff);

    chooser.setDialogTitle("Choose sin file)");
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    // chooser.setFileFilter(newkernelimgFileFilter);
    //
    // disable the "All files" option.
    //
    chooser.setAcceptAllFileFilterUsed(false);
    //
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      return chooser.getSelectedFile().getAbsolutePath();
    }
    return "ERROR";
  }
  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);
  }
 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;
   }
 }
    MyPathChooser(String name, final JTextField path, int fileSelectionMode) {
      super(name);

      final JFrame chooserFrame = this;

      setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

      final JFileChooser chooser = new JFileChooser(path.getText());

      chooser.setFileSelectionMode(fileSelectionMode);
      getContentPane().add(chooser);
      chooser.setFileHidingEnabled(true);
      pack();
      setVisible(true);

      chooser.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String command = e.getActionCommand();
              if (command.equals(JFileChooser.APPROVE_SELECTION)) {
                path.setText(chooser.getSelectedFile().getAbsolutePath().replace('\\', '/'));
                // and pretend like you typed a key:
                path.getKeyListeners()[0].keyReleased(new KeyEvent(path, 0, 0, 0, 0, ' '));
              }
              chooserFrame.setVisible(false);
            }
          });
    }