Exemplo n.º 1
0
  public void createProgressScreen() {
    exportingProgressContainer = new JPanel();
    exportingProgressContainer.setSize(new Dimension(this.getWidth(), this.getHeight()));
    exportingProgressContainer.setLayout(new BorderLayout());
    exportingProgressContainer.setBackground(UIHelper.BG_COLOR);

    exportingProgressContainer.add(
        UIHelper.wrapComponentInPanel(new JLabel(creatingArchiveAnimation, JLabel.CENTER)),
        BorderLayout.CENTER);
    exportingProgressContainer.add(
        UIHelper.wrapComponentInPanel(archiveOutputUtil.getArchiveOutputStatus()),
        BorderLayout.SOUTH);
  }
Exemplo n.º 2
0
  private void tagTerms() {
    selectedSection = TERM_TAGGER_VIEW;

    Thread performer =
        new Thread(
            new Runnable() {
              public void run() {

                if (terms == null) {
                  terms = getTerms();
                }

                boolean haveTerms = terms != null;

                if (haveTerms) {

                  if (annotationPane == null) {

                    annotationPane = new OntologiserAnnotationPane(terms);

                    SwingUtilities.invokeLater(
                        new Runnable() {
                          public void run() {
                            annotationPane.createGUI();
                          }
                        });
                  }

                  SwingUtilities.invokeLater(
                      new Runnable() {
                        public void run() {
                          swapContainers(annotationPane);

                          termTaggerButton.setIcon(termTaggerIconOver);
                          suggestButton.setIcon(suggestIcon);
                          clearAllButton.setIcon(clearAllIcon);
                        }
                      });
                } else {
                  swapContainers(helpPane);
                }

                isLoading = false;
              }
            });
    isLoading = true;
    swapContainers(UIHelper.wrapComponentInPanel(createLoadingPanel()));
    performer.start();
  }
Exemplo n.º 3
0
  private JPanel createCompressionRateChoiceUI() {
    JPanel compressionOptionContainer = new JPanel(new BorderLayout());

    selectedCompression =
        UIHelper.createLabel("", UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR, JLabel.CENTER);

    OptionGroup<String> compressionOptions =
        new OptionGroup<String>(OptionGroup.HORIZONTAL_ALIGNMENT, true, 90);
    compressionOptions.addOptionItem(
        "<html><strong>fast</strong> speed & <strong>low</strong> compression</html>",
        true,
        fastLowCompressionSelected,
        fastLowCompressionNotSelected,
        true,
        false);
    compressionOptions.addOptionItem(
        "<html><strong>medium</strong> speed & <strong>medium</strong> compression</html>",
        false,
        medCompressionSelected,
        medCompressionNotSelected,
        true,
        false);
    compressionOptions.addOptionItem(
        "<html><strong>slow</strong> speed & <strong>high</strong> compression</html>",
        false,
        slowHighCompressionSelected,
        slowHighCompressionNotSelected,
        true,
        false);
    compressionOptionContainer.add(new JLabel(chooseCompression, JLabel.LEFT), BorderLayout.NORTH);
    compressionOptionContainer.add(compressionOptions, BorderLayout.CENTER);

    compressionOptions.addPropertyChangeListener(
        "optionSelectionChange",
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            selectedCompression.setText(
                ((OptionItem<String>) propertyChangeEvent.getNewValue()).getUserObject());
          }
        });

    compressionOptionContainer.add(selectedCompression, BorderLayout.SOUTH);

    selectedCompression.setText(compressionOptions.getSelectedItem());

    return compressionOptionContainer;
  }
