Example usage for javax.swing JSplitPane HORIZONTAL_SPLIT

List of usage examples for javax.swing JSplitPane HORIZONTAL_SPLIT

Introduction

In this page you can find the example usage for javax.swing JSplitPane HORIZONTAL_SPLIT.

Prototype

int HORIZONTAL_SPLIT

To view the source code for javax.swing JSplitPane HORIZONTAL_SPLIT.

Click Source Link

Document

Horizontal split indicates the Components are split along the x axis.

Usage

From source file:org.tros.torgo.ControllerBase.java

/**
 * Initialize the window. This is called here from run() and not the
 * constructor so that the Service Provider doesn't load up all of the
 * necessary resources when the application loads.
 *//* w  w w  . j  av a  2s.c om*/
private void initSwing() {
    this.torgoPanel = createConsole((Controller) this);
    this.torgoCanvas = createCanvas(torgoPanel);

    //init the GUI w/ the components...
    Container contentPane = window.getContentPane();
    JToolBar tb = createToolBar();
    if (tb != null) {
        contentPane.add(tb, BorderLayout.NORTH);
    }

    final java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(NamedWindow.class);
    if (torgoCanvas != null) {
        final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, torgoCanvas.getComponent(),
                torgoPanel.getComponent());
        int dividerLocation = prefs.getInt(this.getClass().getName() + "divider-location",
                window.getWidth() - 300);
        splitPane.setDividerLocation(dividerLocation);
        splitPane.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent pce) {
                prefs.putInt(this.getClass().getName() + "divider-location", splitPane.getDividerLocation());
            }
        });

        contentPane.add(splitPane);
    } else {
        contentPane.add(torgoPanel.getComponent());
    }

    JMenuBar mb = createMenuBar();
    if (mb == null) {
        mb = new TorgoMenuBar(window, this);
    }
    window.setJMenuBar(mb);
    JMenu helpMenu = new JMenu("Help");
    JMenuItem aboutMenu = new JMenuItem("About Torgo");
    try {
        java.util.Enumeration<URL> resources = ClassLoader.getSystemClassLoader()
                .getResources(ABOUT_MENU_TORGO_ICON);
        ImageIcon ico = new ImageIcon(resources.nextElement());
        aboutMenu.setIcon(ico);
    } catch (IOException ex) {
        Logger.getLogger(ControllerBase.class.getName()).log(Level.SEVERE, null, ex);
    }

    aboutMenu.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            AboutWindow aw = new AboutWindow();
            aw.setVisible(true);
        }
    });
    helpMenu.add(aboutMenu);

    JMenu vizMenu = new JMenu("Visualization");
    for (String name : TorgoToolkit.getVisualizers()) {
        JCheckBoxMenuItem item = new JCheckBoxMenuItem(name);
        viz.add(item);
        vizMenu.add(item);
    }
    if (vizMenu.getItemCount() > 0) {
        mb.add(vizMenu);
    }

    mb.add(helpMenu);
    window.setJMenuBar(mb);

    window.addWindowListener(new WindowListener() {

        @Override
        public void windowOpened(WindowEvent e) {
        }

        /**
         * We only care if the window is closing so we can kill the
         * interpreter thread.
         *
         * @param e
         */
        @Override
        public void windowClosing(WindowEvent e) {
            stopInterpreter();
        }

        @Override
        public void windowClosed(WindowEvent e) {
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }
    });
}

From source file:org.ut.biolab.medsavant.client.region.RegionWizard.java

