Esempio n. 1
0
 public MappingChoice(
     String[] columnsToBeMappedTo, boolean lastInList, ISAField preExistingMapping) {
   this(columnsToBeMappedTo, lastInList, preExistingMapping, MappingEntryGUI.getInitialData());
 }
Esempio n. 2
0
  /**
   * Create JPanel allowing users to map a column to an ISATAB column in the sample or assay files.
   *
   * @param sequence - which sequence we are currently in with respect to defining the mappings. -1
   *     = defining sample file.
   * @param tableReference - TableReferenceObject to be used for the definition.
   * @param columnsToBeMappedTo - array of strings representing header value to be mapped to.
   * @param fileName - name of file being mapped
   * @param readerToUse - type of reader to use, @see FileLoader.CSV_READER_TXT,
   *     FileLoader.CSV_READER_CSV or FileLoader.SHEET_READER
   * @return JPanel containing the GUI to allow for mappings!
   */
  private JLayeredPane createMappings(
      final int sequence,
      final TableReferenceObject tableReference,
      final String[] columnsToBeMappedTo,
      final String fileName,
      final int readerToUse)
      throws BiffException, IOException, NoAvailableLoaderException {

    fixedMappings = sequence == -1 ? new HashMap<String, MappedElement>() : fixedMappings;

    final MappingEntryGUI mappingTableGUI =
        new MappingEntryGUI(
            tableReference,
            columnsToBeMappedTo,
            fileName,
            readerToUse,
            preExistingMapping,
            fixedMappings);
    mappingTableGUI.performPreliminaryLoading();
    mappingTableGUI.createGUI();
    mappingTableGUI.setSize(
        new Dimension((int) (menuPanels.getWidth() * 0.80), (int) (menuPanels.getHeight() * 0.90)));
    mappingTableGUI.setBorder(null);

    ImageIcon crumb = sequence == -1 ? breadcrumb3 : breadcrumb5;

    final JLayeredPane finalPanel =
        getGeneralLayout(
            performMappingHeader,
            crumb,
            getDescriptiveStringForFile(fileBeingMapped, sequence),
            mappingTableGUI,
            getHeight());

    final MouseListener[] listeners = new MouseListener[2];

    listeners[0] =
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            backButton.setIcon(backOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            backButton.setIcon(back);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            backButton.setIcon(back);
            HistoryComponent hc = previousPage.pop();
            setCurrentPage(hc.getDisplayComponent());
            assignListenerToLabel(backButton, hc.getListeners()[0]);
            assignListenerToLabel(nextButton, hc.getListeners()[1]);
          }
        };

    assignListenerToLabel(backButton, listeners[0]);

    listeners[1] =
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            nextButton.setIcon(nextOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            nextButton.setIcon(next);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            // call mapping function!
            Thread mappingThread =
                new Thread(
                    new Runnable() {
                      public void run() {

                        final MappingLogic mu =
                            new MappingLogic(
                                mappingTableGUI.getTreeInfo(),
                                tableReference,
                                readerToUse,
                                mapToBlankFields);

                        TableReferenceObject populatedTRO = mu.doMapping(fileName, readerToUse);

                        // whenever we create the mappings now, we now add the mappings in a Map
                        // which
                        // point to the populated TROs for each of the assays to be defined and the
                        // study
                        // sample file to be defined!
                        if (sequence == -1) {
                          fixedMappings.put(
                              "Sample Name", mappingTableGUI.getMappingNodeForField("Sample Name"));
                          definitions.put(MappingObject.STUDY_SAMPLE, populatedTRO);
                        } else {
                          assaySelections.put(
                              populatedTRO.getTableName(), assaysToBeDefined.get(sequence));
                          definitions.put(populatedTRO.getTableName(), populatedTRO);
                        }

                        // at this point, we want to populate a Map relating field names
                        // with ISAFieldMappings for output at a later stage in XML format.
                        mappingsToSave.putAll(mappingTableGUI.createMappingRefs());

                        nextButton.setIcon(next);
                        previousPage.push(new HistoryComponent(finalPanel, listeners));

                        SwingUtilities.invokeLater(
                            new Runnable() {
                              public void run() {
                                setCurrentPage(
                                    createMappingVisualization(
                                        sequence + 1, fileName, mu.getVisMapping()));
                              }
                            });
                      }
                    });

            setCurrentPage(workingProgressScreen);
            mappingThread.start();
          }
        };

    assignListenerToLabel(nextButton, listeners[1]);

    return finalPanel;
  }