Example usage for javax.swing JTabbedPane JTabbedPane

List of usage examples for javax.swing JTabbedPane JTabbedPane

Introduction

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

Prototype

public JTabbedPane(int tabPlacement) 

Source Link

Document

Creates an empty TabbedPane with the specified tab placement of either: JTabbedPane.TOP, JTabbedPane.BOTTOM, JTabbedPane.LEFT, or JTabbedPane.RIGHT.

Usage

From source file:org.nuxeo.launcher.gui.NuxeoFrame.java

protected JTabbedPane buildLogsTab() {
    JTabbedPane logsTabbedPane = new JTabbedPane(SwingConstants.TOP);
    // Get Launcher log file(s)
    ArrayList<String> logFiles = Log4JHelper.getFileAppendersFiles(LogManager.getLoggerRepository());
    // Add nuxeoctl log file
    File nuxeoctlLog = new File(controller.getConfigurationGenerator().getLogDir(), "nuxeoctl.log");
    if (nuxeoctlLog.exists()) {
        logFiles.add(nuxeoctlLog.getAbsolutePath());
    }//from ww w  . j  av  a  2  s  .c  o m
    // Get server log file(s)
    logFiles.addAll(controller.getConfigurationGenerator().getLogFiles());
    for (String logFile : logFiles) {
        addFileToLogsTab(logsTabbedPane, logFile);
    }
    return logsTabbedPane;
}

From source file:org.nuxeo.launcher.gui.NuxeoFrame.java

protected JComponent buildTabbedPanel() {
    tabbedPanel = new JTabbedPane(SwingConstants.TOP);
    tabbedPanel.addTab(NuxeoLauncherGUI.getMessage("tab.summary.title"), buildSummaryPanel());
    logsTab = buildLogsTab();// w  w  w  . j  av a 2  s  .co m
    tabbedPanel.addTab(NuxeoLauncherGUI.getMessage("tab.logs.title"), logsTab);
    tabbedPanel.addTab(NuxeoLauncherGUI.getMessage("tab.shell.title"), buildConsolePanel());
    tabbedPanel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JTabbedPane pane = (JTabbedPane) e.getSource();
            if (pane.getSelectedIndex() == 2) {
                consolePanel.getConsole().requestFocusInWindow();
            }
        }
    });
    return tabbedPanel;
}

From source file:org.nuxeo.launcher.sync.NuxeoSyncFrame.java

@Override
protected JComponent buildTabbedPanel() {
    // do not call super, hiding other tabbed panel (log and summary tab)
    tabbedPanel = new JTabbedPane(SwingConstants.TOP);
    tabbedPanel.addTab("Synchronization", buildSyncPanel());
    return tabbedPanel;
}

From source file:org.opendatakit.briefcase.ui.MainBriefcaseWindow.java

/**
 * Create the application.//from  www.j av  a 2s  . c om
 */