private AbstractWizardPage getGenesPage() {
    return new DefaultWizardPage(PAGENAME_GENES) {
        private static final int GENE_SELECTION_PANE_WIDTH = 350;
        private JPanel leftSide;
        private GeneSelectionPanel geneManiaResultsPanel;
        private Set<String> geneManiaGeneNames = null;

        {//from   w  w  w.j a  v a 2 s.  co  m
            selectedGenesPanel = new GeneSelectionPanel(true, true);
            sourceGenesPanel = new GeneSelectionPanel(true, true);
            geneManiaResultsPanel = new GeneSelectionPanel(true, true) {
                @Override
                protected void dragAndDropAddGenes(Set<Gene> geneSet) {
                    Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames);
                    genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys());
                    selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel);
                    selectedGenesPanel.moveSelectedItems(sourceGenesPanel);
                }

                @Override
                protected void dragAndDropRemoveKeys(Set<Object> keySet) {
                    Set<Object> keys = geneManiaResultsPanel.getSelectedKeys();
                    geneManiaResultsPanel.removeRows(keys);
                    sourceGenesPanel.removeRows(keys);
                }
            };
            geneManiaResultsPanel.setOddRowColor(new Color(242, 249, 245));

            runGeneManiaButton = new JButton("Run GeneMANIA");
            runGeneManiaButton.setEnabled(!DirectorySettings.isGeneManiaInstalled());

            ListSelectionListener selectionListener = new ListSelectionListener() {
                @Override
                public void valueChanged(ListSelectionEvent lse) {
                    int numSel = sourceGenesPanel.getNumSelected() + selectedGenesPanel.getNumSelected();
                    if (geneManiaGeneNames != null) {
                        numSel += geneManiaResultsPanel.getNumSelected();
                    }
                    if (GenemaniaInfoRetriever.isGeneManiaDownloading()) {
                        runGeneManiaButton.setEnabled(false);
                    } else {
                        runGeneManiaButton.setEnabled(numSel > 0 || !DirectorySettings.isGeneManiaInstalled());
                    }
                }
            };

            sourceGenesPanel.getTable().getSelectionModel().addListSelectionListener(selectionListener);
            selectedGenesPanel.getTable().getSelectionModel().addListSelectionListener(selectionListener);
            selectedGenesPanel.getTable().getModel().addTableModelListener(new TableModelListener() {
                @Override
                public void tableChanged(TableModelEvent tme) {
                    if (selectedGenesPanel.getData().length > 0) {
                        fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT);
                    } else {
                        fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT);
                    }
                }
            });

            selectedGenesPanel.setPreferredSize(
                    new Dimension(GENE_SELECTION_PANE_WIDTH, selectedGenesPanel.getPreferredSize().height));

            final JPanel outerLeftSide = new JPanel();
            outerLeftSide.setLayout(new BoxLayout(outerLeftSide, BoxLayout.X_AXIS));

            leftSide = new JPanel();
            leftSide.setLayout(new BoxLayout(leftSide, BoxLayout.Y_AXIS));
            leftSide.add(sourceGenesPanel);
            outerLeftSide.add(leftSide);
            final JPanel bg = new JPanel();
            bg.setLayout(new BoxLayout(bg, BoxLayout.Y_AXIS));

            JButton addButton = new JButton("Add ");
            JButton removeButton = new JButton("? Remove");

            sourceGenesPanel.getTable().addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent me) {
                    if (me.getClickCount() == 2) {
                        sourceGenesPanel.moveSelectedItems(selectedGenesPanel);
                    }
                }
            });

            selectedGenesPanel.getTable().addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent me) {
                    if (me.getClickCount() == 2) {
                        if (geneManiaGeneNames != null) {
                            Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames);
                            genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys());
                            selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel);
                        }
                        selectedGenesPanel.moveSelectedItems(sourceGenesPanel);
                    }
                }
            });

            geneManiaResultsPanel.getTable().addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent me) {
                    if (me.getClickCount() == 2) {
                        Set<Object> keys = geneManiaResultsPanel.getSelectedKeys();
                        geneManiaResultsPanel.moveSelectedItems(selectedGenesPanel);
                        sourceGenesPanel.moveItems(selectedGenesPanel, keys);
                    }
                }
            });

            addButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    if (geneManiaGeneNames != null) {
                        Set<Object> keys = geneManiaResultsPanel.getSelectedKeys();
                        geneManiaResultsPanel.moveSelectedItems(selectedGenesPanel);
                        sourceGenesPanel.moveItems(selectedGenesPanel, keys);
                    } else {
                        sourceGenesPanel.moveSelectedItems(selectedGenesPanel);
                    }
                }
            });

            removeButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    if (geneManiaGeneNames != null) {
                        Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames);
                        genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys());
                        selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel);
                    }
                    selectedGenesPanel.moveSelectedItems(sourceGenesPanel);
                }
            });

            bg.add(Box.createVerticalGlue());
            bg.add(addButton);
            bg.add(removeButton);
            bg.add(Box.createVerticalGlue());
            outerLeftSide.add(bg);

            JPanel rightSide = new JPanel();
            rightSide.setLayout(new BoxLayout(rightSide, BoxLayout.Y_AXIS));
            rightSide.add(selectedGenesPanel);
            rightSide.add(runGeneManiaButton);

            final JSplitPane hsplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, outerLeftSide, rightSide);
            hsplitPane.setResizeWeight(1);
            addComponent(hsplitPane, true);

            if (!DirectorySettings.isGeneManiaInstalled()) {
                runGeneManiaButton.setText("Download GeneMANIA");
                if (GenemaniaInfoRetriever.isGeneManiaDownloading()) {
                    runGeneManiaButton.setEnabled(false);
                    registerDownloadListener();
                }
            }

            runGeneManiaButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {

                    if (!DirectorySettings.isGeneManiaInstalled()) {
                        int response = DialogUtils.askYesNo("Download GeneMANIA?",
                                "GeneMANIA is not yet installed.  Do you want to download and install it now?");
                        try {
                            if (response == DialogUtils.OK) {
                                runGeneManiaButton.setText("Run GeneMANIA");
                                runGeneManiaButton.setEnabled(false);
                                registerDownloadListener();

                                /*
                                 DownloadTask dt = GenemaniaInfoRetriever.getGeneManiaDownloadTask();
                                 dt.addPropertyChangeListener(new PropertyChangeListener() {
                                 @Override
                                 public void propertyChange(PropertyChangeEvent evt) {
                                 if (evt.getPropertyName().equals("downloadState")) {
                                 DownloadTask.DownloadState ds = (DownloadTask.DownloadState) evt.getNewValue();
                                 if (ds == DownloadTask.DownloadState.CANCELLED
                                 || ds == DownloadTask.DownloadState.FINISHED) {
                                        
                                 runGeneManiaButton.setEnabled(
                                 (selectedGenesPanel.getNumSelected() + sourceGenesPanel.getNumSelected()) > 0);
                                 }
                                 }
                                 }
                                 });
                                 */
                                GenemaniaInfoRetriever.getGeneManiaDownloadTask().execute();
                            }
                        } catch (IOException e) {
                            DialogUtils.displayMessage("Error downloading GeneMANIA files");
                            LOG.error(e);
                        }
                    } else {

                        final List<String> selectedGenes = new LinkedList<String>();
                        for (Gene g : selectedGenesPanel.getSelectedGenes()) {
                            selectedGenes.add(g.getName());
                        }
                        for (Gene g : sourceGenesPanel.getSelectedGenes()) {
                            selectedGenes.add(g.getName());
                        }
                        if (geneManiaGeneNames != null) {
                            for (Gene g : geneManiaResultsPanel.getSelectedGenes()) {
                                selectedGenes.add(g.getName());
                            }
                        }
                        final JButton closeGeneManiaButton = new JButton("? Close GeneMANIA results");
                        closeGeneManiaButton.setEnabled(false);
                        final JPanel geneManiaContainingPanel = new JPanel();
                        geneManiaContainingPanel
                                .setLayout(new BoxLayout(geneManiaContainingPanel, BoxLayout.Y_AXIS));

                        final SwingWorker geneManiaWorker = new SwingWorker() {
                            private List<Object[]> results;

                            @Override
                            public void done() {
                                Object[][] newdata = new Object[results.size()][4];
                                results.toArray(newdata);
                                geneManiaResultsPanel.updateData(newdata);
                                geneManiaResultsPanel.updateView();
                                geneManiaContainingPanel.removeAll();
                                geneManiaContainingPanel.add(geneManiaResultsPanel);
                                geneManiaContainingPanel.revalidate();
                                geneManiaContainingPanel.repaint();
                                closeGeneManiaButton.setEnabled(true);
                            }

                            @Override
                            public Object doInBackground() {
                                try {
                                    GenemaniaInfoRetriever genemania = new GenemaniaInfoRetriever();
                                    genemania.setGenes(selectedGenes);
                                    List<String> geneNameList = genemania.getRelatedGeneNamesByScore();
                                    geneManiaGeneNames = new HashSet<String>();
                                    geneManiaGeneNames.addAll(geneNameList);
                                    LOG.debug("Found " + geneNameList.size() + " related genes");

                                    results = new ArrayList<Object[]>(geneNameList.size());

                                    int i = 0;
                                    for (String gene : geneNameList) {
                                        if (isCancelled()) {
                                            return null;
                                        }
                                        Gene g = GeneSetFetcher.getInstance().getGeneDictionary().get(gene);
                                        if (g == null) {
                                            LOG.warn("No gene found for " + gene);
                                        } else if (!selectedGenesPanel.hasKey(g.getName())) {
                                            results.add(new Object[] { g.getName(), g.getChrom(), g.getStart(),
                                                    g.getEnd() });
                                        }
                                    }
                                } catch (IOException e) {
                                    LOG.error(e);
                                } catch (ApplicationException e) {
                                    LOG.error(e);
                                } catch (DataStoreException e) {
                                    LOG.error(e);
                                } catch (NoRelatedGenesInfoException e) {
                                    LOG.error(e);
                                }
                                return null;
                            }
                        };

                        leftSide.removeAll();

                        closeGeneManiaButton.addActionListener(new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent ae) {
                                try {
                                    geneManiaWorker.cancel(true);
                                } catch (Exception e) {
                                    //genemania throws exceptions when cancelled
                                }
                                leftSide.removeAll();
                                leftSide.add(sourceGenesPanel);
                                leftSide.validate();
                                leftSide.repaint();
                                geneManiaGeneNames = null;
                            }
                        });

                        JPanel closeButtonPanel = new JPanel();
                        closeButtonPanel.setLayout(new BoxLayout(closeButtonPanel, BoxLayout.X_AXIS));
                        closeButtonPanel.add(closeGeneManiaButton);
                        closeButtonPanel.add(Box.createHorizontalGlue());

                        leftSide.add(closeButtonPanel);

                        geneManiaContainingPanel.add(new WaitPanel("Querying GeneMANIA for related genes"));

                        leftSide.add(geneManiaContainingPanel);
                        leftSide.validate();
                        leftSide.repaint();
                        geneManiaWorker.execute();

                    } //end else
                }//end actionPerformed
            });//end ActionListener
        }

        @Override
        public void setupWizardButtons() {
            fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH);
            fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK);

            if (selectedGenesPanel.getNumSelected() > 0) {
                fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT);
            } else {
                fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT);
            }
        }
    };
}

