Search in sources :

Example 71 with JSplitPane

use of javax.swing.JSplitPane in project Smack by igniterealtime.

the class EnhancedDebugger method addBasicPanels.

private void addBasicPanels() {
    JSplitPane allPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    allPane.setOneTouchExpandable(true);
    messagesTable = new DefaultTableModel(new Object[] { "Hide", "Timestamp", "", "", "Message", "Id", "Type", "To", "From" }, 0) {

        // CHECKSTYLE:OFF
        private static final long serialVersionUID = 8136121224474217264L;

        @Override
        public boolean isCellEditable(int rowIndex, int mColIndex) {
            // CHECKSTYLE:ON
            return false;
        }

        @Override
        public Class<?> getColumnClass(int columnIndex) {
            if (columnIndex == 2 || columnIndex == 3) {
                return Icon.class;
            }
            return super.getColumnClass(columnIndex);
        }
    };
    JTable table = new JTable(messagesTable);
    // Allow only single a selection
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // Hide the first column
    table.getColumnModel().getColumn(0).setMaxWidth(0);
    table.getColumnModel().getColumn(0).setMinWidth(0);
    table.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
    table.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
    // Set the column "timestamp" size
    table.getColumnModel().getColumn(1).setMaxWidth(300);
    table.getColumnModel().getColumn(1).setPreferredWidth(90);
    // Set the column "direction" icon size
    table.getColumnModel().getColumn(2).setMaxWidth(50);
    table.getColumnModel().getColumn(2).setPreferredWidth(30);
    // Set the column "packet type" icon size
    table.getColumnModel().getColumn(3).setMaxWidth(50);
    table.getColumnModel().getColumn(3).setPreferredWidth(30);
    // Set the column "Id" size
    table.getColumnModel().getColumn(5).setMaxWidth(100);
    table.getColumnModel().getColumn(5).setPreferredWidth(55);
    // Set the column "type" size
    table.getColumnModel().getColumn(6).setMaxWidth(200);
    table.getColumnModel().getColumn(6).setPreferredWidth(50);
    // Set the column "to" size
    table.getColumnModel().getColumn(7).setMaxWidth(300);
    table.getColumnModel().getColumn(7).setPreferredWidth(90);
    // Set the column "from" size
    table.getColumnModel().getColumn(8).setMaxWidth(300);
    table.getColumnModel().getColumn(8).setPreferredWidth(90);
    // Create a table listener that listen for row selection events
    SelectionListener selectionListener = new SelectionListener(table);
    table.getSelectionModel().addListSelectionListener(selectionListener);
    table.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener);
    allPane.setTopComponent(new JScrollPane(table));
    messageTextArea = new JTextArea();
    messageTextArea.setEditable(false);
    // Add pop-up menu.
    JPopupMenu menu = new JPopupMenu();
    JMenuItem menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(messageTextArea.getText()), null);
        }
    });
    menu.add(menuItem1);
    // Add listener to the text area so the popup menu can come up.
    messageTextArea.addMouseListener(new PopupListener(menu));
    // CHECKSTYLE:OFF
    JPanel sublayout = new JPanel(new BorderLayout());
    sublayout.add(new JScrollPane(messageTextArea), BorderLayout.CENTER);
    JButton clearb = new JButton("Clear All Packets");
    clearb.addActionListener(new AbstractAction() {

        private static final long serialVersionUID = -8576045822764763613L;

        @Override
        public void actionPerformed(ActionEvent e) {
            messagesTable.setRowCount(0);
        }
    });
    // CHECKSTYLE:ON
    sublayout.add(clearb, BorderLayout.NORTH);
    allPane.setBottomComponent(sublayout);
    allPane.setDividerLocation(150);
    tabbedPane.add("All Packets", allPane);
    tabbedPane.setToolTipTextAt(0, "Sent and received packets processed by Smack");
    // Create UI elements for client generated XML traffic.
    final JTextArea sentText = new JTextArea();
    sentText.setWrapStyleWord(true);
    sentText.setLineWrap(true);
    sentText.setEditable(false);
    sentText.setForeground(new Color(112, 3, 3));
    tabbedPane.add("Raw Sent Packets", new JScrollPane(sentText));
    tabbedPane.setToolTipTextAt(1, "Raw text of the sent packets");
    // Add pop-up menu.
    menu = new JPopupMenu();
    menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(sentText.getText()), null);
        }
    });
    JMenuItem menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            sentText.setText("");
        }
    });
    // Add listener to the text area so the popup menu can come up.
    sentText.addMouseListener(new PopupListener(menu));
    menu.add(menuItem1);
    menu.add(menuItem2);
    // Create UI elements for server generated XML traffic.
    final JTextArea receivedText = new JTextArea();
    receivedText.setWrapStyleWord(true);
    receivedText.setLineWrap(true);
    receivedText.setEditable(false);
    receivedText.setForeground(new Color(6, 76, 133));
    tabbedPane.add("Raw Received Packets", new JScrollPane(receivedText));
    tabbedPane.setToolTipTextAt(2, "Raw text of the received packets before Smack process them");
    // Add pop-up menu.
    menu = new JPopupMenu();
    menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(receivedText.getText()), null);
        }
    });
    menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            receivedText.setText("");
        }
    });
    // Add listener to the text area so the popup menu can come up.
    receivedText.addMouseListener(new PopupListener(menu));
    menu.add(menuItem1);
    menu.add(menuItem2);
    // Create a special Reader that wraps the main Reader and logs data to the GUI.
    ObservableReader debugReader = new ObservableReader(reader);
    readerListener = new ReaderListener() {

        @Override
        public void read(final String str) {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER && !EnhancedDebuggerWindow.getInstance().isVisible()) {
                        // Do not add content if the parent is not visible
                        return;
                    }
                    int index = str.lastIndexOf(">");
                    if (index != -1) {
                        if (receivedText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) {
                            try {
                                receivedText.replaceRange("", 0, receivedText.getLineEndOffset(0));
                            } catch (BadLocationException e) {
                                LOGGER.log(Level.SEVERE, "Error with line offset, MAX_TABLE_ROWS is set too low: " + EnhancedDebuggerWindow.MAX_TABLE_ROWS, e);
                            }
                        }
                        receivedText.append(str.substring(0, index + 1));
                        receivedText.append(NEWLINE);
                        if (str.length() > index) {
                            receivedText.append(str.substring(index + 1));
                        }
                    } else {
                        receivedText.append(str);
                    }
                }
            });
        }
    };
    debugReader.addReaderListener(readerListener);
    // Create a special Writer that wraps the main Writer and logs data to the GUI.
    ObservableWriter debugWriter = new ObservableWriter(writer);
    writerListener = new WriterListener() {

        @Override
        public void write(final String str) {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER && !EnhancedDebuggerWindow.getInstance().isVisible()) {
                        // Do not add content if the parent is not visible
                        return;
                    }
                    if (sentText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) {
                        try {
                            sentText.replaceRange("", 0, sentText.getLineEndOffset(0));
                        } catch (BadLocationException e) {
                            LOGGER.log(Level.SEVERE, "Error with line offset, MAX_TABLE_ROWS is set too low: " + EnhancedDebuggerWindow.MAX_TABLE_ROWS, e);
                        }
                    }
                    sentText.append(str);
                    if (str.endsWith(">")) {
                        sentText.append(NEWLINE);
                    }
                }
            });
        }
    };
    debugWriter.addWriterListener(writerListener);
    // Assign the reader/writer objects to use the debug versions. The packet reader
    // and writer will use the debug versions when they are created.
    reader = debugReader;
    writer = debugWriter;
}
Also used : JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) DefaultTableModel(javax.swing.table.DefaultTableModel) JButton(javax.swing.JButton) StringSelection(java.awt.datatransfer.StringSelection) BorderLayout(java.awt.BorderLayout) ObservableWriter(org.jivesoftware.smack.util.ObservableWriter) JMenuItem(javax.swing.JMenuItem) ReaderListener(org.jivesoftware.smack.util.ReaderListener) AbstractAction(javax.swing.AbstractAction) JScrollPane(javax.swing.JScrollPane) ObservableReader(org.jivesoftware.smack.util.ObservableReader) Color(java.awt.Color) WriterListener(org.jivesoftware.smack.util.WriterListener) JPopupMenu(javax.swing.JPopupMenu) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) Clipboard(java.awt.datatransfer.Clipboard) JSplitPane(javax.swing.JSplitPane) BadLocationException(javax.swing.text.BadLocationException) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 72 with JSplitPane

