コード例 #1
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;
  }
コード例 #2
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;
  }
コード例 #3
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;
  }
コード例 #4
0
  /** 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;
  }