Exemplo n.º 4
0
  public AutoFilterCombo(final String[] data, boolean editable) {
    // set data in combo to be a copy of the data input. This is required due to behaviour of
    // removeAllItems()
    // method in JComboBox which results in removal of elements from the data source also. By making
    // a copy, only
    // the elements in the copy are removed, not the original source.
    super(data == null ? new String[] {""} : data.clone());
    // make combo editable
    super.setEditable(editable);

    UIHelper.setJComboBoxAsHeavyweight(this);

    // add key listener to the combobox editor to listen for input from user.
    super.getEditor()
        .getEditorComponent()
        .addKeyListener(
            new KeyAdapter() {
              public void keyReleased(KeyEvent e) {
                super.keyPressed(e);

                // as long as the key pressed isnt up arrow, down arrow, or return, the proceed
                if ((e.getKeyCode() != 38) && (e.getKeyCode() != 40) && (e.getKeyCode() != 10)) {
                  String entered = getEditor().getItem().toString().toLowerCase();
                  removeAllItems();

                  int itemCount = 0;

                  for (String aData : data) {
                    if (aData.toLowerCase().contains(entered)) {
                      addItem(aData);
                      itemCount++;
                    }
                  }

                  getEditor().setItem(entered);

                  JTextField textField = (JTextField) e.getSource();
                  textField.setCaretPosition(textField.getDocument().getLength());
                  hidePopup();

                  if (itemCount != 0 && isDisplayable()) {
                    showPopup();
                  }
                }
              }
            });
  }
Exemplo n.º 5
0
  private JPanel createSelectOutputDirectoryUI() {

    JPanel container = new JPanel(new BorderLayout());
    setupFileChooser();

    outputFileLocation = new FileSelectionPanel("", fileChooser);

    Box fileLocationContainer = Box.createVerticalBox();
    fileLocationContainer.add(
        UIHelper.wrapComponentInPanel(new JLabel(chooseOutputLocation, JLabel.LEFT)));
    fileLocationContainer.add(Box.createVerticalStrut(5));
    fileLocationContainer.add(outputFileLocation);

    container.add(fileLocationContainer, BorderLayout.NORTH);

    return container;
  }
Exemplo n.º 6
0
  private JPanel createCreateArchiveButtonUI() {
    JPanel waitContainer = new JPanel(new BorderLayout());

    createArchiveButton = new JLabel(saveArchive);
    createArchiveButton.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseExited(MouseEvent mouseEvent) {

            if (createArchiveButton.isEnabled()) {
              createArchiveButton.setIcon(saveArchive);
            }
          }

          @Override
          public void mouseEntered(MouseEvent mouseEvent) {
            if (createArchiveButton.isEnabled()) {
              createArchiveButton.setIcon(saveArchiveOver);
            }
          }

          @Override
          public void mousePressed(MouseEvent mouseEvent) {
            System.out.println("Selected file path..." + outputFileLocation.getSelectedFilePath());
            if (!outputFileLocation.getSelectedFilePath().isEmpty()) {
              createArchive();
            } else {
              outputFileLocation.setWarning(true);
            }
          }
        });
    waitContainer.add(UIHelper.wrapComponentInPanel(createArchiveButton), BorderLayout.WEST);

    return waitContainer;
  }