use of javax.swing.JSplitPane in project android-classyshark by google.

the class ClassySharkPanel method buildUI.

private void buildUI() {
    BorderLayout borderLayout = new BorderLayout();
    setLayout(borderLayout);
    ringChartPanel = new RingChartPanel(this);
    toolbar = new Toolbar(this);
    add(toolbar, BorderLayout.NORTH);
    toolbar.addKeyListenerToTypingArea(this);
    displayArea = new DisplayArea(this);
    final JScrollPane rightScrollPane = new JScrollPane(displayArea.onAddComponentToPane());
    theme.applyTo(rightScrollPane);
    filesTree = new FilesTree(this);
    JTabbedPane jTabbedPane = new JTabbedPane();
    JScrollPane leftScrollPane = new JScrollPane(filesTree.getJTree());
    theme.applyTo(leftScrollPane);
    jTabbedPane.addTab("Classes", leftScrollPane);
    methodsCountPanel = new MethodsCountPanel(this);
    jTabbedPane.addTab("Methods count", methodsCountPanel);
    theme.applyTo(jTabbedPane);
    jTabbedPane.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            int dividerLocation1 = jSplitPane.getDividerLocation();
            JTabbedPane jTabbedPane1 = (JTabbedPane) e.getSource();
            if (jTabbedPane1.getSelectedIndex() == 0) {
                jSplitPane.setRightComponent(rightScrollPane);
            } else {
                jSplitPane.setRightComponent(ringChartPanel);
            }
            jSplitPane.setDividerLocation(dividerLocation1);
        }
    });
    jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    jSplitPane.setDividerSize(3);
    jSplitPane.setPreferredSize(new Dimension(1000, 700));
    jSplitPane.add(jTabbedPane, JSplitPane.LEFT);
    jSplitPane.add(rightScrollPane, JSplitPane.RIGHT);
    jSplitPane.getLeftComponent().setVisible(true);
    jSplitPane.setDividerLocation(300);
    theme.applyTo(jSplitPane);
    add(jSplitPane, BorderLayout.CENTER);
}
Also used : DisplayArea(com.google.classyshark.gui.panel.displayarea.DisplayArea) IDisplayArea(com.google.classyshark.gui.panel.displayarea.IDisplayArea) JScrollPane(javax.swing.JScrollPane) JTabbedPane(javax.swing.JTabbedPane) Dimension(java.awt.Dimension) RingChartPanel(com.google.classyshark.gui.panel.chart.RingChartPanel) BorderLayout(java.awt.BorderLayout) ChangeEvent(javax.swing.event.ChangeEvent) MethodsCountPanel(com.google.classyshark.gui.panel.methodscount.MethodsCountPanel) ChangeListener(javax.swing.event.ChangeListener) JSplitPane(javax.swing.JSplitPane) FilesTree(com.google.classyshark.gui.panel.tree.FilesTree) Toolbar(com.google.classyshark.gui.panel.toolbar.Toolbar)