public MainBriefcaseWindow() {
    frame = new JFrame();
    frame.setBounds(100, 100, 680, 595);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.addWindowListener(new WindowListener() {
        @Override
        public void windowOpened(WindowEvent e) {
        }

        @Override
        public void windowClosing(WindowEvent e) {
        }

        @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) {
        }
    });

    JLabel lblBriefcaseDirectory = new JLabel(MessageStrings.BRIEFCASE_STORAGE_LOCATION);

    txtBriefcaseDir = new JTextField();
    txtBriefcaseDir.setFocusable(false);
    txtBriefcaseDir.setEditable(false);
    txtBriefcaseDir.setColumns(10);

    btnChoose = new JButton("Change...");
    btnChoose.addActionListener(new FolderActionListener());

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout
            .createSequentialGroup().addContainerGap()
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
                    .addComponent(tabbedPane, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 628,
                            Short.MAX_VALUE)
                    .addGroup(groupLayout.createSequentialGroup().addComponent(lblBriefcaseDirectory).addGap(18)
                            .addComponent(txtBriefcaseDir, GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
                            .addGap(18).addComponent(btnChoose)))
            .addContainerGap()));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup().addContainerGap()
                    .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
                            .addComponent(txtBriefcaseDir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnChoose).addComponent(lblBriefcaseDirectory))
                    .addGap(33).addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
                    .addContainerGap()));

    gatherPanel = new PullTransferPanel(transferTerminationFuture);
    tabbedPane.addTab(PullTransferPanel.TAB_NAME, null, gatherPanel, null);
    PullTransferPanel.TAB_POSITION = 0;

    uploadPanel = new PushTransferPanel(transferTerminationFuture);
    tabbedPane.addTab(PushTransferPanel.TAB_NAME, null, uploadPanel, null);
    PushTransferPanel.TAB_POSITION = 1;

    exportPanel = new ExportPanel(exportTerminationFuture);
    tabbedPane.addTab(ExportPanel.TAB_NAME, null, exportPanel, null);
    frame.getContentPane().setLayout(groupLayout);
    ExportPanel.TAB_POSITION = 2;

    frame.addWindowListener(this);
    setFullUIEnabled(false);

    frame.setFocusTraversalPolicy(new FocusTraversalPolicy() {

        @Override
        public Component getComponentAfter(Container arg0, Component arg1) {
            ArrayList<Component> componentOrdering = new ArrayList<Component>();
            for (;;) {
                int nextPanel = PullTransferPanel.TAB_POSITION;
                componentOrdering.clear();
                componentOrdering.add(txtBriefcaseDir);
                componentOrdering.add(btnChoose);
                componentOrdering.add(tabbedPane);
                int idx = tabbedPane.getSelectedIndex();
                if (idx == PullTransferPanel.TAB_POSITION) {
                    componentOrdering.addAll(gatherPanel.getTraversalOrdering());
                    nextPanel = PushTransferPanel.TAB_POSITION;
                } else if (idx == PushTransferPanel.TAB_POSITION) {
                    componentOrdering.addAll(uploadPanel.getTraversalOrdering());
                    nextPanel = ExportPanel.TAB_POSITION;
                } else if (idx == ExportPanel.TAB_POSITION) {
                    componentOrdering.addAll(exportPanel.getTraversalOrdering());
                    nextPanel = PullTransferPanel.TAB_POSITION;
                }
                componentOrdering.add(btnChoose);
                boolean found = false;
                for (int i = 0; i < componentOrdering.size() - 1; ++i) {
                    if (found || arg1 == componentOrdering.get(i)) {
                        found = true;
                        Component comp = componentOrdering.get(i + 1);
                        if (comp == tabbedPane) {
                            return comp;
                        }
                        if (comp.isVisible() && comp.isEnabled()
                                && (!(comp instanceof JTextField) || ((JTextField) comp).isEditable())) {
                            return comp;
                        }
                    }
                }
                if (!found) {
                    return componentOrdering.get(0);
                }
                tabbedPane.setSelectedIndex(nextPanel);
            }
        }

        @Override
        public Component getComponentBefore(Container arg0, Component arg1) {
            ArrayList<Component> componentOrdering = new ArrayList<Component>();
            for (;;) {
                int nextPanel = PullTransferPanel.TAB_POSITION;
                componentOrdering.clear();
                componentOrdering.add(txtBriefcaseDir);
                componentOrdering.add(btnChoose);
                componentOrdering.add(tabbedPane);
                int idx = tabbedPane.getSelectedIndex();
                if (idx == PullTransferPanel.TAB_POSITION) {
                    componentOrdering.addAll(gatherPanel.getTraversalOrdering());
                    nextPanel = ExportPanel.TAB_POSITION;
                } else if (idx == PushTransferPanel.TAB_POSITION) {
                    componentOrdering.addAll(uploadPanel.getTraversalOrdering());
                    nextPanel = PullTransferPanel.TAB_POSITION;
                } else if (idx == ExportPanel.TAB_POSITION) {
                    componentOrdering.addAll(exportPanel.getTraversalOrdering());
                    nextPanel = PushTransferPanel.TAB_POSITION;
                }
                componentOrdering.add(btnChoose);
                boolean found = false;
                for (int i = componentOrdering.size() - 1; i > 0; --i) {
                    if (found || arg1 == componentOrdering.get(i)) {
                        found = true;
                        Component comp = componentOrdering.get(i - 1);
                        if (comp == tabbedPane) {
                            return comp;
                        }
                        if (comp.isVisible() && comp.isEnabled()
                                && (!(comp instanceof JTextField) || ((JTextField) comp).isEditable())) {
                            return comp;
                        }
                    }
                }
                if (!found) {
                    return componentOrdering.get(componentOrdering.size() - 1);
                }
                tabbedPane.setSelectedIndex(nextPanel);
            }
        }

        @Override
        public Component getDefaultComponent(Container arg0) {
            return btnChoose;
        }

        @Override
        public Component getFirstComponent(Container arg0) {
            return btnChoose;
        }

        @Override
        public Component getLastComponent(Container arg0) {
            return tabbedPane;
        }
    });
}

