Ejemplo n.º 1
0
  public void downloadInteractions(CyNetwork networkToMerge) {
    String networkTitle = peName + ":  Network";
    CPathWebService webApi = CPathWebServiceImpl.getInstance();

    CPathResponseFormat format;
    CPathProperties config = CPathProperties.getInstance();
    if (config.getDownloadMode() == CPathProperties.DOWNLOAD_FULL_BIOPAX) {
      format = CPathResponseFormat.BIOPAX;
    } else {
      format = CPathResponseFormat.BINARY_SIF;
    }

    TaskManager taskManager = factory.getTaskManager();
    ExecuteGetRecordByCPathIdTaskFactory taskFactory =
        factory.createExecuteGetRecordByCPathIdTaskFactory(
            webApi, ids, format, networkTitle, networkToMerge);
    taskManager.execute(taskFactory.createTaskIterator());
  }
  /** Executes Task. */
  public void run(TaskMonitor taskMonitor) throws Exception {
    taskMonitor.setTitle("Loading Network");
    taskMonitor.setProgress(0);
    taskMonitor.setStatusMessage("Reading in Network Data...");

    try {
      CyNetworkReaderManager readerManager = factory.getCyNetworkViewReaderManager();
      CyNetworkReader reader = readerManager.getReader(url.toURI(), url.getFile());

      if (reader == null) {
        JOptionPane.showMessageDialog(
            factory.getCySwingApplication().getJFrame(),
            "Unable to connect to URL " + url,
            "URL Connect Error",
            JOptionPane.ERROR_MESSAGE);
        return;
      }
      taskMonitor.setStatusMessage("Creating Cytoscape Network...");
      reader.run(taskMonitor);
      CyNetwork[] networks = reader.getNetworks();
      CyNetwork cyNetwork = networks[0];

      // TODO: Does CPath2 listen for this?
      //			Object[] ret_val = new Object[2];
      //			ret_val[0] = cyNetwork;
      //			ret_val[1] = url.toString();
      //
      //			Cytoscape.firePropertyChange(Cytoscape.NETWORK_LOADED, null, ret_val);

      if (cyNetwork != null) {
        informUserOfGraphStats(cyNetwork, taskMonitor);
      } else {
        StringBuffer sb = new StringBuffer();
        sb.append("Could not read network from: ");
        sb.append(url);
        sb.append("\nThis file may not be a valid file format.");
        throw new IOException(sb.toString());
      }
      taskMonitor.setProgress(1.0);
    } catch (Exception e) {
      throw new Exception("Unable to load network.", e);
    }
  }
Ejemplo n.º 3
0
  /**
   * Constructor.
   *
   * @param passedRecordList List of Records that Passed over Filter.
   * @param peName Name of Physical Entity.
   * @param bpContainer
   */
  public DownloadDetails(
      List<BasicRecordType> passedRecordList, String peName, CPath2Factory factory) {
    super();
    this.factory = factory;

    this.peName = peName;
    this.setTitle("Retrieval Confirmation");
    this.setModal(true);
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    GradientHeader header =
        new GradientHeader("Confirm Retrieval: " + passedRecordList.size() + " records");
    contentPane.add(header, BorderLayout.NORTH);

    DefaultTableModel tableModel = new NonEditableTableModel();
    Vector headerList = new Vector();
    headerList.add("Name (if available)");
    headerList.add("Type");
    headerList.add("Data Source");
    tableModel.setColumnIdentifiers(headerList);
    tableModel.setRowCount(passedRecordList.size());
    JTable table = new JTable(tableModel);

    //  Adjust width / height of viewport;  fixes bug #1620.
    Dimension d = table.getPreferredSize();
    d.width = d.width * 2;
    if (d.height > 200) {
      d.height = 200;
    }
    table.setPreferredScrollableViewportSize(d);
    table.setAutoCreateColumnsFromModel(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ids = new long[passedRecordList.size()];
    int i = 0;
    for (BasicRecordType record : passedRecordList) {
      if (record.getName().equalsIgnoreCase("N/A")) {
        record.setName("---");
      }
      tableModel.setValueAt(record.getName(), i, 0);
      tableModel.setValueAt(record.getEntityType(), i, 1);
      if (record.getDataSource() != null) {
        tableModel.setValueAt(record.getDataSource().getName(), i, 2);
      } else {
        tableModel.setValueAt("---", i, 3);
      }
      ids[i++] = record.getPrimaryId();
    }
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.add(scrollPane, BorderLayout.CENTER);

    JPanel buttonPanel = createButtonPanel(this);
    mergePanel = factory.createMergePanel();
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    if (mergePanel != null) {
      panel.add(mergePanel);
    }
    panel.add(buttonPanel);
    contentPane.add(panel, BorderLayout.SOUTH);
    pack();
    setLocationRelativeTo(factory.getCySwingApplication().getJFrame());
  }