Example usage for javax.swing Box createHorizontalBox

List of usage examples for javax.swing Box createHorizontalBox

Introduction

In this page you can find the example usage for javax.swing Box createHorizontalBox.

Prototype

public static Box createHorizontalBox() 

Source Link

Document

Creates a Box that displays its components from left to right.

Usage

From source file:org.freeplane.view.swing.features.time.mindmapmode.nodelist.NodeList.java

public void startup() {
    if (dialog != null) {
        dialog.toFront();/*  w ww.  ja  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();/*from www. j a v  a2 s  .com*/
        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

/**
 * Supplies the JPanel which is displayed in the main Jogra window.
 *///  ww  w . j  ava  2 s .  c  o m
public JPanel getMainWindowPlugin() {

    final JPanel ret = new JPanel();
    final JButton loadButton = new JButton("Load Term Rationaliser");
    final JLabel chooseType = new JLabel("Select term: ");
    final JComboBox termTypeBox = new JComboBox(instances.keySet().toArray());
    final JCheckBox showEVCFilter = new JCheckBox("Highlight terms with evidence codes", true);

    loadButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent ae) {

            new SwingWorker<JFrame, Void>() {
                @Override
                protected JFrame doInBackground() throws Exception {
                    ret.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    setTermType(instances.get((String) termTypeBox.getSelectedItem()));
                    setShowEVC(showEVCFilter.isSelected());
                    return makeWindow();
                }

                @Override
                public void done() {
                    try {
                        final GeneDBMessage e = new OpenWindowEvent(TermRationaliser.this, get());
                        EventBus.publish(e);
                    } catch (final InterruptedException exp) {
                        exp.printStackTrace();
                    } catch (final ExecutionException exp) {
                        exp.printStackTrace();
                    }
                    ret.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            }.execute();
        }
    });
    Box verticalBox = Box.createVerticalBox();
    Box horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(chooseType);
    horizontalBox.add(termTypeBox);
    verticalBox.add(horizontalBox);
    verticalBox.add(loadButton);
    verticalBox.add(showEVCFilter);
    ret.add(verticalBox);
    return ret;
}

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 .  jav a2  s . c o  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.isacreatorconfigurator.configui.FieldInterface.java