From source file:org.pmedv.blackboard.board.BoardDesignerPerspective.java

@Override
protected void initializeComponents() {
    setLayout(new BorderLayout());
    toolTabPane = new JTabbedPane(JTabbedPane.BOTTOM);
    horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);

    ctx = AppContext.getContext();/*from  ww w  .j  a v  a 2 s.com*/
    resources = ctx.getBean(ResourceService.class);
    advisor = ctx.getBean(ApplicationWindowAdvisor.class);

    final String position = (String) Preferences.values
            .get("org.pmedv.blackboard.BoardDesignerPerspective.layerPanelPlacement");

    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {

            viewMap = new ViewMap();

            rootWindow = DockingUtil.createRootWindow(viewMap, true);
            rootWindow.getWindowBar(Direction.DOWN).setEnabled(true);
            rootWindow.getWindowProperties().setMinimizeEnabled(true);

            DockingWindowsTheme theme = new SoftBlueIceDockingTheme();

            rootWindow.getRootWindowProperties().addSuperObject(theme.getRootWindowProperties());
            rootWindow.getWindowProperties().getTabProperties().getHighlightedButtonProperties()
                    .getCloseButtonProperties().setVisible(false);
            rootWindow.getWindowProperties().getTabProperties().getNormalButtonProperties()
                    .getCloseButtonProperties().setVisible(false);

            editorArea = new TabWindow();
            editorArea.getWindowProperties().getTabProperties().getNormalButtonProperties()
                    .getCloseButtonProperties().setVisible(false);
            editorArea.getWindowProperties().getTabProperties().getHighlightedButtonProperties()
                    .getCloseButtonProperties().setVisible(false);
            editorArea.getWindowProperties().getTabProperties().getNormalButtonProperties()
                    .getMinimizeButtonProperties().setVisible(true);
            editorArea.getWindowProperties().getTabProperties().getHighlightedButtonProperties()
                    .getMinimizeButtonProperties().setVisible(true);

            DockingWindowAdapter dockingAdapter = new DockingWindowAdapter() {
                @Override
                public void windowClosing(DockingWindow window) throws OperationAbortedException {

                }
            };

            editorArea.addListener(dockingAdapter);
            setDockingListener(dockingAdapter);

            rootWindow.setWindow(editorArea);

            if (position.equalsIgnoreCase("left")) {
                horizontalSplitPane.setRightComponent(rootWindow);
            } else {
                horizontalSplitPane.setLeftComponent(rootWindow);
            }

            advisor.setCurrentEditorArea(editorArea);

        }

    });

    JXTaskPaneContainer taskpanecontainer = new JXTaskPaneContainer();
    taskpanecontainer.setBackground(new Color(182, 191, 205));

    JXTaskPane shapePane = new JXTaskPane();
    shapePane.setTitle(resources.getResourceByKey("BoardDesignerPerspective.shapes.title"));
    shapePane.add(ctx.getBean(ShapePropertiesPanel.class));
    taskpanecontainer.add(shapePane);

    ctx.getBean(ShapePropertiesPanel.class).getStartLineCombo().setSelectedItem(LineEdgeType.STRAIGHT);
    ctx.getBean(ShapePropertiesPanel.class).getEndLineCombo().setSelectedItem(LineEdgeType.STRAIGHT);
    ctx.getBean(ShapePropertiesPanel.class).getThicknessCombo().setSelectedItem(new BasicStroke(2.0f));

    JXTaskPane layerPane = new JXTaskPane();
    layerPane.setTitle(resources.getResourceByKey("BoardDesignerPerspective.layers"));
    layerPane.add(ctx.getBean(ShowLayersCommand.class).getLayerPanel());
    taskpanecontainer.add(layerPane);

    JScrollPane scrollPane = new JScrollPane(taskpanecontainer);

    if (position.equalsIgnoreCase("left")) {
        horizontalSplitPane.setLeftComponent(toolTabPane);
    } else {
        horizontalSplitPane.setRightComponent(toolTabPane);
    }

    horizontalSplitPane.setOneTouchExpandable(true);
    horizontalSplitPane.setDividerSize(10);

    toolTabPane.addTab(resources.getResourceByKey("tooltab.forms"), resources.getIcon("icon.paint"),
            scrollPane);

    final SymbolListPanel symbolListPanel = ctx.getBean(SymbolListPanel.class);
    toolTabPane.addTab(resources.getResourceByKey("tooltab.symbols"), resources.getIcon("icon.symbols"),
            symbolListPanel);

    final ModelListPanel modelListPanel = ctx.getBean(ModelListPanel.class);
    toolTabPane.addTab(resources.getResourceByKey("tooltab.models"), resources.getIcon("icon.model"),
            modelListPanel);

    add(horizontalSplitPane, BorderLayout.CENTER);

    commandArea = new RSyntaxTextArea();
    commandArea.setRows(1);
    commandArea.setColumns(100);

    JPanel commandPanel = new JPanel(new BorderLayout());
    commandPanel.add(new JLabel("Command :"), BorderLayout.WEST);
    commandPanel.add(commandArea, BorderLayout.CENTER);
    commandArea.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2),
            BorderFactory.createLineBorder(Color.BLACK)));
    add(commandPanel, BorderLayout.NORTH);
    setupAutoComplete();

    commandArea.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {

            if (e.getKeyCode() == KeyEvent.VK_ENTER) {

                if (commandArea.getText().startsWith("add ") && commandArea.getText().length() > 4
                        && commandArea.hasFocus()) {

                    PartFactory pf = AppContext.getContext().getBean(PartFactory.class);

                    String tokens[] = commandArea.getText().split(" ");
                    StringBuffer partName = new StringBuffer();

                    for (int i = 1; i < tokens.length; i++) {
                        partName.append(tokens[i] + " ");
                    }

                    String name = partName.toString().trim();

                    if (pf.getPartnames().contains(name)) {
                        e.consume();
                        commandArea.setText("");
                        BoardUtil.addPart(name, EditorUtils.getCurrentActiveEditor());
                    }

                } else if (commandArea.getText().equals("new")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(CreateBoardCommand.class).execute(null);
                } else if (commandArea.getText().equals("resistor")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(AddResistorCommand.class).execute(null);
                } else if (commandArea.getText().equals("diode")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(AddDiodeCommand.class).execute(null);
                } else if (commandArea.getText().equals("text")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(AddTextCommand.class).execute(null);
                } else if (commandArea.getText().equals("open")) {
                    e.consume();
                    commandArea.setText("");
                    new OpenBoardCommand().execute(null);
                } else if (commandArea.getText().equals("save")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(SaveBoardCommand.class).execute(null);
                } else if (commandArea.getText().equals("color")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(ChooseColorCommand.class).execute(null);
                }

            }

        }

    });

    horizontalSplitPane.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equalsIgnoreCase("dividerLocation")) {
                configProvider.getConfig().setDividerLocation(horizontalSplitPane.getDividerLocation());
            }
        }
    });

    ctx.getBean(ShapePropertiesPanel.class).getObjectField()
            .setText(resources.getResourceByKey("ShapePropertiesPanel.items.none"));
    ctx.getBean(ShapePropertiesPanel.class).getRotationSpinner().setEnabled(false);
    ctx.getBean(ShapePropertiesPanel.class).getStartAngleSpinner().setEnabled(false);

    initListeners();

}

