Search in sources :

Example 66 with JTabbedPane

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

the class LiteDebugger method createDebug.

/**
     * Creates the debug process, which is a GUI window that displays XML traffic.
     */
private void createDebug() {
    frame = new JFrame("Smack Debug Window -- " + connection.getXMPPServiceDomain() + ":" + connection.getPort());
    // Add listener for window closing event 
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            rootWindowClosing(evt);
        }
    });
    // We'll arrange the UI into four tabs. The first tab contains all data, the second
    // client generated XML, the third server generated XML, and the fourth is packet
    // data from the server as seen by Smack.
    JTabbedPane tabbedPane = new JTabbedPane();
    JPanel allPane = new JPanel();
    allPane.setLayout(new GridLayout(3, 1));
    tabbedPane.add("All", allPane);
    // Create UI elements for client generated XML traffic.
    final JTextArea sentText1 = new JTextArea();
    final JTextArea sentText2 = new JTextArea();
    sentText1.setEditable(false);
    sentText2.setEditable(false);
    sentText1.setForeground(new Color(112, 3, 3));
    sentText2.setForeground(new Color(112, 3, 3));
    allPane.add(new JScrollPane(sentText1));
    tabbedPane.add("Sent", new JScrollPane(sentText2));
    // 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(sentText1.getText()), null);
        }
    });
    JMenuItem menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            sentText1.setText("");
            sentText2.setText("");
        }
    });
    // Add listener to the text area so the popup menu can come up.
    MouseListener popupListener = new PopupListener(menu);
    sentText1.addMouseListener(popupListener);
    sentText2.addMouseListener(popupListener);
    menu.add(menuItem1);
    menu.add(menuItem2);
    // Create UI elements for server generated XML traffic.
    final JTextArea receivedText1 = new JTextArea();
    final JTextArea receivedText2 = new JTextArea();
    receivedText1.setEditable(false);
    receivedText2.setEditable(false);
    receivedText1.setForeground(new Color(6, 76, 133));
    receivedText2.setForeground(new Color(6, 76, 133));
    allPane.add(new JScrollPane(receivedText1));
    tabbedPane.add("Received", new JScrollPane(receivedText2));
    // 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(receivedText1.getText()), null);
        }
    });
    menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            receivedText1.setText("");
            receivedText2.setText("");
        }
    });
    // Add listener to the text area so the popup menu can come up.
    popupListener = new PopupListener(menu);
    receivedText1.addMouseListener(popupListener);
    receivedText2.addMouseListener(popupListener);
    menu.add(menuItem1);
    menu.add(menuItem2);
    // Create UI elements for interpreted XML traffic.
    final JTextArea interpretedText1 = new JTextArea();
    final JTextArea interpretedText2 = new JTextArea();
    interpretedText1.setEditable(false);
    interpretedText2.setEditable(false);
    interpretedText1.setForeground(new Color(1, 94, 35));
    interpretedText2.setForeground(new Color(1, 94, 35));
    allPane.add(new JScrollPane(interpretedText1));
    tabbedPane.add("Interpreted", new JScrollPane(interpretedText2));
    // 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(interpretedText1.getText()), null);
        }
    });
    menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            interpretedText1.setText("");
            interpretedText2.setText("");
        }
    });
    // Add listener to the text area so the popup menu can come up.
    popupListener = new PopupListener(menu);
    interpretedText1.addMouseListener(popupListener);
    interpretedText2.addMouseListener(popupListener);
    menu.add(menuItem1);
    menu.add(menuItem2);
    frame.getContentPane().add(tabbedPane);
    frame.setSize(550, 400);
    frame.setVisible(true);
    // 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(String str) {
            int index = str.lastIndexOf(">");
            if (index != -1) {
                receivedText1.append(str.substring(0, index + 1));
                receivedText2.append(str.substring(0, index + 1));
                receivedText1.append(NEWLINE);
                receivedText2.append(NEWLINE);
                if (str.length() > index) {
                    receivedText1.append(str.substring(index + 1));
                    receivedText2.append(str.substring(index + 1));
                }
            } else {
                receivedText1.append(str);
                receivedText2.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(String str) {
            sentText1.append(str);
            sentText2.append(str);
            if (str.endsWith(">")) {
                sentText1.append(NEWLINE);
                sentText2.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;
    // Create a thread that will listen for all incoming packets and write them to
    // the GUI. This is what we call "interpreted" packet data, since it's the packet
    // data as Smack sees it and not as it's coming in as raw XML.
    listener = new StanzaListener() {

        @Override
        public void processStanza(Stanza packet) {
            interpretedText1.append(packet.toXML().toString());
            interpretedText2.append(packet.toXML().toString());
            interpretedText1.append(NEWLINE);
            interpretedText2.append(NEWLINE);
        }
    };
}
Also used : JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) JTabbedPane(javax.swing.JTabbedPane) WindowAdapter(java.awt.event.WindowAdapter) StanzaListener(org.jivesoftware.smack.StanzaListener) StringSelection(java.awt.datatransfer.StringSelection) GridLayout(java.awt.GridLayout) MouseListener(java.awt.event.MouseListener) JFrame(javax.swing.JFrame) ObservableWriter(org.jivesoftware.smack.util.ObservableWriter) JMenuItem(javax.swing.JMenuItem) ReaderListener(org.jivesoftware.smack.util.ReaderListener) JScrollPane(javax.swing.JScrollPane) ObservableReader(org.jivesoftware.smack.util.ObservableReader) Color(java.awt.Color) WriterListener(org.jivesoftware.smack.util.WriterListener) Stanza(org.jivesoftware.smack.packet.Stanza) JPopupMenu(javax.swing.JPopupMenu) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) Clipboard(java.awt.datatransfer.Clipboard)