private void instantiateFields(String initFieldName) {
    // OVERALL CONTAINER
    JPanel container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));
    container.setBackground(UIHelper.BG_COLOR);

    JLabel fieldDefinitionLab = new JLabel(fieldDefinitionHeader, JLabel.CENTER);
    container.add(fieldDefinitionLab);//from w w w  . j a va2 s  .  c o m

    container.add(Box.createVerticalStrut(5));

    // FIELD LABEL & INPUT BOX CONTAINER
    JPanel fieldCont = new JPanel(new GridLayout(1, 2));
    fieldCont.setBackground(UIHelper.BG_COLOR);

    fieldName = new RoundedJTextField(15);
    fieldName.setText(initFieldName);
    fieldName.setEditable(false);
    UIHelper.renderComponent(fieldName, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JLabel fieldNameLab = UIHelper.createLabel("Field Name: ", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    fieldCont.add(fieldNameLab);
    fieldCont.add(fieldName);
    container.add(fieldCont);

    JPanel descCont = new JPanel(new GridLayout(1, 2));
    descCont.setBackground(UIHelper.BG_COLOR);
    description = new RoundedJTextArea();
    description.setLineWrap(true);
    description.setWrapStyleWord(true);
    UIHelper.renderComponent(description, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane descScroll = new JScrollPane(description, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    descScroll.setBackground(UIHelper.BG_COLOR);
    descScroll.setPreferredSize(new Dimension(150, 65));
    descScroll.getViewport().setBackground(UIHelper.BG_COLOR);

    IAppWidgetFactory.makeIAppScrollPane(descScroll);

    JLabel descLab = UIHelper.createLabel("Description: ", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    descLab.setVerticalAlignment(JLabel.TOP);
    descCont.add(descLab);
    descCont.add(descScroll);
    container.add(descCont);

    // add datatype information
    JPanel datatypeCont = new JPanel(new GridLayout(1, 2));
    datatypeCont.setBackground(UIHelper.BG_COLOR);

    DataTypes[] allowedDataTypes = initFieldName.equals(UNIT_STR) ? new DataTypes[] { DataTypes.ONTOLOGY_TERM }
            : DataTypes.values();

    datatype = new JComboBox(allowedDataTypes);
    datatype.addActionListener(this);
    UIHelper.renderComponent(datatype, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR);

    JLabel dataTypeLab = UIHelper.createLabel("Datatype:", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    datatypeCont.add(dataTypeLab);
    datatypeCont.add(datatype);
    container.add(datatypeCont);

    defaultValContStd = new JPanel(new GridLayout(1, 2));
    defaultValContStd.setBackground(UIHelper.BG_COLOR);

    defaultValCont = Box.createHorizontalBox();
    defaultValCont.setPreferredSize(new Dimension(150, 25));

    defaultValStd = new RoundedFormattedTextField(null, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR,
            UIHelper.DARK_GREEN_COLOR);
    defaultValCont.setPreferredSize(new Dimension(120, 25));
    defaultValStd.setFormatterFactory(new DefaultFormatterFactory(
            new RegExFormatter(".*", defaultValStd, false, UIHelper.DARK_GREEN_COLOR, UIHelper.RED_COLOR,
                    UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR)));
    defaultValStd.setForeground(UIHelper.DARK_GREEN_COLOR);
    defaultValStd.setFont(UIHelper.VER_11_PLAIN);

    defaultValCont.add(defaultValStd);

    defaultValLabStd = UIHelper.createLabel(DEFAULT_VAL_STR, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);

    defaultValContStd.add(defaultValLabStd);
    defaultValContStd.add(defaultValCont);
    container.add(defaultValContStd);

    defaultValContBool = new JPanel(new GridLayout(1, 2));
    defaultValContBool.setBackground(UIHelper.BG_COLOR);
    defaultValContBool.setVisible(false);

    listDataSourceCont = new JPanel(new GridLayout(2, 1));
    listDataSourceCont.setBackground(UIHelper.BG_COLOR);
    listDataSourceCont.setVisible(false);

    JLabel listValLab = UIHelper.createLabel("Please enter comma separated list of values:",
            UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    listDataSourceCont.add(listValLab);

    listValues = new RoundedJTextArea("SampleVal1, SampleVal2, SampleVal3", 3, 5);
    listValues.setLineWrap(true);
    listValues.setWrapStyleWord(true);
    UIHelper.renderComponent(listValues, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane listScroll = new JScrollPane(listValues, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    listScroll.setBackground(UIHelper.BG_COLOR);
    listScroll.getViewport().setBackground(UIHelper.BG_COLOR);

    listDataSourceCont.add(listScroll);
    container.add(listDataSourceCont);

    IAppWidgetFactory.makeIAppScrollPane(listScroll);

    sourceEntryPanel = new JPanel(new BorderLayout());
    sourceEntryPanel.setSize(new Dimension(125, 190));
    sourceEntryPanel.setOpaque(false);
    sourceEntryPanel.setVisible(false);

    preferredOntologySource = new JPanel();
    preferredOntologySource.setLayout(new BoxLayout(preferredOntologySource, BoxLayout.PAGE_AXIS));
    preferredOntologySource.setVisible(false);
    recommendOntologySource = new JCheckBox("Use recommended ontology source?", false);

    UIHelper.renderComponent(recommendOntologySource, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    recommendOntologySource.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (recommendOntologySource.isSelected()) {
                sourceEntryPanel.setVisible(true);
            } else {
                sourceEntryPanel.setVisible(false);
            }
        }
    });

    JPanel useOntologySourceCont = new JPanel(new GridLayout(1, 1));
    useOntologySourceCont.add(recommendOntologySource);

    preferredOntologySource.add(useOntologySourceCont);

    JPanel infoCont = new JPanel(new GridLayout(1, 1));
    JLabel infoLab = UIHelper.createLabel(
            "<html>click on the <strong>configure ontologies</strong> button to open the ontology configurator to edit the list of ontologies and search areas within an ontology</html>",
            UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR);
    infoLab.setPreferredSize(new Dimension(100, 40));
    infoCont.add(infoLab);

    sourceEntryPanel.add(infoCont, BorderLayout.NORTH);

    JLabel preferredOntologiesLab = new JLabel(preferredOntologiesSidePanelIcon);
    preferredOntologiesLab.setVerticalAlignment(SwingConstants.TOP);

    sourceEntryPanel.add(preferredOntologiesLab, BorderLayout.WEST);

    ontologiesToUseModel = new DefaultTableModel(new String[0][2], ontologyColumnHeaders) {
        @Override
        public boolean isCellEditable(int i, int i1) {
            return false;
        }
    };
    ontologiesToUse = new JTable(ontologiesToUseModel);
    ontologiesToUse.getTableHeader().setBackground(UIHelper.BG_COLOR);

    try {
        ontologiesToUse.setDefaultRenderer(Class.forName("java.lang.Object"),
                new CustomSpreadsheetCellRenderer());
    } catch (ClassNotFoundException e) {
        // empty
    }

    renderTableHeader();

    JScrollPane ontologiesToUseScroller = new JScrollPane(ontologiesToUse,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    ontologiesToUseScroller.setBorder(new EmptyBorder(0, 0, 0, 0));
    ontologiesToUseScroller.setPreferredSize(new Dimension(100, 80));
    ontologiesToUseScroller.setBackground(UIHelper.BG_COLOR);
    ontologiesToUseScroller.getViewport().setBackground(UIHelper.BG_COLOR);

    IAppWidgetFactory.makeIAppScrollPane(ontologiesToUseScroller);

    sourceEntryPanel.add(ontologiesToUseScroller);

    JPanel buttonCont = new JPanel(new BorderLayout());
    final JLabel openConfigButton = new JLabel(ontologyConfigIcon);
    openConfigButton.setVerticalAlignment(SwingConstants.TOP);
    openConfigButton.setHorizontalAlignment(SwingConstants.RIGHT);

    MouseAdapter showOntologyConfigurator = new MouseAdapter() {

        public void mouseEntered(MouseEvent mouseEvent) {
            openConfigButton.setIcon(ontologyConfigIconOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            openConfigButton.setIcon(ontologyConfigIcon);
        }

        public void mousePressed(MouseEvent mouseEvent) {

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    if (openConfigButton.isEnabled()) {
                        openConfigButton.setIcon(ontologyConfigIcon);
                        ontologyConfig = new OntologyConfigUI(ontologiesToQuery, selectedOntologies);
                        ontologyConfig.addPropertyChangeListener("ontologySelected",
                                new PropertyChangeListener() {
                                    public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
                                        selectedOntologies = (ListOrderedMap<String, RecommendedOntology>) propertyChangeEvent
                                                .getNewValue();
                                        updateTable();
                                    }
                                });
                        showPopupInCenter(ontologyConfig);
                    }
                }
            });
        }

    };

    openConfigButton.addMouseListener(showOntologyConfigurator);

    buttonCont.add(openConfigButton, BorderLayout.EAST);

    sourceEntryPanel.add(buttonCont, BorderLayout.SOUTH);
    preferredOntologySource.add(sourceEntryPanel);
    container.add(preferredOntologySource);

    String[] contents = new String[] { "true", "false" };
    defaultValBool = new

    JComboBox(contents);

    UIHelper.renderComponent(defaultValBool, UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR,
            UIHelper.BG_COLOR);

    JLabel defaultValLabBool = UIHelper.createLabel(DEFAULT_VAL_STR, UIHelper.VER_12_BOLD,
            UIHelper.DARK_GREEN_COLOR);

    defaultValContBool.add(defaultValLabBool);
    defaultValContBool.add(defaultValBool);
    container.add(defaultValContBool);

    // RegExp data entry
    isInputFormatted = new JCheckBox("Is the input formatted?", false);
    isInputFormatted.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    isInputFormatted.setHorizontalAlignment(SwingConstants.LEFT);

    UIHelper.renderComponent(isInputFormatted, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    isInputFormatted.addActionListener(this);
    container.add(UIHelper.wrapComponentInPanel(isInputFormatted));

    inputFormatCont = new JPanel();

    inputFormatCont.setLayout(new BoxLayout(inputFormatCont, BoxLayout.LINE_AXIS));
    inputFormatCont.setVisible(false);
    inputFormatCont.setBackground(UIHelper.BG_COLOR);
    inputFormat = new RoundedJTextField(10);
    inputFormat.setText(".*");
    inputFormat.setSize(new Dimension(150, 19));

    inputFormat.setPreferredSize(new Dimension(160, 25));
    inputFormat.setToolTipText("Field expects a regular expression describing the input format.");
    UIHelper.renderComponent(inputFormat, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JLabel inputFormatLab = UIHelper.createLabel("Input format:", UIHelper.VER_11_BOLD,
            UIHelper.DARK_GREEN_COLOR);
    inputFormatLab.setVerticalAlignment(SwingConstants.TOP);

    inputFormatCont.add(inputFormatLab);
    inputFormatCont.add(inputFormat);
    JLabel checkRegExp = new JLabel(checkRegExIcon, JLabel.RIGHT);
    checkRegExp.setOpaque(false);
    checkRegExp.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            String regexToCheck = inputFormat.getText();

            final CheckRegExGUI regexChecker = new CheckRegExGUI(regexToCheck);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    regexChecker.createGUI();
                }
            });
            regexChecker.addPropertyChangeListener("close", new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    main.getApplicationContainer().hideSheet();
                }
            });
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    main.getApplicationContainer().showJDialogAsSheet(regexChecker);
                }
            });
        }

    }

    );
    inputFormatCont.add(checkRegExp);
    container.add(inputFormatCont);

    usesTemplateForWizard = new JCheckBox("Requires template for wizard?", false);
    usesTemplateForWizard.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    usesTemplateForWizard.setHorizontalAlignment(SwingConstants.LEFT);

    UIHelper.renderComponent(usesTemplateForWizard, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    usesTemplateForWizard.addActionListener(this);
    container.add(UIHelper.wrapComponentInPanel(usesTemplateForWizard));

    wizardTemplatePanel = new JPanel(new GridLayout(1, 2));
    wizardTemplatePanel.setVisible(false);
    wizardTemplatePanel.setBackground(UIHelper.BG_COLOR);

    wizardTemplate = new RoundedJTextArea();
    wizardTemplate.setToolTipText("A template for the wizard to auto-create the data...");
    wizardTemplate.setLineWrap(true);
    wizardTemplate.setWrapStyleWord(true);
    UIHelper.renderComponent(wizardTemplate, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane wizScroll = new JScrollPane(wizardTemplate, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    wizScroll.getViewport().setBackground(UIHelper.BG_COLOR);
    wizScroll.setPreferredSize(new Dimension(70, 60));

    IAppWidgetFactory.makeIAppScrollPane(wizScroll);

    JLabel wizardTemplateLab = UIHelper.createLabel("Template definition:", UIHelper.VER_11_BOLD,
            UIHelper.DARK_GREEN_COLOR);
    wizardTemplateLab.setVerticalAlignment(JLabel.TOP);

    wizardTemplatePanel.add(wizardTemplateLab);
    wizardTemplatePanel.add(wizScroll);

    container.add(wizardTemplatePanel);

    JPanel checkCont = new JPanel(new GridLayout(3, 2));
    checkCont.setBackground(UIHelper.BG_COLOR);
    checkCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 4),
            "Behavioural Attributes", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR));

    required = new JCheckBox("Required ", true);

    UIHelper.renderComponent(required, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(required);

    acceptsMultipleValues = new JCheckBox("Allow multiple instances", false);

    UIHelper.renderComponent(acceptsMultipleValues, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(acceptsMultipleValues);
    acceptsFileLocations = new JCheckBox("Accepts file locations", false);

    acceptsFileLocations.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            acceptsMultipleValues.setSelected(false);
            acceptsMultipleValues.setEnabled(!acceptsFileLocations.isSelected());
        }
    });

    UIHelper.renderComponent(acceptsFileLocations, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(acceptsFileLocations);

    hidden = new JCheckBox("hidden?", false);

    UIHelper.renderComponent(hidden, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(hidden);

    forceOntologySelection = new JCheckBox("Force ontology selection", false);
    UIHelper.renderComponent(forceOntologySelection, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    checkCont.add(forceOntologySelection);

    container.add(checkCont);

    JScrollPane contScroll = new JScrollPane(container, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    contScroll.setBorder(null);
    contScroll.setAutoscrolls(true);

    IAppWidgetFactory.makeIAppScrollPane(contScroll);

    add(contScroll, BorderLayout.NORTH);
}

From source file:org.isatools.isacreatorconfigurator.ontologyconfigurationtool.OntologyConfigUI.java

private void createOntologySelectionPanel() {

    OntologyListRenderer listRenderer = new OntologyListRenderer();

    JPanel westPanel = new JPanel(new BorderLayout());

    JPanel selectedOntologiesContainer = new JPanel(new BorderLayout());
    selectedOntologiesContainer.setOpaque(false);

    // create List containing selected ontologies
    selectedOntologyListModel = new DefaultListModel();
    selectedOntologyList = new JList(selectedOntologyListModel);
    selectedOntologyList.setCellRenderer(new SelectedOntologyListRenderer());
    selectedOntologyList.setBackground(UIHelper.BG_COLOR);

    selectedOntologyList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent listSelectionEvent) {
            setOntologySelectionPanelPlaceholder(infoImage);

            setSelectedOntologyButtonVisibility(selectedOntologyList.isSelectionEmpty());
        }/*from w w  w  . ja va 2  s . c om*/
    });

    JScrollPane selectedOntologiesScroller = new JScrollPane(selectedOntologyList,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    selectedOntologiesScroller.setPreferredSize(new Dimension(200, 255));
    selectedOntologiesScroller.setBackground(UIHelper.BG_COLOR);
    selectedOntologiesScroller.getViewport().setBackground(UIHelper.BG_COLOR);

    IAppWidgetFactory.makeIAppScrollPane(selectedOntologiesScroller);

    selectedOntologiesContainer.setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7),
            "selected ontologies", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR));

    selectedOntologiesContainer.add(selectedOntologiesScroller, BorderLayout.CENTER);

    // ADD BUTTONS
    removeOntologyButton = new JLabel(removeOntologyButtonIcon);
    removeOntologyButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {

            if (!selectedOntologyList.isSelectionEmpty()) {
                String ontologyToRemove = selectedOntologyList.getSelectedValue().toString();
                System.out.println("Removing  " + ontologyToRemove);
                selectedOntologies.remove(ontologyToRemove);
                setOntologySelectionPanelPlaceholder(infoImage);

                updateSelectedOntologies();
            }

            removeOntologyButton.setIcon(removeOntologyButtonIcon);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            removeOntologyButton.setIcon(removeOntologyButtonIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            removeOntologyButton.setIcon(removeOntologyButtonIcon);
        }
    });

    removeOntologyButton.setVisible(false);

    viewOntologyButton = new JLabel(browseOntologyButtonIcon);
    viewOntologyButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            performTransition();
            viewOntologyButton.setIcon(browseOntologyButtonIcon);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            viewOntologyButton.setIcon(browseOntologyButtonIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            viewOntologyButton.setIcon(browseOntologyButtonIcon);
        }
    });

    viewOntologyButton.setVisible(false);

    removeRestrictionButton = new JLabel(removeRestrictionButtonIcon);
    removeRestrictionButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            if (!selectedOntologyList.isSelectionEmpty()) {
                ((RecommendedOntology) selectedOntologyList.getSelectedValue()).setBranchToSearchUnder(null);
                removeRestrictionButton.setVisible(false);
                selectedOntologyList.repaint();
            }

            removeRestrictionButton.setIcon(removeRestrictionButtonIcon);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            removeRestrictionButton.setIcon(removeRestrictionButtonIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            removeRestrictionButton.setIcon(removeRestrictionButtonIcon);
        }
    });

    removeRestrictionButton.setVisible(false);

    Box selectedOntologiesOptionContainer = Box.createHorizontalBox();
    selectedOntologiesOptionContainer.setOpaque(false);

    selectedOntologiesOptionContainer.add(removeOntologyButton);
    selectedOntologiesOptionContainer.add(viewOntologyButton);
    selectedOntologiesOptionContainer.add(removeRestrictionButton);

    selectedOntologiesContainer.add(selectedOntologiesOptionContainer, BorderLayout.SOUTH);

    // create panel populated with all available ontologies inside a filterable list!
    JPanel availableOntologiesListContainer = new JPanel(new BorderLayout());
    availableOntologiesListContainer
            .setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7),
                    "available ontologies", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
                    UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR));

    final ExtendedJList availableOntologies = new ExtendedJList(listRenderer);

    final JLabel addOntologyButton = new JLabel(addOntologyButtonIcon);
    addOntologyButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            if (!availableOntologies.isSelectionEmpty()) {
                Ontology ontology = (Ontology) availableOntologies.getSelectedValue();

                selectedOntologies.put(ontology.getOntologyDisplayLabel(), new RecommendedOntology(ontology));
                updateSelectedOntologies();

                setOntologySelectionPanelPlaceholder(infoImage);
            }

            addOntologyButton.setIcon(addOntologyButtonIcon);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            addOntologyButton.setIcon(addOntologyButtonIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            addOntologyButton.setIcon(addOntologyButtonIcon);
        }
    });

    final JLabel info = UIHelper.createLabel("", UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR);

    availableOntologies.addPropertyChangeListener("update", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            info.setText("<html>viewing <b>" + availableOntologies.getFilteredItems().size()
                    + "</b> ontologies</html>");
        }
    });

    Box optionsBox = Box.createVerticalBox();

    optionsBox.add(UIHelper.wrapComponentInPanel(info));

    Box availableOntologiesOptionBox = Box.createHorizontalBox();
    availableOntologiesOptionBox.add(addOntologyButton);
    availableOntologiesOptionBox.add(Box.createHorizontalGlue());

    optionsBox.add(availableOntologiesOptionBox);

    availableOntologiesListContainer.add(optionsBox, BorderLayout.SOUTH);

    if (ontologiesToBrowseOn == null) {
        ontologiesToBrowseOn = new ArrayList<Ontology>();
        List<Ontology> bioportalQueryResult = bioportalClient.getAllOntologies();
        if (bioportalQueryResult != null) {
            ontologiesToBrowseOn.addAll(bioportalQueryResult);
        }
        ontologiesToBrowseOn.addAll(olsClient.getAllOntologies());
    }

    // precautionary check in case of having no ontologies available to search on.
    if (ontologiesToBrowseOn != null) {
        for (Ontology o : ontologiesToBrowseOn) {
            availableOntologies.addItem(o);
        }
    }

    info.setText(
            "<html>viewing <b>" + availableOntologies.getFilteredItems().size() + "</b> ontologies</html>");

    // need to get ontologies available from bioportal and add them here.
    JScrollPane availableOntologiesScroller = new JScrollPane(availableOntologies,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    availableOntologiesScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    availableOntologiesScroller.setPreferredSize(new Dimension(200, 125));
    availableOntologiesScroller.setBorder(new EmptyBorder(0, 0, 0, 0));

    IAppWidgetFactory.makeIAppScrollPane(availableOntologiesScroller);

    availableOntologiesListContainer.add(availableOntologiesScroller);
    availableOntologiesListContainer.add(availableOntologies.getFilterField(), BorderLayout.NORTH);

    westPanel.add(selectedOntologiesContainer, BorderLayout.CENTER);
    westPanel.add(availableOntologiesListContainer, BorderLayout.SOUTH);

    add(westPanel, BorderLayout.WEST);
}