From source file:org.pmedv.blackboard.components.PartView.java

protected void initializeComponents() {

    setLayout(new BorderLayout());

    partPanel = new PartPanel();
    partBusyPanel = new JBusyComponent<PartPanel>(partPanel);

    setSize(new Dimension(900, 650));

    textArea = new RSyntaxTextArea();
    textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
    RTextScrollPane textScrollPane = new RTextScrollPane(textArea);

    CompletionProvider provider = createCompletionProvider();
    AutoCompletion ac = new AutoCompletion(provider);
    ac.install(textArea);//from  ww w.j  a v  a 2  s .  c o m

    JPopupMenu popup = textArea.getPopupMenu();
    popup.addSeparator();
    popup.add(new JMenuItem(new SaveAction()));

    tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);
    tabbedPane.addTab("Parts", partBusyPanel);
    tabbedPane.addTab("Part Editor", textScrollPane);
    tabbedPane.setEnabledAt(1, false);
    add(tabbedPane, BorderLayout.CENTER);

    tablePopupMenu = new JPopupMenu();

    // We do the part loading in background and display a busy panel while loading

    SwingWorker<ArrayList<Part>, Void> w = new SwingWorker<ArrayList<Part>, Void>() {

        @Override
        protected ArrayList<Part> doInBackground() {
            partBusyPanel.setBusy(true);
            try {
                return AppContext.getContext().getBean(PartFactory.class).getAvailableParts();
            } catch (Exception e) {
                ErrorUtils.showErrorDialog(e);
                return new ArrayList<Part>();
            }
        }

        @Override
        protected void done() {
            log.info("Done loading parts.");
            try {
                model = new PartTableModel(get());
                partPanel.getPartTable().setModel(model);
            } catch (Exception e) {
                ErrorUtils.showErrorDialog(e);
            }
            partBusyPanel.setBusy(false);
            partPanel.transferFocus();
        }
    };

    partPanel.getPartTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            JXTable table = partPanel.getPartTable();
            int[] rows = table.getSelectedRows();
            if (rows.length == 1) {
                if (model == null)
                    return;
                Part selectedPart = model.getParts().get(table.convertRowIndexToModel(rows[0]));
                currentPart = selectedPart;
                selectedRow = table.convertRowIndexToModel(rows[0]);
                partPanel.getImageLabel().setIcon(new ImageIcon(selectedPart.getImage()));
                partPanel.getImageLabel().setText(null);
                partPanel.getPartNameField().setText(selectedPart.getName());
                partPanel.getDescriptionPane().setText(selectedPart.getDescription());
                partPanel.getPackageTypeField().setText(selectedPart.getPackageType());
                partPanel.getAuthorField().setText(selectedPart.getAuthor());
                partPanel.getLicenseField().setText(selectedPart.getLicense());
                tabbedPane.setEnabledAt(1, true);
                textArea.setText(selectedPart.getXmlContent());
            } else {
                currentPart = null;
                partPanel.getImageLabel().setText(resources.getResourceByKey("PartDialog.selectmsg"));
                partPanel.getImageLabel().setIcon(null);
                tabbedPane.setEnabledAt(1, false);
                textArea.setText("");
            }
        }
    });

    partPanel.getPartTable().addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            handlePopupTrigger(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            handlePopupTrigger(e);
        }
    });

    tablePopupMenu.add(AppContext.getContext().getBean(DeletePartCommand.class));

    // this is the filter configuration for the filter text box on the top
    PartFilter filter = new PartFilter(partPanel.getPartTable());
    BindingGroup filterGroup = new BindingGroup();
    // bind filter JTextBox's text attribute to part tables filterString
    // attribute
    filterGroup.addBinding(Bindings.createAutoBinding(READ, partPanel.getFilterPanel().getFilterTextField(),
            BeanProperty.create("text"), filter, BeanProperty.create("filterString")));
    filterGroup.bind();
    w.execute();

}

