Search in sources :

Example 41 with TreeSelectionListener

use of javax.swing.event.TreeSelectionListener in project airavata by apache.

the class AmazonS3UtilsWindow method initGUI.

@SuppressWarnings("serial")
protected void initGUI() {
    /* Upload Panel */
    this.fileTextField = new XBayaTextField();
    XBayaLabel fileLabel = new XBayaLabel("Upload File Path", this.fileTextField);
    this.uploadBucketTextField = new XBayaTextField();
    XBayaLabel uploadBucketLabel = new XBayaLabel("Bucket Name", this.uploadBucketTextField);
    GridPanel uploadPanel = new GridPanel();
    uploadPanel.getSwingComponent().setBorder(BorderFactory.createTitledBorder("Upload"));
    uploadPanel.add(fileLabel);
    uploadPanel.add(this.fileTextField);
    uploadPanel.add(uploadBucketLabel);
    uploadPanel.add(this.uploadBucketTextField);
    uploadPanel.layout(2, 2, GridPanel.WEIGHT_NONE, 1);
    /* Download Panel */
    if (AmazonCredential.getInstance().getAwsAccessKeyId().equals("AKIAI3GNMQVYA5LSQNEQ")) {
        // Avoid to use default Aws Access Key
        JOptionPane.showMessageDialog(AmazonS3UtilsWindow.this.dialog.getDialog(), "Aws Access Key not set!", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    this.downloadBucketTextField = new XBayaTextField();
    XBayaLabel downloadBucketLabel = new XBayaLabel("Bucket Name", this.downloadBucketTextField);
    this.keyTextField = new XBayaTextField();
    XBayaLabel keyLabel = new XBayaLabel("Key Name", this.keyTextField);
    this.folderTextField = new XBayaTextField();
    XBayaLabel folderLabel = new XBayaLabel("Download Location", this.folderTextField);
    GridPanel downloadPanel = new GridPanel();
    downloadPanel.getSwingComponent().setBorder(BorderFactory.createTitledBorder("Download"));
    downloadPanel.add(downloadBucketLabel);
    downloadPanel.add(this.downloadBucketTextField);
    downloadPanel.add(keyLabel);
    downloadPanel.add(this.keyTextField);
    downloadPanel.add(folderLabel);
    downloadPanel.add(this.folderTextField);
    downloadPanel.layout(3, 2, GridPanel.WEIGHT_NONE, 1);
    /* Button Panel */
    JButton refreshButton = new JButton("Connect/Refresh");
    refreshButton.addActionListener(new AbstractAction() {

        private ChangeCredentialWindow credentialWindow;

        @Override
        public void actionPerformed(ActionEvent e) {
            if (AmazonCredential.getInstance().getAwsAccessKeyId().isEmpty() || AmazonCredential.getInstance().getAwsSecretAccessKey().isEmpty()) {
                JOptionPane.showMessageDialog(AmazonS3UtilsWindow.this.dialog.getDialog(), "Aws Access Key not set!", "Error", JOptionPane.ERROR_MESSAGE);
                if (this.credentialWindow == null) {
                    this.credentialWindow = new ChangeCredentialWindow(AmazonS3UtilsWindow.this.dialog.getDialog());
                }
                try {
                    this.credentialWindow.show();
                } catch (Exception e1) {
                    xBayaEngine.getGUI().getErrorWindow().error(e1);
                }
                return;
            }
            AmazonS3UtilsWindow.this.s3Tree.clean();
            BucketsLoader bucketsLoader = new BucketsLoader(xBayaEngine.getGUI(), window.dialog.getDialog());
            bucketsLoader.load(getS3Service(), AmazonS3UtilsWindow.this.s3Tree);
        }
    });
    JButton uploadButton = new JButton("Upload");
    uploadButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if ((window.fileTextField.getText().length() != 0) && (window.uploadBucketTextField.getText().length() != 0)) {
                S3Uploader s3Uploader = new S3Uploader(xBayaEngine, window.dialog.getDialog());
                s3Uploader.upload(getS3Service(), AmazonS3UtilsWindow.this.s3Tree, window.uploadBucketTextField.getText(), window.fileTextField.getText());
                window.fileTextField.setText("");
                window.folderTextField.setText("");
            } else {
                xBayaEngine.getGUI().getErrorWindow().error(window.dialog.getDialog(), "Please give input to every upload fields");
            }
        }
    });
    JButton downloadButton = new JButton("Download");
    downloadButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if ((window.downloadBucketTextField.getText().length() != 0) && (window.keyTextField.getText().length() != 0) && (window.folderTextField.getText().length() != 0)) {
                S3Downloader s3Downloader = new S3Downloader(xBayaEngine, window.dialog.getDialog());
                s3Downloader.download(getS3Service(), window.downloadBucketTextField.getText(), window.keyTextField.getText(), window.folderTextField.getText());
                window.downloadBucketTextField.setText("");
                window.keyTextField.setText("");
                window.folderTextField.setText("");
            } else {
                xBayaEngine.getGUI().getErrorWindow().error(window.dialog.getDialog(), "Please give input to every download fields");
            }
        }
    });
    JButton fileButton = new JButton("Choose File & Flolder");
    fileButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final JFileChooser fc = new JFileChooser();
            fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            int returnVal = fc.showOpenDialog(AmazonS3UtilsWindow.this.dialog.getDialog());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                String filePath = fc.getSelectedFile().getAbsolutePath();
                File file = fc.getSelectedFile();
                if (file.isFile()) {
                    window.fileTextField.setText(filePath);
                    window.folderTextField.setText("");
                } else if (file.isDirectory()) {
                    window.folderTextField.setText(filePath);
                    window.fileTextField.setText("");
                }
            }
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(refreshButton);
    buttonPanel.add(uploadButton);
    buttonPanel.add(downloadButton);
    buttonPanel.add(fileButton);
    buttonPanel.add(cancelButton);
    /* Main Panel */
    GridPanel mainPanel = new GridPanel(true);
    this.s3Tree = new S3Tree();
    mainPanel.add(new JScrollPane(this.s3Tree));
    mainPanel.add(uploadPanel);
    mainPanel.add(downloadPanel);
    mainPanel.layout(3, 1, 0, GridPanel.WEIGHT_EQUALLY);
    this.s3Tree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = AmazonS3UtilsWindow.this.s3Tree.getSelectedNode();
            if (node == null)
                return;
            Object nodeInfo = node.getUserObject();
            String bucketName;
            String downloadPanelBucketName = "";
            if (node.isLeaf() && node.getParent() != null) {
                // Node is probably a key
                DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
                bucketName = (String) parentNode.getUserObject();
                if (!bucketName.equals("S3 Contents")) {
                    // Node is indeed a key
                    downloadPanelBucketName = (String) parentNode.getUserObject();
                    String currentNodeName = (String) node.getUserObject();
                    int index = currentNodeName.lastIndexOf('/');
                    index = index >= 0 ? index : 0;
                    if (index > 0) {
                        bucketName = bucketName + "/" + currentNodeName.substring(0, index);
                    }
                    String keyName = (String) nodeInfo;
                    window.keyTextField.setText(keyName);
                } else // Node is a bucket
                {
                    bucketName = (String) nodeInfo;
                    window.keyTextField.setText("");
                }
            } else {
                // Node is a bucket
                bucketName = (String) nodeInfo;
                window.keyTextField.setText("");
            }
            window.uploadBucketTextField.setText(bucketName);
            window.downloadBucketTextField.setText(downloadPanelBucketName);
        }
    });
    this.dialog = new XBayaDialog(xBayaEngine.getGUI(), "Amazon S3 Upload/Download Tool", mainPanel, buttonPanel);
}
Also used : XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ActionEvent(java.awt.event.ActionEvent) S3Tree(org.apache.airavata.xbaya.ui.widgets.amazon.S3Tree) TreeSelectionListener(javax.swing.event.TreeSelectionListener) S3ServiceException(org.jets3t.service.S3ServiceException) GridPanel(org.apache.airavata.xbaya.ui.widgets.GridPanel) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) File(java.io.File) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 42 with TreeSelectionListener