Exemplo n.º 7
0
  public void createGUI() {
    typeSelection = new JComboBox(MappingTypes.values());
    fieldSelection = new JComboBox(columnsToBeMappedTo);
    literalEntry = new RoundedJTextField(10);
    literalEntry.setText("-");

    // set the appearance for ach of the fields!
    UIHelper.renderComponent(typeSelection, UIHelper.VER_10_PLAIN, UIHelper.GREY_COLOR, false);
    UIHelper.setJComboBoxAsHeavyweight(typeSelection);
    UIHelper.renderComponent(fieldSelection, UIHelper.VER_10_PLAIN, UIHelper.GREY_COLOR, false);
    UIHelper.setJComboBoxAsHeavyweight(fieldSelection);
    UIHelper.renderComponent(literalEntry, UIHelper.VER_10_PLAIN, UIHelper.GREY_COLOR, false);

    typeSelection.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            if (typeSelection.getSelectedIndex() == -1) {
              typeSelection.setSelectedIndex(0);
            }
            showHideFields();
          }
        });

    fieldSelection.setPreferredSize(new Dimension(130, 25));

    fieldDrop = createTableBrowseDropdown(fieldSelection);

    fieldDrop.setPreferredSize(new Dimension(160, 25));

    changeableContentContainer = new JPanel();
    changeableContentContainer.setLayout(
        new BoxLayout(changeableContentContainer, BoxLayout.LINE_AXIS));
    changeableContentContainer.setPreferredSize(new Dimension(160, 25));

    add(typeSelection);
    add(changeableContentContainer);

    if (preExistingMapping != null) {
      typeSelection.setSelectedItem(preExistingMapping.getType());

      // check if columns available contains the item it is to be set to.
      if (preExistingMapping.getType() == MappingTypes.LITERAL) {
        literalEntry.setText(preExistingMapping.getMapping());
      } else {
        if (checkFieldExists(preExistingMapping.getMapping())) {
          fieldSelection.setSelectedItem(preExistingMapping.getMapping());
        }
      }
    }

    showHideFields();

    ImageIcon imageToUse = (lastInList) ? addButtonIcon : removeButtonIcon;

    addRemoveMappingChoice = new JLabel(imageToUse);
    addRemoveMappingChoice.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseExited(MouseEvent mouseEvent) {
            if (addRemoveMappingChoice.isEnabled()) {
              addRemoveMappingChoice.setIcon(lastInList ? addButtonIcon : removeButtonIcon);
            }
          }

          @Override
          public void mouseEntered(MouseEvent mouseEvent) {
            if (addRemoveMappingChoice.isEnabled()) {
              addRemoveMappingChoice.setIcon(lastInList ? addButtonIconOver : removeButtonIconOver);
            }
          }

          public void mousePressed(MouseEvent mouseEvent) {

            if (addRemoveMappingChoice.isEnabled()) {
              if (lastInList) {
                // tell the parent to add a new mapping
                addRemoveMappingChoice.setIcon(addButtonIcon);
                firePropertyChange("addNewMapping", "1", "2");
              } else {
                // tell the parent to remove this mapping!
                firePropertyChange("removeThisMapping", "1", getCurrentInstance());
              }
            }
          }
        });

    add(addRemoveMappingChoice);
  }