Example 73 with JSplitPane

use of javax.swing.JSplitPane in project binnavi by google.

the class CAddressSpaceNodeComponent method createGui.

/**
   * Creates all the necessary GUI components of this component.
   */
private void createGui() {
    final JPanel topPanel = new JPanel(new BorderLayout());
    final JPanel innerTopPanel = new JPanel(new BorderLayout());
    final JPanel debuggerChooserPanel = new JPanel(new BorderLayout());
    debuggerChooserPanel.setBorder(new TitledBorder("Address Space Debugger"));
    m_debuggerCombo = new CDebuggerComboBox(new CDebuggerComboModel(m_debuggerContainer));
    m_debuggerCombo.setSelectedDebugger(m_addressSpace.getConfiguration().getDebuggerTemplate());
    final JPanel debuggerComboPanel = new JPanel(new BorderLayout());
    debuggerComboPanel.add(m_debuggerCombo, BorderLayout.CENTER);
    debuggerChooserPanel.add(debuggerComboPanel, BorderLayout.CENTER);
    innerTopPanel.add(m_stdEditPanel);
    innerTopPanel.add(debuggerChooserPanel, BorderLayout.SOUTH);
    topPanel.add(innerTopPanel);
    final JPanel buttonPanel = new JPanel(new GridLayout(1, 2));
    buttonPanel.setBorder(new EmptyBorder(0, 0, 5, 2));
    buttonPanel.add(new JPanel());
    buttonPanel.add(m_saveButton);
    topPanel.add(buttonPanel, BorderLayout.SOUTH);
    final JPanel bottomPanel = new CTablePanel<INaviModule>(m_table, new CModuleFilterCreator(), new CModuleFilterHelp());
    bottomPanel.setBorder(m_titledBorder);
    bottomPanel.add(new JScrollPane(m_table));
    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, topPanel, bottomPanel);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(splitPane.getMinimumDividerLocation());
    splitPane.setResizeWeight(0.5);
    setBorder(new EmptyBorder(0, 0, 0, 1));
    add(splitPane);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) CDebuggerComboModel(com.google.security.zynamics.binnavi.Gui.DebuggerComboBox.CDebuggerComboModel) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) CModuleFilterCreator(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.filters.CModuleFilterCreator) CDebuggerComboBox(com.google.security.zynamics.binnavi.Gui.DebuggerComboBox.CDebuggerComboBox) CModuleFilterHelp(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.AddressSpace.Component.Help.CModuleFilterHelp) TitledBorder(javax.swing.border.TitledBorder) EmptyBorder(javax.swing.border.EmptyBorder) JSplitPane(javax.swing.JSplitPane) CTablePanel(com.google.security.zynamics.binnavi.Gui.FilterPanel.CTablePanel)