use of javax.swing.event.TreeSelectionListener in project netbeans-mmd-plugin by raydac.

the class KnowledgeViewPane method initTree.

private void initTree() {
    myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    UIUtil.setLineStyleAngled(myTree);
    myTree.setRootVisible(false);
    myTree.setShowsRootHandles(true);
    myTree.expandPath(new TreePath(myTree.getModel().getRoot()));
    myTree.setSelectionPath(new TreePath(myTree.getModel().getRoot()));
    EditSourceOnDoubleClickHandler.install(myTree);
    ToolTipManager.sharedInstance().registerComponent(myTree);
    TreeUtil.installActions(myTree);
    myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            fireTreeChangeListener();
        }
    });
    myTree.getModel().addTreeModelListener(new TreeModelListener() {

        @Override
        public void treeNodesChanged(TreeModelEvent e) {
            fireTreeChangeListener();
        }

        @Override
        public void treeNodesInserted(TreeModelEvent e) {
            fireTreeChangeListener();
        }

        @Override
        public void treeNodesRemoved(TreeModelEvent e) {
            fireTreeChangeListener();
        }

        @Override
        public void treeStructureChanged(TreeModelEvent e) {
            fireTreeChangeListener();
        }
    });
    new SpeedSearch(myTree);
    myTree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                final DefaultMutableTreeNode selectedNode = ((ProjectViewTree) myTree).getSelectedNode();
                if (selectedNode != null && !selectedNode.isLeaf()) {
                    return;
                }
                DataContext dataContext = DataManager.getInstance().getDataContext(myTree);
                OpenSourceUtil.openSourcesFrom(dataContext, false);
            } else if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
                if (e.isConsumed())
                    return;
                PsiCopyPasteManager copyPasteManager = PsiCopyPasteManager.getInstance();
                boolean[] isCopied = new boolean[1];
                if (copyPasteManager.getElements(isCopied) != null && !isCopied[0]) {
                    copyPasteManager.clear();
                    e.consume();
                }
            }
        }
    });
    CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP);
}
Also used : TreeModelEvent(javax.swing.event.TreeModelEvent) TreeModelListener(javax.swing.event.TreeModelListener) KeyAdapter(java.awt.event.KeyAdapter) PsiCopyPasteManager(com.intellij.ide.PsiCopyPasteManager) TreeSelectionListener(javax.swing.event.TreeSelectionListener) KeyEvent(java.awt.event.KeyEvent) DataContext(com.intellij.openapi.actionSystem.DataContext) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 43 with TreeSelectionListener