From source file:org.zaproxy.zap.extension.ascan.CustomScanDialog.java

private JPanel getCustomPanel() {
    if (customPanel == null) {
        customPanel = new JPanel(new GridBagLayout());

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setViewportView(getRequestField());

        JPanel buttonPanel = new JPanel(new GridBagLayout());

        getRequestField().addCaretListener(new CaretListener() {
            @Override/*from w  w w.  jav a2s. co m*/
            public void caretUpdate(CaretEvent event) {
                setFieldStates();
            }
        });

        buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 0, 1, 0.5)); // Spacer
        buttonPanel.add(getAddCustomButton(), LayoutHelper.getGBC(1, 0, 1, 1, 0.0D, 0.0D,
                GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

        buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 0, 1, 0.5)); // Spacer

        buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 1, 1, 0.5)); // Spacer
        buttonPanel.add(getRemoveCustomButton(), LayoutHelper.getGBC(1, 1, 1, 1, 0.0D, 0.0D,
                GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

        buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 1, 1, 0.5)); // Spacer

        JScrollPane scrollPane2 = new JScrollPane(getInjectionPointList());
        scrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

        buttonPanel.add(new JLabel(Constant.messages.getString("ascan.custom.label.vectors")),
                LayoutHelper.getGBC(0, 2, 3, 0.0D, 0.0D));

        buttonPanel.add(scrollPane2, LayoutHelper.getGBC(0, 3, 3, 1.0D, 1.0D));

        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPane, buttonPanel);
        splitPane.setDividerLocation(550);
        customPanel.add(splitPane, LayoutHelper.getGBC(0, 0, 1, 1, 1.0D, 1.0D));
        customPanel.add(customPanelStatus, LayoutHelper.getGBC(0, 1, 1, 1, 1.0D, 0.0D));
        customPanel.add(getDisableNonCustomVectors(), LayoutHelper.getGBC(0, 2, 1, 1, 1.0D, 0.0D));
    }

    return customPanel;
}