Example 67 with JTabbedPane

use of javax.swing.JTabbedPane 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 68 with JTabbedPane

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

the class TypeDialog method createControls.

private void createControls(final BaseType baseType) {
    if (baseType == null) {
        atomicTypePanel = new AtomicTypePanel(this, typeManager);
        pointerTypePanel = new PointerTypePanel(this, typeManager);
        arrayTypePanel = new ArrayTypePanel(this, typeManager);
        structureTypePanel = new StructureTypePanel(this, typeManager);
        unionTypePanel = new UnionTypePanel(this, typeManager);
        functionPrototypePanel = new PrototypeTypePanel(this, typeManager);
    } else {
        switch(baseType.getCategory()) {
            case ATOMIC:
                atomicTypePanel = new AtomicTypePanel(this, typeManager, baseType);
                break;
            case POINTER:
                pointerTypePanel = new PointerTypePanel(this, typeManager, baseType);
                break;
            case ARRAY:
                arrayTypePanel = new ArrayTypePanel(this, typeManager, baseType);
                break;
            case STRUCT:
                structureTypePanel = new StructureTypePanel(this, typeManager, baseType);
                break;
            case UNION:
                unionTypePanel = new UnionTypePanel(this, typeManager, baseType);
                break;
            case FUNCTION_PROTOTYPE:
                functionPrototypePanel = new PrototypeTypePanel(this, typeManager, baseType);
                break;
            default:
                throw new IllegalStateException("IE02854: Unknown type category.");
        }
    }
    tabbedPane = new JTabbedPane();
    addTab(atomicTypePanel, "Atomic type");
    addTab(pointerTypePanel, "Pointer type");
    addTab(arrayTypePanel, "Array type");
    addTab(structureTypePanel, "Structure type");
    addTab(unionTypePanel, "Union type");
    addTab(functionPrototypePanel, "Function prototype");
    tabbedPane.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            final JTabbedPane pane = (JTabbedPane) e.getSource();
            TypeDialog.this.currentPanel = panels.get(pane.getSelectedIndex());
        }
    });
    setActivePanel(baseType);
    setBounds(100, 100, 516, 325);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(tabbedPane);
    createButtons();
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) BorderLayout(java.awt.BorderLayout) JTabbedPane(javax.swing.JTabbedPane) ChangeListener(javax.swing.event.ChangeListener)

Example 69 with JTabbedPane

use of javax.swing.JTabbedPane in project LuaViewSDK by alibaba.

the class SrcCodeCenter method running.

public void running(String fileName, String lineNumber) {
    try {
        if (fileName != null) {
            SrcCodeViewer viewer = table.get(fileName);
            if (viewer != null) {
                viewer.gotoLine(Integer.parseInt(lineNumber.trim()));
                JTabbedPane tabbedPane = center.frame.getTabbedPane();
                tabbedPane.setSelectedComponent(viewer);
                if (center.frame.isAlwaysOnTop()) {
                    center.frame.setAlwaysOnTop(true);
                }
                if (center.frame.isVisible()) {
                    center.frame.setVisible(true);
                }
                center.frame.setIsDebugging(true);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
// System.out.println(fileName + lineNumber);
}
Also used : JTabbedPane(javax.swing.JTabbedPane)

Example 70 with JTabbedPane

use of javax.swing.JTabbedPane in project LuaViewSDK by alibaba.

the class SrcCodeCenter method loadfile.

public SrcCodeViewer loadfile(String fileName, String content) {
    content = content.replace("\t", "    ");
    JTabbedPane tabbedPane = center.frame.getTabbedPane();
    if (fileName != null) {
        SrcCodeViewer temp = table.get(fileName);
        tabbedPane.remove(temp);
        table.remove(fileName);
    }
    SrcCodeViewer viewer = new SrcCodeViewer(fileName, content, this.center);
    this.addToTabbedPane(tabbedPane, fileName, viewer);
    table.put(fileName, viewer);
    return viewer;
}
Also used : JTabbedPane(javax.swing.JTabbedPane)

Aggregations

JTabbedPane (javax.swing.JTabbedPane)104 JPanel (javax.swing.JPanel)51 BorderLayout (java.awt.BorderLayout)33 JLabel (javax.swing.JLabel)26 JButton (javax.swing.JButton)25 JScrollPane (javax.swing.JScrollPane)23 Dimension (java.awt.Dimension)19 ActionEvent (java.awt.event.ActionEvent)18 ActionListener (java.awt.event.ActionListener)15 JCheckBox (javax.swing.JCheckBox)14 ChangeListener (javax.swing.event.ChangeListener)13 GridBagLayout (java.awt.GridBagLayout)12 BoxLayout (javax.swing.BoxLayout)12 ChangeEvent (javax.swing.event.ChangeEvent)12 GridBagConstraints (java.awt.GridBagConstraints)11 Insets (java.awt.Insets)11 ArrayList (java.util.ArrayList)10 JFrame (javax.swing.JFrame)10 JMenuItem (javax.swing.JMenuItem)10 JSplitPane (javax.swing.JSplitPane)10