use of javax.swing.event.TreeSelectionListener in project antlr4 by antlr.

the class TreeViewer method showInDialog.

protected static JFrame showInDialog(final TreeViewer viewer) {
    final JFrame dialog = new JFrame();
    dialog.setTitle("Parse Tree Inspector");
    final Preferences prefs = Preferences.userNodeForPackage(TreeViewer.class);
    // Make new content panes
    final Container mainPane = new JPanel(new BorderLayout(5, 5));
    final Container contentPane = new JPanel(new BorderLayout(0, 0));
    contentPane.setBackground(Color.white);
    // Wrap viewer in scroll pane
    JScrollPane scrollPane = new JScrollPane(viewer);
    // Make the scrollpane (containing the viewer) the center component
    contentPane.add(scrollPane, BorderLayout.CENTER);
    JPanel wrapper = new JPanel(new FlowLayout());
    // Add button to bottom
    JPanel bottomPanel = new JPanel(new BorderLayout(0, 0));
    contentPane.add(bottomPanel, BorderLayout.SOUTH);
    JButton ok = new JButton("OK");
    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
        }
    });
    wrapper.add(ok);
    // Add an export-to-png button right of the "OK" button
    JButton png = new JButton("Export as PNG");
    png.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            generatePNGFile(viewer, dialog);
        }
    });
    wrapper.add(png);
    // Add an export-to-png button right of the "OK" button
    JButton svg = new JButton("Export as SVG");
    svg.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            generateSVGFile(viewer, dialog);
        }
    });
    wrapper.add(svg);
    bottomPanel.add(wrapper, BorderLayout.SOUTH);
    // Add scale slider
    double lastKnownViewerScale = prefs.getDouble(DIALOG_VIEWER_SCALE_PREFS_KEY, viewer.getScale());
    viewer.setScale(lastKnownViewerScale);
    int sliderValue = (int) ((lastKnownViewerScale - 1.0) * 1000);
    final JSlider scaleSlider = new JSlider(JSlider.HORIZONTAL, -999, 1000, sliderValue);
    scaleSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            int v = scaleSlider.getValue();
            viewer.setScale(v / 1000.0 + 1.0);
        }
    });
    bottomPanel.add(scaleSlider, BorderLayout.CENTER);
    // Add a JTree representing the parser tree of the input.
    JPanel treePanel = new JPanel(new BorderLayout(5, 5));
    // An "empty" icon that will be used for the JTree's nodes.
    Icon empty = new EmptyIcon();
    UIManager.put("Tree.closedIcon", empty);
    UIManager.put("Tree.openIcon", empty);
    UIManager.put("Tree.leafIcon", empty);
    Tree parseTreeRoot = viewer.getTree().getRoot();
    TreeNodeWrapper nodeRoot = new TreeNodeWrapper(parseTreeRoot, viewer);
    fillTree(nodeRoot, parseTreeRoot, viewer);
    final JTree tree = new JTree(nodeRoot);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            JTree selectedTree = (JTree) e.getSource();
            TreePath path = selectedTree.getSelectionPath();
            if (path != null) {
                TreeNodeWrapper treeNode = (TreeNodeWrapper) path.getLastPathComponent();
                // Set the clicked AST.
                viewer.setTree((Tree) treeNode.getUserObject());
            }
        }
    });
    treePanel.add(new JScrollPane(tree));
    // Create the pane for both the JTree and the AST
    final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePanel, contentPane);
    mainPane.add(splitPane, BorderLayout.CENTER);
    dialog.setContentPane(mainPane);
    // make viz
    WindowListener exitListener = new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            prefs.putInt(DIALOG_WIDTH_PREFS_KEY, (int) dialog.getSize().getWidth());
            prefs.putInt(DIALOG_HEIGHT_PREFS_KEY, (int) dialog.getSize().getHeight());
            prefs.putDouble(DIALOG_X_PREFS_KEY, dialog.getLocationOnScreen().getX());
            prefs.putDouble(DIALOG_Y_PREFS_KEY, dialog.getLocationOnScreen().getY());
            prefs.putInt(DIALOG_DIVIDER_LOC_PREFS_KEY, splitPane.getDividerLocation());
            prefs.putDouble(DIALOG_VIEWER_SCALE_PREFS_KEY, viewer.getScale());
            dialog.setVisible(false);
            dialog.dispose();
        }
    };
    dialog.addWindowListener(exitListener);
    dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    int width = prefs.getInt(DIALOG_WIDTH_PREFS_KEY, 600);
    int height = prefs.getInt(DIALOG_HEIGHT_PREFS_KEY, 500);
    dialog.setPreferredSize(new Dimension(width, height));
    dialog.pack();
    // After pack(): set the divider at 1/3 (200/600) of the frame.
    int dividerLocation = prefs.getInt(DIALOG_DIVIDER_LOC_PREFS_KEY, 200);
    splitPane.setDividerLocation(dividerLocation);
    if (prefs.getDouble(DIALOG_X_PREFS_KEY, -1) != -1) {
        dialog.setLocation((int) prefs.getDouble(DIALOG_X_PREFS_KEY, 100), (int) prefs.getDouble(DIALOG_Y_PREFS_KEY, 100));
    } else {
        dialog.setLocationRelativeTo(null);
    }
    dialog.setVisible(true);
    return dialog;
}
Also used : ActionEvent(java.awt.event.ActionEvent) WindowAdapter(java.awt.event.WindowAdapter) TreeSelectionListener(javax.swing.event.TreeSelectionListener) Tree(org.antlr.v4.runtime.tree.Tree) ChangeListener(javax.swing.event.ChangeListener) Preferences(java.util.prefs.Preferences) WindowListener(java.awt.event.WindowListener) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) TreePath(javax.swing.tree.TreePath) WindowEvent(java.awt.event.WindowEvent) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 44 with TreeSelectionListener