From source file:org.jcurl.demo.editor.EditorApp.java

public EditorApp() {
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            EditorApp.this.cmdExit();
        }/*w w  w  .  jav a 2  s. c  o  m*/
    });
    master = new RockEditDisplay();
    master.setPos(mod_locations);
    master.setSpeed(mod_speeds);
    final PositionDisplay pnl2 = new PositionDisplay();
    pnl2.setPos(mod_locations);
    pnl2.setZoom(Zoomer.HOG2HACK);

    final Container con = getContentPane();

    con.add(master, "Center");
    con.add(new SumWaitDisplay(mod_locations), "West");
    con.add(new SumShotDisplay(mod_locations), "East");
    {
        final Box b0 = Box.createVerticalBox();
        final Box b1 = Box.createHorizontalBox();
        b1.add(Box.createRigidArea(new Dimension(0, 75)));
        b1.add(pnl2);
        b0.add(b1);
        b0.add(new JSlider(0, 100, 0));
        final Box b2 = Box.createHorizontalBox();
        b2.add(Box.createHorizontalGlue());
        b2.add(bStart = this.newButton("Start", this, "cmdRunStart"));
        b2.add(bPause = this.newButton("Pause", this, "cmdRunPause"));
        b2.add(bStop = this.newButton("Stop", this, "cmdRunStop"));
        b2.add(Box.createHorizontalGlue());
        b0.add(b2);
        con.add(b0, "South");
    }
    bStop.getAction().actionPerformed(null);

    setJMenuBar(createMenu());
    refreshTitle();
    this.setSize(900, 400);

    new SpeedController(mod_locations, mod_speeds, master);
    new LocationController(mod_locations, pnl2);
    lastSaved = mod_locations.getLastChanged();
}