From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java

/**
 * /* w w  w  .j av a 2  s.co m*/
 * @param highlightList
 * @param httpReq
 * @return JPanel 
 * Returns CustomPanel with saved injectionList 
 */
private JPanel getSavedCustomPanel(ArrayList highlightList, String httpReq) {

    customPanel = new JPanel(new GridBagLayout());

    JScrollPane scrollPane = new JScrollPane(); //gT
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setViewportView(getRequestField());

    JPanel buttonPanel = new JPanel(new GridBagLayout());

    getRequestField().addCaretListener(new CaretListener() {
        @Override
        public void caretUpdate(CaretEvent event) {
            setFieldStates();

        }
    });

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 0, 1, 0.5)); // Spacer
    buttonPanel.add(getAddCustomButton(), LayoutHelper.getGBC(1, 0, 1, 1, 0.0D, 0.0D, GridBagConstraints.BOTH,
            GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 0, 1, 0.5)); // Spacer

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 1, 1, 0.5)); // Spacer
    buttonPanel.add(getRemoveCustomButton(), LayoutHelper.getGBC(1, 1, 1, 1, 0.0D, 0.0D,
            GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 1, 1, 0.5)); // Spacer

    JScrollPane scrollPane2 = new JScrollPane(getSavedInjectionPointList(highlightList, httpReq));

    scrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    buttonPanel.add(new JLabel(Constant.messages.getString("customFire.custom.label.vectors")),
            LayoutHelper.getGBC(0, 2, 3, 0.0D, 0.0D));

    buttonPanel.add(scrollPane2, LayoutHelper.getGBC(0, 3, 3, 1.0D, 1.0D)); //gT

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPane, buttonPanel);
    splitPane.setDividerLocation(550);

    customPanel.add(splitPane, LayoutHelper.getGBC(0, 0, 1, 1, 1.0D, 1.0D));
    customPanel.add(customPanelStatus, LayoutHelper.getGBC(0, 1, 1, 1, 1.0D, 0.0D));
    customPanel.add(getDisableNonCustomVectors(), LayoutHelper.getGBC(0, 2, 1, 1, 1.0D, 0.0D));

    return customPanel;
}

From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java

