List of usage examples for javax.swing JLabel addMouseListener
public synchronized void addMouseListener(MouseListener l)
From source file:org.geworkbench.components.lincs.LincsInterface.java
public LincsInterface() { final String lincsCwbFileName = this.getClass().getPackage().getName().replace(".", FilePathnameUtils.FILE_SEPARATOR) + FilePathnameUtils.FILE_SEPARATOR + "Lincs.cwb.xml"; setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); // temp do this, if data is there, then may be take out hideColumnList.add("P-value"); add(queryTypePanel);// w w w .ja v a 2s . co m add(queryConditionPanel1); add(queryConditionPanel2); add(queryCommandPanel); experimental.setSelected(true); ButtonGroup group = new ButtonGroup(); group.add(experimental); group.add(computational); queryTypePanel.add(new JLabel("Query Type")); queryTypePanel.add(experimental); queryTypePanel.add(computational); queryTypePanel.add(new JLabel(" ")); JLabel viewLicenseLabel = new JLabel("<html><font color=blue><u><b>View License</b></u></font></html>"); ; queryTypePanel.add(viewLicenseLabel); viewLicenseLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { viewLicense_actionPerformed(lincsCwbFileName); } }); String url = getLincsWsdlUrl(); // String url = // "http://localhost:8080/axis2/services/LincsService?wsdl"; lincs = new Lincs(url, null, null); queryConditionPanel1.setLayout(new GridLayout(2, 7)); final JLabel tissueTypeLabel = new JLabel("Tissue Type"); final JLabel cellLineLabel = new JLabel("Cell Line"); final JLabel drug1Label = new JLabel("Drug 1"); final JLabel drug2Label = new JLabel("Drug 2"); final JLabel assayTypeLabel = new JLabel("Assay Type"); final JLabel synergyMeasurementLabel = new JLabel("Synergy Measurement Type"); final JLabel similarityAlgorithmLabel = new JLabel("Similarity Algorithm"); final JLabel blankLabel = new JLabel(""); queryConditionPanel1.add(new JLabel("")); queryConditionPanel1.add(new JLabel("")); queryConditionPanel1.add(drug1Label); queryConditionPanel1.add(new JLabel("")); queryConditionPanel1.add(new JLabel("")); queryConditionPanel1.add(new JLabel("")); queryConditionPanel1.add(blankLabel); queryConditionPanel1.add(tissueTypeLabel); queryConditionPanel1.add(cellLineLabel); queryConditionPanel1.add(drug1Search); queryConditionPanel1.add(drug2Label); queryConditionPanel1.add(assayTypeLabel); queryConditionPanel1.add(synergyMeasurementLabel); queryConditionPanel1.add(new JLabel("")); queryConditionPanel2.setLayout(new GridLayout(1, 7)); List<String> tissueTypeList = null; List<String> drug1List = null; List<String> assayTypeList = null; List<String> synergyMeasuremetnTypeList = null; List<String> similarityAlgorithmList = null; try { tissueTypeList = addAll(lincs.getAllTissueNames()); drug1List = addAll(lincs.getCompound1NamesFromExperimental(null, null)); assayTypeList = addAll(lincs.getAllAssayTypeNames()); synergyMeasuremetnTypeList = addAll(lincs.getAllMeasurementTypeNames()); similarityAlgorithmList = addAll(lincs.getALLSimilarAlgorithmNames()); } catch (Exception ex) { log.error(ex.getMessage()); } tissueTypeBox = new JList(); final JScrollPane tissueTypeBoxPanel = buildJListPanel(tissueTypeList, tissueTypeBox); cellLineBox = new JList(); final JScrollPane cellLineBoxPanel = buildJListPanel(null, cellLineBox); cellLineBox.setEnabled(false); final JScrollPane drug1BoxPanel = buildFilterJListPanel(drug1List, drug1Box); drug2Box = new JList(); final JScrollPane drug2BoxPanel = buildJListPanel(null, drug2Box); drug2Box.setEnabled(false); assayTypeBox = new JList(); final JScrollPane assayTypeBoxPanel = buildJListPanel(assayTypeList, assayTypeBox); synergyMeasurementTypeBox = new JList(); final JScrollPane synergyMeasuremetnTypeBoxPanel = buildJListPanel(synergyMeasuremetnTypeList, synergyMeasurementTypeBox); similarityAlgorithmTypeBox = new JList(); final JScrollPane similarityAlgorithmTypeBoxPanel = buildJListPanel(similarityAlgorithmList, similarityAlgorithmTypeBox); onlyTitration = new JCheckBox("Only with titration"); queryConditionPanel2.add(tissueTypeBoxPanel); queryConditionPanel2.add(cellLineBoxPanel); queryConditionPanel2.add(drug1BoxPanel); queryConditionPanel2.add(drug2BoxPanel); queryConditionPanel2.add(assayTypeBoxPanel); queryConditionPanel2.add(synergyMeasuremetnTypeBoxPanel); queryConditionPanel2.add(onlyTitration); // dynamic dependency parts tissueTypeBox.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { List<String> selectedTissueList = getSelectedValues(tissueTypeBox); List<String> cellLineDataList = null; List<String> drug1DataList = null; try { cellLineDataList = addAll(lincs.getAllCellLineNamesForTissueTypes(selectedTissueList)); if (experimental.isSelected() == true) drug1DataList = addAll( lincs.getCompound1NamesFromExperimental(selectedTissueList, null)); else drug1DataList = addAll( lincs.getCompound1NamesFromComputational(selectedTissueList, null)); } catch (Exception ex) { log.error(ex.getMessage()); } if (tissueTypeBox.getSelectedValues() != null && tissueTypeBox.getSelectedValues().length > 0) cellLineBox.setModel(new LincsListModel(cellLineDataList)); else cellLineBox.setModel(new LincsListModel(null)); cellLineBox.setEnabled(true); cellLineBox.clearSelection(); drug1Box.removeAllItems(); for (int i = 0; i < drug1DataList.size(); i++) drug1Box.addItem(drug1DataList.get(i)); drug1Box.clearSelection(); drug2Box.clearSelection(); drug2Box.setModel(new LincsListModel(null)); drug2Box.setEnabled(false); cellLineBox.ensureIndexIsVisible(0); drug1Box.ensureIndexIsVisible(0); } } }); // dynamic dependency parts cellLineBox.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { List<String> selectedTissueList = getSelectedValues(tissueTypeBox); List<String> selectedCellLineList = getSelectedValues(cellLineBox); List<String> drug1DataList = null; try { if (experimental.isSelected() == true) drug1DataList = addAll(lincs.getCompound1NamesFromExperimental(selectedTissueList, selectedCellLineList)); else drug1DataList = addAll(lincs.getCompound1NamesFromComputational(selectedTissueList, selectedCellLineList)); } catch (Exception ex) { log.error(ex.getMessage()); } drug1Box.removeAllItems(); for (int i = 0; i < drug1DataList.size(); i++) drug1Box.addItem(drug1DataList.get(i)); drug1Box.ensureIndexIsVisible(0); drug1Box.clearSelection(); drug2Box.clearSelection(); drug2Box.setModel(new LincsListModel(null)); drug2Box.setEnabled(false); } } }); // dynamic dependency parts drug1Box.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { List<String> selectedTissueList = getSelectedValues(tissueTypeBox); List<String> selectedCellLineList = getSelectedValues(cellLineBox); List<String> selectedDrug1List = getSelectedValues(drug1Box); List<String> drug2DataList = null; try { if (experimental.isSelected() == true) drug2DataList = addAll(lincs.getCompound2NamesFromExperimental(selectedTissueList, selectedCellLineList, selectedDrug1List)); else drug2DataList = addAll(lincs.getCompound2NamesFromComputational(selectedTissueList, selectedCellLineList, selectedDrug1List)); } catch (Exception ex) { log.error(ex.getMessage()); } if (drug1Box.getSelectedValues() != null && drug1Box.getSelectedValues().length > 0) drug2Box.setModel(new LincsListModel(drug2DataList)); else drug2Box.setModel(new LincsListModel(null)); drug2Box.setEnabled(true); drug2Box.ensureIndexIsVisible(0); } } }); maxResult = new JCheckBox("Max results"); maxResultNumber = new JTextField("10", 10); searchButton = new JButton("Search"); resetButton = new JButton("Reset"); colorGradient = new JCheckBox("Color gradient for Score"); queryCommandPanel.add(maxResult); queryCommandPanel.add(maxResultNumber); queryCommandPanel.add(searchButton); queryCommandPanel.add(resetButton); queryCommandPanel.add(colorGradient); resultTable = new TableViewer(experimentalColumnNames, null, hideColumnList); add(resultTable); add(resultProcessingPanel); queryResultPanel.setLayout(new BorderLayout()); // queryResultPanel.add(new JScrollPane(resultTable), // BorderLayout.CENTER); plotOptions = new JComboBox(new String[] { HEATMAP, NETWORK }); JButton plotButton = new JButton("Plot"); final JCheckBox limitNetwork = new JCheckBox("Limit network to multiply-connected pairs"); limitNetwork.setEnabled(false); limitNetwork.setVisible(false); JButton exportButton = new JButton("Export"); exportButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { List<String> hideColumns = new ArrayList<String>(); hideColumns.add("Include"); TableViewer.export(resultTable.getTable(), hideColumns, resultTable); } }); resultProcessingPanel.add(new JLabel("Plot options:")); resultProcessingPanel.add(plotOptions); resultProcessingPanel.add(plotButton); resultProcessingPanel.add(limitNetwork); resultProcessingPanel.add(exportButton); plotOptions.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (plotOptions.getSelectedItem().toString().equals(HEATMAP)) { limitNetwork.setEnabled(false); } else if (plotOptions.getSelectedItem().toString().equals(NETWORK)) { limitNetwork.setEnabled(true); } } }); plotButton.addActionListener(plotListener); colorGradient.addActionListener(colorGradientListener); computational.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { queryConditionPanel1.remove(blankLabel); queryConditionPanel1.remove(assayTypeLabel); queryConditionPanel1.remove(synergyMeasurementLabel); queryConditionPanel2.remove(assayTypeBoxPanel); queryConditionPanel2.remove(synergyMeasuremetnTypeBoxPanel); queryConditionPanel1.add(similarityAlgorithmLabel, 10); queryConditionPanel2.add(similarityAlgorithmTypeBoxPanel, 4); queryConditionPanel1.updateUI(); queryConditionPanel2.updateUI(); onlyTitration.setEnabled(false); reset(); } }); experimental.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { queryConditionPanel1.remove(similarityAlgorithmLabel); queryConditionPanel2.remove(similarityAlgorithmTypeBoxPanel); queryConditionPanel1.add(blankLabel, 6); queryConditionPanel1.add(assayTypeLabel, 11); queryConditionPanel1.add(synergyMeasurementLabel, 12); queryConditionPanel2.add(assayTypeBoxPanel, 4); queryConditionPanel2.add(synergyMeasuremetnTypeBoxPanel, 5); queryConditionPanel1.updateUI(); queryConditionPanel2.updateUI(); onlyTitration.setEnabled(true); reset(); } }); searchButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int rowLimit = 0; List<String> tissueTypes = getSelectedValues(tissueTypeBox); List<String> cellLineNames = getSelectedValues(cellLineBox); List<String> drug1Names = getSelectedValues(drug1Box); List<String> drug2Names = getSelectedValues(drug2Box); if (maxResult.isSelected()) { try { rowLimit = new Integer(maxResultNumber.getText().trim()).intValue(); } catch (NumberFormatException nbe) { JOptionPane.showMessageDialog(null, "Please enter a number."); maxResultNumber.requestFocus(); return; } } if ((drug1Names == null || drug1Names.isEmpty()) && (drug2Names == null || drug2Names.isEmpty())) { JOptionPane.showMessageDialog(null, "Please select at least one drug constraint, multiple drugs can be selected."); return; } AbstractAnalysis selectedAnalysis = new LincsSearchAnalysis(); String dataSetName = null; if (experimental.isSelected()) { selectedAnalysis.setLabel("LINCS Experimental Query"); dataSetName = "LINCS Data"; } else { selectedAnalysis.setLabel("LINCS Computational Query"); dataSetName = "LINCS Data"; } final AnalysisInvokedEvent invokeEvent = new AnalysisInvokedEvent(selectedAnalysis, dataSetName); publishAnalysisInvokedEvent(invokeEvent); try { if (experimental.isSelected()) { List<String> assayTypes = getSelectedValues(assayTypeBox); List<String> measurementTypes = getSelectedValues(synergyMeasurementTypeBox); List<ExperimentalData> dataList = lincs.getExperimentalData(tissueTypes, cellLineNames, drug1Names, drug2Names, measurementTypes, assayTypes, onlyTitration.isSelected(), rowLimit); Object[][] objects = convertExperimentalData(dataList); updateResultTable(objects); } else { List<String> similarityAlgorithmTypes = getSelectedValues(similarityAlgorithmTypeBox); List<ComputationalData> dataList = lincs.getComputationalData(tissueTypes, cellLineNames, drug1Names, drug2Names, similarityAlgorithmTypes, rowLimit); Object[][] objects = convertComputationalData(dataList); updateResultTable(objects); } publishAnalysisCompleteEvent(new AnalysisCompleteEvent(invokeEvent)); } catch (Exception ex) { log.error(ex.getMessage()); publishAnalysisAbortEvent(new AnalysisAbortEvent(invokeEvent)); } if (resultTable.getData() == null || resultTable.getData().length == 0) { JOptionPane.showMessageDialog(null, "There is no row in the database for your query.", "Empty Set", JOptionPane.INFORMATION_MESSAGE); return; } freeVariables = getFreeVariables(); } }); resetButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); }
From source file:org.isatools.gui.datamanager.exportisa.ExportISAGUI.java
private JPanel createSouthPanel() { JPanel southPanel = new JPanel(new BorderLayout()); southPanel.setOpaque(false);//from w w w .ja va 2 s.co m errorDisplay = new JLabel(warningIcon); UIHelper.renderComponent(errorDisplay, UIHelper.VER_11_BOLD, UIHelper.LIGHT_GREY_COLOR, false); errorDisplay.setVisible(false); southPanel.add(UIHelper.wrapComponentInPanel(errorDisplay), BorderLayout.NORTH); southPanel.add(createBackToMainMenuButton(), BorderLayout.WEST); final JLabel exportISAButton = new JLabel(exportISAIcon); exportISAButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { exportISAButton.setIcon(exportISAIcon); if (!selectedOutputFolderExists() && !exportToRepository()) { localDirectoryLocation.setBackgroundToError(); } else { if (studyAvailabilityTree.getCheckedStudies(studyAvailabilityTree.getRoot()).size() == 0) { errorDisplay.setText("<html>please select <i>at least one study</i> to export!</html>"); errorDisplay.setVisible(true); } else { errorDisplay.setVisible(false); firePropertyChange("doISATabExport", "", "doExport"); } } } @Override public void mouseExited(MouseEvent mouseEvent) { exportISAButton.setIcon(exportISAIcon); } @Override public void mouseEntered(MouseEvent mouseEvent) { exportISAButton.setIcon(exportISAIconOver); } }); southPanel.add(exportISAButton, BorderLayout.EAST); return southPanel; }
From source file:org.isatools.gui.datamanager.studyaccess.StudyAccessionGUI.java
private JPanel createStudySelectionPanel() { JPanel container = new JPanel(); container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS)); container.setOpaque(false);//from www . ja va2s. co m JPanel studyAccessionSelector = new JPanel(); studyAccessionSelector.setLayout(new BorderLayout()); studyAccessionSelector.setOpaque(false); JLabel information = new JLabel(unloadStudyHeader); information.setHorizontalAlignment(SwingConstants.RIGHT); information.setVerticalAlignment(SwingConstants.TOP); studyAccessionSelector.add(information, BorderLayout.NORTH); retrieveAndProcessStudyInformation(); JScrollPane treeScroller = new JScrollPane(studyAvailabilityTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); treeScroller.getViewport().setOpaque(false); treeScroller.setOpaque(false); treeScroller.setBorder(new EmptyBorder(1, 1, 1, 1)); treeScroller.setPreferredSize(new Dimension(380, 210)); studyAccessionSelector.add(treeScroller); container.add(studyAccessionSelector); // and need a convert button! JPanel buttonCont = new JPanel(new BorderLayout()); buttonCont.setOpaque(false); final JLabel unload = new JLabel(this.unloadButton, JLabel.RIGHT); unload.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { unload.setIcon(unloadButtonOver); } public void mouseExited(MouseEvent mouseEvent) { unload.setIcon(StudyAccessionGUI.this.unloadButton); } public void mousePressed(MouseEvent mouseEvent) { Set<String> studiesToUnload = studyAvailabilityTree .getCheckedStudies(studyAvailabilityTree.getRoot()); log.info("going to unload: "); for (String acc : studiesToUnload) { log.info("study with acc " + acc); } doUnloading(studiesToUnload); } }); buttonCont.add(unload, BorderLayout.EAST); buttonCont.add(createBackToMainMenuButton(), BorderLayout.WEST); container.add(buttonCont); return container; }
From source file:org.isatools.isacreator.filechooser.FileChooserUI.java
private JPanel createTopPanel() { final JTextField uri = new RoundedJTextField(20); final JTextField username = new RoundedJTextField(20); final JPasswordField password = new RoundedJPasswordField(20); final JPanel topContainer = new JPanel(); topContainer.setLayout(new BoxLayout(topContainer, BoxLayout.PAGE_AXIS)); topContainer.setBackground(UIHelper.BG_COLOR); HUDTitleBar titlePanel = new HUDTitleBar(null, null, true); add(titlePanel, BorderLayout.NORTH); titlePanel.installListeners();//from w ww. j a v a 2s .c o m topContainer.add(titlePanel); JPanel buttonPanel = new JPanel(new GridLayout(1, 1)); buttonPanel.setOpaque(false); JPanel fileSystemPanel = new JPanel(); fileSystemPanel.setLayout(new BoxLayout(fileSystemPanel, BoxLayout.LINE_AXIS)); fileSystemPanel.setBackground(UIHelper.BG_COLOR); localFsChoice = new JLabel(localFileSystemIcon, JLabel.LEFT); localFsChoice.setBackground(UIHelper.BG_COLOR); localFsChoice.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { SwingUtilities.invokeLater(new Runnable() { public void run() { localFsChoice.setIcon(localFileSystemIconOver); remoteFsChoice.setIcon(remoteFileSystemIcon); ftpConnectionContainer.setVisible(false); topContainer.revalidate(); status.setText(""); fileBrowser = new LocalBrowser(); try { updateTree(fileBrowser.getHomeDirectory()); } catch (IOException e) { FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } } }); } }); fileSystemPanel.add(localFsChoice); fileSystemPanel.add(Box.createHorizontalStrut(5)); remoteFsChoice = new JLabel(remoteFileSystemIcon, JLabel.LEFT); remoteFsChoice.setBackground(UIHelper.BG_COLOR); remoteFsChoice.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { SwingUtilities.invokeLater(new Runnable() { public void run() { localFsChoice.setIcon(localFileSystemIcon); remoteFsChoice.setIcon(remoteFileSystemIconOver); ftpConnectionContainer.setVisible(true); topContainer.revalidate(); } }); // immediately try to call FTP manager to get last sessions details final FTPAuthentication lastSession; if ((lastSession = ftpManager.getLastSession()) != null) { Thread remoteConnector = new Thread(new Runnable() { public void run() { connectToFTP(lastSession.getUri(), lastSession.getUsername(), lastSession.getPassword()); } }); remoteConnector.start(); } else { errorAction("no ftp location"); } } }); fileSystemPanel.add(remoteFsChoice); fileSystemPanel.add(Box.createHorizontalStrut(5)); status = UIHelper.createLabel("", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); status.setHorizontalAlignment(JLabel.RIGHT); fileSystemPanel.add(status); buttonPanel.add(fileSystemPanel); topContainer.add(buttonPanel); // now create panel to configure the FTP site ftpConnectionContainer = new JPanel(new GridLayout(1, 1)); ftpConnectionContainer.setBackground(UIHelper.BG_COLOR); JPanel userAuthFTP = new JPanel(); userAuthFTP.setLayout(new BoxLayout(userAuthFTP, BoxLayout.LINE_AXIS)); userAuthFTP.setOpaque(false); // add field to add URI JPanel uriPanel = new JPanel(new GridLayout(1, 2)); uriPanel.setBackground(UIHelper.BG_COLOR); JLabel uriLab = UIHelper.createLabel("FTP URI: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); UIHelper.renderComponent(uri, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false); uriPanel.add(uriLab); uriPanel.add(uri); userAuthFTP.add(uriPanel); // add field to add username JPanel usernamePanel = new JPanel(new GridLayout(1, 2)); usernamePanel.setBackground(UIHelper.BG_COLOR); JLabel usernameLab = UIHelper.createLabel("Username: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); UIHelper.renderComponent(username, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false); uriPanel.add(usernameLab); uriPanel.add(username); userAuthFTP.add(usernamePanel); // add field to add password JPanel passwordPanel = new JPanel(new GridLayout(1, 2)); passwordPanel.setBackground(UIHelper.BG_COLOR); JLabel passwordLab = UIHelper.createLabel("Password: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); UIHelper.renderComponent(password, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false); passwordPanel.add(passwordLab); passwordPanel.add(password); userAuthFTP.add(passwordPanel); JLabel connectLab = new JLabel(connectIcon); connectLab.setOpaque(false); connectLab.setToolTipText("<html><b>Connect</b><p>Connect to the FTP source defined!</p></html>"); connectLab.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); if (uri.getText() != null && !uri.getText().trim().equals("")) { String user = (username.getText() != null) ? username.getText() : ""; String pass = (password.getPassword() != null) ? new String(password.getPassword()) : ""; final FTPAuthentication newFTPLocation = new FTPAuthentication(uri.getText(), user, pass); Thread remoteConnector = new Thread(new Runnable() { public void run() { connectToFTP(newFTPLocation.getUri(), newFTPLocation.getUsername(), newFTPLocation.getPassword()); } }); remoteConnector.start(); } } }); userAuthFTP.add(connectLab); JLabel historyLab = new JLabel(viewHistoryIcon); historyLab.setOpaque(false); historyLab.setToolTipText( "<html><b>Search previously connected to FTP locations</b><p>Connect to a previously defined FTP location</p></html>"); historyLab.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); SelectFromFTPHistory selectFTP = new SelectFromFTPHistory(); selectFTP.addPropertyChangeListener("locationSelected", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getNewValue() != null) { final FTPAuthentication ftpRecord = ftpManager .retrieveFTPAuthenticationObject(event.getNewValue().toString()); Thread remoteConnector = new Thread(new Runnable() { public void run() { connectToFTP(ftpRecord.getUri(), ftpRecord.getUsername(), ftpRecord.getPassword()); } }); remoteConnector.start(); } } }); selectFTP.createGUI(); showJDialogAsSheet(selectFTP); } }); userAuthFTP.add(historyLab); ftpConnectionContainer.add(userAuthFTP); ftpConnectionContainer.setVisible(false); topContainer.add(ftpConnectionContainer); return topContainer; }
From source file:org.isatools.isacreator.filechooser.FileChooserUI.java
/** * Creates the FileSelection panel containing the list of selected files, and the toolbar to modify the list * * @return JPanel containing a selection pane */// w w w . ja va2 s . co m private JPanel createFilesSelectedPanel() { JPanel selectionContainer = new JPanel(new BorderLayout()); selectionContainer.setBackground(UIHelper.BG_COLOR); selectionContainer.setBorder( new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "selection(s)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); selectedFiles = new DirectoryFileList(); listModel = (DefaultListModel) selectedFiles.getModel(); selectedFiles.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); selectedFiles.setDragEnabled(false); JScrollPane selectedFileScroller = new JScrollPane(selectedFiles, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); selectedFileScroller.setPreferredSize(new Dimension(200, 175)); selectedFileScroller.setBorder(new EmptyBorder(0, 0, 0, 0)); IAppWidgetFactory.makeIAppScrollPane(selectedFileScroller); selectionContainer.add(selectedFileScroller, BorderLayout.CENTER); // add list modification toolbar to sort, move, and delete files from the list. JPanel optionsPanel = new JPanel(); optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.LINE_AXIS)); optionsPanel.setBackground(UIHelper.BG_COLOR); final JLabel moveDown = new JLabel(downIcon); moveDown.setOpaque(false); moveDown.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { moveDown.setIcon(downIcon); if (!selectedFiles.isSelectionEmpty()) { int toMoveDown = selectedFiles.getSelectedIndex(); if (toMoveDown != (listModel.getSize() - 1)) { swapElements(toMoveDown, toMoveDown + 1); } } } public void mouseEntered(MouseEvent event) { moveDown.setIcon(downIconOver); } public void mouseExited(MouseEvent event) { moveDown.setIcon(downIcon); } }); optionsPanel.add(moveDown); optionsPanel.add(Box.createHorizontalStrut(5)); final JLabel moveUp = new JLabel(upIcon); moveUp.setOpaque(false); moveUp.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { moveUp.setIcon(upIcon); if (!selectedFiles.isSelectionEmpty()) { int toMoveUp = selectedFiles.getSelectedIndex(); if (toMoveUp != 0) { swapElements(toMoveUp, toMoveUp - 1); } } } public void mouseEntered(MouseEvent event) { moveUp.setIcon(upIconOver); } public void mouseExited(MouseEvent event) { moveUp.setIcon(upIcon); } }); optionsPanel.add(moveUp); optionsPanel.add(Box.createHorizontalStrut(5)); final JLabel deleteItem = new JLabel(deleteIcon); deleteItem.setOpaque(false); deleteItem.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { deleteItem.setIcon(deleteIcon); if (selectedFiles.getSelectedValues() != null) { for (Object o : selectedFiles.getSelectedValues()) { listModel.removeElement(o); } } } public void mouseEntered(MouseEvent event) { deleteItem.setIcon(deleteIconOver); } public void mouseExited(MouseEvent event) { deleteItem.setIcon(deleteIcon); } }); optionsPanel.add(deleteItem); optionsPanel.add(Box.createHorizontalStrut(5)); final JLabel sortAsc = new JLabel(sortAscIcon); sortAsc.setOpaque(false); sortAsc.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { sortAsc.setIcon(sortAscIcon); if (listModel.getSize() > 0) { sort(true); } } public void mouseEntered(MouseEvent event) { sortAsc.setIcon(sortAscIconOver); } public void mouseExited(MouseEvent event) { sortAsc.setIcon(sortAscIcon); } }); optionsPanel.add(sortAsc); optionsPanel.add(Box.createHorizontalStrut(5)); final JLabel sortDesc = new JLabel(sortDescIcon); sortDesc.setOpaque(false); sortDesc.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { sortDesc.setIcon(sortDescIcon); if (listModel.getSize() > 0) { sort(false); } } public void mouseEntered(MouseEvent event) { sortDesc.setIcon(sortDescIconOver); } public void mouseExited(MouseEvent event) { sortDesc.setIcon(sortDescIcon); } }); optionsPanel.add(sortDesc); optionsPanel.add(Box.createHorizontalStrut(5)); selectionContainer.add(optionsPanel, BorderLayout.SOUTH); return selectionContainer; }
From source file:org.isatools.isacreator.filechooser.FileChooserUI.java
/** * Create the Navigation Tree panel//from w w w . j a va2 s . c o m * * @return @see JPanel containing the navigation tree to browse a file system. */ private JPanel createNavTree() { JPanel treeContainer = new JPanel(new BorderLayout()); treeContainer.setBackground(UIHelper.BG_COLOR); treeContainer .setBorder(new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); JPanel navigationControls = new JPanel(); navigationControls.setLayout(new BoxLayout(navigationControls, BoxLayout.LINE_AXIS)); navigationControls.setOpaque(false); final JLabel navToParentDir = new JLabel(upIcon); navToParentDir.setOpaque(false); navToParentDir.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); navToParentDir.setIcon(upIcon); try { updateTree(fileBrowser.getParentDirectory()); } catch (IOException e) { errorAction("problem occurred!"); } } public void mouseEntered(MouseEvent event) { super.mouseEntered(event); navToParentDir.setIcon(upIconOver); } public void mouseExited(MouseEvent event) { super.mouseExited(event); navToParentDir.setIcon(upIcon); } }); navigationControls.add(navToParentDir); navigationControls.add(Box.createHorizontalStrut(5)); final JLabel navToHomeDir = new JLabel(homeIcon); navToHomeDir.setOpaque(false); navToHomeDir.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); navToHomeDir.setIcon(homeIcon); try { updateTree(fileBrowser.getHomeDirectory()); } catch (IOException e) { if (e instanceof ConnectionException) { status.setText("<html>status: not connected!</html>"); } FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } } public void mouseEntered(MouseEvent event) { super.mouseEntered(event); navToHomeDir.setIcon(homeIconOver); } public void mouseExited(MouseEvent event) { super.mouseExited(event); navToHomeDir.setIcon(homeIcon); } }); navigationControls.add(navToHomeDir); navigationControls.add(Box.createGlue()); treeContainer.add(navigationControls, BorderLayout.NORTH); try { treeModel = new DefaultTreeModel(fileBrowser.getHomeDirectory()); directoryTree = new JTree(treeModel); directoryTree.setFont(UIHelper.VER_11_PLAIN); directoryTree.setCellRenderer(new FileSystemTreeCellRenderer()); } catch (IOException e) { FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } directoryTree.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); int selRow = directoryTree.getRowForLocation(event.getX(), event.getY()); TreePath selPath = directoryTree.getPathForLocation(event.getX(), event.getY()); if (selRow != -1) { final FileBrowserTreeNode node = (FileBrowserTreeNode) selPath.getLastPathComponent(); if (SwingUtilities.isLeftMouseButton(event)) { if (event.getClickCount() == 2) { if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) { String newPath; if (fileBrowser instanceof LocalBrowser) { newPath = ((File) fileBrowser.getDirFiles().get(node.toString())).getPath(); } else { newPath = node.toString(); } updateTree(fileBrowser.changeDirectory(newPath)); } // else, if a leaf node, then add file to to list if (node.isLeaf() && (node.getType() != FileBrowserTreeNode.DIRECTORY)) { String extension = node.toString().substring(node.toString().lastIndexOf(".") + 1) .trim().toUpperCase(); FileChooserFile toAdd = null; for (Object o : fileBrowser.getFileMap().get(extension)) { String fileName; String filePath; if (fileBrowser instanceof LocalBrowser) { File file = (File) o; fileName = file.getName(); filePath = file.getPath(); if (fileName.equals(node.toString())) { toAdd = new CustomFile(filePath); break; } } else { FTPFile ftpFile = (FTPFile) o; fileName = ftpFile.getName(); filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator + ftpFile.getName(); if (fileName.equals(node.toString())) { toAdd = new CustomFTPFile(ftpFile, filePath); break; } } } if (toAdd != null && !checkIfInList(toAdd)) { selectedFiles.addFileItem(toAdd); } } } } else { if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) { // show popup to add the directory to the selected files JPopupMenu popup = new JPopupMenu(); JMenuItem addDirectory = new JMenuItem("add directory"); addDirectory.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { Object fileToAdd = fileBrowser.getDirFiles().get(node.toString()); FileChooserFile toAdd; if (fileToAdd instanceof File) { toAdd = new CustomFile(((File) fileToAdd).getPath()); } else { FTPFile ftpFile = (FTPFile) fileToAdd; String filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator + ftpFile.getName(); toAdd = new CustomFTPFile(ftpFile, filePath); } if (!checkIfInList(toAdd)) { selectedFiles.addDirectoryItem(toAdd); } } }); popup.add(addDirectory); popup.show(directoryTree, event.getX(), event.getY()); } } } } }); BasicTreeUI ui = new BasicTreeUI() { public Icon getCollapsedIcon() { return null; } public Icon getExpandedIcon() { return null; } }; directoryTree.setUI(ui); directoryTree.setFont(UIHelper.VER_12_PLAIN); JScrollPane treeScroll = new JScrollPane(directoryTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); treeScroll.setPreferredSize(new Dimension(300, 200)); treeScroll.setBorder(new EmptyBorder(0, 0, 0, 0)); treeContainer.add(treeScroll, BorderLayout.CENTER); IAppWidgetFactory.makeIAppScrollPane(treeScroll); return treeContainer; }
From source file:org.isatools.isacreator.gui.formelements.SubForm.java
private JPanel setupOptionsPanel() { options = new JPanel(); options.setLayout(new BoxLayout(options, BoxLayout.LINE_AXIS)); options.setOpaque(false);/* w w w.j a v a 2s . c om*/ String addRecordString = fieldType == FieldTypes.ASSAY && dataEntryForm != null ? "create assay" : "add a new " + fieldType + " column"; final JLabel addRecord = new JLabel(addRecordString, addRecordIcon, JLabel.LEFT); String toolTipText; if (fieldType == FieldTypes.ASSAY) { toolTipText = "<html><b>Create a new Assay</b>" + " <p>Complete the details for the assay in the fields provided</p>" + " <p>and click this button to add the assay to this study...</p>" + "</html>"; } else { toolTipText = "<html><b>Add a new " + fieldType + "</b>" + " <p>Click here to add a new column to enter an additional " + fieldType + "</p>" + "</html>"; } addRecord.setToolTipText(toolTipText); Font fontToUse = fieldType == FieldTypes.ASSAY && dataEntryForm != null ? UIHelper.VER_12_BOLD : UIHelper.VER_12_PLAIN; UIHelper.renderComponent(addRecord, fontToUse, UIHelper.DARK_GREEN_COLOR, false); addRecord.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { addRecord.setIcon(addRecordIcon); if (addColumn()) { updateTables(); } } @Override public void mouseEntered(MouseEvent mouseEvent) { addRecord.setIcon(addRecordIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { addRecord.setIcon(addRecordIcon); } }); options.add(addRecord); options.add(Box.createHorizontalStrut(10)); removeRecord = new JLabel("Remove " + fieldType + "...", removeIcon, JLabel.LEFT); removeRecord.setVisible(false); UIHelper.renderComponent(removeRecord, UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR, false); removeRecord.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { if (removeRecord.getIcon() != null) { removeRecord.setIcon(removeIcon); } removalConfirmation(fieldType); } @Override public void mouseExited(MouseEvent mouseEvent) { if (removeRecord.getIcon() != null) { removeRecord.setIcon(removeIcon); } } @Override public void mouseEntered(MouseEvent mouseEvent) { if (removeRecord.getIcon() != null) { removeRecord.setIcon(removeIconOver); } } }); if (!showRemoveOption) { removeRecord.setIcon(null); removeRecord.setText(""); } options.add(removeRecord); options.add(Box.createHorizontalStrut(10)); createCustomOptions(); options.add(Box.createGlue()); return options; }
From source file:org.isatools.isacreator.ontologyselectiontool.ViewTermDefinitionUI.java
private JPanel createOntologyInformationPane(final OntologyBranch term) { JPanel contentPane = new JPanel(new BorderLayout()); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(2, 2, 2, 2)); JEditorPane ontologyInfoPane = createOntologyInformationDisplay(term); JScrollPane ontologyInfoScroller = new JScrollPane(ontologyInfoPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); ontologyInfoScroller.getViewport().setBackground(UIHelper.BG_COLOR); ontologyInfoScroller.setBorder(new EmptyBorder(2, 2, 2, 2)); IAppWidgetFactory.makeIAppScrollPane(ontologyInfoScroller); contentPane.add(ontologyInfoScroller, BorderLayout.CENTER); JLabel viewOntologyInBrowser = new JLabel("View in resource."); viewOntologyInBrowser.addMouseListener(new CommonMouseAdapter() { @Override//from w ww .j a v a2 s . c o m public void mouseExited(MouseEvent mouseEvent) { super.mouseExited(mouseEvent); } @Override public void mouseEntered(MouseEvent mouseEvent) { super.mouseEntered(mouseEvent); } @Override public void mousePressed(MouseEvent mouseEvent) { super.mousePressed(mouseEvent); try { String termSource = term.getComments().get("Source"); System.out.println("Source: " + termSource); System.out.println("Accession: " + term.getBranchIdentifier()); String serviceProvider = term.getComments().get("Service Provider"); System.out.println("Service Provider: " + serviceProvider); String url = ""; if (serviceProvider.equalsIgnoreCase("ols")) { url = "http://www.ebi.ac.uk/ontology-lookup/?termId=" + termSource + ":" + term.getComments().get("accession"); } else if (serviceProvider.equalsIgnoreCase("bioportal")) { url = "http://bioportal.bioontology.org/ontologies/" + termSource.substring(termSource.lastIndexOf("/") + 1) + "?p=classes&conceptid=" + term.getBranchIdentifier(); } System.out.println(url); Desktop.getDesktop().browse(new URI(url)); } catch (Exception e) { System.err.println("Unable to open URL: " + e.getMessage()); } } }); UIHelper.renderComponent(viewOntologyInBrowser, UIHelper.VER_10_BOLD, new Color(28, 117, 188), false); contentPane.add(viewOntologyInBrowser, BorderLayout.SOUTH); return contentPane; }
From source file:org.isatools.isacreator.wizard.GeneralCreationAlgorithm.java
public JPanel instantiatePanel() { final JPanel generalQuestionCont = new JPanel(); generalQuestionCont.setLayout(new BoxLayout(generalQuestionCont, BoxLayout.PAGE_AXIS)); generalQuestionCont.setBackground(UIHelper.BG_COLOR); JLabel info = new JLabel("<html><b>" + assay.getMeasurementEndpoint() + "</b> using <b>" + assay.getTechnologyType() + "</b></html>", JLabel.LEFT); UIHelper.renderComponent(info, UIHelper.VER_12_PLAIN, UIHelper.GREY_COLOR, false); if (assay.getTechnologyType().equals("")) { info.setText("<html><b>" + assay.getMeasurementEndpoint() + "</html>"); }/*from www.jav a 2 s . c o m*/ info.setPreferredSize(new Dimension(300, 40)); JPanel infoPanel = new JPanel(new GridLayout(1, 1)); infoPanel.setBackground(UIHelper.BG_COLOR); infoPanel.add(info); generalQuestionCont.add(infoPanel); JPanel labelPanel = new JPanel(new GridLayout(1, 2)); labelPanel.setBackground(UIHelper.BG_COLOR); labelCapture = new LabelCapture("Label"); labelCapture.setVisible(false); labelUsed = new JCheckBox("Label used?", false); UIHelper.renderComponent(labelUsed, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR); labelUsed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { labelCapture.setVisible(labelUsed.isSelected()); } }); labelPanel.add(labelUsed); labelPanel.add(labelCapture); generalQuestionCont.add(labelPanel); final JPanel extractPanel = new JPanel(new GridLayout(2, 2)); extractPanel.setBackground(UIHelper.BG_COLOR); extractDetails.clear(); JLabel extractsUsedLab = UIHelper.createLabel("Sample(s) used *"); extractsUsedLab.setHorizontalAlignment(JLabel.LEFT); extractsUsedLab.setVerticalAlignment(JLabel.TOP); final JPanel extractNameContainer = new JPanel(); extractNameContainer.setLayout(new BoxLayout(extractNameContainer, BoxLayout.PAGE_AXIS)); extractNameContainer.setBackground(UIHelper.BG_COLOR); extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); JLabel addButton = new JLabel("add sample", addRecordIcon, JLabel.RIGHT); UIHelper.renderComponent(addButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); addButton.setVerticalAlignment(JLabel.TOP); addButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); extractNameContainer.revalidate(); generalQuestionCont.revalidate(); } }); addButton.setToolTipText( "<html><b>add new sample</b><p>add another sample (e.g. Liver, Heart, Urine, Blood)</p></html>"); JLabel removeButton = new JLabel("remove sample", removeIcon, JLabel.RIGHT); removeButton.setVerticalAlignment(JLabel.TOP); UIHelper.renderComponent(removeButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); removeButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { if (extractDetails.size() > 1) { extract = extractDetails.get(extractDetails.size() - 1); extractDetails.remove(extract); extractNameContainer.remove(extract); generalQuestionCont.revalidate(); } } }); removeButton.setToolTipText( "<html><b>remove previously added sample</b><p>remove the sample field last added</p></html>"); extractPanel.add(extractsUsedLab); extractPanel.add(extractNameContainer); JPanel buttonContainer = new JPanel(new GridLayout(1, 2)); buttonContainer.setBackground(UIHelper.BG_COLOR); buttonContainer.add(addButton); buttonContainer.add(removeButton); extractPanel.add(new JLabel()); extractPanel.add(buttonContainer); generalQuestionCont.add(extractPanel); generalQuestionCont.add(Box.createVerticalStrut(5)); generalQuestionCont.add(Box.createHorizontalGlue()); generalQuestionCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 9), assay.getAssayReference(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); return generalQuestionCont; }
From source file:org.isatools.isacreator.wizard.MicroarrayCreationAlgorithm.java
private JPanel instantiatePanel() { final JPanel microArrayQuestionCont = new JPanel(); microArrayQuestionCont.setLayout(new BoxLayout(microArrayQuestionCont, BoxLayout.PAGE_AXIS)); microArrayQuestionCont.setOpaque(false); StringBuilder text = new StringBuilder("<html><b>" + assay.getMeasurementEndpoint() + "</b> using <b>" + assay.getTechnologyType() + "</b>"); if (!StringUtils.isEmpty(assay.getAssayPlatform())) { text.append(" on <b>").append(assay.getAssayPlatform()).append("</b>"); }/*ww w . java 2 s. c o m*/ JLabel info = new JLabel(text.append("</html>").toString(), JLabel.LEFT); UIHelper.renderComponent(info, UIHelper.VER_12_PLAIN, UIHelper.GREY_COLOR, false); info.setPreferredSize(new Dimension(300, 40)); JPanel infoPanel = new JPanel(new GridLayout(1, 1)); infoPanel.setOpaque(false); infoPanel.add(info); microArrayQuestionCont.add(infoPanel); // create reference sample used checkbox JPanel labelPanel = new JPanel(new GridLayout(2, 2)); labelPanel.setBackground(UIHelper.BG_COLOR); final DataEntryForm studyUISection = ApplicationManager.getUserInterfaceForISASection(study); System.out.println("Study user interface is null? " + (studyUISection == null)); System.out .println("Study user interface dep is null? " + (studyUISection.getDataEntryEnvironment() == null)); label1Capture = new LabelCapture("Label (e.g. Cy3)"); label2Capture = new LabelCapture("Label (e.g. Cy5)"); label2Capture.setVisible(false); // create dye swap check box dyeSwapUsed = new JCheckBox("dye-swap performed?", false); UIHelper.renderComponent(dyeSwapUsed, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); dyeSwapUsed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { label2Capture.setVisible(dyeSwapUsed.isSelected()); } }); labelPanel.add(UIHelper.createLabel("Label(s) used")); labelPanel.add(label1Capture); labelPanel.add(dyeSwapUsed); labelPanel.add(label2Capture); microArrayQuestionCont.add(labelPanel); final JPanel extractPanel = new JPanel(new GridLayout(2, 2)); extractPanel.setOpaque(false); extractDetails.clear(); JLabel extractsUsedLab = UIHelper.createLabel("sample(s) used *"); extractsUsedLab.setHorizontalAlignment(JLabel.LEFT); extractsUsedLab.setVerticalAlignment(JLabel.TOP); final JPanel extractNameContainer = new JPanel(); extractNameContainer.setLayout(new BoxLayout(extractNameContainer, BoxLayout.PAGE_AXIS)); extractNameContainer.setOpaque(false); extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), studyUISection.getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); JLabel addExtractButton = new JLabel("add sample", addRecordIcon, JLabel.RIGHT); UIHelper.renderComponent(addExtractButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); addExtractButton.setVerticalAlignment(JLabel.TOP); addExtractButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), studyUISection.getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); extractNameContainer.revalidate(); microArrayQuestionCont.revalidate(); } }); addExtractButton.setToolTipText( "<html><b>add new sample</b><p>add another sample (e.g. Liver, Heart, Urine, Blood)</p></html>"); JLabel removeExtractButton = new JLabel("remove sample", removeIcon, JLabel.RIGHT); removeExtractButton.setVerticalAlignment(JLabel.TOP); UIHelper.renderComponent(removeExtractButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); removeExtractButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { if (extractDetails.size() > 1) { extract = extractDetails.get(extractDetails.size() - 1); extractDetails.remove(extract); extractNameContainer.remove(extract); microArrayQuestionCont.revalidate(); } } }); removeExtractButton.setToolTipText( "<html><b>remove previously added sample</b><p>remove the array design field last added</p></html>"); extractPanel.add(extractsUsedLab); extractPanel.add(extractNameContainer); JPanel extractButtonContainer = new JPanel(new GridLayout(1, 2)); extractButtonContainer.setOpaque(false); extractButtonContainer.add(addExtractButton); extractButtonContainer.add(removeExtractButton); extractPanel.add(new JLabel()); extractPanel.add(extractButtonContainer); microArrayQuestionCont.add(extractPanel); // ask for array designs used... // create array designs panel final JPanel arrayDesignPanel = new JPanel(new GridLayout(2, 2)); arrayDesignPanel.setOpaque(false); arrayDesignsUsed.clear(); JLabel arrayDesignLab = UIHelper.createLabel("array design(s) used *"); arrayDesignLab.setVerticalAlignment(JLabel.TOP); // the array designs container must adjust to an unknown number of fields. therefore, a JPanel with a BoxLayout // will be used since it is flexible! final JPanel arrayDesignsContainer = new JPanel(); arrayDesignsContainer.setLayout(new BoxLayout(arrayDesignsContainer, BoxLayout.PAGE_AXIS)); arrayDesignsContainer.setOpaque(false); newArrayDesign = new AutoFilterCombo(arrayDesigns, true); UIHelper.renderComponent(newArrayDesign, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false); newArrayDesign.setPreferredSize(new Dimension(70, 30)); arrayDesignsContainer.add(newArrayDesign); arrayDesignsUsed.add(newArrayDesign); JLabel addButton = new JLabel("add design", addRecordIcon, JLabel.RIGHT); UIHelper.renderComponent(addButton, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false); addButton.setVerticalAlignment(JLabel.TOP); addButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { newArrayDesign = new AutoFilterCombo(arrayDesigns, true); UIHelper.renderComponent(newArrayDesign, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false); newArrayDesign.setPreferredSize(new Dimension(70, 30)); arrayDesignsUsed.add(newArrayDesign); arrayDesignsContainer.add(newArrayDesign); arrayDesignsContainer.revalidate(); microArrayQuestionCont.revalidate(); } }); addButton.setToolTipText("<html><b>add new array design</b><p>add another array design</p></html>"); JLabel removeButton = new JLabel("remove design", removeIcon, JLabel.RIGHT); removeButton.setVerticalAlignment(JLabel.TOP); UIHelper.renderComponent(removeButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); removeButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { if (arrayDesignsUsed.size() > 1) { newArrayDesign = arrayDesignsUsed.get(arrayDesignsUsed.size() - 1); arrayDesignsUsed.remove(newArrayDesign); arrayDesignsContainer.remove(newArrayDesign); arrayDesignPanel.revalidate(); microArrayQuestionCont.validate(); } } }); removeButton.setToolTipText( "<html><b>remove previously added array design</b><p>remove the array design field last added</p></html>"); arrayDesignPanel.add(arrayDesignLab); arrayDesignPanel.add(arrayDesignsContainer); JPanel buttonContainer = new JPanel(new GridLayout(1, 2)); buttonContainer.setOpaque(false); buttonContainer.add(addButton); buttonContainer.add(removeButton); arrayDesignPanel.add(new JLabel()); arrayDesignPanel.add(buttonContainer); microArrayQuestionCont.add(arrayDesignPanel); microArrayQuestionCont.add(Box.createVerticalStrut(5)); microArrayQuestionCont.add(Box.createHorizontalGlue()); microArrayQuestionCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 9), assay.getAssayReference(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); return microArrayQuestionCont; }