Exemplo n.º 8
0
  /**
   * Create the JPanel to allow users to save the mappings created to be used in a proceeding
   * mapping activity!
   *
   * @return JLayeredPane containing the gui to allow a user to save the mapping file!
   */
  private JLayeredPane createSaveMappings() {
    JPanel saveMappingFilesCont = new JPanel();
    saveMappingFilesCont.setSize(new Dimension(400, 300));
    saveMappingFilesCont.setLayout(new BoxLayout(saveMappingFilesCont, BoxLayout.PAGE_AXIS));

    saveMappingFilesCont.add(
        UIHelper.wrapComponentInPanel(new JLabel(saveMappingHelp, SwingConstants.CENTER)));
    saveMappingFilesCont.add(Box.createVerticalStrut(10));
    saveMappingFilesCont.add(
        UIHelper.wrapComponentInPanel(
            UIHelper.createLabel(
                ""
                    + "<html>"
                    + "Please be aware, the mappings saved are saved on a field by field basis. "
                    + "This means that regardless of what assay you selected to do this/these mappings,"
                    + " common fields amongst all assays automatically inherit the mapping information. This has a number"
                    + " of benefits and a number of negative points. "
                    + "<br/>"
                    + "<p>The <strong>main benefit</strong> being that common field mappings are transportable regardless of assay types.<p>"
                    + "<p>The <strong>main problem</strong> is that because fields are saved on a field name basis, duplicate fields like"
                    + " <strong>Protocol REF</strong> columns are not saved. This mechanism for saving will be changed in the next release!</p>"
                    + "<br/>"
                    + "<br/>"
                    + "<br/>"
                    + "</html>",
                UIHelper.VER_11_PLAIN,
                UIHelper.GREY_COLOR)));

    // create selector for mapping files
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle("Choose where and what to save the file as...");
    chooser.setApproveButtonText("Select file");

    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    JPanel selectMappingPanel = new JPanel();
    selectMappingPanel.setLayout(new BoxLayout(selectMappingPanel, BoxLayout.PAGE_AXIS));
    selectMappingPanel.setOpaque(false);

    // need a jcheckbox to ask users if they wish to use a mapping
    JPanel useMappingContainer = new JPanel(new BorderLayout());
    useMappingContainer.setOpaque(false);

    final JPanel savedMappingsPanel = new JPanel();
    savedMappingsPanel.setLayout(new BoxLayout(savedMappingsPanel, BoxLayout.PAGE_AXIS));
    savedMappingsPanel.setOpaque(false);
    savedMappingsPanel.setVisible(false);

    final JLabel saveStatusInfo =
        UIHelper.createLabel("", UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR);

    final FileSelectionPanel savedMappingsFile =
        new FileSelectionPanel(
            "<html>select <strong>where</strong> to save file and <strong>it's name</strong>: </html>",
            chooser,
            FileSelectionPanel.SAVE);

    final JCheckBox useMapping = new JCheckBox("save mapping?");
    UIHelper.renderComponent(useMapping, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false);
    useMapping.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            savedMappingsPanel.setVisible(useMapping.isSelected());
            saveStatusInfo.setText("");
          }
        });

    useMappingContainer.add(useMapping, BorderLayout.WEST);
    selectMappingPanel.add(useMappingContainer);

    // add button to save mappings
    final JLabel saveMappingsButton = new JLabel(saveMappingsButtonIcon);
    saveMappingsButton.setVerticalAlignment(JLabel.BOTTOM);
    saveMappingsButton.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            saveMappingsButton.setIcon(saveMappingsButtonIconOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            saveMappingsButton.setIcon(saveMappingsButtonIcon);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            // save the mapping

            MappingXMLCreator mappingCreator = new MappingXMLCreator();
            try {
              if (useMapping.isSelected()) {
                if (!savedMappingsFile.getSelectedFilePath().equals("")) {
                  nextButton.setEnabled(false);
                  backButton.setEnabled(false);
                  mappingCreator.createXMLFile(
                      savedMappingsFile.getSelectedFilePath(), mappingsToSave, assaysToBeDefined);
                  saveStatusInfo.setText("mappings saved successfully...");
                } else {
                  saveStatusInfo.setText("please select a file...");
                }
              }
            } catch (FileNotFoundException e) {
              e.printStackTrace();
              saveStatusInfo.setText("mappings not saved..." + e.getMessage());
            } finally {
              nextButton.setEnabled(true);
              backButton.setEnabled(true);
            }
          }
        });

    final JLayeredPane finalPanel =
        getGeneralLayout(saveMappingsHeader, breadcrumb7, "", saveMappingFilesCont, 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);
            saveStatusInfo.setText("");
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    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) {

            nextButton.setIcon(next);
            Thread performMappingLogic =
                new Thread(
                    new Runnable() {
                      public void run() {
                        investigation =
                            MappingLogic.createInvestigation(
                                definitions, assaySelections, dataEntryEnvironment);
                        // now we need to construct the investigation from the defined table
                        // reference objects and the
                        ApplicationManager.assignDataEntryToISASection(
                            investigation,
                            new InvestigationDataEntry(investigation, dataEntryEnvironment));

                        investigation.setConfigurationCreateWith(
                            ApplicationManager.getCurrentApplicationInstance()
                                .getLoadedConfiguration());
                        investigation.setLastConfigurationUsed(
                            ApplicationManager.getCurrentApplicationInstance()
                                .getLoadedConfiguration());

                        dataEntryEnvironment.createGUIFromInvestigation(investigation);

                        previousPage.push(new HistoryComponent(finalPanel, listeners));
                        ApplicationManager.getCurrentApplicationInstance().hideGlassPane();
                        ApplicationManager.getCurrentApplicationInstance()
                            .setCurDataEntryPanel(dataEntryEnvironment);
                        ApplicationManager.getCurrentApplicationInstance()
                            .setCurrentPage(dataEntryEnvironment);
                      }
                    });

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

    JPanel saveMappingsSection = new JPanel();
    saveMappingsSection.setLayout(new BoxLayout(saveMappingsSection, BoxLayout.LINE_AXIS));

    saveMappingsSection.add(savedMappingsFile);
    saveMappingsSection.add(Box.createHorizontalStrut(10));

    JPanel saveButtonContainer = new JPanel(new BorderLayout());
    saveButtonContainer.add(saveMappingsButton, BorderLayout.SOUTH);

    saveMappingsSection.add(UIHelper.wrapComponentInPanel(saveButtonContainer));

    savedMappingsPanel.add(saveMappingsSection);
    selectMappingPanel.add(savedMappingsPanel);

    saveMappingFilesCont.add(selectMappingPanel);
    saveMappingFilesCont.add(UIHelper.wrapComponentInPanel(saveStatusInfo));

    assignListenerToLabel(nextButton, listeners[1]);
    return finalPanel;
  }
