List of usage examples for javax.swing JScrollPane setBorder
@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.") public void setBorder(Border border)
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);// w w w .j av a2s .com 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
/** * Creates the FileSelection panel containing the list of selected files, and the toolbar to modify the list * * @return JPanel containing a selection pane *//*from w w w. j a v a2 s . c o 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/* w w w .j a v a 2 s .co 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.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 a 2 s. com 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.spreadsheet.Spreadsheet.java
public void instantiateSpreadsheet() { ResourceInjector.get("spreadsheet-package.style").inject(this); observers = new ArrayList<CopyPasteObserver>(); spreadsheetPopups = new SpreadsheetPopupMenus(this); spreadsheetFunctions = new SpreadsheetFunctions(this); columnDependencies = new HashMap<TableColumn, List<TableColumn>>(); Collections.synchronizedMap(columnDependencies); hiddenColumns = new HashSet<String>(); setLayout(new BorderLayout()); createSpreadsheetModel();//from w w w. ja v a 2 s . com populateSpreadsheetWithContent(); addOntologyTermsToUserHistory(); // assign copy/paste listener new CopyPasteAdaptor(this); JScrollPane pane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); pane.setBackground(UIHelper.BG_COLOR); pane.setAutoscrolls(true); pane.getViewport().setBackground(UIHelper.BG_COLOR); pane.setBorder(UIHelper.EMPTY_BORDER); IAppWidgetFactory.makeIAppScrollPane(pane); add(pane, BorderLayout.CENTER); createButtonPanel(); addUndoableEditListener(undoManager); }
From source file:org.isatools.isacreator.visualization.InvestigationInfoPanel.java
private JPanel prepareInvestigationInformation() { investigationInformation.removeAll(); JEditorPane currentlyShowingInfo = new JEditorPane(); currentlyShowingInfo.setContentType("text/html"); currentlyShowingInfo.setEditable(false); currentlyShowingInfo.setBackground(UIHelper.BG_COLOR); JScrollPane infoScroller = new JScrollPane(currentlyShowingInfo, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); infoScroller.setBackground(UIHelper.BG_COLOR); infoScroller.getViewport().setBackground(UIHelper.BG_COLOR); infoScroller.setPreferredSize(new Dimension(width - 10, height - 50)); infoScroller.setBorder(null); IAppWidgetFactory.makeIAppScrollPane(infoScroller); Map<String, String> data = getInvestigationDetails(); String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {" + " font-family: Verdana;" + " font-size: 9px;" + " color: #006838;" + "}" + "-->" + "</style>" + "</head>" + "<body class=\"bodyFont\">"; for (Object key : data.keySet()) { labelContent += ("<p><b>" + ((String) key).trim() + ": </b>"); labelContent += (data.get(key) + "</font></p>"); }/* w w w . j av a 2 s . co m*/ labelContent += "</body></html>"; currentlyShowingInfo.setText(labelContent); investigationInformation.add(infoScroller); return investigationInformation; }
From source file:org.isatools.isacreator.visualization.StudyInfoPanel.java
private JPanel prepareStudyInformation() { studyInformation.removeAll();//from w ww . j ava2s . com JEditorPane currentlyShowingInfo = new JEditorPane(); currentlyShowingInfo.setContentType("text/html"); currentlyShowingInfo.setEditable(false); currentlyShowingInfo.setBackground(UIHelper.BG_COLOR); currentlyShowingInfo.setPreferredSize(new Dimension(width - 10, height - 30)); JScrollPane infoScroller = new JScrollPane(currentlyShowingInfo, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); infoScroller.setBackground(UIHelper.BG_COLOR); infoScroller.getViewport().setBackground(UIHelper.BG_COLOR); infoScroller.setPreferredSize(new Dimension(width - 10, height - 50)); infoScroller.setBorder(null); IAppWidgetFactory.makeIAppScrollPane(infoScroller); Map<String, String> data = getStudyDetails(); String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {" + " font-family: Verdana;" + " font-size: 9px;" + " color: #006838;" + "}" + "-->" + "</style>" + "</head>" + "<body class=\"bodyFont\">"; for (Object key : data.keySet()) { labelContent += ("<p><b>" + ((String) key).trim() + ": </b>"); labelContent += (data.get(key) + "</font></p>"); } labelContent += "</body></html>"; currentlyShowingInfo.setText(labelContent); studyInformation.add(infoScroller); return studyInformation; }
From source file:org.isatools.isacreator.wizard.AddAssayPane.java
public JComponent createCenterPanel() { JPanel centerPanel = new JPanel(); centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.PAGE_AXIS)); centerPanel.setOpaque(false);//w ww . j a va2s. co m centerPanel.add(Box.createVerticalStrut(15)); String sourceNameFormat = ConfigurationManager.selectTROForUserSelection(MappingObject.STUDY_SAMPLE) .getColumnFormatByName("source name"); String[] arrayDesigns = retrieveArrayDesigns(); for (Assay a : assaysToDefine) { if (a.getTechnologyType().equalsIgnoreCase("dna microarray")) { MicroarrayCreationAlgorithm maAlg = new MicroarrayCreationAlgorithm(study, a, factorsToAdd, treatmentGroups, new TableReferenceObject(ConfigurationManager .selectTROForUserSelection(a.getMeasurementEndpoint(), a.getTechnologyType()) .getTableFields()), up.getInstitution(), sourceNameFormat, arrayDesigns); algorithmsToRun.add(maAlg); centerPanel.add(maAlg); } else { GeneralCreationAlgorithm gca = new GeneralCreationAlgorithm(study, a, factorsToAdd, treatmentGroups, new TableReferenceObject(ConfigurationManager .selectTROForUserSelection(a.getMeasurementEndpoint(), a.getTechnologyType()) .getTableFields()), up.getInstitution(), sourceNameFormat); algorithmsToRun.add(gca); centerPanel.add(gca); } } JScrollPane assayScroller = new JScrollPane(centerPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); assayScroller.setBackground(UIHelper.BG_COLOR); assayScroller.setBorder(null); assayScroller.getViewport().setOpaque(false); assayScroller.getViewport().putClientProperty("EnableWindowBlit", Boolean.TRUE); IAppWidgetFactory.makeIAppScrollPane(assayScroller); return abstractDataEntryEnvironment.getGeneralLayout( new ImageIcon(getClass().getResource("/images/wizard/defineassay.png")), new ImageIcon(getClass().getResource("/images/wizard/BC_4.png")), "Please provide some information about these assays...", assayScroller, getHeight()); }
From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java
private JPanel createTableListPanel() { JPanel container = new JPanel(); container.setBackground(UIHelper.BG_COLOR); container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS)); JLabel lab = new JLabel(tableListTitle); container.add(UIHelper.wrapComponentInPanel(lab)); container.add(Box.createVerticalStrut(5)); tableModel = new DefaultListModel(); tableList = new JList(tableModel); tableList.setCellRenderer(new TableListRenderer()); tableList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); tableList.setBackground(UIHelper.BG_COLOR); tableList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { try { saveCurrentField(false, false); } catch (DataNotCompleteException dce) { showMessagePane(dce.getMessage(), JOptionPane.ERROR_MESSAGE); }//w ww . ja v a 2 s . c o m MappingObject currentlyEditedTable = getCurrentlySelectedTable(); ApplicationManager.setCurrentMappingObject(currentlyEditedTable); // update the view error button visibility depending on selected tables error state. viewErrorsButton.setVisible(areThereErrorsInThisCurrentObject()); updateTableInfoDisplay(currentlyEditedTable); reformFieldList(currentlyEditedTable); } }); JScrollPane listScroller = new JScrollPane(tableList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); listScroller.getViewport().setBackground(UIHelper.BG_COLOR); listScroller.setBorder(null); listScroller.setPreferredSize(new Dimension(((int) (WIDTH * 0.25)), ((int) (HEIGHT * 0.75)))); IAppWidgetFactory.makeIAppScrollPane(listScroller); container.add(listScroller); container.add(Box.createVerticalStrut(5)); tableCountInfo = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR); container.add(UIHelper.wrapComponentInPanel(tableCountInfo)); container.add(Box.createVerticalStrut(5)); // create button panel to add and remove tables JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.setBackground(UIHelper.BG_COLOR); final JLabel addTableButton = new JLabel(addTable, JLabel.LEFT); UIHelper.renderComponent(addTableButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); addTableButton.setOpaque(false); addTableButton.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent mouseEvent) { addTableButton.setIcon(addTableOver); } @Override public void mouseExited(MouseEvent mouseEvent) { addTableButton.setIcon(addTable); } public void mousePressed(MouseEvent event) { SwingUtilities.invokeLater(new Runnable() { public void run() { addTableButton.setIcon(addTable); applicationContainer.showJDialogAsSheet(addTableUI); } }); } }); addTableButton.setToolTipText("<html><b>Add table</b><p>Add a new table definition.</p></html>"); final JLabel removeTableButton = new JLabel(removeTable, JLabel.LEFT); UIHelper.renderComponent(removeTableButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); removeTableButton.setOpaque(false); removeTableButton.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent mouseEvent) { removeTableButton.setIcon(removeTableOver); } @Override public void mouseExited(MouseEvent mouseEvent) { removeTableButton.setIcon(removeTable); } public void mousePressed(MouseEvent event) { removeTableButton.setIcon(removeTable); if (tableList.getSelectedValue() != null) { String selectedTable = tableList.getSelectedValue().toString(); MappingObject toRemove = null; for (MappingObject mo : tableFields.keySet()) { if (mo.getAssayName().equals(selectedTable)) { toRemove = mo; break; } } if (toRemove != null) { tableFields.remove(toRemove); reformTableList(); } } } }); removeTableButton.setToolTipText("<html><b>Remove table</b><p>Remove table from definitions?</p></html>"); viewErrorsButton = new JLabel(viewErrorsIcon); viewErrorsButton.setVisible(false); viewErrorsButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { viewErrorsButton.setIcon(viewErrorsIcon); // show error pane for current table only. Validator validator = new Validator(); validateFormOrTable(validator, ApplicationManager.getCurrentMappingObject()); ValidationReport report = validator.getReport(); ConfigurationValidationUI validationUI = new ConfigurationValidationUI(tableFields.keySet(), report); validationUI.createGUI(); validationUI.setLocationRelativeTo(getApplicationContainer()); validationUI.setAlwaysOnTop(true); validationUI.setVisible(true); } @Override public void mouseEntered(MouseEvent mouseEvent) { viewErrorsButton.setIcon(viewErrorsIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { viewErrorsButton.setIcon(viewErrorsIcon); } }); buttonPanel.add(addTableButton); buttonPanel.add(removeTableButton); buttonPanel.add(viewErrorsButton); buttonPanel.add(Box.createHorizontalGlue()); container.add(buttonPanel); container.add(Box.createVerticalGlue()); return container; }
From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java
private JPanel createFieldListPanel() { JPanel container = new JPanel(); container.setBackground(UIHelper.BG_COLOR); container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS)); JPanel headerLab = new JPanel(new GridLayout(1, 1)); headerLab.setOpaque(false);//from ww w . j ava2 s.co m JLabel lab = new JLabel(fieldListTitle); headerLab.add(lab); container.add(headerLab); container.add(Box.createVerticalStrut(5)); elementModel = new DefaultListModel(); elementList = new ReOrderableJList(elementModel); elementList.setCellRenderer(new CustomReOrderableListCellRenderer(elementList)); elementList.setDragEnabled(true); elementList.setBackground(UIHelper.BG_COLOR); elementList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { Display selectedNode = (Display) elementList.getSelectedValue(); if (selectedNode != null) { try { saveCurrentField(false, false); } catch (DataNotCompleteException dce) { showMessagePane(dce.getMessage(), JOptionPane.ERROR_MESSAGE); } if (selectedNode instanceof FieldElement) { fieldInterface.setCurrentField((FieldElement) selectedNode); if (currentPage != fieldInterface) { setCurrentPage(fieldInterface); } removeElementButton.setEnabled(!standardISAFields.isFieldRequired(selectedNode.toString())); } else { setCurrentPage(structureElement); } } } }); elementList.addPropertyChangeListener("orderChanged", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { updateFieldOrder(); if (tableList.getSelectedValue() instanceof MappingObject) { validateFormOrTable(ApplicationManager.getCurrentMappingObject()); } } }); JScrollPane listScroller = new JScrollPane(elementList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); listScroller.getViewport().setBackground(UIHelper.BG_COLOR); listScroller.setBorder(new EmptyBorder(2, 2, 2, 10)); listScroller.setPreferredSize(new Dimension(((int) (WIDTH * 0.25)), ((int) (HEIGHT * 0.75)))); IAppWidgetFactory.makeIAppScrollPane(listScroller); container.add(listScroller); container.add(Box.createVerticalStrut(5)); elementCountInfo = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR); container.add(UIHelper.wrapComponentInPanel(elementCountInfo)); container.add(Box.createVerticalStrut(5)); // create button panel to add and remove tables JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.setBackground(UIHelper.BG_COLOR); final JLabel addFieldButton = new JLabel(addElement, JLabel.LEFT); addFieldButton.setOpaque(false); addFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent mouseEvent) { addFieldButton.setIcon(addElementOver); } @Override public void mouseExited(MouseEvent mouseEvent) { addFieldButton.setIcon(addElement); } public void mousePressed(MouseEvent event) { addFieldButton.setIcon(addElement); showAddFieldUI(); } }); addFieldButton.setToolTipText( "<html><b>Add Field to table</b><p>Add a new field to currently selected table</b></p></html>"); removeElementButton = new JLabel(removeElement, JLabel.LEFT); removeElementButton.setOpaque(false); removeElementButton.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent mouseEvent) { removeElementButton.setIcon(removeElementOver); } @Override public void mouseExited(MouseEvent mouseEvent) { removeElementButton.setIcon(removeElement); } public void mousePressed(MouseEvent event) { removeElementButton.setIcon(removeElement); if (removeElementButton.isEnabled()) { removeSelectedElement(); } } }); removeElementButton.setToolTipText( "<html><b>Remove Field from table</b><p>Remove this field from this list and the currently selected table.</b></p></html>"); final JLabel moveDownButton = new JLabel(moveDown); moveDownButton.setOpaque(false); moveDownButton.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent mouseEvent) { moveDownButton.setIcon(moveDownOver); } @Override public void mouseExited(MouseEvent mouseEvent) { moveDownButton.setIcon(moveDown); } public void mousePressed(MouseEvent event) { moveDownButton.setIcon(moveDown); if (elementList.getSelectedIndex() != -1) { int toMoveDown = elementList.getSelectedIndex(); if (toMoveDown != (elementModel.getSize() - 1)) { swapElements(elementList, elementModel, toMoveDown, toMoveDown + 1); } updateFieldOrder(); validateFormOrTable(ApplicationManager.getCurrentMappingObject()); } } }); moveDownButton.setToolTipText( "<html><b>Move Field Down</b><p>Move the selected field down <b>one</b> position in the list.</p></html>"); final JLabel moveUpButton = new JLabel(moveUp); moveUpButton.setOpaque(false); moveUpButton.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent mouseEvent) { moveUpButton.setIcon(moveUpOver); } @Override public void mouseExited(MouseEvent mouseEvent) { moveUpButton.setIcon(moveUp); } public void mousePressed(MouseEvent event) { moveUpButton.setIcon(moveUp); if (elementList.getSelectedIndex() != -1) { int toMoveUp = elementList.getSelectedIndex(); if (toMoveUp != 0) { swapElements(elementList, elementModel, toMoveUp, toMoveUp - 1); } updateFieldOrder(); validateFormOrTable(ApplicationManager.getCurrentMappingObject()); } } }); moveUpButton.setToolTipText( "<html><b>Move Field Up</b><p>Move the selected field up <b>one</b> position in the list.</p></html>"); buttonPanel.add(addFieldButton); buttonPanel.add(removeElementButton); buttonPanel.add(moveDownButton); buttonPanel.add(moveUpButton); container.add(buttonPanel); container.add(Box.createVerticalGlue()); return container; }