List of usage examples for javax.swing Box createHorizontalStrut
public static Component createHorizontalStrut(int width)
From source file:org.freeplane.view.swing.features.time.mindmapmode.nodelist.NodeList.java
public void startup() { if (dialog != null) { dialog.toFront();//from w w w. j a v a 2 s . c o m return; } NodeList.COLUMN_MODIFIED = TextUtils.getText(PLUGINS_TIME_LIST_XML_MODIFIED); NodeList.COLUMN_CREATED = TextUtils.getText(PLUGINS_TIME_LIST_XML_CREATED); NodeList.COLUMN_ICONS = TextUtils.getText(PLUGINS_TIME_LIST_XML_ICONS); NodeList.COLUMN_TEXT = TextUtils.getText(PLUGINS_TIME_LIST_XML_TEXT); NodeList.COLUMN_DETAILS = TextUtils.getText(PLUGINS_TIME_LIST_XML_DETAILS); NodeList.COLUMN_DATE = TextUtils.getText(PLUGINS_TIME_LIST_XML_DATE); NodeList.COLUMN_NOTES = TextUtils.getText(PLUGINS_TIME_LIST_XML_NOTES); dialog = new JDialog(Controller.getCurrentController().getViewController().getFrame(), modal /* modal */); String windowTitle; if (showAllNodes) { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE_ALL_NODES; } else { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE; } dialog.setTitle(TextUtils.getText(windowTitle)); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); final WindowAdapter windowListener = new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { mFilterTextSearchField.getEditor().selectAll(); } @Override public void windowClosing(final WindowEvent event) { disposeDialog(); } }; dialog.addWindowListener(windowListener); dialog.addWindowFocusListener(windowListener); UITools.addEscapeActionToDialog(dialog, new AbstractAction() { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }); final Container contentPane = dialog.getContentPane(); final GridBagLayout gbl = new GridBagLayout(); contentPane.setLayout(gbl); final GridBagConstraints layoutConstraints = new GridBagConstraints(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.weightx = 0.0; layoutConstraints.weighty = 0.0; layoutConstraints.anchor = GridBagConstraints.WEST; layoutConstraints.fill = GridBagConstraints.HORIZONTAL; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_FIND)), layoutConstraints); layoutConstraints.gridwidth = 1; layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("filter_match_case")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(matchCase, layoutConstraints); layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInFind, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextSearchField), layoutConstraints); layoutConstraints.gridy++; layoutConstraints.weightx = 0.0; layoutConstraints.gridwidth = 1; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_REPLACE)), layoutConstraints); layoutConstraints.gridx = 5; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInReplace, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextReplaceField), layoutConstraints); dateRenderer = new DateRenderer(); textRenderer = new TextRenderer(); iconsRenderer = new IconsRenderer(); tableView = new FlatNodeTable(); tableView.addKeyListener(new FlatNodeTableKeyListener()); tableView.addMouseListener(new FlatNodeTableMouseAdapter()); tableView.getTableHeader().setReorderingAllowed(false); tableModel = updateModel(); mFlatNodeTableFilterModel = new FlatNodeTableFilterModel(tableModel, new int[] { NodeList.NODE_TEXT_COLUMN, NodeList.NODE_DETAILS_COLUMN, NodeList.NODE_NOTES_COLUMN }); sorter = new TableSorter(mFlatNodeTableFilterModel); tableView.setModel(sorter); sorter.setTableHeader(tableView.getTableHeader()); sorter.setColumnComparator(Date.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setColumnComparator(NodeModel.class, TableSorter.LEXICAL_COMPARATOR); sorter.setColumnComparator(IconsHolder.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setSortingStatus(NodeList.DATE_COLUMN, TableSorter.ASCENDING); final JScrollPane pane = new JScrollPane(tableView); UITools.setScrollbarIncrement(pane); layoutConstraints.gridy++; GridBagConstraints tableConstraints = (GridBagConstraints) layoutConstraints.clone(); tableConstraints.weightx = 1; tableConstraints.weighty = 10; tableConstraints.fill = GridBagConstraints.BOTH; contentPane.add(pane, tableConstraints); mTreeLabel = new JLabel(); layoutConstraints.gridy++; GridBagConstraints treeConstraints = (GridBagConstraints) layoutConstraints.clone(); treeConstraints.fill = GridBagConstraints.BOTH; @SuppressWarnings("serial") JScrollPane scrollPane = new JScrollPane(mTreeLabel) { @Override public boolean isValidateRoot() { return false; } }; contentPane.add(scrollPane, treeConstraints); final AbstractAction exportAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Export")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { exportSelectedRowsAndClose(); } }; final JButton exportButton = new JButton(exportAction); final AbstractAction replaceAllAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_All")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new HolderAccessor(false)); } }; final JButton replaceAllButton = new JButton(replaceAllAction); final AbstractAction replaceSelectedAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_Selected")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new HolderAccessor(true)); } }; final JButton replaceSelectedButton = new JButton(replaceSelectedAction); final AbstractAction gotoAction = new AbstractAction(TextUtils.getText("plugins/TimeManagement.xml_Goto")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { selectSelectedRows(); } }; final JButton gotoButton = new JButton(gotoAction); final AbstractAction disposeAction = new AbstractAction( TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_CLOSE)) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }; final JButton cancelButton = new JButton(disposeAction); /* Initial State */ gotoAction.setEnabled(false); exportAction.setEnabled(false); replaceSelectedAction.setEnabled(false); final Box bar = Box.createHorizontalBox(); bar.add(Box.createHorizontalGlue()); bar.add(cancelButton); bar.add(exportButton); bar.add(replaceAllButton); bar.add(replaceSelectedButton); bar.add(gotoButton); bar.add(Box.createHorizontalGlue()); layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(bar), layoutConstraints); final JMenuBar menuBar = new JMenuBar(); final JMenu menu = new JMenu(TextUtils.getText("plugins/TimeManagement.xml_menu_actions")); final AbstractAction[] actionList = new AbstractAction[] { gotoAction, replaceSelectedAction, replaceAllAction, exportAction, disposeAction }; for (int i = 0; i < actionList.length; i++) { final AbstractAction action = actionList[i]; final JMenuItem item = menu.add(action); item.setIcon(new BlindIcon(UIBuilder.ICON_SIZE)); } menuBar.add(menu); dialog.setJMenuBar(menuBar); final ListSelectionModel rowSM = tableView.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); final boolean enable = !(lsm.isSelectionEmpty()); replaceSelectedAction.setEnabled(enable); gotoAction.setEnabled(enable); exportAction.setEnabled(enable); } }); rowSM.addListSelectionListener(new ListSelectionListener() { String getNodeText(final NodeModel node) { return TextController.getController().getShortText(node) + ((node.isRoot()) ? "" : (" <- " + getNodeText(node.getParentNode()))); } public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { mTreeLabel.setText(""); return; } final int selectedRow = lsm.getLeadSelectionIndex(); final NodeModel mindMapNode = getMindMapNode(selectedRow); mTreeLabel.setText(getNodeText(mindMapNode)); } }); final String marshalled = ResourceController.getResourceController() .getProperty(NodeList.WINDOW_PREFERENCE_STORAGE_PROPERTY); final WindowConfigurationStorage result = TimeWindowConfigurationStorage.decorateDialog(marshalled, dialog); final WindowConfigurationStorage storage = result; if (storage != null) { tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); int column = 0; for (final TimeWindowColumnSetting setting : ((TimeWindowConfigurationStorage) storage) .getListTimeWindowColumnSettingList()) { tableView.getColumnModel().getColumn(column).setPreferredWidth(setting.getColumnWidth()); sorter.setSortingStatus(column, setting.getColumnSorting()); column++; } } mFlatNodeTableFilterModel.setFilter((String) mFilterTextSearchField.getSelectedItem(), matchCase.isSelected(), useRegexInFind.isSelected()); dialog.setVisible(true); }
From source file:org.freeplane.view.swing.features.time.mindmapmode.NodeList.java
public void startup() { if (dialog != null) { dialog.toFront();/* w w w . j a va 2s . c om*/ return; } NodeList.COLUMN_MODIFIED = TextUtils.getText(PLUGINS_TIME_LIST_XML_MODIFIED); NodeList.COLUMN_CREATED = TextUtils.getText(PLUGINS_TIME_LIST_XML_CREATED); NodeList.COLUMN_ICONS = TextUtils.getText(PLUGINS_TIME_LIST_XML_ICONS); NodeList.COLUMN_TEXT = TextUtils.getText(PLUGINS_TIME_LIST_XML_TEXT); NodeList.COLUMN_DATE = TextUtils.getText(PLUGINS_TIME_LIST_XML_DATE); NodeList.COLUMN_NOTES = TextUtils.getText(PLUGINS_TIME_LIST_XML_NOTES); dialog = new JDialog(Controller.getCurrentController().getViewController().getFrame(), modal /* modal */); String windowTitle; if (showAllNodes) { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE_ALL_NODES; } else { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE; } dialog.setTitle(TextUtils.getText(windowTitle)); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); final WindowAdapter windowListener = new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { mFilterTextSearchField.getEditor().selectAll(); } @Override public void windowClosing(final WindowEvent event) { disposeDialog(); } }; dialog.addWindowListener(windowListener); dialog.addWindowFocusListener(windowListener); UITools.addEscapeActionToDialog(dialog, new AbstractAction() { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }); final Container contentPane = dialog.getContentPane(); final GridBagLayout gbl = new GridBagLayout(); contentPane.setLayout(gbl); final GridBagConstraints layoutConstraints = new GridBagConstraints(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.weightx = 0.0; layoutConstraints.weighty = 0.0; layoutConstraints.anchor = GridBagConstraints.WEST; layoutConstraints.fill = GridBagConstraints.HORIZONTAL; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_FIND)), layoutConstraints); layoutConstraints.gridwidth = 1; layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("filter_match_case")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(matchCase, layoutConstraints); layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInFind, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextSearchField), layoutConstraints); layoutConstraints.gridy++; layoutConstraints.weightx = 0.0; layoutConstraints.gridwidth = 1; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_REPLACE)), layoutConstraints); layoutConstraints.gridx = 5; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInReplace, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextReplaceField), layoutConstraints); dateRenderer = new DateRenderer(); nodeRenderer = new NodeRenderer(); notesRenderer = new NotesRenderer(); iconsRenderer = new IconsRenderer(); timeTable = new FlatNodeTable(); timeTable.addKeyListener(new FlatNodeTableKeyListener()); timeTable.addMouseListener(new FlatNodeTableMouseAdapter()); timeTable.getTableHeader().setReorderingAllowed(false); timeTableModel = updateModel(); mFlatNodeTableFilterModel = new FlatNodeTableFilterModel(timeTableModel, NodeList.NODE_TEXT_COLUMN); sorter = new TableSorter(mFlatNodeTableFilterModel); timeTable.setModel(sorter); sorter.setTableHeader(timeTable.getTableHeader()); sorter.setColumnComparator(Date.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setColumnComparator(NodeModel.class, TableSorter.LEXICAL_COMPARATOR); sorter.setColumnComparator(IconsHolder.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setSortingStatus(NodeList.DATE_COLUMN, TableSorter.ASCENDING); final JScrollPane pane = new JScrollPane(timeTable); UITools.setScrollbarIncrement(pane); layoutConstraints.gridy++; GridBagConstraints tableConstraints = (GridBagConstraints) layoutConstraints.clone(); tableConstraints.weightx = 1; tableConstraints.weighty = 10; tableConstraints.fill = GridBagConstraints.BOTH; contentPane.add(pane, tableConstraints); mTreeLabel = new JLabel(); layoutConstraints.gridy++; GridBagConstraints treeConstraints = (GridBagConstraints) layoutConstraints.clone(); treeConstraints.fill = GridBagConstraints.BOTH; @SuppressWarnings("serial") JScrollPane scrollPane = new JScrollPane(mTreeLabel) { @Override public boolean isValidateRoot() { return false; } }; contentPane.add(scrollPane, treeConstraints); final AbstractAction exportAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Export")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { exportSelectedRowsAndClose(); } }; final JButton exportButton = new JButton(exportAction); final AbstractAction replaceAllAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_All")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new ReplaceAllInfo()); } }; final JButton replaceAllButton = new JButton(replaceAllAction); final AbstractAction replaceSelectedAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_Selected")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new ReplaceSelectedInfo()); } }; final JButton replaceSelectedButton = new JButton(replaceSelectedAction); final AbstractAction gotoAction = new AbstractAction(TextUtils.getText("plugins/TimeManagement.xml_Goto")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { selectSelectedRows(); } }; final JButton gotoButton = new JButton(gotoAction); final AbstractAction disposeAction = new AbstractAction( TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_CLOSE)) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }; final JButton cancelButton = new JButton(disposeAction); /* Initial State */ gotoAction.setEnabled(false); exportAction.setEnabled(false); replaceSelectedAction.setEnabled(false); final Box bar = Box.createHorizontalBox(); bar.add(Box.createHorizontalGlue()); bar.add(cancelButton); bar.add(exportButton); bar.add(replaceAllButton); bar.add(replaceSelectedButton); bar.add(gotoButton); bar.add(Box.createHorizontalGlue()); layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(bar), layoutConstraints); final JMenuBar menuBar = new JMenuBar(); final JMenu menu = new JMenu(TextUtils.getText("plugins/TimeManagement.xml_menu_actions")); final AbstractAction[] actionList = new AbstractAction[] { gotoAction, replaceSelectedAction, replaceAllAction, exportAction, disposeAction }; for (int i = 0; i < actionList.length; i++) { final AbstractAction action = actionList[i]; final JMenuItem item = menu.add(action); item.setIcon(new BlindIcon(UIBuilder.ICON_SIZE)); } menuBar.add(menu); dialog.setJMenuBar(menuBar); final ListSelectionModel rowSM = timeTable.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); final boolean enable = !(lsm.isSelectionEmpty()); replaceSelectedAction.setEnabled(enable); gotoAction.setEnabled(enable); exportAction.setEnabled(enable); } }); rowSM.addListSelectionListener(new ListSelectionListener() { String getNodeText(final NodeModel node) { return TextController.getController().getShortText(node) + ((node.isRoot()) ? "" : (" <- " + getNodeText(node.getParentNode()))); } public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { mTreeLabel.setText(""); return; } final int selectedRow = lsm.getLeadSelectionIndex(); final NodeModel mindMapNode = getMindMapNode(selectedRow); mTreeLabel.setText(getNodeText(mindMapNode)); } }); final String marshalled = ResourceController.getResourceController() .getProperty(NodeList.WINDOW_PREFERENCE_STORAGE_PROPERTY); final WindowConfigurationStorage result = TimeWindowConfigurationStorage.decorateDialog(marshalled, dialog); final WindowConfigurationStorage storage = result; if (storage != null) { timeTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); int column = 0; for (final TimeWindowColumnSetting setting : ((TimeWindowConfigurationStorage) storage) .getListTimeWindowColumnSettingList()) { timeTable.getColumnModel().getColumn(column).setPreferredWidth(setting.getColumnWidth()); sorter.setSortingStatus(column, setting.getColumnSorting()); column++; } } mFlatNodeTableFilterModel.setFilter((String) mFilterTextSearchField.getSelectedItem(), matchCase.isSelected(), useRegexInFind.isSelected()); dialog.setVisible(true); }
From source file:org.genedb.jogra.plugins.TermRationaliser.java
/** * Return a new JFrame which is the main interface to the Rationaliser. *///from w w w . j ava2 s .co m public JFrame getMainPanel() { /* JFRAME */ frame.setTitle(WINDOW_TITLE); frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); frame.setLayout(new BorderLayout()); /* MENU */ JMenuBar menuBar = new JMenuBar(); JMenu actions_menu = new JMenu("Actions"); JMenuItem actions_mitem_1 = new JMenuItem("Refresh lists"); actions_mitem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { initModels(); } }); actions_menu.add(actions_mitem_1); JMenu about_menu = new JMenu("About"); JMenuItem about_mitem_1 = new JMenuItem("About"); about_mitem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JOptionPane.showMessageDialog(null, "Term Rationaliser \n" + "Wellcome Trust Sanger Institute, UK \n" + "2009", "Term Rationaliser", JOptionPane.PLAIN_MESSAGE); } }); about_menu.add(about_mitem_1); menuBar.add(about_menu); menuBar.add(actions_menu); frame.add(menuBar, BorderLayout.NORTH); /* MAIN BOX */ Box center = Box.createHorizontalBox(); //A box that displays contents from left to right center.add(Box.createHorizontalStrut(5)); //Invisible fixed-width component /* FROM LIST AND PANEL */ fromList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); //Allow multiple products to be selected fromList.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) { synchroniseLists(fromList, toList); //synchronise from left to right } } @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); Box fromPanel = this.createRationaliserPanel(FROM_LIST_NAME, fromList); //Box on left hand side fromPanel.add(Box.createVerticalStrut(55)); //Add some space center.add(fromPanel); //Add to main box center.add(Box.createHorizontalStrut(3)); //Add some space /* MIDDLE PANE */ Box middlePane = Box.createVerticalBox(); ClassLoader classLoader = this.getClass().getClassLoader(); //Needed to access the images later on ImageIcon leftButtonIcon = new ImageIcon(classLoader.getResource("left_arrow.gif")); ImageIcon rightButtonIcon = new ImageIcon(classLoader.getResource("right_arrow.gif")); leftButtonIcon = new ImageIcon(leftButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon! rightButtonIcon = new ImageIcon(rightButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon! JButton rightSynch = new JButton(rightButtonIcon); rightSynch.setToolTipText("Synchronise TO list. \n Shortcut: Right-arrow key"); rightSynch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { synchroniseLists(fromList, toList); } }); JButton leftSynch = new JButton(leftButtonIcon); leftSynch.setToolTipText("Synchronise FROM list. \n Shortcut: Left-arrow key"); leftSynch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { synchroniseLists(toList, fromList); } }); middlePane.add(rightSynch); middlePane.add(leftSynch); center.add(middlePane); //Add middle pane to main box center.add(Box.createHorizontalStrut(3)); /* TO LIST AND PANEL */ toList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //Single product selection in TO list toList.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_LEFT) { synchroniseLists(toList, fromList); //synchronise from right to left } } @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); Box toPanel = this.createRationaliserPanel(TO_LIST_NAME, toList); Box newTerm = Box.createVerticalBox(); textField = new JTextArea(1, 1); //textfield to let the user edit the name of an existing term textField.setMaximumSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().height, 10)); textField.setForeground(Color.BLUE); JScrollPane jsp = new JScrollPane(textField); //scroll pane so that there is a horizontal scrollbar jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); newTerm.add(jsp); TitledBorder editBorder = BorderFactory.createTitledBorder("Edit term name"); editBorder.setTitleColor(Color.DARK_GRAY); newTerm.setBorder(editBorder); toPanel.add(newTerm); //add textfield to panel center.add(toPanel); //add panel to main box center.add(Box.createHorizontalStrut(5)); frame.add(center); //add the main panel to the frame initModels(); //load the lists with data /* BOTTOM HALF OF FRAME */ Box main = Box.createVerticalBox(); TitledBorder border = BorderFactory.createTitledBorder("Information"); border.setTitleColor(Color.DARK_GRAY); /* INFORMATION BOX */ Box info = Box.createVerticalBox(); Box scope = Box.createHorizontalBox(); scope.add(Box.createHorizontalStrut(5)); scope.add(scopeLabel); //label showing the scope of the terms scope.add(Box.createHorizontalGlue()); Box productCount = Box.createHorizontalBox(); productCount.add(Box.createHorizontalStrut(5)); productCount.add(productCountLabel); //display the label showing the number of terms productCount.add(Box.createHorizontalGlue()); info.add(scope); info.add(productCount); info.setBorder(border); /* ACTION BUTTONS */ Box actionButtons = Box.createHorizontalBox(); actionButtons.add(Box.createHorizontalGlue()); actionButtons.add(Box.createHorizontalStrut(10)); JButton findFix = new JButton(new FindClosestMatchAction()); actionButtons.add(findFix); actionButtons.add(Box.createHorizontalStrut(10)); RationaliserAction ra = new RationaliserAction(); // RationaliserAction2 ra2 = new RationaliserAction2(); JButton go = new JButton(ra); actionButtons.add(go); actionButtons.add(Box.createHorizontalGlue()); /* MORE INFORMATION TOGGLE */ Box buttonBox = Box.createHorizontalBox(); final JButton toggle = new JButton("Hide information <<"); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(toggle); buttonBox.add(Box.createHorizontalGlue()); Box textBox = Box.createHorizontalBox(); final JScrollPane scrollPane = new JScrollPane(information); scrollPane.setPreferredSize(new Dimension(frame.getWidth(), 100)); scrollPane.setVisible(true); textBox.add(Box.createHorizontalStrut(5)); textBox.add(scrollPane); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if (toggle.getText().equals("Show information >>")) { scrollPane.setVisible(true); toggle.setText("Hide information <<"); frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() + 100)); frame.pack(); } else if (toggle.getText().equals("Hide information <<")) { scrollPane.setVisible(false); toggle.setText("Show information >>"); frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() - 100)); frame.pack(); } } }; toggle.addActionListener(actionListener); main.add(Box.createVerticalStrut(5)); main.add(info); main.add(Box.createVerticalStrut(5)); main.add(Box.createVerticalStrut(5)); main.add(actionButtons); main.add(Box.createVerticalStrut(10)); main.add(buttonBox); main.add(textBox); frame.add(main, BorderLayout.SOUTH); frame.pack(); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setVisible(true); //initModels(); return frame; }
From source file:org.isatools.gui.optionselector.OptionGroup.java
public void addOptionItem(T item, boolean setSelected) { OptionItem<T> option = new OptionItem<T>(setSelected, item); option.addMouseListener(this); if (!availableOptions.containsKey(item)) { availableOptions.put(item, option); add(option);/*from www. ja v a 2 s . c om*/ add(alignment == OptionGroup.HORIZONTAL_ALIGNMENT ? Box.createHorizontalStrut(5) : Box.createVerticalStrut(5)); } }
From source file:org.isatools.isacreator.filechooser.FileChooserUI.java
private JPanel createTopPanel() { final JTextField uri = new RoundedJTextField(20); final JTextField username = new RoundedJTextField(20); final JPasswordField password = new RoundedJPasswordField(20); final JPanel topContainer = new JPanel(); topContainer.setLayout(new BoxLayout(topContainer, BoxLayout.PAGE_AXIS)); topContainer.setBackground(UIHelper.BG_COLOR); HUDTitleBar titlePanel = new HUDTitleBar(null, null, true); add(titlePanel, BorderLayout.NORTH); titlePanel.installListeners();//from w ww .ja va2s. co m topContainer.add(titlePanel); JPanel buttonPanel = new JPanel(new GridLayout(1, 1)); buttonPanel.setOpaque(false); JPanel fileSystemPanel = new JPanel(); fileSystemPanel.setLayout(new BoxLayout(fileSystemPanel, BoxLayout.LINE_AXIS)); fileSystemPanel.setBackground(UIHelper.BG_COLOR); localFsChoice = new JLabel(localFileSystemIcon, JLabel.LEFT); localFsChoice.setBackground(UIHelper.BG_COLOR); localFsChoice.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { SwingUtilities.invokeLater(new Runnable() { public void run() { localFsChoice.setIcon(localFileSystemIconOver); remoteFsChoice.setIcon(remoteFileSystemIcon); ftpConnectionContainer.setVisible(false); topContainer.revalidate(); status.setText(""); fileBrowser = new LocalBrowser(); try { updateTree(fileBrowser.getHomeDirectory()); } catch (IOException e) { FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } } }); } }); fileSystemPanel.add(localFsChoice); fileSystemPanel.add(Box.createHorizontalStrut(5)); remoteFsChoice = new JLabel(remoteFileSystemIcon, JLabel.LEFT); remoteFsChoice.setBackground(UIHelper.BG_COLOR); remoteFsChoice.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { SwingUtilities.invokeLater(new Runnable() { public void run() { localFsChoice.setIcon(localFileSystemIcon); remoteFsChoice.setIcon(remoteFileSystemIconOver); ftpConnectionContainer.setVisible(true); topContainer.revalidate(); } }); // immediately try to call FTP manager to get last sessions details final FTPAuthentication lastSession; if ((lastSession = ftpManager.getLastSession()) != null) { Thread remoteConnector = new Thread(new Runnable() { public void run() { connectToFTP(lastSession.getUri(), lastSession.getUsername(), lastSession.getPassword()); } }); remoteConnector.start(); } else { errorAction("no ftp location"); } } }); fileSystemPanel.add(remoteFsChoice); fileSystemPanel.add(Box.createHorizontalStrut(5)); status = UIHelper.createLabel("", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); status.setHorizontalAlignment(JLabel.RIGHT); fileSystemPanel.add(status); buttonPanel.add(fileSystemPanel); topContainer.add(buttonPanel); // now create panel to configure the FTP site ftpConnectionContainer = new JPanel(new GridLayout(1, 1)); ftpConnectionContainer.setBackground(UIHelper.BG_COLOR); JPanel userAuthFTP = new JPanel(); userAuthFTP.setLayout(new BoxLayout(userAuthFTP, BoxLayout.LINE_AXIS)); userAuthFTP.setOpaque(false); // add field to add URI JPanel uriPanel = new JPanel(new GridLayout(1, 2)); uriPanel.setBackground(UIHelper.BG_COLOR); JLabel uriLab = UIHelper.createLabel("FTP URI: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); UIHelper.renderComponent(uri, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false); uriPanel.add(uriLab); uriPanel.add(uri); userAuthFTP.add(uriPanel); // add field to add username JPanel usernamePanel = new JPanel(new GridLayout(1, 2)); usernamePanel.setBackground(UIHelper.BG_COLOR); JLabel usernameLab = UIHelper.createLabel("Username: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); UIHelper.renderComponent(username, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false); uriPanel.add(usernameLab); uriPanel.add(username); userAuthFTP.add(usernamePanel); // add field to add password JPanel passwordPanel = new JPanel(new GridLayout(1, 2)); passwordPanel.setBackground(UIHelper.BG_COLOR); JLabel passwordLab = UIHelper.createLabel("Password: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR); UIHelper.renderComponent(password, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false); passwordPanel.add(passwordLab); passwordPanel.add(password); userAuthFTP.add(passwordPanel); JLabel connectLab = new JLabel(connectIcon); connectLab.setOpaque(false); connectLab.setToolTipText("<html><b>Connect</b><p>Connect to the FTP source defined!</p></html>"); connectLab.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); if (uri.getText() != null && !uri.getText().trim().equals("")) { String user = (username.getText() != null) ? username.getText() : ""; String pass = (password.getPassword() != null) ? new String(password.getPassword()) : ""; final FTPAuthentication newFTPLocation = new FTPAuthentication(uri.getText(), user, pass); Thread remoteConnector = new Thread(new Runnable() { public void run() { connectToFTP(newFTPLocation.getUri(), newFTPLocation.getUsername(), newFTPLocation.getPassword()); } }); remoteConnector.start(); } } }); userAuthFTP.add(connectLab); JLabel historyLab = new JLabel(viewHistoryIcon); historyLab.setOpaque(false); historyLab.setToolTipText( "<html><b>Search previously connected to FTP locations</b><p>Connect to a previously defined FTP location</p></html>"); historyLab.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); SelectFromFTPHistory selectFTP = new SelectFromFTPHistory(); selectFTP.addPropertyChangeListener("locationSelected", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getNewValue() != null) { final FTPAuthentication ftpRecord = ftpManager .retrieveFTPAuthenticationObject(event.getNewValue().toString()); Thread remoteConnector = new Thread(new Runnable() { public void run() { connectToFTP(ftpRecord.getUri(), ftpRecord.getUsername(), ftpRecord.getPassword()); } }); remoteConnector.start(); } } }); selectFTP.createGUI(); showJDialogAsSheet(selectFTP); } }); userAuthFTP.add(historyLab); ftpConnectionContainer.add(userAuthFTP); ftpConnectionContainer.setVisible(false); topContainer.add(ftpConnectionContainer); return topContainer; }
From source file:org.isatools.isacreator.filechooser.FileChooserUI.java
/** * Creates the FileSelection panel containing the list of selected files, and the toolbar to modify the list * * @return JPanel containing a selection pane *///ww w. j ava 2 s . com 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 a2 s .c o m*/ * * @return @see JPanel containing the navigation tree to browse a file system. */ private JPanel createNavTree() { JPanel treeContainer = new JPanel(new BorderLayout()); treeContainer.setBackground(UIHelper.BG_COLOR); treeContainer .setBorder(new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); JPanel navigationControls = new JPanel(); navigationControls.setLayout(new BoxLayout(navigationControls, BoxLayout.LINE_AXIS)); navigationControls.setOpaque(false); final JLabel navToParentDir = new JLabel(upIcon); navToParentDir.setOpaque(false); navToParentDir.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); navToParentDir.setIcon(upIcon); try { updateTree(fileBrowser.getParentDirectory()); } catch (IOException e) { errorAction("problem occurred!"); } } public void mouseEntered(MouseEvent event) { super.mouseEntered(event); navToParentDir.setIcon(upIconOver); } public void mouseExited(MouseEvent event) { super.mouseExited(event); navToParentDir.setIcon(upIcon); } }); navigationControls.add(navToParentDir); navigationControls.add(Box.createHorizontalStrut(5)); final JLabel navToHomeDir = new JLabel(homeIcon); navToHomeDir.setOpaque(false); navToHomeDir.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); navToHomeDir.setIcon(homeIcon); try { updateTree(fileBrowser.getHomeDirectory()); } catch (IOException e) { if (e instanceof ConnectionException) { status.setText("<html>status: not connected!</html>"); } FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } } public void mouseEntered(MouseEvent event) { super.mouseEntered(event); navToHomeDir.setIcon(homeIconOver); } public void mouseExited(MouseEvent event) { super.mouseExited(event); navToHomeDir.setIcon(homeIcon); } }); navigationControls.add(navToHomeDir); navigationControls.add(Box.createGlue()); treeContainer.add(navigationControls, BorderLayout.NORTH); try { treeModel = new DefaultTreeModel(fileBrowser.getHomeDirectory()); directoryTree = new JTree(treeModel); directoryTree.setFont(UIHelper.VER_11_PLAIN); directoryTree.setCellRenderer(new FileSystemTreeCellRenderer()); } catch (IOException e) { FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false, FileBrowserTreeNode.DIRECTORY); updateTree(defaultFTPNode); } directoryTree.addMouseListener(new CommonMouseAdapter() { public void mousePressed(MouseEvent event) { super.mousePressed(event); int selRow = directoryTree.getRowForLocation(event.getX(), event.getY()); TreePath selPath = directoryTree.getPathForLocation(event.getX(), event.getY()); if (selRow != -1) { final FileBrowserTreeNode node = (FileBrowserTreeNode) selPath.getLastPathComponent(); if (SwingUtilities.isLeftMouseButton(event)) { if (event.getClickCount() == 2) { if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) { String newPath; if (fileBrowser instanceof LocalBrowser) { newPath = ((File) fileBrowser.getDirFiles().get(node.toString())).getPath(); } else { newPath = node.toString(); } updateTree(fileBrowser.changeDirectory(newPath)); } // else, if a leaf node, then add file to to list if (node.isLeaf() && (node.getType() != FileBrowserTreeNode.DIRECTORY)) { String extension = node.toString().substring(node.toString().lastIndexOf(".") + 1) .trim().toUpperCase(); FileChooserFile toAdd = null; for (Object o : fileBrowser.getFileMap().get(extension)) { String fileName; String filePath; if (fileBrowser instanceof LocalBrowser) { File file = (File) o; fileName = file.getName(); filePath = file.getPath(); if (fileName.equals(node.toString())) { toAdd = new CustomFile(filePath); break; } } else { FTPFile ftpFile = (FTPFile) o; fileName = ftpFile.getName(); filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator + ftpFile.getName(); if (fileName.equals(node.toString())) { toAdd = new CustomFTPFile(ftpFile, filePath); break; } } } if (toAdd != null && !checkIfInList(toAdd)) { selectedFiles.addFileItem(toAdd); } } } } else { if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) { // show popup to add the directory to the selected files JPopupMenu popup = new JPopupMenu(); JMenuItem addDirectory = new JMenuItem("add directory"); addDirectory.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { Object fileToAdd = fileBrowser.getDirFiles().get(node.toString()); FileChooserFile toAdd; if (fileToAdd instanceof File) { toAdd = new CustomFile(((File) fileToAdd).getPath()); } else { FTPFile ftpFile = (FTPFile) fileToAdd; String filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator + ftpFile.getName(); toAdd = new CustomFTPFile(ftpFile, filePath); } if (!checkIfInList(toAdd)) { selectedFiles.addDirectoryItem(toAdd); } } }); popup.add(addDirectory); popup.show(directoryTree, event.getX(), event.getY()); } } } } }); BasicTreeUI ui = new BasicTreeUI() { public Icon getCollapsedIcon() { return null; } public Icon getExpandedIcon() { return null; } }; directoryTree.setUI(ui); directoryTree.setFont(UIHelper.VER_12_PLAIN); JScrollPane treeScroll = new JScrollPane(directoryTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); treeScroll.setPreferredSize(new Dimension(300, 200)); treeScroll.setBorder(new EmptyBorder(0, 0, 0, 0)); treeContainer.add(treeScroll, BorderLayout.CENTER); IAppWidgetFactory.makeIAppScrollPane(treeScroll); return treeContainer; }
From source file:org.isatools.isacreator.gui.formelements.SubForm.java
private JPanel setupOptionsPanel() { options = new JPanel(); options.setLayout(new BoxLayout(options, BoxLayout.LINE_AXIS)); options.setOpaque(false);//from w w w. j a v a 2 s. c om String addRecordString = fieldType == FieldTypes.ASSAY && dataEntryForm != null ? "create assay" : "add a new " + fieldType + " column"; final JLabel addRecord = new JLabel(addRecordString, addRecordIcon, JLabel.LEFT); String toolTipText; if (fieldType == FieldTypes.ASSAY) { toolTipText = "<html><b>Create a new Assay</b>" + " <p>Complete the details for the assay in the fields provided</p>" + " <p>and click this button to add the assay to this study...</p>" + "</html>"; } else { toolTipText = "<html><b>Add a new " + fieldType + "</b>" + " <p>Click here to add a new column to enter an additional " + fieldType + "</p>" + "</html>"; } addRecord.setToolTipText(toolTipText); Font fontToUse = fieldType == FieldTypes.ASSAY && dataEntryForm != null ? UIHelper.VER_12_BOLD : UIHelper.VER_12_PLAIN; UIHelper.renderComponent(addRecord, fontToUse, UIHelper.DARK_GREEN_COLOR, false); addRecord.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { addRecord.setIcon(addRecordIcon); if (addColumn()) { updateTables(); } } @Override public void mouseEntered(MouseEvent mouseEvent) { addRecord.setIcon(addRecordIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { addRecord.setIcon(addRecordIcon); } }); options.add(addRecord); options.add(Box.createHorizontalStrut(10)); removeRecord = new JLabel("Remove " + fieldType + "...", removeIcon, JLabel.LEFT); removeRecord.setVisible(false); UIHelper.renderComponent(removeRecord, UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR, false); removeRecord.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { if (removeRecord.getIcon() != null) { removeRecord.setIcon(removeIcon); } removalConfirmation(fieldType); } @Override public void mouseExited(MouseEvent mouseEvent) { if (removeRecord.getIcon() != null) { removeRecord.setIcon(removeIcon); } } @Override public void mouseEntered(MouseEvent mouseEvent) { if (removeRecord.getIcon() != null) { removeRecord.setIcon(removeIconOver); } } }); if (!showRemoveOption) { removeRecord.setIcon(null); removeRecord.setText(""); } options.add(removeRecord); options.add(Box.createHorizontalStrut(10)); createCustomOptions(); options.add(Box.createGlue()); return options; }
From source file:org.isatools.isacreator.optionselector.OptionGroup.java
public OptionGroup(int alignment, boolean singleSelection, int leftPadding) { this.singleSelection = singleSelection; this.alignment = alignment; availableOptions = new ListOrderedMap<T, OptionItem>(); setLayout(//ww w . j av a2 s . c om new BoxLayout(this, alignment == HORIZONTAL_ALIGNMENT ? BoxLayout.LINE_AXIS : BoxLayout.PAGE_AXIS)); add(Box.createHorizontalStrut(leftPadding)); setOpaque(false); }
From source file:org.isatools.isacreator.optionselector.OptionGroup.java
public void addOptionItem(T item, boolean setSelected, ImageIcon selectedImage, ImageIcon unselectedImage, boolean enabled, boolean useStringRepresentation) { OptionItem<T> option = new OptionItem<T>(setSelected, item, selectedImage, unselectedImage, useStringRepresentation);// w w w .ja va 2s. c o m option.addMouseListener(this); if (!availableOptions.containsKey(item)) { availableOptions.put(item, option); option.setEnabled(enabled); add(option); add(alignment == OptionGroup.HORIZONTAL_ALIGNMENT ? Box.createHorizontalStrut(5) : Box.createVerticalStrut(5)); } }