Examples of XJFileChooser


Examples of gate.swing.XJFileChooser

        setFormat(theOwner.getCommentFormat());
    }


  void saveControllerAndGenerateDoc() {
      final XJFileChooser fileChooser = MainFrame.getFileChooser();
      ExtensionFileFilter filter = new ExtensionFileFilter(
        "GATE Application files", "gapp");
      fileChooser.addChoosableFileFilter(filter);
      fileChooser.setDialogTitle("Select a file where to save the application "
        + ((theTarget instanceof CorpusController
           && ((CorpusController)theTarget).getCorpus() != null) ?
        "WITH" : "WITHOUT") + " corpus.");
      fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
      fileChooser.setResource("application." + theTarget.getName());

      if(fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
        final File gappFile = fileChooser.getSelectedFile();
        final JPanel parentPanel = this;
        Runnable runnable = new Runnable() {
          public void run() {
            try {
              // Relativize the directory paths with relation to the gappFile path
              // before storing
              owner.setTemplateDirName(owner.getTemplateDirName(), gappFile.getAbsolutePath());
              owner.setOutputDirName(owner.getOutputDirName(), gappFile.getAbsolutePath());

              Iterator it = ((Controller)theTarget).getPRs().iterator();
              while(it.hasNext()) {
                ProcessingResource pr = (ProcessingResource)it.next();
                String resourceClassName = pr.getClass().getName();
                ResourceData rd = Gate.getCreoleRegister().get(resourceClassName);
                String helpURL = rd.getHelpURL();
                if(helpURL != null) {
                  if(!helpURL.startsWith("http://") && !helpURL.startsWith("file:")) {
                    helpURL = "http://gate.ac.uk/userguide/" + helpURL;
                  }
                  pr.getFeatures().put("%@helpURL", helpURL);
                }
              }
              Map<String, String> locations = fileChooser.getLocations();
              // When saving an application state, use paths relative to
              // GATE HOME for resources inside GATE HOME and warn about them.
              gate.util.persistence.PersistenceManager
                .saveObjectToFile(theTarget, gappFile, true, true);
              // save also the location of the application as last application
              locations.put("lastapplication", gappFile.getCanonicalPath());
              // add this application to the list of recent applications
              String list = locations.get("applications");
              if (list == null) { list = ""; }
              list = list.replaceFirst("\\Q"+theTarget.getName()+"\\E(;|$)", "");
              list = theTarget.getName() + ";" + list;
              locations.put("applications", list);
              fileChooser.setLocations(locations);
              // after the pipeline has been saved, generate the documentation
              DocGenerator.generateDoc(gappFile, owner.getTemplateDirName(), owner.getOutputDirName());
            }
            catch(Exception e) {
              JOptionPane.showMessageDialog(parentPanel, "Error!\n"
View Full Code Here

Examples of gate.swing.XJFileChooser

      //System.out.println("Template button pressed");
      // show the filepicker: if a new dir is picked, use
      // owner.setTemplateDirName to update it, also update the
      // dir shown
      // first get canonical name
      final XJFileChooser fileChooser = MainFrame.getFileChooser();
      String knownLocation = fileChooser.getLocationForResource("application.templatedir." + owner.theTarget.getName());
      if(knownLocation == null) {
        // TODO: can this property be null or blank?
        fileChooser.setCurrentDirectory(new File(owner.getTemplateDirName()));
      }
      fileChooser.setDialogTitle("Chose the template directory");
      fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      fileChooser.setResource("application.templatedir." + owner.theTarget.getName());

      if(fileChooser.showDialog(owner,"Choose Directory") == JFileChooser.APPROVE_OPTION) {
        try {
          final File file = fileChooser.getSelectedFile();
          String templateDir = file.getCanonicalPath();
          owner.setTemplateDirName(templateDir,null);
          jLabelTemplateDirPath.setText(templateDir);
        } catch (IOException ex) {
          System.err.println("Could not set template directory: "+ex);
View Full Code Here

Examples of gate.swing.XJFileChooser

    public void actionPerformed(ActionEvent evt) {
      //System.out.println("OutputDir button pressed");
      // show the filepicker: if new dir is picked, use owner.setOutputDir
      // to save it, also change the dir shown
      // First get canonical name
      final XJFileChooser fileChooser = MainFrame.getFileChooser();
      String knownLocation = fileChooser.getLocationForResource("application.outputdir." + owner.theTarget.getName());
      if(knownLocation == null) {
        // TODO: can this property be null or blank?
        fileChooser.setCurrentDirectory(new File(owner.getOutputDirName()));
      }
      fileChooser.setDialogTitle("Chose the output directory");
      fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      fileChooser.setResource("application.outputdir." + owner.theTarget.getName());

      if(fileChooser.showDialog(owner,"Choose Directory") == JFileChooser.APPROVE_OPTION) {
        try {
          final File file = fileChooser.getSelectedFile();
          String outputDir = file.getCanonicalPath();
          owner.setOutputDirName(outputDir,null);
          jLabelOutputDirPath.setText(outputDir);
        } catch (IOException ex) {
          System.err.println("Could not set output directory: "+ex);
View Full Code Here

Examples of org.antlr.xjlib.appkit.utils.XJFileChooser

    public Component getTabComponent() {
        return getContainer();
    }

    public void serializeSyntaxDiagram() {
        XJFileChooser fc = XJFileChooser.shared();
        if(fc.displaySaveDialog(window.getJavaContainer(), "txt", "XML representation", false)) {
            String[] args = new String[] { "-f", window.getFilePath(),
                    "-serialize", fc.getSelectedFilePath(), "-verbose"};
            try {
                org.antlr.works.Console.main(args);
            } catch (Exception e) {
                e.printStackTrace();
                XJAlert.display(window.getJavaContainer(), "Serialize Syntax Diagram", e.toString());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.