Example 74 with JSplitPane

use of javax.swing.JSplitPane in project binnavi by google.

the class CTagNodeComponent method createGui.

/**
   * Creates the GUI of the component.
   */
private void createGui() {
    final JPanel outerNamePanel = new JPanel(new BorderLayout());
    outerNamePanel.setBorder(new TitledBorder("Tag"));
    final JPanel namePanel = new JPanel(new BorderLayout());
    namePanel.setBorder(new EmptyBorder(0, 0, 5, 0));
    final JLabel nameLabel = new CHelpLabel("Name" + ":", new CNameHelp());
    nameLabel.setPreferredSize(new Dimension(110, 25));
    namePanel.add(nameLabel, BorderLayout.WEST);
    namePanel.add(m_nameTextField, BorderLayout.CENTER);
    outerNamePanel.add(namePanel, BorderLayout.CENTER);
    final JPanel outerDescriptionPanel = new JPanel(new BorderLayout());
    outerDescriptionPanel.setBorder(new EmptyBorder(5, 0, 0, 0));
    final JPanel descriptionPanel = new JPanel(new BorderLayout());
    descriptionPanel.setBorder(new TitledBorder("Description"));
    descriptionPanel.setMinimumSize(new Dimension(0, 120));
    descriptionPanel.add(new JScrollPane(m_descriptionField));
    outerDescriptionPanel.add(descriptionPanel, BorderLayout.CENTER);
    final JPanel buttonPanel = new JPanel(new GridLayout(1, 2));
    buttonPanel.add(new JPanel());
    buttonPanel.setBorder(new EmptyBorder(5, 0, 5, 2));
    buttonPanel.add(m_saveButton);
    final JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(outerNamePanel, BorderLayout.NORTH);
    topPanel.add(outerDescriptionPanel, BorderLayout.CENTER);
    topPanel.add(buttonPanel, BorderLayout.SOUTH);
    final JPanel bottomPanel = new JPanel(new BorderLayout());
    bottomPanel.setBorder(m_tableBorder);
    final JScrollPane scrollPane = new JScrollPane(m_childrenTagTable);
    bottomPanel.add(scrollPane, BorderLayout.CENTER);
    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, topPanel, bottomPanel);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(splitPane.getMinimumDividerLocation());
    splitPane.setResizeWeight(0.5);
    add(splitPane);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) JLabel(javax.swing.JLabel) CHelpLabel(com.google.security.zynamics.binnavi.Help.CHelpLabel) Dimension(java.awt.Dimension) TitledBorder(javax.swing.border.TitledBorder) EmptyBorder(javax.swing.border.EmptyBorder) JSplitPane(javax.swing.JSplitPane) CNameHelp(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Tag.Component.Help.CNameHelp)