Exemplo n.º 9
0
  /**
   * Create JPanel asking users to select the file or directory containing files to be mapped and an
   * existing mapping file if they have one.
   *
   * @return JPanel containing elements!
   */
  private JLayeredPane createSelectFilesPanel() {
    // create overall panel

    final JPanel selectFilesContainer = new JPanel();
    selectFilesContainer.setSize(new Dimension(400, 100));
    selectFilesContainer.setLayout(new BoxLayout(selectFilesContainer, BoxLayout.PAGE_AXIS));

    // create selector for mapping files
    final FileSelectionPanel fileToMapFSP =
        new FileSelectionPanel(
            "<html>please select file(s) to be mapped (txt, csv or xls (Excel). Please ensure "
                + "that this file has <b>no empty columns</b> and if possible, please remove any special characters, e.g. &mu;</html>",
            fileChooser);
    selectFilesContainer.add(fileToMapFSP);

    JPanel selectMappingPanel = new JPanel();
    selectMappingPanel.setLayout(new BoxLayout(selectMappingPanel, BoxLayout.PAGE_AXIS));
    selectMappingPanel.setOpaque(false);

    // need a jcheckbox to ask users if they wish to use a mapping
    JPanel useMappingContainer = new JPanel(new BorderLayout());
    useMappingContainer.setOpaque(false);

    // need a file selection panel to select the file.
    JFileChooser mappingFileChooser = new JFileChooser();
    mappingFileChooser.setDialogTitle("Choose mapping file (XML)");
    mappingFileChooser.setApproveButtonText("select file");
    mappingFileChooser.setFont(UIHelper.VER_11_PLAIN);
    mappingFileChooser.setFileFilter(new CustomizableFileFilter("xml"));

    final FileSelectionPanel savedMappingsFile =
        new FileSelectionPanel(
            "<html>please select saved mapping file (xml): </html>", mappingFileChooser);
    savedMappingsFile.setVisible(false);

    final JCheckBox useMapping = new JCheckBox("use a previous mapping?");
    UIHelper.renderComponent(useMapping, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false);
    useMapping.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            savedMappingsFile.setVisible(useMapping.isSelected());
          }
        });

    useMappingContainer.add(useMapping, BorderLayout.WEST);

    selectMappingPanel.add(useMappingContainer);

    selectMappingPanel.add(savedMappingsFile);

    selectFilesContainer.add(selectMappingPanel);

    final RoundedJTextField rowOffset = new RoundedJTextField(3);
    rowOffset.setEnabled(false);
    rowOffset.setSize(new Dimension(20, 20));
    rowOffset.setText("1");

    final JCheckBox overrideRowPosition = new JCheckBox("override row start position?");
    UIHelper.renderComponent(overrideRowPosition, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false);
    overrideRowPosition.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            rowOffset.setEnabled(overrideRowPosition.isSelected());
          }
        });

    Box fileInputPanel = Box.createHorizontalBox();
    fileInputPanel.setSize(new Dimension(100, 20));
    fileInputPanel.add(overrideRowPosition);
    fileInputPanel.add(Box.createHorizontalStrut(5));
    fileInputPanel.add(rowOffset);

    selectFilesContainer.add(fileInputPanel);

    selectFilesContainer.add(selectMappingPanel);

    final JCheckBox mapToBlankFieldsCheckbox = new JCheckBox("Do not remove blank fields?", false);
    UIHelper.renderComponent(
        mapToBlankFieldsCheckbox, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false);
    mapToBlankFieldsCheckbox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            mapToBlankFields = mapToBlankFieldsCheckbox.isSelected();
          }
        });

    JPanel removeBlanksContainer = new JPanel(new BorderLayout());
    removeBlanksContainer.setOpaque(false);

    removeBlanksContainer.add(mapToBlankFieldsCheckbox, BorderLayout.WEST);

    selectFilesContainer.add(removeBlanksContainer);

    JPanel statusPanel = new JPanel(new GridLayout(1, 1));
    statusPanel.setPreferredSize(new Dimension(400, 30));
    final JLabel statusLab = UIHelper.createLabel("", UIHelper.VER_11_BOLD, UIHelper.RED_COLOR);
    statusPanel.add(statusLab);

    selectFilesContainer.add(statusPanel);

    final JLayeredPane finalLayout =
        getGeneralLayout(selectFilesHeader, breadcrumb1, "", selectFilesContainer, 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);
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    ApplicationManager.getCurrentApplicationInstance().setCurrentPage(menuPanels);
                    ApplicationManager.getCurrentApplicationInstance()
                        .setGlassPanelContents(menuPanels.getCreateISAMenuGUI());
                    menuPanels.startAnimation();
                  }
                });
          }
        };

    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) {
            nextButton.setIcon(next);

            Thread loadFile =
                new Thread(
                    new Runnable() {
                      public void run() {
                        ISAcreatorProperties.setProperty(
                            "isacreator.rowOffset",
                            rowOffset.isEnabled() ? rowOffset.getText() : "1");

                        if (useMapping.isSelected()) {

                          if (!savedMappingsFile.getSelectedFilePath().trim().equals("")) {

                            MappingXMLLoader loader =
                                new MappingXMLLoader(savedMappingsFile.getSelectedFilePath());
                            try {
                              preExistingMapping = loader.loadMappings();
                            } catch (XmlException e) {
                              log.error(e.getMessage());
                              statusLab.setText(
                                  "<html>problem found in xml for saved mapping: "
                                      + e.getMessage()
                                      + " </html>");
                              setCurrentPage(lastPage);
                              return;
                            } catch (IOException e) {
                              log.error(e.getMessage());
                              statusLab.setText(
                                  "<html>problem found when resolving file for saved mapping: "
                                      + e.getMessage()
                                      + " </html>");
                              setCurrentPage(lastPage);
                              return;
                            }
                          } else {
                            statusLab.setText(
                                "<html>please select a file containing previous mappings...</html>");
                            setCurrentPage(lastPage);
                            return;
                          }
                        } else {
                          log.info("Mapping is not selected");
                          statusLab.setText("");
                        }

                        if (fileToMapFSP.notEmpty()) {
                          previousPage.push(new HistoryComponent(finalLayout, listeners));
                          statusLab.setText("");
                          SwingUtilities.invokeLater(
                              new Runnable() {
                                public void run() {
                                  setCurrentPage(
                                      createAssayUsedPanel(fileToMapFSP.getSelectedFilePath()));
                                }
                              });
                        } else {
                          statusLab.setText(
                              "<html>please <strong>select</strong> a file to map!</html>");
                          setCurrentPage(lastPage);
                        }
                      }
                    });

            if (fileToMapFSP.notEmpty()
                && fileToMapFSP.checkFileExtensionValid("xls", "csv", "txt")) {
              statusLab.setText("");
              lastPage = currentPage;
              setCurrentPage(workingProgressScreen);
              loadFile.start();
            } else {
              statusLab.setText(
                  "<html>please select a file with the extension <strong>.xls</strong>, <strong>.csv</strong> or <strong>.txt</strong>...</html>");
            }
          }
        };
    assignListenerToLabel(nextButton, listeners[1]);
    return finalLayout;
  }
  /** Creates panel with function logo and some utilities */
  private Container createTopPanel() {
    JPanel topContainer = new JPanel(new BorderLayout());

    Box logoContainer = Box.createHorizontalBox();
    logoContainer.add(new JLabel(logo));

    topContainer.add(logoContainer, BorderLayout.WEST);

    Box toolBox = Box.createHorizontalBox();

    toolBox.add(new JLabel(toolboxIcon));

    final JLabel highlightGroups = new JLabel(highlightOffIcon);
    highlightGroups.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            highlightGroups.setIcon(isHighlighted ? highlightOnOver : highlightOffOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            highlightGroups.setIcon(isHighlighted ? highlightOnIcon : highlightOffIcon);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            if (isHighlighted) {

              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getLockedTable(), null);
              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getScrollTable(), null);
            } else {

              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getLockedTable(),
                  new CustomRowRenderer(
                      transposedSpreadsheetModel.getRowToColour(), UIHelper.VER_11_BOLD));

              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getScrollTable(),
                  new CustomRowRenderer(
                      transposedSpreadsheetModel.getRowToColour(), UIHelper.VER_11_PLAIN));
            }

            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    transposedSpreadsheetSubform.validate();
                    transposedSpreadsheetSubform.repaint();
                    highlightGroups.setIcon(isHighlighted ? highlightOnIcon : highlightOffIcon);
                  }
                });
            isHighlighted = !isHighlighted;
          }
        });

    toolBox.add(highlightGroups);

    final JLabel goToRecordButton = new JLabel(goToRecord);
    goToRecordButton.addMouseListener(
        new MouseAdapter() {
          public void mouseEntered(MouseEvent mouseEvent) {
            goToRecordButton.setIcon(goToRecordOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            goToRecordButton.setIcon(goToRecord);
          }
        });

    toolBox.add(goToRecordButton);

    Box goToRecordEntryField = Box.createVerticalBox();

    final JTextField field = new JTextField("row #");
    UIHelper.renderComponent(field, UIHelper.VER_10_PLAIN, UIHelper.LIGHT_GREY_COLOR, false);

    Dimension fieldSize = new Dimension(60, 16);
    field.setPreferredSize(fieldSize);
    field.setSize(fieldSize);

    goToRecordEntryField.add(Box.createVerticalStrut(5));
    goToRecordEntryField.add(field);
    goToRecordEntryField.add(Box.createVerticalStrut(5));

    final JLabel goButton = new JLabel(go);
    goButton.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            goButton.setIcon(goOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            goButton.setIcon(go);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            goToColumn(field);
          }
        });

    Action locateColumn =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            goToColumn(field);
          }
        };

    field.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "LOCATE_COLUMN");
    field.getActionMap().put("LOCATE_COLUMN", locateColumn);

    toolBox.add(goToRecordEntryField);
    toolBox.add(goButton);
    goToRecordEntryField.add(Box.createVerticalStrut(5));

    topContainer.add(toolBox, BorderLayout.EAST);

    information = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.LIGHT_GREY_COLOR);
    information.setHorizontalAlignment(SwingConstants.RIGHT);

    topContainer.add(UIHelper.wrapComponentInPanel(information), BorderLayout.SOUTH);

    return topContainer;
  }