From source file:org.jcurl.demo.tactics.TacticsApp.java

public TacticsApp() {
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            TacticsApp.this.cmdExit();
        }/*w ww.ja  v  a 2 s.c  om*/
    });
    master = new RockEditDisplay();
    master.setPos(mod_locations);
    master.setSpeed(mod_speeds);
    final PositionDisplay pnl2 = new PositionDisplay();
    pnl2.setPos(mod_locations);
    pnl2.setZoom(Zoomer.HOG2HACK);

    final Container con = getContentPane();
    {
        final JPanel p = new JPanel(new BorderLayout());
        p.add(new SumWaitDisplay(mod_locations), "West");
        p.add(master, "Center");
        p.add(new SumShotDisplay(mod_locations), "East");
        con.add(p, "Center");
    }
    // con.add(new SumWaitDisplay(mod_locations), "West");
    con.add(new SumOutDisplay(mod_locations), "West");
    {
        final Box b1 = Box.createHorizontalBox();
        b1.add(Box.createRigidArea(new Dimension(0, 75)));
        b1.add(pnl2);
        con.add(b1, "South");
    }
    final JTabbedPane t = new JTabbedPane();
    con.add(t, "East");
    {
        final Box b0 = Box.createHorizontalBox();
        t.add("Rock", b0);
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            final Box b2 = Box.createVerticalBox();
            b2.add(new JComboBox(new String[] { "Dark", "Light" }));
            b2.add(new JLabel("Broom", SwingConstants.LEFT));
            b1.add(b2, "North");
            JSlider s = new JSlider(-2000, 2000, 0);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(1000);
            s.setMinorTickSpacing(100);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final Box b3 = Box.createHorizontalBox();
            b3.add(new JFormattedTextField());
            b3.add(new JLabel("mm", SwingConstants.LEFT));
            b1.add(b3, "South");
            b0.add(b1);
        }
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            final Box b2 = Box.createVerticalBox();
            b2.add(new JComboBox(new String[] { "1", "2", "3", "4", "5", "6", "7", "8" }));
            b2.add(new JLabel("Splittime", SwingConstants.LEFT));
            b1.add(b2, "North");
            JSlider s = new JSlider(500, 2500, 1500);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(1000);
            s.setMinorTickSpacing(100);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final Box b3 = Box.createHorizontalBox();
            b3.add(new JSpinner());
            b3.add(new JLabel("ms", SwingConstants.LEFT));
            b1.add(b3, "South");
            b0.add(b1);
        }
    }
    {
        final Box b0 = Box.createHorizontalBox();
        t.add("Ice", b0);
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            b1.add(new JLabel("Curl"), "North");
            JSlider s = new JSlider(0, 5000, 0);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(1000);
            s.setMinorTickSpacing(100);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final JSpinner s1 = new JSpinner();
            b1.add(s1, "South");
            b0.add(b1);
        }
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            b1.add(new JLabel("DrawToTee"), "North");
            JSlider s = new JSlider(15000, 30000, 25000);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(5000);
            s.setMinorTickSpacing(1000);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final JSpinner s1 = new JSpinner();
            b1.add(s1, "South");
            b0.add(b1);
        }
    }
    setJMenuBar(createMenu());
    refreshTitle();
    this.setSize(900, 400);

    new SpeedController(mod_locations, mod_speeds, master);
    new LocationController(mod_locations, pnl2);
    lastSaved = mod_locations.getLastChanged();
}