From source file:org.pmedv.blackboard.dialogs.PartDialog.java

@Override
protected void initializeComponents() {

    partPanel = new PartPanel();
    partBusyPanel = new JBusyComponent<PartPanel>(partPanel);

    setSize(new Dimension(900, 750));

    textArea = new RSyntaxTextArea();
    textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
    RTextScrollPane textScrollPane = new RTextScrollPane(textArea);

    CompletionProvider provider = createCompletionProvider();
    AutoCompletion ac = new AutoCompletion(provider);
    ac.install(textArea);/*from   w  ww  . j  av a2 s .  c  om*/

    JPopupMenu popup = textArea.getPopupMenu();
    popup.addSeparator();
    popup.add(new JMenuItem(new SaveAction()));

    tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);
    tabbedPane.addTab("Parts", partBusyPanel);
    tabbedPane.addTab("Part Editor", textScrollPane);
    tabbedPane.setEnabledAt(1, false);
    getContentPanel().add(tabbedPane);

    tablePopupMenu = new JPopupMenu();

    // We do the part loading in background and display a busy panel while loading

    SwingWorker<ArrayList<Part>, Void> w = new SwingWorker<ArrayList<Part>, Void>() {

        @Override
        protected ArrayList<Part> doInBackground() {
            partBusyPanel.setBusy(true);
            try {
                return AppContext.getContext().getBean(PartFactory.class).getAvailableParts();
            } catch (Exception e) {
                ErrorUtils.showErrorDialog(e);
                return new ArrayList<Part>();
            }
        }

        @Override
        protected void done() {
            log.info("Done loading parts.");
            try {
                model = new PartTableModel(get());
                partPanel.getPartTable().setModel(model);
            } catch (Exception e) {
                ErrorUtils.showErrorDialog(e);
            }
            partBusyPanel.setBusy(false);
            partPanel.transferFocus();
        }
    };

    getOkButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JXTable table = partPanel.getPartTable();
            result = OPTION_OK;
            selectedParts = new ArrayList<Part>();
            int rows[] = partPanel.getPartTable().getSelectedRows();
            try {
                for (int i = 0; i < rows.length; i++) {
                    selectedParts.add(AppContext.getContext().getBean(PartFactory.class).createPart(
                            model.getParts().get(table.convertRowIndexToModel(rows[i])).getFilename()));
                }
            } catch (Exception e1) {
                ErrorUtils.showErrorDialog(e1);
            }
            setVisible(false);
        }
    });

    getCancelButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            result = OPTION_CANCEL;
            setVisible(false);
        }
    });

    getNewButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            AppContext.getContext().getBean(CreatePartCommand.class).execute(e);
        }
    });

    partPanel.getPartTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            JXTable table = partPanel.getPartTable();
            int[] rows = table.getSelectedRows();
            if (rows.length == 1) {
                if (model == null)
                    return;
                Part selectedPart = model.getParts().get(table.convertRowIndexToModel(rows[0]));
                currentPart = selectedPart;
                selectedRow = table.convertRowIndexToModel(rows[0]);
                partPanel.getImageLabel().setIcon(new ImageIcon(selectedPart.getImage()));
                partPanel.getImageLabel().setText(null);
                partPanel.getPartNameField().setText(selectedPart.getName());
                partPanel.getDescriptionPane().setText(selectedPart.getDescription());
                partPanel.getPackageTypeField().setText(selectedPart.getPackageType());
                partPanel.getAuthorField().setText(selectedPart.getAuthor());
                partPanel.getLicenseField().setText(selectedPart.getLicense());
                tabbedPane.setEnabledAt(1, true);
                textArea.setText(selectedPart.getXmlContent());
            } else {
                currentPart = null;
                partPanel.getImageLabel().setText(resources.getResourceByKey("PartDialog.selectmsg"));
                partPanel.getImageLabel().setIcon(null);
                tabbedPane.setEnabledAt(1, false);
                textArea.setText("");
            }
        }
    });

    tabbedPane.addChangeListener(new ChangeListener() {
        // This method is called whenever the selected tab changes
        public void stateChanged(ChangeEvent evt) {
            JTabbedPane pane = (JTabbedPane) evt.getSource();
            int index = pane.getSelectedIndex();
            if (index == 0) {
                getTitleLabel().setText(title);
                getSubTitleLabel().setText(subTitle);
            } else {
                getTitleLabel().setText(editTitle);
                getSubTitleLabel().setText(editSubTitle + " : " + currentPart.getName());
            }
        }
    });

    partPanel.getPartTable().addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            handlePopupTrigger(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            handlePopupTrigger(e);
        }
    });

    tablePopupMenu.add(ctx.getBean(DeletePartCommand.class));

    // this is the filter configuration for the filter text box on the top
    PartFilter filter = new PartFilter(partPanel.getPartTable());
    BindingGroup filterGroup = new BindingGroup();
    // bind filter JTextBox's text attribute to part tables filterString
    // attribute
    filterGroup.addBinding(Bindings.createAutoBinding(READ, partPanel.getFilterPanel().getFilterTextField(),
            BeanProperty.create("text"), filter, BeanProperty.create("filterString")));
    filterGroup.bind();
    w.execute();

}