Exemplo n.º 11
0
  void createGUI() {
    // create username field info
    Box fields = Box.createVerticalBox();
    fields.add(Box.createVerticalStrut(10));
    fields.setOpaque(false);

    JPanel userNameCont = new JPanel(new GridLayout(1, 2));
    JLabel usernameLabel = new JLabel("username ");
    usernameLabel.setFont(UIHelper.VER_12_BOLD);
    usernameLabel.setForeground(UIHelper.DARK_GREEN_COLOR);
    userNameCont.add(usernameLabel);

    username = new RoundedJTextField(10, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR);
    username.setOpaque(false);

    UIHelper.renderComponent(username, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    userNameCont.add(username);
    userNameCont.setOpaque(false);

    JPanel passwordCont = new JPanel(new GridLayout(1, 2));
    JLabel passwordLabel = new JLabel("password ");
    passwordLabel.setFont(UIHelper.VER_12_BOLD);
    passwordLabel.setForeground(UIHelper.DARK_GREEN_COLOR);
    passwordCont.add(passwordLabel);
    password = new RoundedJPasswordField(10, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR);
    UIHelper.renderComponent(password, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    passwordCont.add(password);
    passwordCont.setOpaque(false);

    fields.add(userNameCont);
    fields.add(Box.createVerticalStrut(10));
    fields.add(passwordCont);

    JPanel northPanel = new JPanel();
    northPanel.add(new JLabel(pleaseLogin, JLabel.RIGHT), BorderLayout.NORTH);
    northPanel.add(fields, BorderLayout.CENTER);

    JPanel southPanel = new JPanel(new GridLayout(4, 1));
    southPanel.setOpaque(false);

    JPanel buttonContainer = new JPanel(new GridLayout(1, 2));
    buttonContainer.setOpaque(false);

    createProfile = new JLabel(createProfileButton, JLabel.LEFT);
    createProfile.addMouseListener(
        new MouseAdapter() {

          public void mousePressed(MouseEvent event) {
            createProfile.setIcon(createProfileButton);

            clearFields();

            confirmExitPanel.setVisible(false);

            menu.changeView(menu.getCreateProfileGUI());
          }

          public void mouseEntered(MouseEvent event) {
            createProfile.setIcon(createProfileButtonOver);
          }

          public void mouseExited(MouseEvent event) {
            createProfile.setIcon(createProfileButton);
          }
        });

    buttonContainer.add(createProfile);

    login = new JLabel(loginButton, JLabel.RIGHT);
    login.addMouseListener(
        new MouseAdapter() {

          public void mousePressed(MouseEvent event) {
            login.setIcon(Authentication.this.loginButton);
            confirmExitPanel.setVisible(false);
            login();
          }

          public void mouseEntered(MouseEvent event) {
            login.setIcon(loginButtonOver);
          }

          public void mouseExited(MouseEvent event) {
            login.setIcon(Authentication.this.loginButton);
          }
        });

    Action loginAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            login();
          }
        };

    password.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "LOGIN");
    password.getActionMap().put("LOGIN", loginAction);
    username.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "LOGIN");
    username.getActionMap().put("LOGIN", loginAction);

    buttonContainer.add(login);

    southPanel.add(status);
    southPanel.add(buttonContainer);

    exit = new JLabel(exitButtonSml, JLabel.CENTER);
    exit.addMouseListener(
        new MouseAdapter() {

          public void mousePressed(MouseEvent event) {
            exit.setIcon(exitButtonSml);
            confirmExitPanel.setVisible(true);
            confirmExitPanel.getParent().validate();
          }

          public void mouseEntered(MouseEvent event) {
            exit.setIcon(exitButtonSmlOver);
          }

          public void mouseExited(MouseEvent event) {
            exit.setIcon(exitButtonSml);
          }
        });

    JPanel exitCont = new JPanel(new GridLayout(1, 1));
    exitCont.setOpaque(false);

    exitCont.add(exit);

    southPanel.add(exitCont);

    southPanel.add(confirmExitPanel);

    northPanel.add(southPanel, BorderLayout.SOUTH);
    northPanel.setOpaque(false);

    add(northPanel, BorderLayout.CENTER);
  }