use of javax.swing.event.TreeSelectionListener in project binnavi by google.

the class TypeSubstitutionDialog method createControls.

private void createControls(final BaseType stackFrame) {
    setBounds(100, 100, 691, 470);
    final JPanel panel = new JPanel();
    getContentPane().add(panel, BorderLayout.SOUTH);
    panel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    final JButton buttonOk = new JButton("OK");
    buttonOk.addActionListener(new OkActionListener());
    panel.add(buttonOk);
    final JButton buttonCancel = new JButton("Cancel");
    buttonCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            dispose();
        }
    });
    buttonCancel.setActionCommand("Cancel");
    panel.add(buttonCancel);
    final JPanel panel1 = new JPanel();
    getContentPane().add(panel1, BorderLayout.NORTH);
    final GridBagLayout gblPanel1 = new GridBagLayout();
    gblPanel1.columnWidths = new int[] { 0, 143, 114, 0 };
    gblPanel1.rowHeights = new int[] { 23, 0 };
    gblPanel1.columnWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE };
    gblPanel1.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
    panel1.setLayout(gblPanel1);
    JCheckBox onlyFitting = new JCheckBox("Only show structs that fit immediate offset");
    onlyFitting.setEnabled(false);
    GridBagConstraints gbcOnlyFitting = new GridBagConstraints();
    gbcOnlyFitting.anchor = GridBagConstraints.WEST;
    gbcOnlyFitting.insets = new Insets(0, 0, 0, 5);
    gbcOnlyFitting.gridx = 0;
    gbcOnlyFitting.gridy = 0;
    panel1.add(onlyFitting, gbcOnlyFitting);
    types = new TypesTree();
    types.setModel(new TypesTreeModel(typeManager, new LocalTypesFilter(stackFrame)));
    types.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    types.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent event) {
            final TypeSelectionPath path = types.determineTypePath();
            if (validateUserInput(path)) {
                updatePreview(path);
            }
        }
    });
    final JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.PAGE_AXIS));
    centerPanel.add(new JScrollPane(types));
    centerPanel.add(preview);
    getContentPane().add(centerPanel, BorderLayout.CENTER);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) TypeSelectionPath(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.TypesTree.TypeSelectionPath) TreeSelectionListener(javax.swing.event.TreeSelectionListener) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 45 with TreeSelectionListener