From source file:org.roche.antibody.ui.components.AntibodyEditorPane.java

/**
 * initates swing component//from   w  ww . j av  a  2  s  .  c  o  m
 */
private void initComponents() {
    abstractGraphLayouter = AbstractGraphLayoutService.createLayouter();
    this.abstractAntibodyView = new Graph2DView();
    this.abstractAntibodyView.setFitContentOnResize(true);
    editMode = new AntibodyEditMode(this);
    abstractAntibodyView.addViewMode(editMode);

    // enable bridges for PolyLineEdgeRealizer
    BridgeCalculator bridgeCalculator = new BridgeCalculator();
    bridgeCalculator.setCrossingMode(BridgeCalculator.CROSSING_MODE_HORIZONTAL_CROSSES_VERTICAL);
    ((DefaultGraph2DRenderer) abstractAntibodyView.getGraph2DRenderer()).setBridgeCalculator(bridgeCalculator);
    configureKeyboardActions();

    this.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentShown(ComponentEvent e) {
            super.componentShown(e);
            LOG.debug("Call componentShown of: {}", this.getClass().getName());
            updateGraphLayout();
        }
    });
    this.setLayout(new BorderLayout());

    // --- START Graphical Representation of Antybody (Center Panel)
    JSplitPane pnlSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    pnlSplit.setOneTouchExpandable(true);
    this.add(pnlSplit, BorderLayout.CENTER);
    pnlSplit.setLeftComponent(abstractAntibodyView);
    pnlSplit.setResizeWeight(1);
    // --- START Property Table, HELM Notation etc. (Right Panel)
    pnlEast = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    pnlEast.setBorder(DEFAULT_BORDER);
    pnlEast.setResizeWeight(0.65);
    antibodyPropertyModel = new DomainTableModel();
    antibodyPropertyModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            abstractGraph.updateViews();
        }
    });
    propertyTable = new JTable(antibodyPropertyModel);
    propertyTable.setDefaultRenderer(Object.class, new DomainTableCellRenderer());

    JScrollPane spnlPropertyTable = new JScrollPane(propertyTable);
    pnlEast.setTopComponent(spnlPropertyTable);
    pnlSplit.setRightComponent(pnlEast);

    // graphical preview
    graphicsPane = new JPanel(new BorderLayout());
    anotherView = new Graph2DView();
    graphicsPane.add(anotherView, BorderLayout.CENTER);

    // Tabcontainer for graphic and helm notation preview
    tabbedPane = new JTabbedPane(JTabbedPane.TOP);

    // --- HELM notation Preview Panel
    helmPreviewPane = new JPanel();
    helmPreviewPane.setLayout(new BorderLayout());
    tabbedPane.addTab("HELM Notation Preview", null, helmPreviewPane, null);

    // --- Button Panel for HELM notation preview
    JPanel pnlButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    cmdSaveAsXml = new JButton("Save Antibody",
            new ImageIcon(ResourceProvider.getInstance().get(ResourceProvider.DISK_IMAGE)));
    cmdSaveAsXml.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            XmlFileChooser dialog = new XmlFileChooser();
            if (dialog.showSaveDialog(mainEditor.getFrame()) == JFileChooser.APPROVE_OPTION) {
                File abFile = dialog.getSelectedFile();
                String newPath = FilenameUtils.removeExtension(abFile.getAbsolutePath());
                abFile = new File(newPath + AntibodyFileChooser.XML_EXTENSION);
                AntibodyContainer abContainer = new AntibodyContainer();
                try {
                    antibody.setDomainLibraryPath(ConfigFileService.getInstance().getDomainLibFilename());
                    // PreferencesService.getInstance().getDomainLibraryFile().getAbsolutePath());

                    abContainer.setAntibody(antibody);
                    abContainer.setHelmCode(helmTextArea.getText());
                    xmlService.marshal(abContainer, abFile);
                } catch (JAXBException e1) {
                    JOptionPane.showMessageDialog(mainEditor.getFrame(),
                            "Could not save Antibody! Please try again", "Error", JOptionPane.ERROR_MESSAGE);
                    LOG.error("Could not save Antibody-XML to disk! {}", e1);
                }
            }
        }
    });
    pnlButtons.add(cmdSaveAsXml);

    cmdLoadFromXml = new JButton("Load Antibody",
            new ImageIcon(ResourceProvider.getInstance().get(ResourceProvider.OPEN_FOLDER)));
    cmdLoadFromXml.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            XmlFileChooser dialog = new XmlFileChooser();
            if (dialog.showOpenDialog(mainEditor.getFrame()) == JFileChooser.APPROVE_OPTION) {
                File abFile = dialog.getSelectedFile();
                try {
                    AntibodyContainer newAbContainer = xmlService.unmarshal(abFile);
                    setModel(newAbContainer.getAntibody());
                } catch (JAXBException e1) {
                    JOptionPane.showMessageDialog(mainEditor.getFrame(),
                            "Could not load Antibody! Please try again", "Error", JOptionPane.ERROR_MESSAGE);
                    LOG.error("Could not load Antibody-XML to disk! {}", e1);
                }
            }
        }
    });
    pnlButtons.add(cmdLoadFromXml);
    helmPreviewPane.add(pnlButtons, BorderLayout.SOUTH);

    pnlEast.setBottomComponent(tabbedPane);

    // --- HELM Notation Text Area
    helmTextArea = new JTextArea();
    helmTextArea.setLineWrap(true);
    JScrollPane spnlHELMTextArea = new JScrollPane(helmTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    helmPreviewPane.add(spnlHELMTextArea, BorderLayout.CENTER);
}

