Beispiel #1
0
  /**
   * The constructor creates all the components for the main Artemis window and sets up all the menu
   * callbacks.
   */
  public ArtemisMain(final String args[]) {
    super("Artemis", "Artemis", version);

    ActionListener menu_listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            if (filemanager == null) filemanager = new FileManager(ArtemisMain.this);
            else filemanager.setVisible(true);
          }
        };
    makeMenuItem(file_menu, "Open File Manager ...", menu_listener);

    ActionListener menu_listener_ssh =
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            if (fm == null) fm = new LocalAndRemoteFileManager(ArtemisMain.this);
            else fm.setVisible(true);
          }
        };

    if (System.getProperty("chado") != null)
      makeMenuItem(file_menu, "Open Database and SSH File Manager ...", menu_listener_ssh);
    else makeMenuItem(file_menu, "Open SSH File Manager ...", menu_listener_ssh);

    final EntrySourceVector entry_sources = getEntrySources(this);

    for (int source_index = 0; source_index < entry_sources.size(); ++source_index) {
      final EntrySource this_entry_source = entry_sources.elementAt(source_index);

      String entry_source_name = this_entry_source.getSourceName();
      String menu_name = null;

      if (entry_source_name.equals("Filesystem")) menu_name = "Open ...";
      else menu_name = "Open from " + entry_source_name + " ...";

      menu_listener =
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              getEntryEditFromEntrySource(this_entry_source);
            }
          };
      makeMenuItem(file_menu, menu_name, menu_listener);
    }

    menu_listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            launchDatabaseJFrame();
          }
        };

    // final boolean sanger_options =
    //  Options.getOptions().getPropertyTruthValue("sanger_options");

    // makeMenuItem(file_menu, "Database Entry ...", menu_listener);

    menu_listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            exit();
          }
        };
    makeMenuItem(file_menu, "Quit", menu_listener);

    getCanvas()
        .addMouseListener(
            new MouseAdapter() {
              /** Listen for mouse press events so that we can do popup menus and selection. */
              public void mousePressed(MouseEvent event) {
                handleCanvasMousePress(event);
              }
            });
  }
Beispiel #2
0
  /** Read the entries named in args and in the diana.ini file. */
  protected void readArgsAndOptions(final String[] args) {
    if (args.length == 0) {
      if (System.getProperty("chado") != null && (args.length < 1 || args[0].indexOf(':') == -1))
        fm = new LocalAndRemoteFileManager(ArtemisMain.this);

      // open the entries given in the options file(diana.ini)
      readDefaultEntries();
      return;
    }

    if (args[0].equals("-biojava")) {
      handleBioJava(args);
      return;
    }

    final EntryInformation artemis_entry_information = Options.getArtemisEntryInformation();

    EntryEdit last_entry_edit = null;
    boolean seen_plus = false;

    for (int i = 0; i < args.length; ++i) {
      String new_entry_name = args[i];

      if (new_entry_name.length() == 0) continue;

      if (new_entry_name.equals("+")) {
        seen_plus = true;
        continue;
      }

      if (new_entry_name.startsWith("+") && last_entry_edit != null || seen_plus) {
        // new feature file

        final Document entry_document;

        if (seen_plus) entry_document = DocumentFactory.makeDocument(new_entry_name);
        else entry_document = DocumentFactory.makeDocument(new_entry_name.substring(1));

        final InputStreamProgressListener progress_listener = getInputStreamProgressListener();

        entry_document.addInputStreamProgressListener(progress_listener);

        final uk.ac.sanger.artemis.io.Entry new_embl_entry =
            EntryFileDialog.getEntryFromFile(
                this, entry_document, artemis_entry_information, false);

        if (new_embl_entry == null) // the read failed
        break;

        try {
          final Entry new_entry =
              new Entry(last_entry_edit.getEntryGroup().getBases(), new_embl_entry);

          last_entry_edit.getEntryGroup().add(new_entry);
        } catch (OutOfRangeException e) {
          new MessageDialog(
              this,
              "read failed: one of the features in "
                  + new_entry_name
                  + " has an out of range "
                  + "location: "
                  + e.getMessage());
        }
      } else if (System.getProperty("chado") != null && new_entry_name.indexOf(':') > -1) {
        // open from database e.g. Pfalciparum:Pf3D7_09:95000..150000
        Splash.logger4j.info("OPEN ENTRY " + new_entry_name);
        getStatusLabel().setText("Connecting ...");
        DatabaseEntrySource entry_source = new DatabaseEntrySource();

        boolean promptUser = true;
        if (System.getProperty("read_only") != null) {
          promptUser = false;
          entry_source.setReadOnly(true);
        }

        if (!entry_source.setLocation(promptUser)) return;

        last_entry_edit =
            DatabaseJPanel.show(
                entry_source, this, getInputStreamProgressListener(), new_entry_name);
      } else {
        // new sequence file

        if (last_entry_edit != null) {
          last_entry_edit.setVisible(true);
          last_entry_edit = null;
        }

        if (new_entry_name.indexOf("://") == -1) {
          File file = new File(new_entry_name);
          if (!file.exists()) {
            JOptionPane.showMessageDialog(
                null,
                "File " + new_entry_name + " not found.\n" + "Check the file name.",
                "File Not Found",
                JOptionPane.WARNING_MESSAGE);
          }
        }

        final Document entry_document = DocumentFactory.makeDocument(new_entry_name);

        entry_document.addInputStreamProgressListener(getInputStreamProgressListener());

        final uk.ac.sanger.artemis.io.Entry new_embl_entry =
            EntryFileDialog.getEntryFromFile(
                this, entry_document, artemis_entry_information, false);

        if (new_embl_entry == null) // the read failed
        break;

        try {
          final Entry entry = new Entry(new_embl_entry);
          last_entry_edit = makeEntryEdit(entry);
          addEntryEdit(last_entry_edit);
          getStatusLabel().setText("");
        } catch (OutOfRangeException e) {
          new MessageDialog(
              this,
              "read failed: one of the features in "
                  + new_entry_name
                  + " has an out of range "
                  + "location: "
                  + e.getMessage());
          break;
        } catch (NoSequenceException e) {
          new MessageDialog(this, "read failed: " + new_entry_name + " contains no sequence");
          break;
        }
      }
    }

    if (System.getProperty("offset") != null)
      last_entry_edit.getGotoEventSource().gotoBase(Integer.parseInt(System.getProperty("offset")));

    last_entry_edit.setVisible(true);
    for (int entry_index = 0; entry_index < entry_edit_objects.size(); ++entry_index) {
      if (System.getProperty("offset") != null)
        entry_edit_objects
            .elementAt(entry_index)
            .getGotoEventSource()
            .gotoBase(Integer.parseInt(System.getProperty("offset")));
    }
  }