use of javax.swing.event.TreeSelectionListener in project sonarqube by SonarSource.

the class ScannerReportViewerApp method initialize.

/**
   * Initialize the contents of the frame.
   */
private void initialize() {
    try {
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (Exception e) {
    // If Nimbus is not available, you can set the GUI to another look and feel.
    }
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    splitPane = new JSplitPane();
    frame.getContentPane().add(splitPane, BorderLayout.CENTER);
    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setPreferredSize(new Dimension(500, 7));
    splitPane.setRightComponent(tabbedPane);
    componentDetailsTab = new JScrollPane();
    tabbedPane.addTab("Component details", null, componentDetailsTab, null);
    componentEditor = new JEditorPane();
    componentDetailsTab.setViewportView(componentEditor);
    sourceTab = new JScrollPane();
    tabbedPane.addTab("Source", null, sourceTab, null);
    sourceEditor = createSourceEditor();
    sourceEditor.setEditable(false);
    sourceTab.setViewportView(sourceEditor);
    textLineNumber = createTextLineNumber();
    sourceTab.setRowHeaderView(textLineNumber);
    highlightingTab = new JScrollPane();
    tabbedPane.addTab("Highlighting", null, highlightingTab, null);
    highlightingEditor = new JEditorPane();
    highlightingTab.setViewportView(highlightingEditor);
    symbolTab = new JScrollPane();
    tabbedPane.addTab("Symbol references", null, symbolTab, null);
    symbolEditor = new JEditorPane();
    symbolTab.setViewportView(symbolEditor);
    coverageTab = new JScrollPane();
    tabbedPane.addTab("Coverage", null, coverageTab, null);
    coverageEditor = new JEditorPane();
    coverageTab.setViewportView(coverageEditor);
    duplicationTab = new JScrollPane();
    tabbedPane.addTab("Duplications", null, duplicationTab, null);
    duplicationEditor = new JEditorPane();
    duplicationTab.setViewportView(duplicationEditor);
    testsTab = new JScrollPane();
    tabbedPane.addTab("Tests", null, testsTab, null);
    testsEditor = new JEditorPane();
    testsTab.setViewportView(testsEditor);
    issuesTab = new JScrollPane();
    tabbedPane.addTab("Issues", null, issuesTab, null);
    issuesEditor = new JEditorPane();
    issuesTab.setViewportView(issuesEditor);
    measuresTab = new JScrollPane();
    tabbedPane.addTab("Measures", null, measuresTab, null);
    measuresEditor = new JEditorPane();
    measuresTab.setViewportView(measuresEditor);
    scmTab = new JScrollPane();
    tabbedPane.addTab("SCM", null, scmTab, null);
    scmEditor = new JEditorPane();
    scmTab.setViewportView(scmEditor);
    treeScrollPane = new JScrollPane();
    treeScrollPane.setPreferredSize(new Dimension(200, 400));
    splitPane.setLeftComponent(treeScrollPane);
    componentTree = new JTree();
    componentTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("empty") {

        {
        }
    }));
    treeScrollPane.setViewportView(componentTree);
    componentTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    componentTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) componentTree.getLastSelectedPathComponent();
            if (node == null) {
                // Nothing is selected.
                return;
            }
            frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
            updateDetails((Component) node.getUserObject());
            frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    });
    frame.pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JTabbedPane(javax.swing.JTabbedPane) TreeSelectionListener(javax.swing.event.TreeSelectionListener) Dimension(java.awt.Dimension) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Cursor(java.awt.Cursor) IOException(java.io.IOException) JTree(javax.swing.JTree) JFrame(javax.swing.JFrame) JEditorPane(javax.swing.JEditorPane) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) JSplitPane(javax.swing.JSplitPane) Component(org.sonar.scanner.protocol.output.ScannerReport.Component)

Aggregations

TreeSelectionListener (javax.swing.event.TreeSelectionListener)86 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)81 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)36 TreePath (javax.swing.tree.TreePath)32 JTree (javax.swing.JTree)28 JScrollPane (javax.swing.JScrollPane)26 ActionEvent (java.awt.event.ActionEvent)23 JPanel (javax.swing.JPanel)22 ActionListener (java.awt.event.ActionListener)20 MouseEvent (java.awt.event.MouseEvent)16 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)16 Dimension (java.awt.Dimension)15 BorderLayout (java.awt.BorderLayout)14 GridBagConstraints (java.awt.GridBagConstraints)11 GridBagLayout (java.awt.GridBagLayout)11 Insets (java.awt.Insets)11 JButton (javax.swing.JButton)11 Tree (com.intellij.ui.treeStructure.Tree)10 KeyAdapter (java.awt.event.KeyAdapter)9 KeyEvent (java.awt.event.KeyEvent)9