From source file:org.sonar.scanner.protocol.viewer.ScannerReportViewerApp.java

/**
 * Initialize the contents of the frame.
 *///from w w  w . j  a  v a2 s .  co m
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);

    activeRuleTab = new JScrollPane();
    tabbedPane.addTab("ActiveRules", null, activeRuleTab, null);

    activeRuleEditor = new JEditorPane();
    activeRuleTab.setViewportView(activeRuleEditor);

    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();
}

From source file:org.tellervo.desktop.io.ImportDialog.java

private void initGui() {
    setTitle("Import to Database");
    setBounds(100, 100, 804, 734);// w  w  w  .j  ava  2 s  .  c  o m

    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));
    {
        horizSplitPane = new JSplitPane();
        horizSplitPane.setOneTouchExpandable(true);
        horizSplitPane.setBorder(null);
        horizSplitPane.setDividerLocation(0.4);
        contentPanel.add(horizSplitPane);
        {
            splitPaneVert = new JSplitPane();
            splitPaneVert.setOneTouchExpandable(true);
            splitPaneVert.setBorder(null);
            splitPaneVert.setOrientation(JSplitPane.VERTICAL_SPLIT);
            horizSplitPane.setLeftComponent(splitPaneVert);
            {
                panelTreeTable = new JPanel();
                panelTreeTable.setBorder(new TitledBorder(null, "TRiDaS Representation", TitledBorder.LEADING,
                        TitledBorder.TOP, null, null));
                splitPaneVert.setLeftComponent(panelTreeTable);
                panelTreeTable.setLayout(new BorderLayout(0, 0));
                {
                    JButton btnSetFromDB = new JButton("Set current entity from database");
                    panelTreeTable.add(btnSetFromDB, BorderLayout.SOUTH);
                }
            }
            {
                panelWarnings = new JPanel();
                panelWarnings.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
                        "Warnings", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
                splitPaneVert.setRightComponent(panelWarnings);
                panelWarnings.setLayout(new BorderLayout(0, 0));
                {
                    JScrollPane scrollPane = new JScrollPane();
                    panelWarnings.add(scrollPane, BorderLayout.CENTER);
                    {
                        tblWarnings = new JTable();
                        scrollPane.setViewportView(tblWarnings);
                    }
                }
            }
        }
        {
            tabbedPane = new JTabbedPane(JTabbedPane.TOP);
            tabbedPane.setBorder(null);
            horizSplitPane.setRightComponent(tabbedPane);
            {
                JPanel panelMetadata = new JPanel();
                panelMetadata.setLayout(new BorderLayout());
                initPropertiesPanel();

                panelMetadata.add(propertiesPanel, BorderLayout.CENTER);
                tabbedPane.addTab("Metadata", null, panelMetadata, null);

            }
            {
                JPanel panelData = new JPanel();
                tabbedPane.addTab("Data", null, panelData, null);
                tabbedPane.setEnabledAt(1, false);
            }
            {
                panelOrigFile = new JPanel();
                tabbedPane.addTab("Original file", null, panelOrigFile, null);
                panelOrigFile.setLayout(new BorderLayout(0, 0));
                {
                    DefaultSyntaxKit.initKit();

                }
                {
                    JScrollPane scrollPane = new JScrollPane();
                    panelOrigFile.add(scrollPane, BorderLayout.CENTER);

                    originalFilePane = new JTextArea();
                    scrollPane.setViewportView(originalFilePane);
                    originalFilePane.setEditable(false);
                    originalFilePane.setFont(new java.awt.Font("Courier", 0, 12));
                }
            }
        }
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton button = new JButton("Finish");
            buttonPane.add(button);
        }
    }
}