From source file:org.jdal.swing.report.ReportFileView.java

@Override
protected JComponent buildPanel() {
    Box box = Box.createHorizontalBox();

    fileName.setEditable(false);//w w w .j  av a  2 s  .  c  o  m

    box.add(new JLabel("Fichero"));
    box.add(fileName);
    box.add(Box.createHorizontalStrut(5));

    box.add(Box.createHorizontalStrut(5));
    box.add(new JButton(new FileAction()));

    return box;
}

From source file:org.kepler.gui.DialogGeneralTab.java

/**
 * getTopPanel//from  ww  w  .  j  a v a  2s .c o  m
 * 
 * @return Component
 */
protected Component getTopPanel() {

    Box topPanel = Box.createHorizontalBox();
    JLabel nameLbl = WidgetFactory.makeJLabel(
            StaticResources.getDisplayString("dialogs." + _targetType + ".general.name", ""),
            TabbedDialog.jLabelDims);
    topPanel.add(nameLbl);

    nameTxtFld = WidgetFactory.makeJTextField((_target != null ? _target.getName() : ""),
            TabbedDialog.textFieldDims);
    topPanel.add(nameTxtFld);

    JLabel idLbl = WidgetFactory.makeJLabel(
            StaticResources.getDisplayString("dialogs." + _targetType + ".general.id", ""),
            TabbedDialog.idLabelDims);
    idLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    topPanel.add(idLbl);

    topPanel.add(WidgetFactory.getDefaultSpacer());

    JLabel idFieldLbl = WidgetFactory.makeJLabel(getLSIDString(_target), TabbedDialog.idValueDims);
    topPanel.add(idFieldLbl);

    topPanel.add(Box.createHorizontalGlue());

    return topPanel;
}