List of usage examples for javax.swing JSplitPane HORIZONTAL_SPLIT
int HORIZONTAL_SPLIT
To view the source code for javax.swing JSplitPane HORIZONTAL_SPLIT.
Click Source Link
Component
s are split along the x axis. From source file:com.jvms.i18neditor.editor.Editor.java
private void setupUI() { Color borderColor = Colors.scale(UIManager.getColor("Panel.background"), .8f); setTitle(TITLE);// www. j a v a 2 s. c om setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new EditorWindowListener()); setIconImages(Lists.newArrayList("512", "256", "128", "64", "48", "32", "24", "20", "16").stream() .map(size -> Images.loadFromClasspath("images/icon-" + size + ".png").getImage()) .collect(Collectors.toList())); translationTree = new TranslationTree(); translationTree.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); translationTree.addTreeSelectionListener(new TranslationTreeNodeSelectionListener()); translationTree.addMouseListener(new TranslationTreeMouseListener()); translationField = new TranslationField(); translationField.addKeyListener(new TranslationFieldKeyListener()); translationField.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1, 0, 0, 1, borderColor), ((CompoundBorder) translationField.getBorder()).getInsideBorder())); JScrollPane translationsScrollPane = new JScrollPane(translationTree); translationsScrollPane.getViewport().setOpaque(false); translationsScrollPane.setOpaque(false); translationsScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, borderColor)); translationsPanel = new JPanel(new BorderLayout()); translationsPanel.add(translationsScrollPane); translationsPanel.add(translationField, BorderLayout.SOUTH); resourcesPanel = new JScrollablePanel(true, false); resourcesPanel.setLayout(new BoxLayout(resourcesPanel, BoxLayout.Y_AXIS)); resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); resourcesPanel.setOpaque(false); resourcesPanel.addMouseListener(new ResourcesPaneMouseListener()); resourcesScrollPane = new JScrollPane(resourcesPanel); resourcesScrollPane.getViewport().setOpaque(false); resourcesScrollPane.setOpaque(false); resourcesScrollPane.setBorder(null); resourcesScrollPane.addMouseListener(new ResourcesPaneMouseListener()); contentPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, translationsPanel, resourcesScrollPane); contentPane.setBorder(null); contentPane.setDividerSize(10); // Style the split pane divider if possible SplitPaneUI splitPaneUI = contentPane.getUI(); if (splitPaneUI instanceof BasicSplitPaneUI) { BasicSplitPaneDivider divider = ((BasicSplitPaneUI) splitPaneUI).getDivider(); divider.setBorder(null); resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 20)); } introText = new JLabel("<html><body style=\"text-align:center; padding:30px;\">" + MessageBundle.get("core.intro.text") + "</body></html>"); introText.setOpaque(true); introText.setFont(introText.getFont().deriveFont(28f)); introText.setHorizontalTextPosition(JLabel.CENTER); introText.setVerticalTextPosition(JLabel.BOTTOM); introText.setHorizontalAlignment(JLabel.CENTER); introText.setVerticalAlignment(JLabel.CENTER); introText.setForeground(getBackground().darker()); introText.setIcon(Images.loadFromClasspath("images/icon-intro.png")); Container container = getContentPane(); container.add(introText); editorMenu = new EditorMenuBar(this, translationTree); setJMenuBar(editorMenu); }
From source file:com.ejie.uda.jsonI18nEditor.Editor.java
private void setupUI() { setTitle(TITLE);/* ww w . j a v a2 s. c om*/ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new EditorWindowListener()); setIconImages(Lists.newArrayList(getResourceImage("images/icon-512.png"), getResourceImage("images/icon-256.png"), getResourceImage("images/icon-128.png"), getResourceImage("images/icon-64.png"), getResourceImage("images/icon-48.png"), getResourceImage("images/icon-32.png"), getResourceImage("images/icon-24.png"), getResourceImage("images/icon-20.png"), getResourceImage("images/icon-16.png"))); translationsPanel = new JPanel(new BorderLayout()); translationTree = new TranslationTree(this); translationTree.addTreeSelectionListener(new TranslationTreeNodeSelectionListener()); translationField = new TranslationField(); translationField.addKeyListener(new TranslationFieldKeyListener()); translationsPanel.add(new JScrollPane(translationTree)); translationsPanel.add(translationField, BorderLayout.SOUTH); resourcesPanel = new JScrollablePanel(true, false); resourcesPanel.setLayout(new BoxLayout(resourcesPanel, BoxLayout.Y_AXIS)); resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); resourcesScrollPane = new JScrollPane(resourcesPanel); resourcesScrollPane.getViewport().setOpaque(false); contentPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, translationsPanel, resourcesScrollPane); editorMenu = new EditorMenu(this, translationTree); Container container = getContentPane(); container.add(editorMenu, BorderLayout.NORTH); container.add(contentPane); // Instead of selecting text in text field when applying focus, set caret position to end of input KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("permanentFocusOwner", e -> { if (e.getNewValue() instanceof JTextField) { JTextField field = (JTextField) e.getNewValue(); field.setCaretPosition(field.getText().length()); } }); }
From source file:kr.ac.kaist.swrc.jhannanum.demo.GUIDemo.java
/** * Returns a panel for the input and output text areas. * /*from w w w . j av a2 s. c o m*/ * @return a panel for the input and output text areas */ private JComponent createPaneCenter() { splitPaneBottom = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); JPanel panel = new JPanel(new GridLayout(1, 1)); panel.setBorder(BorderFactory.createTitledBorder("Input Text")); inputTextArea = new JTextArea(); JScrollPane scroll = new JScrollPane(); scroll.setViewportView(inputTextArea); panel.add(scroll); splitPaneBottom.setLeftComponent(panel); panel = new JPanel(new GridLayout(1, 1)); panel.setBorder(BorderFactory.createTitledBorder("Result")); outputTextArea = new JTextArea(); scroll = new JScrollPane(); scroll.setViewportView(outputTextArea); panel.add(scroll); splitPaneBottom.setRightComponent(panel); splitPaneBottom.setOneTouchExpandable(true); return splitPaneBottom; }
From source file:de.codesourcery.eve.skills.ui.components.impl.planning.ShoppingListComponent.java
@Override protected JPanel createPanel() { table.setFillsViewportHeight(true);/*from w w w .j a v a 2 s . c o m*/ table.setRowSorter(tableModel.getRowSorter()); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { final int[] selectedViewRows = table.getSelectedRows(); final int[] selectedModelRows = new int[selectedViewRows.length]; int i = 0; for (int viewRow : selectedViewRows) { selectedModelRows[i++] = viewRow; } List<TableRow> selection = new ArrayList<TableRow>(); for (int modelRow : selectedModelRows) { selection.add(tableModel.getRow(modelRow)); } totalValue.setItems(selection); totalVolume.setItems(selection); } }); FixedBooleanTableCellRenderer.attach(table); final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); final JPanel controlsPanel = new JPanel(); controlsPanel.setLayout(new GridBagLayout()); controlsPanel.add(this.tableViewModePanel, constraints(0, 0).useRemainingWidth().end()); final JPanel totalsPanel = new JPanel(); totalsPanel.setLayout(new GridBagLayout()); totalsPanel.add(totalValue.getPanel(), constraints(0, 0).weightX(0.2).width(1).weightY(0).anchorWest().end()); totalsPanel.add(totalVolume.getPanel(), constraints(1, 0).weightX(0.2).width(1).weightY(0).anchorWest().end()); final JPanel rest = new JPanel(); rest.setLayout(new GridBagLayout()); rest.add(componentPanel, constraints(0, 0).weightX(0.2).width(1).weightY(0.3).anchorWest().end()); rest.add(totalsPanel, constraints(0, 1).weightX(0.2).width(1).weightY(0).resizeHorizontally().anchorWest().end()); rest.add(controlsPanel, constraints(0, 2).weightX(0.2).width(1).weightY(0).resizeHorizontally().anchorWest().end()); rest.add(new JScrollPane(table), constraints(0, 3).weightX(0.2).width(1).weightY(0.7).resizeBoth().anchorWest().end()); // new GridLayoutBuilder().add( // new VerticalGroup( new Cell( componentPanel ), // new FixedCell( controlsPanel ), // new FixedCell( totalsPanel ), // new Cell( new JScrollPane( table ) ) ) ).addTo( rest ); final ImprovedSplitPane splitPane = new ImprovedSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tree), rest); panel.add(splitPane, constraints(0, 0).resizeBoth().end()); tree.setRootVisible(false); tree.setCellRenderer(cellRenderer); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { final TreePath selection = e.getPath(); selectedNodeChanged((ITreeNode) (selection != null ? selection.getLastPathComponent() : null)); } }); final PopupMenuBuilder menuBuilder = new PopupMenuBuilder(); menuBuilder.addItem("New shopping list...", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final ShoppingListEditorComponent comp = new ShoppingListEditorComponent("New list", "", new ArrayList<ItemWithQuantity>()); comp.setModal(true); ComponentWrapper.wrapComponent("Create new shopping list", comp).setVisible(true); if (!comp.wasCancelled()) { manager.addShoppingList(comp.getShoppingList()); } } }); menuBuilder.addItem("Edit list...", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final ITreeNode node = getSelectedTreeNode(); if (node == null) { return; } final ShoppingList list = (ShoppingList) node.getValue(); final ShoppingListEditorComponent comp = new ShoppingListEditorComponent(list); comp.setModal(true); ComponentWrapper.wrapComponent(list.getTitle(), comp).setVisible(true); if (!comp.wasCancelled() && comp.isExistingEntryEdited()) { manager.shoppingListChanged(comp.getShoppingList()); } } @Override public boolean isEnabled() { final ITreeNode node = getSelectedTreeNode(); return node != null && node.getValue() instanceof ShoppingList; } }); menuBuilder.addItem("Delete item", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final ITreeNode node = getSelectedTreeNode(); if (node != null && node.getValue() instanceof ShoppingListEntry) { final ShoppingListEntry entry = (ShoppingListEntry) node.getValue(); final ShoppingList list = entry.getShoppingList(); manager.removeEntry(list, entry); selectedNodeChanged(null); } } @Override public boolean isEnabled() { final ITreeNode node = getSelectedTreeNode(); return node != null && node.getValue() instanceof ShoppingListEntry; } }); menuBuilder.addItem("Delete list", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final ShoppingList list = getSelectedShoppingList(); if (list != null) { manager.removeShoppingList(list); selectedNodeChanged(null); } } @Override public boolean isEnabled() { final ITreeNode node = getSelectedTreeNode(); return node.getValue() instanceof ShoppingList; } }); menuBuilder.addItem("Copy this list to clipboard (text)", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { putSelectedShoppingListOnClipboard(); } @Override public boolean isEnabled() { return getSelectedShoppingList() != null; } }); menuBuilder.attach(tree); return panel; }
From source file:au.org.ala.delta.intkey.Intkey.java
/** * Creates and shows the GUI. Called by the swing application framework *//* w ww . j a va2 s . c o m*/ @Override protected void startup() { final JFrame mainFrame = getMainFrame(); _defaultGlassPane = mainFrame.getGlassPane(); mainFrame.setTitle("Intkey"); mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); mainFrame.setIconImages(IconHelper.getRedIconList()); _helpController = new HelpController(HELPSET_PATH); _taxonformatter = new ItemFormatter(false, CommentStrippingMode.STRIP_ALL, AngleBracketHandlingMode.REMOVE, true, false, true); _context = new IntkeyContext(new IntkeyUIInterceptor(this), new DirectivePopulatorInterceptor(this)); _advancedModeOnlyDynamicButtons = new ArrayList<JButton>(); _normalModeOnlyDynamicButtons = new ArrayList<JButton>(); _activeOnlyWhenCharactersUsedButtons = new ArrayList<JButton>(); _dynamicButtonsFullHelp = new HashMap<JButton, String>(); ActionMap actionMap = getContext().getActionMap(); _rootPanel = new JPanel(); _rootPanel.setAlignmentX(Component.LEFT_ALIGNMENT); _rootPanel.setBackground(SystemColor.control); _rootPanel.setLayout(new BorderLayout(0, 0)); _globalOptionBar = new JPanel(); _globalOptionBar.setBorder(new EmptyBorder(0, 5, 0, 5)); _rootPanel.add(_globalOptionBar, BorderLayout.NORTH); _globalOptionBar.setLayout(new BorderLayout(0, 0)); _pnlDynamicButtons = new JPanel(); FlowLayout flowLayout_1 = (FlowLayout) _pnlDynamicButtons.getLayout(); flowLayout_1.setVgap(0); flowLayout_1.setHgap(0); _globalOptionBar.add(_pnlDynamicButtons, BorderLayout.WEST); _btnContextHelp = new JButton(); _btnContextHelp.setMinimumSize(new Dimension(30, 30)); _btnContextHelp.setMaximumSize(new Dimension(30, 30)); _btnContextHelp.setAction(actionMap.get("btnContextHelp")); _btnContextHelp.setPreferredSize(new Dimension(30, 30)); _btnContextHelp.setMargin(new Insets(2, 5, 2, 5)); _btnContextHelp.addActionListener(actionMap.get("btnContextHelp")); _globalOptionBar.add(_btnContextHelp, BorderLayout.EAST); _rootSplitPane = new JSplitPane(); _rootSplitPane.setDividerSize(3); _rootSplitPane.setResizeWeight(0.5); _rootSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT); _rootSplitPane.setContinuousLayout(true); _rootPanel.add(_rootSplitPane); _innerSplitPaneLeft = new JSplitPane(); _innerSplitPaneLeft.setMinimumSize(new Dimension(25, 25)); _innerSplitPaneLeft.setAlignmentX(Component.CENTER_ALIGNMENT); _innerSplitPaneLeft.setDividerSize(3); _innerSplitPaneLeft.setResizeWeight(0.5); _innerSplitPaneLeft.setContinuousLayout(true); _innerSplitPaneLeft.setOrientation(JSplitPane.VERTICAL_SPLIT); _rootSplitPane.setLeftComponent(_innerSplitPaneLeft); _pnlAvailableCharacters = new JPanel(); _innerSplitPaneLeft.setLeftComponent(_pnlAvailableCharacters); _pnlAvailableCharacters.setLayout(new BorderLayout(0, 0)); _sclPaneAvailableCharacters = new JScrollPane(); _pnlAvailableCharacters.add(_sclPaneAvailableCharacters, BorderLayout.CENTER); _listAvailableCharacters = new JList(); // _listAvailableCharacters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); _listAvailableCharacters.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); _listAvailableCharacters.setCellRenderer(_availableCharactersListCellRenderer); _listAvailableCharacters.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { int selectedIndex = _listAvailableCharacters.getSelectedIndex(); if (selectedIndex >= 0) { try { Character ch = (Character) _availableCharacterListModel.getElementAt(selectedIndex); executeDirective(new UseDirective(), Integer.toString(ch.getCharacterId())); } catch (Exception ex) { ex.printStackTrace(); } } } } }); _sclPaneAvailableCharacters.setViewportView(_listAvailableCharacters); _pnlAvailableCharactersHeader = new JPanel(); _pnlAvailableCharacters.add(_pnlAvailableCharactersHeader, BorderLayout.NORTH); _pnlAvailableCharactersHeader.setLayout(new BorderLayout(0, 0)); _lblNumAvailableCharacters = new JLabel(); _lblNumAvailableCharacters.setBorder(new EmptyBorder(0, 5, 0, 0)); _lblNumAvailableCharacters.setFont(new Font("Tahoma", Font.PLAIN, 15)); _lblNumAvailableCharacters.setText(MessageFormat.format(availableCharactersCaption, 0)); _pnlAvailableCharactersHeader.add(_lblNumAvailableCharacters, BorderLayout.WEST); _pnlAvailableCharactersButtons = new JPanel(); FlowLayout flowLayout = (FlowLayout) _pnlAvailableCharactersButtons.getLayout(); flowLayout.setVgap(2); flowLayout.setHgap(2); _pnlAvailableCharactersHeader.add(_pnlAvailableCharactersButtons, BorderLayout.EAST); // All toolbar buttons should be disabled until a dataset is loaded. _btnRestart = new JButton(); _btnRestart.setAction(actionMap.get("btnRestart")); _btnRestart.setPreferredSize(new Dimension(30, 30)); _btnRestart.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnRestart); _btnBestOrder = new JButton(); _btnBestOrder.setAction(actionMap.get("btnBestOrder")); _btnBestOrder.setPreferredSize(new Dimension(30, 30)); _btnBestOrder.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnBestOrder); _btnSeparate = new JButton(); _btnSeparate.setAction(actionMap.get("btnSeparate")); _btnSeparate.setVisible(_advancedMode); _btnSeparate.setPreferredSize(new Dimension(30, 30)); _btnSeparate.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnSeparate); _btnNaturalOrder = new JButton(); _btnNaturalOrder.setAction(actionMap.get("btnNaturalOrder")); _btnNaturalOrder.setPreferredSize(new Dimension(30, 30)); _btnNaturalOrder.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnNaturalOrder); _btnDiffSpecimenTaxa = new JButton(); _btnDiffSpecimenTaxa.setAction(actionMap.get("btnDiffSpecimenTaxa")); _btnDiffSpecimenTaxa.setEnabled(false); _btnDiffSpecimenTaxa.setPreferredSize(new Dimension(30, 30)); _pnlAvailableCharactersButtons.add(_btnDiffSpecimenTaxa); _btnSetTolerance = new JButton(); _btnSetTolerance.setAction(actionMap.get("btnSetTolerance")); _btnSetTolerance.setPreferredSize(new Dimension(30, 30)); _btnSetTolerance.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnSetTolerance); _btnSetMatch = new JButton(); _btnSetMatch.setAction(actionMap.get("btnSetMatch")); _btnSetMatch.setVisible(_advancedMode); _btnSetMatch.setPreferredSize(new Dimension(30, 30)); _btnSetMatch.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnSetMatch); _btnSubsetCharacters = new JButton(); _btnSubsetCharacters.setAction(actionMap.get("btnSubsetCharacters")); _btnSubsetCharacters.setPreferredSize(new Dimension(30, 30)); _btnSubsetCharacters.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnSubsetCharacters); _btnFindCharacter = new JButton(); _btnFindCharacter.setAction(actionMap.get("btnFindCharacter")); _btnFindCharacter.setPreferredSize(new Dimension(30, 30)); _btnFindCharacter.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnFindCharacter); _pnlAvailableCharactersButtons.setEnabled(false); _pnlUsedCharacters = new JPanel(); _innerSplitPaneLeft.setRightComponent(_pnlUsedCharacters); _pnlUsedCharacters.setLayout(new BorderLayout(0, 0)); _sclPnUsedCharacters = new JScrollPane(); _pnlUsedCharacters.add(_sclPnUsedCharacters, BorderLayout.CENTER); _listUsedCharacters = new JList(); _listUsedCharacters.setCellRenderer(_usedCharactersListCellRenderer); _listUsedCharacters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); _listUsedCharacters.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { int selectedIndex = _listUsedCharacters.getSelectedIndex(); if (selectedIndex >= 0) { try { Attribute attr = (Attribute) _usedCharacterListModel.getElementAt(selectedIndex); if (_context.charactersFixed() && _context.getFixedCharactersList() .contains(attr.getCharacter().getCharacterId())) { return; } executeDirective(new ChangeDirective(), Integer.toString(attr.getCharacter().getCharacterId())); } catch (Exception ex) { ex.printStackTrace(); } } } } }); _sclPnUsedCharacters.setViewportView(_listUsedCharacters); _pnlUsedCharactersHeader = new JPanel(); _pnlUsedCharacters.add(_pnlUsedCharactersHeader, BorderLayout.NORTH); _pnlUsedCharactersHeader.setLayout(new BorderLayout(0, 0)); _lblNumUsedCharacters = new JLabel(); _lblNumUsedCharacters.setBorder(new EmptyBorder(7, 5, 7, 0)); _lblNumUsedCharacters.setFont(new Font("Tahoma", Font.PLAIN, 15)); _lblNumUsedCharacters.setText(MessageFormat.format(usedCharactersCaption, 0)); _pnlUsedCharactersHeader.add(_lblNumUsedCharacters, BorderLayout.WEST); _innerSplitPaneRight = new JSplitPane(); _innerSplitPaneRight.setMinimumSize(new Dimension(25, 25)); _innerSplitPaneRight.setDividerSize(3); _innerSplitPaneRight.setResizeWeight(0.5); _innerSplitPaneRight.setContinuousLayout(true); _innerSplitPaneRight.setOrientation(JSplitPane.VERTICAL_SPLIT); _rootSplitPane.setRightComponent(_innerSplitPaneRight); _pnlRemainingTaxa = new JPanel(); _innerSplitPaneRight.setLeftComponent(_pnlRemainingTaxa); _pnlRemainingTaxa.setLayout(new BorderLayout(0, 0)); _sclPnRemainingTaxa = new JScrollPane(); _pnlRemainingTaxa.add(_sclPnRemainingTaxa, BorderLayout.CENTER); _listRemainingTaxa = new JList(); _listRemainingTaxa.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { displayInfoForSelectedTaxa(); } } }); _sclPnRemainingTaxa.setViewportView(_listRemainingTaxa); _pnlRemainingTaxaHeader = new JPanel(); _pnlRemainingTaxa.add(_pnlRemainingTaxaHeader, BorderLayout.NORTH); _pnlRemainingTaxaHeader.setLayout(new BorderLayout(0, 0)); _lblNumRemainingTaxa = new JLabel(); _lblNumRemainingTaxa.setBorder(new EmptyBorder(0, 5, 0, 0)); _lblNumRemainingTaxa.setFont(new Font("Tahoma", Font.PLAIN, 15)); _lblNumRemainingTaxa.setText(MessageFormat.format(remainingTaxaCaption, 0)); _pnlRemainingTaxaHeader.add(_lblNumRemainingTaxa, BorderLayout.WEST); _pnlRemainingTaxaButtons = new JPanel(); FlowLayout fl_pnlRemainingTaxaButtons = (FlowLayout) _pnlRemainingTaxaButtons.getLayout(); fl_pnlRemainingTaxaButtons.setVgap(2); fl_pnlRemainingTaxaButtons.setHgap(2); _pnlRemainingTaxaHeader.add(_pnlRemainingTaxaButtons, BorderLayout.EAST); // All toolbar buttons should be disabled until a dataset is loaded. _btnTaxonInfo = new JButton(); _btnTaxonInfo.setAction(actionMap.get("btnTaxonInfo")); _btnTaxonInfo.setPreferredSize(new Dimension(30, 30)); _btnTaxonInfo.setEnabled(false); _pnlRemainingTaxaButtons.add(_btnTaxonInfo); _btnDiffTaxa = new JButton(); _btnDiffTaxa.setAction(actionMap.get("btnDiffTaxa")); _btnDiffTaxa.setPreferredSize(new Dimension(30, 30)); _btnDiffTaxa.setEnabled(false); _pnlRemainingTaxaButtons.add(_btnDiffTaxa); _btnSubsetTaxa = new JButton(); _btnSubsetTaxa.setAction(actionMap.get("btnSubsetTaxa")); _btnSubsetTaxa.setPreferredSize(new Dimension(30, 30)); _btnSubsetTaxa.setEnabled(false); _pnlRemainingTaxaButtons.add(_btnSubsetTaxa); _btnFindTaxon = new JButton(); _btnFindTaxon.setAction(actionMap.get("btnFindTaxon")); _btnFindTaxon.setPreferredSize(new Dimension(30, 30)); _btnFindTaxon.setEnabled(false); _pnlRemainingTaxaButtons.add(_btnFindTaxon); _pnlEliminatedTaxa = new JPanel(); _innerSplitPaneRight.setRightComponent(_pnlEliminatedTaxa); _pnlEliminatedTaxa.setLayout(new BorderLayout(0, 0)); _sclPnEliminatedTaxa = new JScrollPane(); _pnlEliminatedTaxa.add(_sclPnEliminatedTaxa, BorderLayout.CENTER); _listEliminatedTaxa = new JList(); _listEliminatedTaxa.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { displayInfoForSelectedTaxa(); } } }); _sclPnEliminatedTaxa.setViewportView(_listEliminatedTaxa); _pnlEliminatedTaxaHeader = new JPanel(); _pnlEliminatedTaxa.add(_pnlEliminatedTaxaHeader, BorderLayout.NORTH); _pnlEliminatedTaxaHeader.setLayout(new BorderLayout(0, 0)); _lblEliminatedTaxa = new JLabel(); _lblEliminatedTaxa.setBorder(new EmptyBorder(7, 5, 7, 0)); _lblEliminatedTaxa.setFont(new Font("Tahoma", Font.PLAIN, 15)); _lblEliminatedTaxa.setText(MessageFormat.format(eliminatedTaxaCaption, 0)); _pnlEliminatedTaxaHeader.add(_lblEliminatedTaxa, BorderLayout.WEST); JMenuBar menuBar = buildMenus(_advancedMode); getMainView().setMenuBar(menuBar); _txtFldCmdBar = new JTextField(); _txtFldCmdBar.setCaretColor(Color.WHITE); _txtFldCmdBar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { String cmdStr = _txtFldCmdBar.getText(); cmdStr = cmdStr.trim(); if (_cmdMenus.containsKey(cmdStr)) { JMenu cmdMenu = _cmdMenus.get(cmdStr); cmdMenu.doClick(); } else { _context.parseAndExecuteDirective(cmdStr); } _txtFldCmdBar.setText(null); } }); _txtFldCmdBar.setFont(new Font("Courier New", Font.BOLD, 13)); _txtFldCmdBar.setForeground(SystemColor.text); _txtFldCmdBar.setBackground(Color.BLACK); _txtFldCmdBar.setOpaque(true); _txtFldCmdBar.setVisible(_advancedMode); _rootPanel.add(_txtFldCmdBar, BorderLayout.SOUTH); _txtFldCmdBar.setColumns(10); _logDialog = new RtfReportDisplayDialog(getMainFrame(), new SimpleRtfEditorKit(null), null, logDialogTitle); // Set context-sensitive help keys for toolbar buttons _helpController.setHelpKeyForComponent(_btnRestart, HELP_ID_CHARACTERS_TOOLBAR_RESTART); _helpController.setHelpKeyForComponent(_btnBestOrder, HELP_ID_CHARACTERS_TOOLBAR_BEST); _helpController.setHelpKeyForComponent(_btnSeparate, HELP_ID_CHARACTERS_TOOLBAR_SEPARATE); _helpController.setHelpKeyForComponent(_btnNaturalOrder, HELP_ID_CHARACTERS_TOOLBAR_NATURAL); _helpController.setHelpKeyForComponent(_btnDiffSpecimenTaxa, HELP_ID_CHARACTERS_TOOLBAR_DIFF_SPECIMEN_REMAINING); _helpController.setHelpKeyForComponent(_btnSetTolerance, HELP_ID_CHARACTERS_TOOLBAR_TOLERANCE); _helpController.setHelpKeyForComponent(_btnSetMatch, HELP_ID_CHARACTERS_TOOLBAR_SET_MATCH); _helpController.setHelpKeyForComponent(_btnSubsetCharacters, HELP_ID_CHARACTERS_TOOLBAR_SUBSET_CHARACTERS); _helpController.setHelpKeyForComponent(_btnFindCharacter, HELP_ID_CHARACTERS_TOOLBAR_FIND_CHARACTERS); _helpController.setHelpKeyForComponent(_btnTaxonInfo, HELP_ID_TAXA_TOOLBAR_INFO); _helpController.setHelpKeyForComponent(_btnDiffTaxa, HELP_ID_TAXA_TOOLBAR_DIFF_TAXA); _helpController.setHelpKeyForComponent(_btnSubsetTaxa, HELP_ID_TAXA_TOOLBAR_SUBSET_TAXA); _helpController.setHelpKeyForComponent(_btnFindTaxon, HELP_ID_TAXA_TOOLBAR_FIND_TAXA); // This mouse listener on the default glasspane is to assist with // context senstive help. It intercepts the mouse events, // determines what component was being clicked on, then takes the // appropriate action to provide help for the component _defaultGlassPane.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { // Determine what point has been clicked on Point glassPanePoint = e.getPoint(); Point containerPoint = SwingUtilities.convertPoint(getMainFrame().getGlassPane(), glassPanePoint, getMainFrame().getContentPane()); Component component = SwingUtilities.getDeepestComponentAt(getMainFrame().getContentPane(), containerPoint.x, containerPoint.y); // Get the java help ID for this component. If none has been // defined, this will be null String helpID = _helpController.getHelpKeyForComponent(component); // change the cursor back to the normal one and take down the // classpane mainFrame.setCursor(Cursor.getDefaultCursor()); mainFrame.getGlassPane().setVisible(false); // If a help ID was found, display the related help page in the // help viewer if (_helpController.getHelpKeyForComponent(component) != null) { _helpController.helpAction().actionPerformed(new ActionEvent(component, 0, null)); _helpController.displayHelpTopic(mainFrame, helpID); } else { // If a dynamically-defined toolbar button was clicked, show // the help for this button in the ToolbarHelpDialog. if (component instanceof JButton) { JButton button = (JButton) component; if (_dynamicButtonsFullHelp.containsKey(button)) { String fullHelpText = _dynamicButtonsFullHelp.get(button); if (fullHelpText == null) { fullHelpText = noHelpAvailableCaption; } RTFBuilder builder = new RTFBuilder(); builder.startDocument(); builder.appendText(fullHelpText); builder.endDocument(); ToolbarHelpDialog dlg = new ToolbarHelpDialog(mainFrame, builder.toString(), button.getIcon()); show(dlg); } } } } }); show(_rootPanel); }
From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java
public TrialDataEditor(CurationData cd, WindowOpener<JFrame> windowOpener, MessageLogger messageLogger, KdxploreDatabase kdxdb, IntFunction<Trait> traitProvider, SampleType[] sampleTypes) throws IOException { super(new BorderLayout()); this.traitProvider = traitProvider; this.windowOpener = windowOpener; this.curationData = cd; this.curationData.setChangeManager(changeManager); this.curationData.setKDSmartDatabase(kdxdb.getKDXploreKSmartDatabase()); inactiveTagFilterIcon = KDClientUtils.getIcon(ImageId.TAG_FILTER_24); activeTagFilterIcon = KDClientUtils.getIcon(ImageId.TAG_FILTER_ACTIVE_24); inactivePlotOrSpecimenFilterIcon = KDClientUtils.getIcon(ImageId.FILTER_PLOT_SPEC_INACTIVE); activePlotFilterIcon = KDClientUtils.getIcon(ImageId.FILTER_PLOT_ACTIVE); activeSpecimenFilterIcon = KDClientUtils.getIcon(ImageId.FILTER_SPEC_ACTIVE); updatePlotSpecimenIcon();//from w ww . j av a 2s. c om TraitColorProvider traitColourProvider = new TraitColorProvider(false); this.curationData.setTraitColorProvider(traitColourProvider); curationData.addCurationDataChangeListener(new CurationDataChangeListener() { @Override public void plotActivationChanged(Object source, boolean activated, List<Plot> plots) { updateRowFilter(); if (toolController != null) { toolController.plotActivationsChanged(activated, plots); } } @Override public void editedSamplesChanged(Object source, List<CurationCellId> curationCellIds) { if (toolController != null) { toolController.editedSamplesChanged(); } } }); this.selectedValueStore = new SelectedValueStore(curationData.getTrial().getTrialName()); this.messageLogger = messageLogger; smallFont = KDClientUtils.makeSmallFont(this); // undockViewAction.putValue(Action.SHORT_DESCRIPTION, "Click to undock // this view"); KDClientUtils.initAction(ImageId.HELP_24, curationHelpAction, Msg.TOOLTIP_HELP_DATA_CURATION(), false); KDClientUtils.initAction(ImageId.SAVE_24, saveChangesAction, Msg.TOOLTIP_SAVE_CHANGES(), true); KDClientUtils.initAction(ImageId.EXPORT_24, exportCuratedData, Msg.TOOLTIP_EXPORT(), true); KDClientUtils.initAction(ImageId.UNDO_24, undoAction, Msg.TOOLTIP_UNDO(), true); KDClientUtils.initAction(ImageId.REDO_24, redoAction, Msg.TOOLTIP_REDO(), true); KDClientUtils.initAction(ImageId.FIELD_VIEW_24, showFieldViewAction, Msg.TOOLTIP_FIELD_VIEW(), false); KDClientUtils.initAction(ImageId.GET_TRIALINFO_24, importCuratedData, Msg.TOOLTIP_IMPORT_DATA(), true); Function<TraitInstance, List<KdxSample>> sampleProvider = new Function<TraitInstance, List<KdxSample>>() { @Override public List<KdxSample> apply(TraitInstance ti) { return curationData.getSampleMeasurements(ti); } }; tivrByTi = VisToolUtil.buildTraitInstanceValueRetrieverMap(curationData.getTrial(), curationData.getTraitInstances(), sampleProvider); // = = = = = = = = boolean readOnly = false; // FIXME work out if the Trial can be edited or not curationTableModel = new CurationTableModel(curationData, readOnly); // See FIXME comment in CurationTableModel.isReadOnly() curationTableSelectionModel = new CurationTableSelectionModelImpl(selectedValueStore, curationTableModel); curationTableSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); curationTable = new CurationTable("CurationTable-" + (++UNIQUE_CURATION_TABLE_ID), //$NON-NLS-1$ curationTableModel, curationTableSelectionModel); curationTable.setCellSelectionEnabled(true); curationTable.setAutoCreateRowSorter(true); // = = = = = = = = this.sampleSourcesTablePanel = new SampleSourcesTablePanel(curationData, curationTableModel, handler); @SuppressWarnings("unchecked") TableRowSorter<CurationTableModel> rowSorter = (TableRowSorter<CurationTableModel>) curationTable .getRowSorter(); rowSorter.setSortsOnUpdates(true); rowSorter.addRowSorterListener(rowSorterListener); curationCellRenderer = new CurationTableCellRenderer(curationTableModel, colorProviderFactory, curationTableSelectionModel); curationTable.setDefaultRenderer(Object.class, curationCellRenderer); curationTable.setDefaultRenderer(Integer.class, curationCellRenderer); curationTable.setDefaultRenderer(String.class, curationCellRenderer); curationTable.setDefaultRenderer(CurationCellValue.class, curationCellRenderer); curationTable.setDefaultRenderer(Double.class, curationCellRenderer); curationTable.setDefaultRenderer(TraitValue.class, curationCellRenderer); // If either the rows selected change or the columns selected change // then we // need to inform the visualisation tools. curationTable.getSelectionModel().addListSelectionListener(curationTableCellSelectionListener); curationTable.getColumnModel().addColumnModelListener(curationTableCellSelectionListener); fieldLayoutView = new InterceptFieldLayoutView(); this.curationCellEditor = new CurationCellEditorImpl(curationTableModel, fieldLayoutView, curationData, refreshFieldLayoutView, kdxdb, traitProvider, sampleTypes); SuppressionInfoProvider suppressionInfoProvider = new SuppressionInfoProvider(curationData, curationTableModel, curationTable); suppressionHandler = new SuppressionHandler(curationContext, curationData, curationCellEditor, suppressionInfoProvider); loadVisualisationTools(); curationMenuProvider = new CurationMenuProvider(curationContext, curationData, messages, visualisationTools, suppressionHandler); curationMenuProvider.setSuppressionInfoProvider(suppressionInfoProvider); fieldLayoutView.addTraitInstanceSelectionListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (ItemEvent.SELECTED == e.getStateChange()) { TraitInstance traitInstance = fieldLayoutView.getActiveTraitInstance(true); if (traitInstance == null) { curationCellEditor.setCurationCellValue(null); } else { // startEdit(HowStarted.FIELD_VIEW_CHANGED_ACTIVE_TRAIT_INSTANCE); } fieldLayoutView.updateSamplesSelectedInTable(); } } }); // = = = = = = = curationData.addUnsavedChangesListener(new UnsavedChangesListener() { @Override public void unsavedChangesExist(Object source, int nChanges) { int unsavedCount = curationData.getUnsavedChangesCount(); saveChangesAction.setEnabled(unsavedCount > 0); if (unsavedCount > 0) { statusInfoLine.setMessage("Unsaved changes: " + unsavedCount); } else { statusInfoLine.setMessage("No Unsaved changes"); } } }); // curationData.addEditedSampleChangeListener(new ChangeListener() { // @Override // public void stateChanged(ChangeEvent e) { // handleEditedSampleChanges(); // } // }); saveChangesAction.setEnabled(false); changeManager.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateUndoRedoActions(); } }); undoAction.setEnabled(false); redoAction.setEnabled(false); // = = = = = = = = // TODO provide one of these for each relevant device type DeviceType deviceTypeForSamples = null; StatsData statsData = curationData.getStatsData(deviceTypeForSamples); TIStatsTableModel statsTableModel = new TIStatsTableModel2(curationData, statsData, deviceTypeForSamples); traitColourProvider.generateColorMap(statsData.getTraitInstancesWithData()); Set<Integer> instanceNumbers = statsData.getInstanceNumbers(); String nonHtmlLabel; if (instanceNumbers.size() > 1) { tAndIpanelLabel = "<HTML><i>Plot Info</i> & Trait Instances"; nonHtmlLabel = "Plot Info & Trait Instances"; } else { tAndIpanelLabel = "<HTML><i>Plot Info</i> & Traits"; nonHtmlLabel = "Plot Info & Traits"; } traitsAndInstancesPanel = new TraitsAndInstancesPanel2(curationContext, smallFont, statsTableModel, instanceNumbers.size() > 1, statsData.getInvalidRuleCount(), nonHtmlLabel, curationMenuProvider, outlierConsumer); traitsAndInstancesPanel.addTraitInstanceStatsItemListener(new ItemListener() { boolean busy; @Override public void itemStateChanged(ItemEvent e) { // NOTE: we want to process both SELECTED and DESELECTED // variants if (busy) { Shared.Log.d(TAG, "***** LOOPED in traitsAndInstancesPanel.ItemListener"); //$NON-NLS-1$ } else { Shared.Log.d(TAG, "traitsAndInstancesPanel.ItemListener BEGIN"); //$NON-NLS-1$ busy = true; try { updateViewedTraitInstances(e); // !!!!! } finally { busy = false; Shared.Log.d(TAG, "traitsAndInstancesPanel.ItemListener END\n"); //$NON-NLS-1$ } } } }); // = = = = = = = = plotCellChoicesPanel = new PlotCellChoicesPanel(curationContext, curationData, deviceTypeForSamples, tAndIpanelLabel, curationMenuProvider, colorProviderFactory); // plotCellChoicesPanel.setData( // curationData.getPlotAttributes(), // traitsAndInstancesPanel.getTraitInstancesWithData()); plotCellChoicesPanel.addPlotCellChoicesListener(new PlotCellChoicesListener() { @Override public void traitInstanceChoicesChanged(Object source, boolean choiceAdded, TraitInstance[] choice, Map<Integer, Set<TraitInstance>> traitInstancesByTraitId) { traitsAndInstancesPanel.changeTraitInstanceChoice(choiceAdded, choice); } @Override public void plotAttributeChoicesChanged(Object source, List<ValueRetriever<?>> vrList) { curationTableModel.setSelectedPlotAttributes(vrList); } }); // = = = = = = = = statsAndSamplesSplit = createStatsAndSamplesTable(traitsAndInstancesPanel.getComponent()); mainTabbedPane.addTab(TAB_SAMPLES, samplesTableIcon, statsAndSamplesSplit, Msg.TOOLTIP_SAMPLES_TABLE()); // = = = = = = = = checkForInvalidTraits(); leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createCurationCellEditorComponent(), plotCellChoicesPanel); leftSplit.setResizeWeight(0.5); // traitToDoTaskPaneContainer); // rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, // traitsAndInstancesPanel, fieldViewAndPlots); // rightSplit.setResizeWeight(0.5); // rightSplit.setOneTouchExpandable(true); leftAndRightSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSplit, mainTabbedPane); leftAndRightSplit.setOneTouchExpandable(true); mainVerticalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, messages, leftAndRightSplit); mainVerticalSplit.setOneTouchExpandable(true); mainVerticalSplit.setResizeWeight(0.0); add(statusInfoLine, BorderLayout.NORTH); add(mainVerticalSplit, BorderLayout.CENTER); fieldLayoutView.addCellSelectionListener(fieldViewCellSelectionListener); curationTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (SwingUtilities.isRightMouseButton(me) && 1 == me.getClickCount()) { me.consume(); displayPopupMenu(me); } } }); }
From source file:com.diversityarrays.kdxplore.trialmgr.trait.TraitExplorerPanel.java
public TraitExplorerPanel(MessagePrinter mp, OfflineData od, DALClientProvider clientProvider, // KdxUploadHandler uploadHandler, BackgroundRunner backgroundRunner, ImageIcon addBarcodeIcon, Transformer<Trial, Boolean> checkIfEditorActive) { super(new BorderLayout()); this.backgroundRunner = backgroundRunner; this.clientProvider = clientProvider; // this.uploadHandler = uploadHandler; this.messagePrinter = mp; this.offlineData = od; this.checkIfEditorActive = checkIfEditorActive; offlineData.addOfflineDataChangeListener(offlineDataListener); editingLocked.setIcon(KDClientUtils.getIcon(ImageId.LOCKED)); editingLocked.addActionListener(new ActionListener() { @Override/*from w w w . j a v a 2 s .c o m*/ public void actionPerformed(ActionEvent e) { changeEditable(editingLocked.isSelected(), DONT_OVERRIDE); } }); changeManager.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateUndoRedoActions(); } }); KDClientUtils.initAction(ImageId.TRASH_24, deleteTraitsAction, "Remove Trait"); deleteTraitsAction.setEnabled(false); KDClientUtils.initAction(ImageId.REFRESH_24, refreshAction, "Refresh Data"); KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addNewTraitAction, "Add Trait"); KDClientUtils.initAction(ImageId.UPLOAD_24, uploadTraitsAction, "Upload Traits"); KDClientUtils.initAction(ImageId.ADD_TRIALS_24, importTraitsAction, "Import Traits"); KDClientUtils.initAction(ImageId.EXPORT_24, exportTraitsAction, "Export Traits"); try { Class.forName("com.diversityarrays.kdxplore.upload.TraitUploadTask"); } catch (ClassNotFoundException e1) { uploadTraitsAction.setEnabled(false); if (RunMode.getRunMode().isDeveloper()) { new Toast((JComponent) null, "<HTML>Developer Warning<BR>" + "Trait Upload currently unavailable<BR>", 4000) .showAsError(); } } traitPropertiesTable .setTransferHandler(TableTransferHandler.initialiseForCopySelectAll(traitPropertiesTable, true)); traitPropertiesTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (traitPropertiesTableModel.getRowCount() > 0) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GuiUtil.initialiseTableColumnWidths(traitPropertiesTable); } }); traitPropertiesTableModel.removeTableModelListener(this); } } }); traitTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { showCorrectCard(); } }); TrialManagerPreferences preferences = TrialManagerPreferences.getInstance(); preferences.addChangeListener(TrialManagerPreferences.BAD_FOR_CALC, badForCalcColorChangeListener); badForCalc.setForeground(preferences.getBadForCalcColor()); badForCalc.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) { KdxPreference<Color> pref = TrialManagerPreferences.BAD_FOR_CALC; String title = pref.getName(); KdxplorePreferenceEditor.startEditorDialog(TraitExplorerPanel.this, title, pref); } } }); traitsTable.setAutoCreateRowSorter(true); int index = traitTableModel.getTraitNameColumnIndex(); if (index >= 0) { traitsTable.getColumnModel().getColumn(index).setCellRenderer(traitNameCellRenderer); } traitsTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && 2 == e.getClickCount()) { e.consume(); int vrow = traitsTable.rowAtPoint(e.getPoint()); if (vrow >= 0) { int mrow = traitsTable.convertRowIndexToModel(vrow); if (mrow >= 0) { Trait trait = traitTableModel.getTraitAtRow(mrow); Integer selectViewRow = null; if (!traitTrialsTableModel.isSelectedTrait(trait)) { selectViewRow = vrow; } if (traitsEditable) { startEditingTraitInternal(trait, selectViewRow, null); } else { warnEditingLocked(); } } } } } }); traitsTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); traitsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { List<Trait> selectedTraits = getSelectedTraits(); traitTrialsTableModel.setSelectedTraits(selectedTraits); if (selectedTraits.size() == 1) { Trait trait = null; int vrow = traitsTable.getSelectedRow(); if (vrow >= 0) { int mrow = traitsTable.convertRowIndexToModel(vrow); if (mrow >= 0) { trait = traitTableModel.getEntityAt(mrow); } } showTraitDetails(trait); } deleteTraitsAction.setEnabled(selectedTraits.size() > 0); showCorrectCard(); } } }); TraitTableModel.initValidationExpressionRenderer(traitsTable); if (RunMode.getRunMode().isDeveloper()) { TraitTableModel.initTableForRawExpression(traitsTable); } cardPanel.add(noTraitsComponent, CARD_NO_TRAITS); cardPanel.add(selectTraitComponent, CARD_SELECT_TO_EDIT); cardPanel.add(new JScrollPane(traitPropertiesTable), CARD_TRAIT_EDITOR); JButton undoButton = initAction(undoAction, ImageId.UNDO_24, "Undo", KeyStroke.getKeyStroke('Z', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); JButton redoButton = initAction(redoAction, ImageId.REDO_24, "Redo", KeyStroke.getKeyStroke('Y', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); Box undoRedoButtons = Box.createHorizontalBox(); undoRedoButtons.add(undoButton); undoRedoButtons.add(redoButton); JPanel detailsPanel = new JPanel(new BorderLayout()); detailsPanel.add(GuiUtil.createLabelSeparator("Details", undoRedoButtons), BorderLayout.NORTH); detailsPanel.add(cardPanel, BorderLayout.CENTER); detailsPanel.add(legendPanel, BorderLayout.SOUTH); PromptScrollPane scrollPane = new PromptScrollPane(traitsTable, "Drag/Drop Traits CSV file or use 'Import Traits'"); TableTransferHandler tth = TableTransferHandler.initialiseForCopySelectAll(traitsTable, true); traitsTable.setTransferHandler(new ChainingTransferHandler(flth, tth)); scrollPane.setTransferHandler(flth); if (addBarcodeIcon == null) { barcodesMenuAction.putValue(Action.NAME, "Barcodes..."); } else { barcodesMenuAction.putValue(Action.SMALL_ICON, addBarcodeIcon); } italicsForProtectedCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { traitNameCellRenderer.setUseItalicsForProtected(italicsForProtectedCheckbox.isSelected()); traitsTable.repaint(); } }); Box leftTopControls = Box.createHorizontalBox(); leftTopControls.add(importTraitsButton); leftTopControls.add(barcodesMenuButton); leftTopControls.add(new JButton(addNewTraitAction)); leftTopControls.add(new JButton(uploadTraitsAction)); leftTopControls.add(new JButton(exportTraitsAction)); leftTopControls.add(Box.createHorizontalGlue()); leftTopControls.add(editingLocked); leftTopControls.add(fixTraitLevelsButton); leftTopControls.add(refreshButton); leftTopControls.add(Box.createHorizontalStrut(8)); leftTopControls.add(new JButton(deleteTraitsAction)); // leftTopControls.add(Box.createHorizontalStrut(4)); Box explanations = Box.createHorizontalBox(); explanations.add(italicsForProtectedCheckbox); explanations.add(badForCalc); explanations.add(Box.createHorizontalGlue()); fixTraitLevelsButton.setToolTipText("Fix Traits with " + TraitLevel.UNDECIDABLE.visible + " 'Level'"); fixTraitLevelsButton.setVisible(false); JPanel leftTop = new JPanel(new BorderLayout()); leftTop.add(leftTopControls, BorderLayout.NORTH); leftTop.add(scrollPane, BorderLayout.CENTER); leftTop.add(explanations, BorderLayout.SOUTH); JPanel leftBot = new JPanel(new BorderLayout()); leftBot.add(GuiUtil.createLabelSeparator("Used by Trials"), BorderLayout.NORTH); leftBot.add(new PromptScrollPane(traitTrialsTable, "Any Trials using selected Traits appear here")); JSplitPane leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, leftTop, leftBot); leftSplit.setResizeWeight(0.5); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSplit, detailsPanel); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); add(splitPane, BorderLayout.CENTER); }
From source file:jp.massbank.spectrumsearch.SearchPage.java
/** * ?// w w w . j a v a 2 s. c o m */ private void createWindow() { // ?? ToolTipManager ttm = ToolTipManager.sharedInstance(); ttm.setInitialDelay(50); ttm.setDismissDelay(8000); // Search? JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); Border border = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(), new EmptyBorder(1, 1, 1, 1)); mainPanel.setBorder(border); // ********************************************************************* // User File Query // ********************************************************************* DefaultTableModel fileDm = new DefaultTableModel(); fileSorter = new TableSorter(fileDm, TABLE_QUERY_FILE); queryFileTable = new JTable(fileSorter) { @Override public boolean isCellEditable(int row, int column) { // super.isCellEditable(row, column); // ?????? return false; } }; queryFileTable.addMouseListener(new TblMouseListener()); fileSorter.setTableHeader(queryFileTable.getTableHeader()); queryFileTable.setRowSelectionAllowed(true); queryFileTable.setColumnSelectionAllowed(false); queryFileTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); String[] col = { COL_LABEL_NO, COL_LABEL_NAME, COL_LABEL_ID }; ((DefaultTableModel) fileSorter.getTableModel()).setColumnIdentifiers(col); (queryFileTable.getColumn(queryFileTable.getColumnName(0))).setPreferredWidth(44); (queryFileTable.getColumn(queryFileTable.getColumnName(1))).setPreferredWidth(LEFT_PANEL_WIDTH - 44); (queryFileTable.getColumn(queryFileTable.getColumnName(2))).setPreferredWidth(70); ListSelectionModel lm = queryFileTable.getSelectionModel(); lm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lm.addListSelectionListener(new LmFileListener()); queryFilePane = new JScrollPane(queryFileTable); queryFilePane.addMouseListener(new PaneMouseListener()); queryFilePane.setPreferredSize(new Dimension(300, 300)); // ********************************************************************* // Result // ********************************************************************* DefaultTableModel resultDm = new DefaultTableModel(); resultSorter = new TableSorter(resultDm, TABLE_RESULT); resultTable = new JTable(resultSorter) { @Override public String getToolTipText(MouseEvent me) { // super.getToolTipText(me); // ????? Point pt = me.getPoint(); int row = rowAtPoint(pt); if (row < 0) { return null; } else { int nameCol = getColumnModel().getColumnIndex(COL_LABEL_NAME); return " " + getValueAt(row, nameCol) + " "; } } @Override public boolean isCellEditable(int row, int column) { // super.isCellEditable(row, column); // ?????? return false; } }; resultTable.addMouseListener(new TblMouseListener()); resultSorter.setTableHeader(resultTable.getTableHeader()); JPanel dbPanel = new JPanel(); dbPanel.setLayout(new BorderLayout()); resultPane = new JScrollPane(resultTable); resultPane.addMouseListener(new PaneMouseListener()); resultTable.setRowSelectionAllowed(true); resultTable.setColumnSelectionAllowed(false); resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); String[] col2 = { COL_LABEL_NAME, COL_LABEL_SCORE, COL_LABEL_HIT, COL_LABEL_ID, COL_LABEL_ION, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO }; resultDm.setColumnIdentifiers(col2); (resultTable.getColumn(resultTable.getColumnName(0))).setPreferredWidth(LEFT_PANEL_WIDTH - 180); (resultTable.getColumn(resultTable.getColumnName(1))).setPreferredWidth(70); (resultTable.getColumn(resultTable.getColumnName(2))).setPreferredWidth(20); (resultTable.getColumn(resultTable.getColumnName(3))).setPreferredWidth(70); (resultTable.getColumn(resultTable.getColumnName(4))).setPreferredWidth(20); (resultTable.getColumn(resultTable.getColumnName(5))).setPreferredWidth(70); (resultTable.getColumn(resultTable.getColumnName(6))).setPreferredWidth(50); ListSelectionModel lm2 = resultTable.getSelectionModel(); lm2.addListSelectionListener(new LmResultListener()); resultPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, 200)); dbPanel.add(resultPane, BorderLayout.CENTER); // ********************************************************************* // DB Query // ********************************************************************* DefaultTableModel dbDm = new DefaultTableModel(); querySorter = new TableSorter(dbDm, TABLE_QUERY_DB); queryDbTable = new JTable(querySorter) { @Override public boolean isCellEditable(int row, int column) { // super.isCellEditable(row, column); // ?????? return false; } }; queryDbTable.addMouseListener(new TblMouseListener()); querySorter.setTableHeader(queryDbTable.getTableHeader()); queryDbPane = new JScrollPane(queryDbTable); queryDbPane.addMouseListener(new PaneMouseListener()); int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); queryDbPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, h)); queryDbTable.setRowSelectionAllowed(true); queryDbTable.setColumnSelectionAllowed(false); queryDbTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); String[] col3 = { COL_LABEL_ID, COL_LABEL_NAME, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO }; DefaultTableModel model = (DefaultTableModel) querySorter.getTableModel(); model.setColumnIdentifiers(col3); // queryDbTable.getColumn(queryDbTable.getColumnName(0)).setPreferredWidth(70); queryDbTable.getColumn(queryDbTable.getColumnName(1)).setPreferredWidth(LEFT_PANEL_WIDTH - 70); queryDbTable.getColumn(queryDbTable.getColumnName(2)).setPreferredWidth(70); queryDbTable.getColumn(queryDbTable.getColumnName(3)).setPreferredWidth(50); ListSelectionModel lm3 = queryDbTable.getSelectionModel(); lm3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lm3.addListSelectionListener(new LmQueryDbListener()); // ? JPanel btnPanel = new JPanel(); btnName.addActionListener(new BtnSearchNameListener()); btnAll.addActionListener(new BtnAllListener()); btnPanel.add(btnName); btnPanel.add(btnAll); parentPanel2 = new JPanel(); parentPanel2.setLayout(new BoxLayout(parentPanel2, BoxLayout.PAGE_AXIS)); parentPanel2.add(btnPanel); parentPanel2.add(queryDbPane); // ? JPanel dispModePanel = new JPanel(); isDispSelected = dispSelected.isSelected(); isDispRelated = dispRelated.isSelected(); if (isDispSelected) { resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } else if (isDispRelated) { resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } Object[] retRadio = new Object[] { dispSelected, dispRelated }; for (int i = 0; i < retRadio.length; i++) { ((JRadioButton) retRadio[i]).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (isDispSelected != dispSelected.isSelected() || isDispRelated != dispRelated.isSelected()) { isDispSelected = dispSelected.isSelected(); isDispRelated = dispRelated.isSelected(); // ?? resultTable.clearSelection(); resultPlot.clear(); compPlot.setPeaks(null, 1); resultPlot.setPeaks(null, 0); setAllPlotAreaRange(); pkgView.initResultRecInfo(); if (isDispSelected) { resultTable.getSelectionModel() .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } else if (isDispRelated) { resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } } } }); } ButtonGroup disGroup = new ButtonGroup(); disGroup.add(dispSelected); disGroup.add(dispRelated); dispModePanel.add(lbl2); dispModePanel.add(dispSelected); dispModePanel.add(dispRelated); JPanel paramPanel = new JPanel(); paramPanel.add(etcPropertyButton); etcPropertyButton.setMargin(new Insets(0, 10, 0, 10)); etcPropertyButton.addActionListener(new ActionListener() { private ParameterSetWindow ps = null; public void actionPerformed(ActionEvent e) { // ?????????? if (!isSubWindow) { ps = new ParameterSetWindow(getParentFrame()); } else { ps.requestFocus(); } } }); JPanel optionPanel = new JPanel(); optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS)); optionPanel.add(dispModePanel); optionPanel.add(paramPanel); // PackageView????? pkgView = new PackageViewPanel(); pkgView.initAllRecInfo(); queryTabPane.addTab("DB", parentPanel2); queryTabPane.setToolTipTextAt(TAB_ORDER_DB, "Query from DB."); queryTabPane.addTab("File", queryFilePane); queryTabPane.setToolTipTextAt(TAB_ORDER_FILE, "Query from user file."); queryTabPane.setSelectedIndex(TAB_ORDER_DB); queryTabPane.setFocusable(false); queryTabPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // ? queryPlot.clear(); compPlot.clear(); resultPlot.clear(); queryPlot.setPeaks(null, 0); compPlot.setPeaks(null, 1); resultPlot.setPeaks(null, 0); // PackageView? pkgView.initAllRecInfo(); // DB Hit? if (resultTabPane.getTabCount() > 0) { resultTabPane.setSelectedIndex(0); } DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel(); dataModel.setRowCount(0); hitLabel.setText(" "); // DB?User File?????? queryTabPane.update(queryTabPane.getGraphics()); if (queryTabPane.getSelectedIndex() == TAB_ORDER_DB) { parentPanel2.update(parentPanel2.getGraphics()); updateSelectQueryTable(queryDbTable); } else if (queryTabPane.getSelectedIndex() == TAB_ORDER_FILE) { queryFilePane.update(queryFilePane.getGraphics()); updateSelectQueryTable(queryFileTable); } } }); // JPanel queryPanel = new JPanel(); queryPanel.setLayout(new BorderLayout()); queryPanel.add(queryTabPane, BorderLayout.CENTER); queryPanel.add(optionPanel, BorderLayout.SOUTH); queryPanel.setMinimumSize(new Dimension(0, 170)); JPanel jtp2Panel = new JPanel(); jtp2Panel.setLayout(new BorderLayout()); jtp2Panel.add(dbPanel, BorderLayout.CENTER); jtp2Panel.add(hitLabel, BorderLayout.SOUTH); jtp2Panel.setMinimumSize(new Dimension(0, 70)); Color colorGreen = new Color(0, 128, 0); hitLabel.setForeground(colorGreen); resultTabPane.addTab("Result", jtp2Panel); resultTabPane.setToolTipTextAt(TAB_RESULT_DB, "Result of DB hit."); resultTabPane.setFocusable(false); queryPlot.setMinimumSize(new Dimension(0, 100)); compPlot.setMinimumSize(new Dimension(0, 120)); resultPlot.setMinimumSize(new Dimension(0, 100)); int height = initAppletHight / 3; JSplitPane jsp_cmp2db = new JSplitPane(JSplitPane.VERTICAL_SPLIT, compPlot, resultPlot); JSplitPane jsp_qry2cmp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPlot, jsp_cmp2db); jsp_cmp2db.setDividerLocation(height); jsp_qry2cmp.setDividerLocation(height - 25); jsp_qry2cmp.setMinimumSize(new Dimension(190, 0)); viewTabPane.addTab("Compare View", jsp_qry2cmp); viewTabPane.addTab("Package View", pkgView); viewTabPane.setToolTipTextAt(TAB_VIEW_COMPARE, "Comparison of query and result spectrum."); viewTabPane.setToolTipTextAt(TAB_VIEW_PACKAGE, "Package comparison of query and result spectrum."); viewTabPane.setSelectedIndex(TAB_VIEW_COMPARE); viewTabPane.setFocusable(false); JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPanel, resultTabPane); jsp.setDividerLocation(310); jsp.setMinimumSize(new Dimension(180, 0)); jsp.setOneTouchExpandable(true); JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jsp, viewTabPane); int divideSize = (int) (initAppletWidth * 0.4); divideSize = (divideSize >= 180) ? divideSize : 180; jsp2.setDividerLocation(divideSize); jsp2.setOneTouchExpandable(true); mainPanel.add(jsp2, BorderLayout.CENTER); add(mainPanel); queryPlot.setSearchPage(this); compPlot.setSearchPage(this); resultPlot.setSearchPage(this); setJMenuBar(MenuBarGenerator.generateMenuBar(this)); }
From source file:ffx.ui.MainPanel.java
/** * <p>/*from www . j av a 2s . co m*/ * initialize</p> */ public void initialize() { if (init) { return; } init = true; String dir = System.getProperty("user.dir", FileSystemView.getFileSystemView().getDefaultDirectory().getAbsolutePath()); setCWD(new File(dir)); locale = new FFXLocale("en", "US"); JDialog splashScreen = null; ClassLoader loader = getClass().getClassLoader(); if (!GraphicsEnvironment.isHeadless()) { // Splash Screen JFrame.setDefaultLookAndFeelDecorated(true); splashScreen = new JDialog(frame, false); ImageIcon logo = new ImageIcon(loader.getResource("ffx/ui/icons/splash.png")); JLabel ffxLabel = new JLabel(logo); ffxLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); Container contentpane = splashScreen.getContentPane(); contentpane.setLayout(new BorderLayout()); contentpane.add(ffxLabel, BorderLayout.CENTER); splashScreen.setUndecorated(true); splashScreen.pack(); Dimension screenDimension = getToolkit().getScreenSize(); Dimension splashDimension = splashScreen.getSize(); splashScreen.setLocation((screenDimension.width - splashDimension.width) / 2, (screenDimension.height - splashDimension.height) / 2); splashScreen.setResizable(false); splashScreen.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); splashScreen.setVisible(true); // Make all pop-up Menus Heavyweight so they play nicely with Java3D JPopupMenu.setDefaultLightWeightPopupEnabled(false); } // Create the Root Node dataRoot = new MSRoot(); Border bb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); statusLabel = new JLabel(" "); JLabel stepLabel = new JLabel(" "); stepLabel.setHorizontalAlignment(JLabel.RIGHT); JLabel energyLabel = new JLabel(" "); energyLabel.setHorizontalAlignment(JLabel.RIGHT); JPanel statusPanel = new JPanel(new GridLayout(1, 3)); statusPanel.setBorder(bb); statusPanel.add(statusLabel); statusPanel.add(stepLabel); statusPanel.add(energyLabel); if (!GraphicsEnvironment.isHeadless()) { GraphicsConfigTemplate3D template3D = new GraphicsConfigTemplate3D(); template3D.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED); GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getBestConfiguration(template3D); graphicsCanvas = new GraphicsCanvas(gc, this); graphicsPanel = new GraphicsPanel(graphicsCanvas, statusPanel); } // Initialize various Panels hierarchy = new Hierarchy(this); hierarchy.setStatus(statusLabel, stepLabel, energyLabel); keywordPanel = new KeywordPanel(this); modelingPanel = new ModelingPanel(this); JPanel treePane = new JPanel(new BorderLayout()); JScrollPane scrollPane = new JScrollPane(hierarchy, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); treePane.add(scrollPane, BorderLayout.CENTER); tabbedPane = new JTabbedPane(); ImageIcon graphicsIcon = new ImageIcon(loader.getResource("ffx/ui/icons/monitor.png")); ImageIcon keywordIcon = new ImageIcon(loader.getResource("ffx/ui/icons/key.png")); ImageIcon modelingIcon = new ImageIcon(loader.getResource("ffx/ui/icons/cog.png")); tabbedPane.addTab(locale.getValue("Graphics"), graphicsIcon, graphicsPanel); tabbedPane.addTab(locale.getValue("KeywordEditor"), keywordIcon, keywordPanel); tabbedPane.addTab(locale.getValue("ModelingCommands"), modelingIcon, modelingPanel); tabbedPane.addChangeListener(this); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, tabbedPane); /* splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, graphicsPanel); */ splitPane.setResizeWeight(0.25); splitPane.setOneTouchExpandable(true); setLayout(new BorderLayout()); add(splitPane, BorderLayout.CENTER); if (!GraphicsEnvironment.isHeadless()) { mainMenu = new MainMenu(this); add(mainMenu.getToolBar(), BorderLayout.NORTH); getModelingShell(); loadPrefs(); SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this)); splashScreen.dispose(); } }
From source file:statistic.ca.gui.JCAStatisticPanel.java
private void addComponents() { diagrams = new DiagramContainer(this); contentD = new JScrollPane(diagrams); west = new JPanel(new BorderLayout()); west.add(contentD, BorderLayout.CENTER); properties = addPropertiesComponents(); contentP = new JScrollPane(properties); east = new JPanel(new BorderLayout()); east.add(contentP, BorderLayout.CENTER); east.setMinimumSize(new Dimension((int) properties.getMinimumSize().getWidth() + 22, (int) properties.getMinimumSize().getHeight())); east.setPreferredSize(east.getMinimumSize()); east.setMaximumSize(east.getMinimumSize()); pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); pane.setLeftComponent(west);/*from w w w. j a va 2 s .c o m*/ pane.setRightComponent(east); pane.setResizeWeight(1); //pane.resetToPreferredSizes(); add(pane, BorderLayout.CENTER); }