Example 75 with JSplitPane

use of javax.swing.JSplitPane in project binnavi by google.

the class CModuleOverviewPanel method createGui.

/**
   * Creates the GUI elements of the component.
   */
private void createGui() {
    final JPanel topPanel = new JPanel(new BorderLayout());
    final JPanel innerTopPanel = new JPanel(new BorderLayout());
    topPanel.add(innerTopPanel);
    innerTopPanel.add(m_stdEditPanel);
    innerTopPanel.add(m_debuggerPanel, BorderLayout.SOUTH);
    final JPanel buttonPanel = new JPanel(new GridLayout(1, 2));
    buttonPanel.setBorder(new EmptyBorder(0, 0, 5, 2));
    buttonPanel.add(new JPanel());
    buttonPanel.add(m_saveButton);
    topPanel.add(buttonPanel, BorderLayout.SOUTH);
    final JPanel innerSp = new JPanel(new BorderLayout());
    m_middlePanel.setPreferredSize(new Dimension(m_middlePanel.getPreferredSize().width, 75));
    innerSp.add(m_middlePanel, BorderLayout.NORTH);
    innerSp.add(m_bottomPanel, BorderLayout.CENTER);
    final JSplitPane outerSp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, topPanel, innerSp);
    outerSp.setOneTouchExpandable(true);
    outerSp.setDividerLocation(outerSp.getMinimumDividerLocation());
    outerSp.setResizeWeight(0.5);
    final JPanel innerPanel = new JPanel(new BorderLayout());
    innerPanel.add(outerSp);
    add(innerPanel);
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) Dimension(java.awt.Dimension) EmptyBorder(javax.swing.border.EmptyBorder) JSplitPane(javax.swing.JSplitPane)

Aggregations

JSplitPane (javax.swing.JSplitPane)109 BorderLayout (java.awt.BorderLayout)69 JPanel (javax.swing.JPanel)64 JScrollPane (javax.swing.JScrollPane)54 Dimension (java.awt.Dimension)40 JLabel (javax.swing.JLabel)31 JButton (javax.swing.JButton)17 JTextArea (javax.swing.JTextArea)16 FlowLayout (java.awt.FlowLayout)15 Insets (java.awt.Insets)15 GridBagLayout (java.awt.GridBagLayout)14 GridBagConstraints (java.awt.GridBagConstraints)13 JTable (javax.swing.JTable)13 Container (java.awt.Container)10 GridLayout (java.awt.GridLayout)10 ArrayList (java.util.ArrayList)10 BoxLayout (javax.swing.BoxLayout)10 JComponent (javax.swing.JComponent)10 JTabbedPane (javax.swing.JTabbedPane)10 EmptyBorder (javax.swing.border.EmptyBorder)10