/**
 * /*w ww . j av  a 2  s.c om*/
 * @return JPanel `
 */
private JPanel getCustomPanel() {

    customPanel = new JPanel(new GridBagLayout());

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setViewportView(getRequestField());

    JPanel buttonPanel = new JPanel(new GridBagLayout());

    getRequestField().addCaretListener(new CaretListener() {
        @Override
        public void caretUpdate(CaretEvent event) {
            setFieldStates();

        }
    });

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 0, 1, 0.5)); // Spacer
    buttonPanel.add(getAddCustomButton(), LayoutHelper.getGBC(1, 0, 1, 1, 0.0D, 0.0D, GridBagConstraints.BOTH,
            GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 0, 1, 0.5)); // Spacer

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 1, 1, 0.5)); // Spacer
    buttonPanel.add(getRemoveCustomButton(), LayoutHelper.getGBC(1, 1, 1, 1, 0.0D, 0.0D,
            GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 1, 1, 0.5)); // Spacer

    JScrollPane scrollPane2 = new JScrollPane(getInjectionPointList());
    scrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    buttonPanel.add(new JLabel(Constant.messages.getString("customFire.custom.label.vectors")),
            LayoutHelper.getGBC(0, 2, 3, 0.0D, 0.0D));

    buttonPanel.add(scrollPane2, LayoutHelper.getGBC(0, 3, 3, 1.0D, 1.0D)); //gT

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPane, buttonPanel);
    splitPane.setDividerLocation(550);

    customPanel.add(splitPane, LayoutHelper.getGBC(0, 0, 1, 1, 1.0D, 1.0D));
    customPanel.add(customPanelStatus, LayoutHelper.getGBC(0, 1, 1, 1, 1.0D, 0.0D));
    customPanel.add(getDisableNonCustomVectors(), LayoutHelper.getGBC(0, 2, 1, 1, 1.0D, 0.0D));
    //}

    return customPanel;
}

From source file:org.zaproxy.zap.view.MessagePanelsPositionController.java

private void changeMessageTabsPosition(MessagePanelsPosition position) {
    // 29.12.2013 Dejan Lukan: commented out this code, so the function is called when
    // changing the layout where the Request/Response tab representation stays the same.
    /*if (currentPosition == position) {
    return;//from ww w.  j  av a2s .  co m
    }*/

    // save the current position, so we can change Request/Response view in 'Full Layout'
    currentPosition = position;
    saveState(position);

    // Prevent 'Request' icon from being removed when changing Request/Response tabs
    // in Full Layout mode.
    if (View.getDisplayOption() == View.DISPLAY_OPTION_TOP_FULL) {
        return;
    }

    TabbedPanel tabbedPanel = restoreOriginalParentTabbedPanel();

    switch (position) {
    case PANEL_ABOVE:
        splitResponsePanelWithWorkTabbedPanel(JSplitPane.VERTICAL_SPLIT);
        break;
    case PANELS_SIDE_BY_SIDE:
        splitResponsePanelWithWorkTabbedPanel(JSplitPane.HORIZONTAL_SPLIT);
        break;
    case TABS_SIDE_BY_SIDE:
    default:
        if (tabbedPanel == splitTabbedPanel) {
            tabbedPanel = tabbedWork;
        }
        boolean showTabNames = Model.getSingleton().getOptionsParam().getViewParam().getShowTabNames();
        String tabName = responsePanel.getName();
        if (!showTabNames) {
            tabName = "";
        }
        tabbedWork.insertTab(tabName, DisplayUtils.getScaledIcon(responsePanel.getIcon()), responsePanel, null,
                tabbedWork.indexOfComponent(requestPanel) + 1);
        workbenchPanel.removeSplitPaneWork();
    }

    restoreAlternativeParentTabbedPanel(tabbedPanel);

}

From source file:phex.gui.tabs.library.LibraryTab.java

public void initComponent(XJBGUISettings guiSettings) {
    CellConstraints cc = new CellConstraints();
    FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns
            "2dlu, fill:p:grow, 2dlu"); //rows
    PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this);
    JPanel contentPanel = new JPanel();
    FWElegantPanel elegantPanel = new FWElegantPanel(Localizer.getString("Library"), contentPanel);
    tabBuilder.add(elegantPanel, cc.xy(2, 2));

    FormLayout contentLayout = new FormLayout("fill:d:grow", // columns
            "fill:d:grow"); //rows
    PanelBuilder contentBuilder = new PanelBuilder(contentLayout, contentPanel);

    MouseHandler mouseHandler = new MouseHandler();

    JPanel treePanel = createTreePanel(mouseHandler);
    JPanel tablePanel = createTablePanel(guiSettings, mouseHandler);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePanel, tablePanel);
    splitPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    splitPane.setDividerSize(4);//w  w  w  . j  a v a 2 s  .  c  o  m
    splitPane.setOneTouchExpandable(false);
    contentBuilder.add(splitPane, cc.xy(1, 1));

    sharedFilesLabel = new JLabel(" ");
    sharedFilesLabel.setHorizontalAlignment(JLabel.RIGHT);
    elegantPanel.addHeaderPanelComponent(sharedFilesLabel, BorderLayout.EAST);
    ShareManager.getInstance().getSharedFilesService()
            .addSharedFilesChangeListener(new SharedFilesChangeHandler());

    fileTreePopup = new FWPopupMenu();
    fileTablePopup = new FWPopupMenu();

    FWAction action;

    action = getTabAction(ADD_SHARE_FOLDER_ACTION_KEY);
    fileTreePopup.addAction(action);
    action = getTabAction(REMOVE_SHARE_FOLDER_ACTION_KEY);
    fileTreePopup.addAction(action);

    if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) {
        action = getTabAction(EXPLORE_FOLDER_ACTION_KEY);
        fileTreePopup.addAction(action);
    }

    action = getTabAction(OPEN_FILE_ACTION_KEY);
    fileTablePopup.addAction(action);

    action = getTabAction(VIEW_BITZI_ACTION_KEY);
    fileTablePopup.addAction(action);

    fileTablePopup.addSeparator();
    fileTreePopup.addSeparator();

    action = getTabAction(RESCAN_ACTION_KEY);
    fileTablePopup.addAction(action);
    fileTreePopup.addAction(action);

    action = getTabAction(EXPORT_ACTION_KEY);
    fileTablePopup.addAction(action);
    fileTreePopup.addAction(action);

    action = getTabAction(FILTER_ACTION_KEY);
    fileTablePopup.addAction(action);
    fileTreePopup.addAction(action);
}

From source file:picocash.Picocash.java

private JPanel initMainFrame() {
    this.accountPanel = new StandardAccountPanel();
    mainPanel = new JXPanel(new MigLayout("fill, insets 0 0 0 0", "[grow]", "[40!] 0 [31!] 0 [grow] 0 [20!]"));
    headerPanel = new HeaderPanel();
    modePanel = new ModePanel();
    accountContainer = new JXPanel(new MigLayout("fill, insets 0 0 0 0"));
    statisticPanel = new StatisticPanel();
    footerPanel = new FooterPanel();
    headerPanel.addMouseListener(new MouseAdapter() {

        @Override//  w  ww .j  ava  2 s.c o m
        public void mousePressed(MouseEvent arg0) {
            Point clickPoint = new Point(arg0.getPoint());
            SwingUtilities.convertPointToScreen(clickPoint, getMainFrame());
            dX = clickPoint.x - getMainFrame().getX();
            dY = clickPoint.y - getMainFrame().getY();
        }

        @Override
        public void mouseClicked(MouseEvent arg0) {
            if (System.currentTimeMillis() - lastClickOn < DOUBLE_CLICK_TIME) {
                maximize();
            }
            lastClickOn = System.currentTimeMillis();
        }
    });

    headerPanel.addMouseMotionListener(new MouseMotionAdapter() {

        @Override
        public void mouseDragged(MouseEvent arg0) {
            Point dragPoint = new Point(arg0.getPoint());
            SwingUtilities.convertPointToScreen(dragPoint, getMainFrame());
            getMainFrame().setLocation(dragPoint.x - dX, dragPoint.y - dY);
        }
    });

    modePanel.addModePanelSelectionListener(this);

    mainPanel.add(headerPanel, "aligny top, growx, h 40!, wrap");
    mainPanel.add(modePanel, "aligny top, growx, h 31!, wrap");

    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, accountContainer, statisticPanel);
    splitPane.setDividerLocation(0.7d);
    JXPanel tmp = new JXPanel(new MigLayout("fill, insets 0 0 0 0"));
    tmp.add(splitPane, "grow");
    mainPanel.add(tmp, "growx, growy, wrap");

    mainPanel.add(footerPanel, "aligny bottom, growx, h 20!");

    return mainPanel;
}

From source file:pl.otros.logview.gui.Log4jPatternParserEditor.java

private void createGui() {
    this.setLayout(new BorderLayout());
    heading1Font = new JLabel().getFont().deriveFont(20f).deriveFont(Font.BOLD);
    heading2Font = new JLabel().getFont().deriveFont(14f).deriveFont(Font.BOLD);

    loadLog = new JButton("Load log", Icons.FOLDER_OPEN);
    testParser = new JButton("Test parser", Icons.WRENCH_ARROW);
    saveParser = new JButton("Save", Icons.DISK);
    logFileContent = new JTextArea();
    DefaultSyntaxKit.initKit();/*  w  ww  . j  a  va 2 s .  c o  m*/
    propertyEditor = new JEditorPane();

    logFileContent = new JTextArea();
    logViewPanel = new LogViewPanel(new LogDataTableModel(), TableColumns.ALL_WITHOUT_LOG_SOURCE,
            otrosApplication);
    JPanel panelEditorActions = new JPanel(new BorderLayout(5, 5));
    JToolBar actionsToolBar = new JToolBar("Actions");
    actionsToolBar.setFloatable(false);
    actionsToolBar.add(testParser);
    actionsToolBar.add(saveParser);

    JToolBar propertyEditorToolbar = new JToolBar();
    JLabel labelEditProperties = new JLabel("Edit your properties: and test parser");
    labelEditProperties.setFont(heading2Font);
    propertyEditorToolbar.add(labelEditProperties);
    panelEditorActions.add(propertyEditorToolbar, BorderLayout.NORTH);
    panelEditorActions.add(actionsToolBar, BorderLayout.SOUTH);
    panelEditorActions.add(new JScrollPane(propertyEditor));

    logFileContentLabel = new JLabel(" Load your log file, paste from clipboard or drag and drop file. ");
    JToolBar loadToolbar = new JToolBar();
    loadToolbar.add(logFileContentLabel);
    loadToolbar.add(loadLog);
    logFileContentLabel.setFont(heading2Font);
    JPanel logContentPanel = new JPanel(new BorderLayout(5, 5));
    logContentPanel.add(new JScrollPane(logFileContent));
    logContentPanel.add(loadToolbar, BorderLayout.NORTH);

    JSplitPane northSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    northSplit.setOneTouchExpandable(true);
    northSplit.add(logContentPanel);
    northSplit.add(panelEditorActions);

    JPanel southPanel = new JPanel(new BorderLayout(5, 5));
    JLabel labelParsingResult = new JLabel(" Parsing result:");
    labelParsingResult.setFont(heading1Font);
    southPanel.add(labelParsingResult, BorderLayout.NORTH);
    southPanel.add(logViewPanel);

    JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mainSplit.setOneTouchExpandable(true);
    mainSplit.add(northSplit);
    mainSplit.add(southPanel);
    mainSplit.setDividerLocation(0.5f);

    add(mainSplit);

    propertyEditor.setContentType("text/properties");

}

From source file:pl.otros.logview.gui.LogViewPanel.java

public LogViewPanel(final LogDataTableModel dataTableModel, TableColumns[] visibleColumns,
        final OtrosApplication otrosApplication) {
    super();/*w ww . jav  a 2 s .  c om*/
    this.dataTableModel = dataTableModel;
    this.otrosApplication = otrosApplication;
    this.statusObserver = otrosApplication.getStatusObserver();
    configuration = otrosApplication.getConfiguration();

    AllPluginables allPluginable = AllPluginables.getInstance();
    markersContainer = allPluginable.getMarkersContainser();
    markersContainer.addListener(new MarkersMenuReloader());
    logFiltersContainer = allPluginable.getLogFiltersContainer();
    messageColorizersContainer = allPluginable.getMessageColorizers();
    messageFormattersContainer = allPluginable.getMessageFormatters();
    selectedMessageColorizersContainer = new PluginableElementsContainer<MessageColorizer>();
    selectedMessageFormattersContainer = new PluginableElementsContainer<MessageFormatter>();
    for (MessageColorizer messageColorizer : messageColorizersContainer.getElements()) {
        selectedMessageColorizersContainer.addElement(messageColorizer);
    }
    for (MessageFormatter messageFormatter : messageFormattersContainer.getElements()) {
        selectedMessageFormattersContainer.addElement(messageFormatter);
    }
    messageColorizersContainer.addListener(
            new SynchronizePluginableContainerListener<MessageColorizer>(selectedMessageColorizersContainer));
    messageFormattersContainer.addListener(
            new SynchronizePluginableContainerListener<MessageFormatter>(selectedMessageFormattersContainer));

    menuLabelFont = new JLabel().getFont().deriveFont(Font.BOLD);
    filtersPanel = new JPanel();
    logsTablePanel = new JPanel();
    logsMarkersPanel = new JPanel();
    leftPanel = new JPanel(new MigLayout());
    logDetailTextArea = new JTextPane();
    logDetailTextArea.setEditable(false);
    MouseAdapter locationInfo = new LocationClickMouseAdapter(otrosApplication, logDetailTextArea);
    logDetailTextArea.addMouseMotionListener(locationInfo);
    logDetailTextArea.addMouseListener(locationInfo);
    logDetailTextArea.setBorder(BorderFactory.createTitledBorder("Details"));
    logDetailWithRulerScrollPane = RulerBarHelper.wrapTextComponent(logDetailTextArea);
    table = new JTableWith2RowHighliting(dataTableModel);

    // Initialize default column visible before creating context menu
    table.setColumnControlVisible(true);
    final ColumnControlButton columnControlButton = new ColumnControlButton(table) {

        @Override
        public void togglePopup() {
            populatePopup();
            super.togglePopup();
        }

        @Override
        protected List<Action> getAdditionalActions() {
            final List<Action> additionalActions = super.getAdditionalActions();
            final AbstractAction saveLayout = new AbstractAction("Save current to new column layout",
                    Icons.DISK) {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {
                    String newLayoutName = JOptionPane.showInputDialog(table, "New Layout name");
                    if (newLayoutName == null) {
                        return;
                    }
                    newLayoutName = newLayoutName.trim();
                    LOGGER.info(String.format("Saving New column layout '%s'", newLayoutName));
                    ArrayList<String> visibleColNames = new ArrayList<String>();
                    for (TableColumn tc : table.getColumns()) {
                        Object o = tc.getIdentifier();
                        if (!(o instanceof TableColumns)) {
                            LOGGER.severe("TableColumn identifier of unexpected type: "
                                    + tc.getIdentifier().getClass().getName());
                            LOGGER.warning("Throw up a pop-up");
                            return;
                        }
                        TableColumns tcs = (TableColumns) o;
                        visibleColNames.add(tcs.getName());
                    }
                    ColumnLayout columnLayout = new ColumnLayout(newLayoutName, visibleColNames);
                    final List<ColumnLayout> columnLayouts = LogTableFormatConfigView
                            .loadColumnLayouts(configuration);
                    columnLayouts.add(columnLayout);
                    LogTableFormatConfigView.saveColumnLayouts(columnLayouts, configuration);
                    populatePopup();
                }
            };
            additionalActions.add(saveLayout);

            final List<ColumnLayout> columnLayoutNames = LogTableFormatConfigView
                    .loadColumnLayouts(configuration);
            for (final ColumnLayout columnLayout : columnLayoutNames) {
                final String name = columnLayout.getName();
                final AbstractAction applyColumnLayout = new ApplyColumnLayoutAction(name, Icons.EDIT_COLUMNS,
                        columnLayout, table);
                additionalActions.add(applyColumnLayout);
            }
            return additionalActions;
        }
    };
    table.setColumnControl(columnControlButton);

    List<TableColumn> columns = table.getColumns(true);
    for (int i = 0; i < columns.size(); i++) {
        columns.get(i).setIdentifier(TableColumns.getColumnById(i));
    }
    for (TableColumn tableColumn : columns) {
        table.getColumnExt(tableColumn.getIdentifier()).setVisible(false);
    }
    for (TableColumns tableColumns : visibleColumns) {
        table.getColumnExt(tableColumns).setVisible(true);
    }

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    updateColumnsSize();
    table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
    final Renderers renderers = Renderers.getInstance(otrosApplication);
    table.setDefaultRenderer(String.class, new TableMarkDecoratorRenderer(renderers.getStringRenderer()));
    table.setDefaultRenderer(Object.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Object.class)));
    table.setDefaultRenderer(Integer.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Object.class)));
    table.setDefaultRenderer(Level.class, new TableMarkDecoratorRenderer(renderers.getLevelRenderer()));
    table.setDefaultRenderer(Date.class, new TableMarkDecoratorRenderer(renderers.getDateRenderer()));
    final TimeDeltaRenderer timeDeltaRenderer = new TimeDeltaRenderer();
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent listSelectionEvent) {
            final int[] selectedRows = table.getSelectedRows();
            if (selectedRows.length > 0) {
                final int selectedRow = selectedRows[selectedRows.length - 1];
                final Date selectedDate = dataTableModel.getLogData(table.convertRowIndexToModel(selectedRow))
                        .getDate();
                timeDeltaRenderer.setSelectedTimestamp(selectedDate);
                table.repaint();
            }
        }
    });
    table.setDefaultRenderer(TimeDelta.class, new TableMarkDecoratorRenderer(timeDeltaRenderer));

    ((EventSource) configuration.getConfiguration()).addConfigurationListener(new ConfigurationListener() {
        @Override
        public void configurationChanged(ConfigurationEvent ce) {
            if (ce.getType() == AbstractConfiguration.EVENT_SET_PROPERTY && !ce.isBeforeUpdate()) {
                if (ce.getPropertyName().equals(ConfKeys.LOG_TABLE_FORMAT_DATE_FORMAT)) {
                    table.setDefaultRenderer(Date.class, new TableMarkDecoratorRenderer(new DateRenderer(
                            configuration.getString(ConfKeys.LOG_TABLE_FORMAT_DATE_FORMAT, "HH:mm:ss.SSS"))));
                    updateTimeColumnSize();
                } else if (ce.getPropertyName().equals(ConfKeys.LOG_TABLE_FORMAT_LEVEL_RENDERER)) {
                    table.setDefaultRenderer(Level.class,
                            new TableMarkDecoratorRenderer(new LevelRenderer(configuration.get(
                                    LevelRenderer.Mode.class, ConfKeys.LOG_TABLE_FORMAT_LEVEL_RENDERER,
                                    LevelRenderer.Mode.IconsOnly))));
                    updateLevelColumnSize();
                }
            }
        }
    });

    table.setDefaultRenderer(Boolean.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Boolean.class)));
    table.setDefaultRenderer(Note.class, new TableMarkDecoratorRenderer(new NoteRenderer()));
    table.setDefaultRenderer(MarkerColors.class, new TableMarkDecoratorRenderer(new MarkTableRenderer()));
    table.setDefaultEditor(Note.class, new NoteTableEditor());
    table.setDefaultEditor(MarkerColors.class, new MarkTableEditor(otrosApplication));
    table.setDefaultRenderer(ClassWrapper.class,
            new TableMarkDecoratorRenderer(renderers.getClassWrapperRenderer()));
    sorter = new TableRowSorter<LogDataTableModel>(dataTableModel);
    for (int i = 0; i < dataTableModel.getColumnCount(); i++) {
        sorter.setSortable(i, false);
    }
    sorter.setSortable(TableColumns.ID.getColumn(), true);
    sorter.setSortable(TableColumns.TIME.getColumn(), true);
    table.setRowSorter(sorter);

    messageDetailListener = new MessageDetailListener(this, dateFormat, selectedMessageFormattersContainer,
            selectedMessageColorizersContainer);
    table.getSelectionModel().addListSelectionListener(messageDetailListener);
    dataTableModel.addNoteObserver(messageDetailListener);

    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            boolean hasFocus = otrosApplication.getApplicationJFrame().isFocused();
            final boolean enabled = otrosApplication.getConfiguration()
                    .getBoolean(ConfKeys.JUMP_TO_CODE_AUTO_JUMP_ENABLED, false);
            if (hasFocus && enabled && !e.getValueIsAdjusting()) {
                try {
                    final LogData logData = dataTableModel
                            .getLogData(table.convertRowIndexToModel(e.getFirstIndex()));
                    LocationInfo li = new LocationInfo(logData.getClazz(), logData.getMethod(),
                            logData.getFile(), Integer.valueOf(logData.getLine()));
                    final JumpToCodeService jumpToCodeService = otrosApplication.getServices()
                            .getJumpToCodeService();
                    final boolean ideAvailable = jumpToCodeService.isIdeAvailable();
                    if (ideAvailable) {
                        LOGGER.fine("Jumping to " + li);
                        jumpToCodeService.jump(li);
                    }
                } catch (Exception e1) {
                    LOGGER.warning("Can't perform jump to code " + e1.getMessage());
                }

            }
        }
    });

    notes = new JTextArea();
    notes.setEditable(false);
    NoteObserver allNotesObserver = new AllNotesTextAreaObserver(notes);
    dataTableModel.addNoteObserver(allNotesObserver);

    addFiltersGUIsToPanel(filtersPanel);
    logsTablePanel.setLayout(new BorderLayout());
    logsTablePanel.add(new JScrollPane(table));
    JPanel messageDetailsPanel = new JPanel(new BorderLayout());
    messageDetailToolbar = new JToolBar("MessageDetail");
    messageDetailsPanel.add(messageDetailToolbar, BorderLayout.NORTH);
    messageDetailsPanel.add(logDetailWithRulerScrollPane);
    initMessageDetailsToolbar();

    jTabbedPane = new JTabbedPane();
    jTabbedPane.add("Message detail", messageDetailsPanel);
    jTabbedPane.add("All notes", new JScrollPane(notes));

    leftPanel.add(filtersPanel, "wrap, growx");
    leftPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "wrap,growx");
    leftPanel.add(logsMarkersPanel, "wrap,growx");

    JSplitPane splitPaneLogsTableAndDetails = new JSplitPane(JSplitPane.VERTICAL_SPLIT, logsTablePanel,
            jTabbedPane);
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftPanel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED),
            splitPaneLogsTableAndDetails);
    splitPane.setOneTouchExpandable(true);
    this.setLayout(new BorderLayout());
    this.add(splitPane);

    splitPaneLogsTableAndDetails.setDividerLocation(0.5d);
    splitPaneLogsTableAndDetails.setOneTouchExpandable(true);
    splitPane.setDividerLocation(leftPanel.getPreferredSize().width + 10);

    PopupListener popupListener = new PopupListener(new Callable<JPopupMenu>() {
        @Override
        public JPopupMenu call() throws Exception {
            return initTableContextMenu();
        }
    });
    table.addMouseListener(popupListener);
    table.addKeyListener(popupListener);

    PopupListener popupListenerMessageDetailMenu = new PopupListener(new Callable<JPopupMenu>() {
        @Override
        public JPopupMenu call() throws Exception {
            return initMessageDetailPopupMenu();
        }
    });
    logDetailTextArea.addMouseListener(popupListenerMessageDetailMenu);
    logDetailTextArea.addKeyListener(popupListenerMessageDetailMenu);

    dataTableModel.notifyAllNoteObservers(new NoteEvent(EventType.CLEAR, dataTableModel, null, 0));

    table.addKeyListener(new MarkRowBySpaceKeyListener(otrosApplication));
    initAcceptConditions();
}