Search in sources :

Example 61 with JTabbedPane

use of javax.swing.JTabbedPane in project gitblit by gitblit.

the class GitblitManager method getCenterPanel.

private JPanel getCenterPanel() {
    serverTabs = new JTabbedPane(JTabbedPane.TOP);
    JMenuBar menubar = setupMenu();
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(menubar, BorderLayout.NORTH);
    panel.add(serverTabs, BorderLayout.CENTER);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JTabbedPane(javax.swing.JTabbedPane) JMenuBar(javax.swing.JMenuBar)

Example 62 with JTabbedPane

use of javax.swing.JTabbedPane in project gitblit by gitblit.

the class EditRepositoryDialog method initialize.

private void initialize(int protocolVersion, RepositoryModel anRepository) {
    nameField = new JTextField(anRepository.name == null ? "" : anRepository.name, 35);
    descriptionField = new JTextField(anRepository.description == null ? "" : anRepository.description, 35);
    JTextField originField = new JTextField(anRepository.origin == null ? "" : anRepository.origin, 40);
    originField.setEditable(false);
    if (ArrayUtils.isEmpty(anRepository.availableRefs)) {
        headRefField = new JComboBox();
        headRefField.setEnabled(false);
    } else {
        headRefField = new JComboBox(anRepository.availableRefs.toArray());
        headRefField.setSelectedItem(anRepository.HEAD);
    }
    Integer[] gcPeriods = { 1, 2, 3, 4, 5, 7, 10, 14 };
    gcPeriod = new JComboBox(gcPeriods);
    gcPeriod.setSelectedItem(anRepository.gcPeriod);
    gcThreshold = new JTextField(8);
    gcThreshold.setText(anRepository.gcThreshold);
    ownersPalette = new JPalette<String>(true);
    acceptNewTickets = new JCheckBox(Translation.get("gb.acceptsNewTicketsDescription"), anRepository.acceptNewTickets);
    acceptNewPatchsets = new JCheckBox(Translation.get("gb.acceptsNewPatchsetsDescription"), anRepository.acceptNewPatchsets);
    requireApproval = new JCheckBox(Translation.get("gb.requireApprovalDescription"), anRepository.requireApproval);
    if (ArrayUtils.isEmpty(anRepository.availableRefs)) {
        mergeToField = new JComboBox();
        mergeToField.setEnabled(false);
    } else {
        mergeToField = new JComboBox(anRepository.availableRefs.toArray());
        mergeToField.setSelectedItem(anRepository.mergeTo);
    }
    useIncrementalPushTags = new JCheckBox(Translation.get("gb.useIncrementalPushTagsDescription"), anRepository.useIncrementalPushTags);
    showRemoteBranches = new JCheckBox(Translation.get("gb.showRemoteBranchesDescription"), anRepository.showRemoteBranches);
    skipSizeCalculation = new JCheckBox(Translation.get("gb.skipSizeCalculationDescription"), anRepository.skipSizeCalculation);
    skipSummaryMetrics = new JCheckBox(Translation.get("gb.skipSummaryMetricsDescription"), anRepository.skipSummaryMetrics);
    isFrozen = new JCheckBox(Translation.get("gb.isFrozenDescription"), anRepository.isFrozen);
    maxActivityCommits = new JComboBox(new Integer[] { -1, 0, 25, 50, 75, 100, 150, 250, 500 });
    maxActivityCommits.setSelectedItem(anRepository.maxActivityCommits);
    mailingListsField = new JTextField(ArrayUtils.isEmpty(anRepository.mailingLists) ? "" : StringUtils.flattenStrings(anRepository.mailingLists, " "), 50);
    accessRestriction = new JComboBox(AccessRestrictionType.values());
    accessRestriction.setRenderer(new AccessRestrictionRenderer());
    accessRestriction.setSelectedItem(anRepository.accessRestriction);
    accessRestriction.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                AccessRestrictionType art = (AccessRestrictionType) accessRestriction.getSelectedItem();
                EditRepositoryDialog.this.setupAccessPermissions(art);
            }
        }
    });
    boolean authenticated = anRepository.authorizationControl != null && AuthorizationControl.AUTHENTICATED.equals(anRepository.authorizationControl);
    allowAuthenticated = new JRadioButton(Translation.get("gb.allowAuthenticatedDescription"));
    allowAuthenticated.setSelected(authenticated);
    allowAuthenticated.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                usersPalette.setEnabled(false);
                teamsPalette.setEnabled(false);
            }
        }
    });
    allowNamed = new JRadioButton(Translation.get("gb.allowNamedDescription"));
    allowNamed.setSelected(!authenticated);
    allowNamed.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                usersPalette.setEnabled(true);
                teamsPalette.setEnabled(true);
            }
        }
    });
    ButtonGroup group = new ButtonGroup();
    group.add(allowAuthenticated);
    group.add(allowNamed);
    JPanel authorizationPanel = new JPanel(new GridLayout(0, 1));
    authorizationPanel.add(allowAuthenticated);
    authorizationPanel.add(allowNamed);
    allowForks = new JCheckBox(Translation.get("gb.allowForksDescription"), anRepository.allowForks);
    verifyCommitter = new JCheckBox(Translation.get("gb.verifyCommitterDescription"), anRepository.verifyCommitter);
    // federation strategies - remove ORIGIN choice if this repository has
    // no origin.
    List<FederationStrategy> federationStrategies = new ArrayList<FederationStrategy>(Arrays.asList(FederationStrategy.values()));
    if (StringUtils.isEmpty(anRepository.origin)) {
        federationStrategies.remove(FederationStrategy.FEDERATE_ORIGIN);
    }
    federationStrategy = new JComboBox(federationStrategies.toArray());
    federationStrategy.setRenderer(new FederationStrategyRenderer());
    federationStrategy.setSelectedItem(anRepository.federationStrategy);
    JPanel fieldsPanel = new JPanel(new GridLayout(0, 1));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.name"), nameField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.description"), descriptionField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.origin"), originField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.headRef"), headRefField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.gcPeriod"), gcPeriod));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.gcThreshold"), gcThreshold));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.acceptsNewTickets"), acceptNewTickets));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.acceptsNewPatchsets"), acceptNewPatchsets));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.requireApproval"), requireApproval));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.mergeTo"), mergeToField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.enableIncrementalPushTags"), useIncrementalPushTags));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.showRemoteBranches"), showRemoteBranches));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSizeCalculation"), skipSizeCalculation));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSummaryMetrics"), skipSummaryMetrics));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.maxActivityCommits"), maxActivityCommits));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.mailingLists"), mailingListsField));
    JPanel clonePushPanel = new JPanel(new GridLayout(0, 1));
    clonePushPanel.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen));
    clonePushPanel.add(newFieldPanel(Translation.get("gb.allowForks"), allowForks));
    clonePushPanel.add(newFieldPanel(Translation.get("gb.verifyCommitter"), verifyCommitter));
    usersPalette = new RegistrantPermissionsPanel(RegistrantType.USER);
    JPanel northFieldsPanel = new JPanel(new BorderLayout(0, 5));
    northFieldsPanel.add(newFieldPanel(Translation.get("gb.owners"), ownersPalette), BorderLayout.NORTH);
    northFieldsPanel.add(newFieldPanel(Translation.get("gb.accessRestriction"), accessRestriction), BorderLayout.CENTER);
    JPanel northAccessPanel = new JPanel(new BorderLayout(5, 5));
    northAccessPanel.add(northFieldsPanel, BorderLayout.NORTH);
    northAccessPanel.add(newFieldPanel(Translation.get("gb.authorizationControl"), authorizationPanel), BorderLayout.CENTER);
    northAccessPanel.add(clonePushPanel, BorderLayout.SOUTH);
    JPanel accessPanel = new JPanel(new BorderLayout(5, 5));
    accessPanel.add(northAccessPanel, BorderLayout.NORTH);
    accessPanel.add(newFieldPanel(Translation.get("gb.userPermissions"), usersPalette), BorderLayout.CENTER);
    teamsPalette = new RegistrantPermissionsPanel(RegistrantType.TEAM);
    JPanel teamsPanel = new JPanel(new BorderLayout(5, 5));
    teamsPanel.add(newFieldPanel(Translation.get("gb.teamPermissions"), teamsPalette), BorderLayout.CENTER);
    setsPalette = new JPalette<String>();
    JPanel federationPanel = new JPanel(new BorderLayout(5, 5));
    federationPanel.add(newFieldPanel(Translation.get("gb.federationStrategy"), federationStrategy), BorderLayout.NORTH);
    federationPanel.add(newFieldPanel(Translation.get("gb.federationSets"), setsPalette), BorderLayout.CENTER);
    indexedBranchesPalette = new JPalette<String>();
    JPanel indexedBranchesPanel = new JPanel(new BorderLayout(5, 5));
    indexedBranchesPanel.add(newFieldPanel(Translation.get("gb.indexedBranches"), indexedBranchesPalette), BorderLayout.CENTER);
    preReceivePalette = new JPalette<String>(true);
    preReceiveInherited = new JLabel();
    JPanel preReceivePanel = new JPanel(new BorderLayout(5, 5));
    preReceivePanel.add(preReceivePalette, BorderLayout.CENTER);
    preReceivePanel.add(preReceiveInherited, BorderLayout.WEST);
    postReceivePalette = new JPalette<String>(true);
    postReceiveInherited = new JLabel();
    JPanel postReceivePanel = new JPanel(new BorderLayout(5, 5));
    postReceivePanel.add(postReceivePalette, BorderLayout.CENTER);
    postReceivePanel.add(postReceiveInherited, BorderLayout.WEST);
    customFieldsPanel = new JPanel();
    customFieldsPanel.setLayout(new BoxLayout(customFieldsPanel, BoxLayout.Y_AXIS));
    JScrollPane customFieldsScrollPane = new JScrollPane(customFieldsPanel);
    customFieldsScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    customFieldsScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    JTabbedPane panel = new JTabbedPane(JTabbedPane.TOP);
    panel.addTab(Translation.get("gb.general"), fieldsPanel);
    panel.addTab(Translation.get("gb.accessRestriction"), accessPanel);
    if (protocolVersion >= 2) {
        panel.addTab(Translation.get("gb.teams"), teamsPanel);
    }
    panel.addTab(Translation.get("gb.federation"), federationPanel);
    if (protocolVersion >= 3) {
        panel.addTab(Translation.get("gb.indexedBranches"), indexedBranchesPanel);
    }
    panel.addTab(Translation.get("gb.preReceiveScripts"), preReceivePanel);
    panel.addTab(Translation.get("gb.postReceiveScripts"), postReceivePanel);
    panel.addTab(Translation.get("gb.customFields"), customFieldsScrollPane);
    setupAccessPermissions(anRepository.accessRestriction);
    JButton createButton = new JButton(Translation.get("gb.save"));
    createButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if (validateFields()) {
                canceled = false;
                setVisible(false);
            }
        }
    });
    JButton cancelButton = new JButton(Translation.get("gb.cancel"));
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            canceled = true;
            setVisible(false);
        }
    });
    JPanel controls = new JPanel();
    controls.add(cancelButton);
    controls.add(createButton);
    final Insets _insets = new Insets(5, 5, 5, 5);
    JPanel centerPanel = new JPanel(new BorderLayout(5, 5)) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return _insets;
        }
    };
    centerPanel.add(panel, BorderLayout.CENTER);
    centerPanel.add(controls, BorderLayout.SOUTH);
    getContentPane().setLayout(new BorderLayout(5, 5));
    getContentPane().add(centerPanel, BorderLayout.CENTER);
    pack();
    nameField.requestFocus();
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) JRadioButton(javax.swing.JRadioButton) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JTabbedPane(javax.swing.JTabbedPane) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) AccessRestrictionType(com.gitblit.Constants.AccessRestrictionType) JScrollPane(javax.swing.JScrollPane) JComboBox(javax.swing.JComboBox) FederationStrategy(com.gitblit.Constants.FederationStrategy) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ItemListener(java.awt.event.ItemListener)

Example 63 with JTabbedPane

use of javax.swing.JTabbedPane in project gitblit by gitblit.

the class EditTeamDialog method initialize.

private void initialize(int protocolVersion, TeamModel aTeam) {
    teamnameField = new JTextField(aTeam.name == null ? "" : aTeam.name, 25);
    canAdminCheckbox = new JCheckBox(Translation.get("gb.canAdminDescription"), aTeam.canAdmin);
    canForkCheckbox = new JCheckBox(Translation.get("gb.canForkDescription"), aTeam.canFork);
    canCreateCheckbox = new JCheckBox(Translation.get("gb.canCreateDescription"), aTeam.canCreate);
    mailingListsField = new JTextField(aTeam.mailingLists == null ? "" : StringUtils.flattenStrings(aTeam.mailingLists, " "), 50);
    JPanel fieldsPanel = new JPanel(new GridLayout(0, 1));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.teamName"), teamnameField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.canAdmin"), canAdminCheckbox));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.canFork"), canForkCheckbox));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.canCreate"), canCreateCheckbox));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.mailingLists"), mailingListsField));
    final Insets _insets = new Insets(5, 5, 5, 5);
    repositoryPalette = new RegistrantPermissionsPanel(RegistrantType.REPOSITORY);
    userPalette = new JPalette<String>();
    JPanel fieldsPanelTop = new JPanel(new BorderLayout());
    fieldsPanelTop.add(fieldsPanel, BorderLayout.NORTH);
    JPanel repositoriesPanel = new JPanel(new BorderLayout()) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return _insets;
        }
    };
    repositoriesPanel.add(repositoryPalette, BorderLayout.CENTER);
    JPanel usersPanel = new JPanel(new BorderLayout()) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return _insets;
        }
    };
    usersPanel.add(userPalette, BorderLayout.CENTER);
    preReceivePalette = new JPalette<String>(true);
    preReceiveInherited = new JLabel();
    JPanel preReceivePanel = new JPanel(new BorderLayout(5, 5));
    preReceivePanel.add(preReceivePalette, BorderLayout.CENTER);
    preReceivePanel.add(preReceiveInherited, BorderLayout.WEST);
    postReceivePalette = new JPalette<String>(true);
    postReceiveInherited = new JLabel();
    JPanel postReceivePanel = new JPanel(new BorderLayout(5, 5));
    postReceivePanel.add(postReceivePalette, BorderLayout.CENTER);
    postReceivePanel.add(postReceiveInherited, BorderLayout.WEST);
    JTabbedPane panel = new JTabbedPane(JTabbedPane.TOP);
    panel.addTab(Translation.get("gb.general"), fieldsPanelTop);
    panel.addTab(Translation.get("gb.teamMembers"), usersPanel);
    panel.addTab(Translation.get("gb.restrictedRepositories"), repositoriesPanel);
    panel.addTab(Translation.get("gb.preReceiveScripts"), preReceivePanel);
    panel.addTab(Translation.get("gb.postReceiveScripts"), postReceivePanel);
    JButton createButton = new JButton(Translation.get("gb.save"));
    createButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if (validateFields()) {
                canceled = false;
                setVisible(false);
            }
        }
    });
    JButton cancelButton = new JButton(Translation.get("gb.cancel"));
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            canceled = true;
            setVisible(false);
        }
    });
    JPanel controls = new JPanel();
    controls.add(cancelButton);
    controls.add(createButton);
    JPanel centerPanel = new JPanel(new BorderLayout(5, 5)) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return _insets;
        }
    };
    centerPanel.add(panel, BorderLayout.CENTER);
    centerPanel.add(controls, BorderLayout.SOUTH);
    getContentPane().setLayout(new BorderLayout(5, 5));
    getContentPane().add(centerPanel, BorderLayout.CENTER);
    pack();
}
Also used : JPanel(javax.swing.JPanel) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener)

Example 64 with JTabbedPane

use of javax.swing.JTabbedPane in project gitblit by gitblit.

the class EditUserDialog method initialize.

private void initialize(int protocolVersion, UserModel anUser) {
    usernameField = new JTextField(anUser.username == null ? "" : anUser.username, 25);
    passwordField = new JPasswordField(anUser.password == null ? "" : anUser.password, 25);
    confirmPasswordField = new JPasswordField(anUser.password == null ? "" : anUser.password, 25);
    displayNameField = new JTextField(anUser.displayName == null ? "" : anUser.displayName, 25);
    emailAddressField = new JTextField(anUser.emailAddress == null ? "" : anUser.emailAddress, 25);
    canAdminCheckbox = new JCheckBox(Translation.get("gb.canAdminDescription"), anUser.canAdmin);
    canForkCheckbox = new JCheckBox(Translation.get("gb.canForkDescription"), anUser.canFork);
    canCreateCheckbox = new JCheckBox(Translation.get("gb.canCreateDescription"), anUser.canCreate);
    notFederatedCheckbox = new JCheckBox(Translation.get("gb.excludeFromFederationDescription"), anUser.excludeFromFederation);
    disabledCheckbox = new JCheckBox(Translation.get("gb.disableUserDescription"), anUser.disabled);
    organizationalUnitField = new JTextField(anUser.organizationalUnit == null ? "" : anUser.organizationalUnit, 25);
    organizationField = new JTextField(anUser.organization == null ? "" : anUser.organization, 25);
    localityField = new JTextField(anUser.locality == null ? "" : anUser.locality, 25);
    stateProvinceField = new JTextField(anUser.stateProvince == null ? "" : anUser.stateProvince, 25);
    countryCodeField = new JTextField(anUser.countryCode == null ? "" : anUser.countryCode, 15);
    // credentials are optionally controlled by 3rd-party authentication
    usernameField.setEnabled(anUser.isLocalAccount());
    passwordField.setEnabled(anUser.isLocalAccount());
    confirmPasswordField.setEnabled(anUser.isLocalAccount());
    JPanel fieldsPanel = new JPanel(new GridLayout(0, 1));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.username"), usernameField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.password"), passwordField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.confirmPassword"), confirmPasswordField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.displayName"), displayNameField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.emailAddress"), emailAddressField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.canAdmin"), canAdminCheckbox));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.canFork"), canForkCheckbox));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.canCreate"), canCreateCheckbox));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.excludeFromFederation"), notFederatedCheckbox));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.disableUser"), disabledCheckbox));
    JPanel attributesPanel = new JPanel(new GridLayout(0, 1, 5, 2));
    attributesPanel.add(newFieldPanel(Translation.get("gb.organizationalUnit") + " (OU)", organizationalUnitField));
    attributesPanel.add(newFieldPanel(Translation.get("gb.organization") + " (O)", organizationField));
    attributesPanel.add(newFieldPanel(Translation.get("gb.locality") + " (L)", localityField));
    attributesPanel.add(newFieldPanel(Translation.get("gb.stateProvince") + " (ST)", stateProvinceField));
    attributesPanel.add(newFieldPanel(Translation.get("gb.countryCode") + " (C)", countryCodeField));
    final Insets _insets = new Insets(5, 5, 5, 5);
    repositoryPalette = new RegistrantPermissionsPanel(RegistrantType.REPOSITORY);
    teamsPalette = new JPalette<TeamModel>();
    JPanel fieldsPanelTop = new JPanel(new BorderLayout());
    fieldsPanelTop.add(fieldsPanel, BorderLayout.NORTH);
    JPanel attributesPanelTop = new JPanel(new BorderLayout());
    attributesPanelTop.add(attributesPanel, BorderLayout.NORTH);
    JPanel repositoriesPanel = new JPanel(new BorderLayout()) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return _insets;
        }
    };
    repositoriesPanel.add(repositoryPalette, BorderLayout.CENTER);
    JPanel teamsPanel = new JPanel(new BorderLayout()) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return _insets;
        }
    };
    teamsPanel.add(teamsPalette, BorderLayout.CENTER);
    JTabbedPane panel = new JTabbedPane(JTabbedPane.TOP);
    panel.addTab(Translation.get("gb.general"), fieldsPanelTop);
    panel.addTab(Translation.get("gb.attributes"), attributesPanelTop);
    if (protocolVersion > 1) {
        panel.addTab(Translation.get("gb.teamMemberships"), teamsPanel);
    }
    panel.addTab(Translation.get("gb.restrictedRepositories"), repositoriesPanel);
    JButton createButton = new JButton(Translation.get("gb.save"));
    createButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if (validateFields()) {
                canceled = false;
                setVisible(false);
            }
        }
    });
    JButton cancelButton = new JButton(Translation.get("gb.cancel"));
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            canceled = true;
            setVisible(false);
        }
    });
    JPanel controls = new JPanel();
    controls.add(cancelButton);
    controls.add(createButton);
    JPanel centerPanel = new JPanel(new BorderLayout(5, 5)) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return _insets;
        }
    };
    centerPanel.add(panel, BorderLayout.CENTER);
    centerPanel.add(controls, BorderLayout.SOUTH);
    getContentPane().setLayout(new BorderLayout(5, 5));
    getContentPane().add(centerPanel, BorderLayout.CENTER);
    pack();
}
Also used : JPanel(javax.swing.JPanel) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) GridLayout(java.awt.GridLayout) TeamModel(com.gitblit.models.TeamModel) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JPasswordField(javax.swing.JPasswordField)

Example 65 with JTabbedPane

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

the class EnhancedDebuggerWindow method createDebug.

/**
     * Creates the main debug window that provides information about Smack and also shows
     * a tab panel for each connection that is being debugged.
     */
@SuppressWarnings({ "rawtypes", "unchecked" })
private void createDebug() {
    frame = new JFrame("Smack Debug Window");
    if (!PERSISTED_DEBUGGER) {
        // Add listener for window closing event
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent evt) {
                rootWindowClosing(evt);
            }
        });
    }
    // We'll arrange the UI into tabs. The last tab contains Smack's information.
    // All the connection debugger tabs will be shown before the Smack info tab. 
    tabbedPane = new JTabbedPane();
    // Create the Smack info panel 
    JPanel informationPanel = new JPanel();
    informationPanel.setLayout(new BoxLayout(informationPanel, BoxLayout.Y_AXIS));
    // Add the Smack version label
    JPanel versionPanel = new JPanel();
    versionPanel.setLayout(new BoxLayout(versionPanel, BoxLayout.X_AXIS));
    versionPanel.setMaximumSize(new Dimension(2000, 31));
    versionPanel.add(new JLabel(" Smack version: "));
    JFormattedTextField field = new JFormattedTextField(SmackConfiguration.getVersion());
    field.setEditable(false);
    field.setBorder(null);
    versionPanel.add(field);
    informationPanel.add(versionPanel);
    // Add the list of installed IQ Providers
    JPanel iqProvidersPanel = new JPanel();
    iqProvidersPanel.setLayout(new GridLayout(1, 1));
    iqProvidersPanel.setBorder(BorderFactory.createTitledBorder("Installed IQ Providers"));
    Vector<String> providers = new Vector<String>();
    for (Object provider : ProviderManager.getIQProviders()) {
        if (provider.getClass() == Class.class) {
            providers.add(((Class<?>) provider).getName());
        } else {
            providers.add(provider.getClass().getName());
        }
    }
    // Sort the collection of providers
    Collections.sort(providers);
    JList list = new JList(providers);
    iqProvidersPanel.add(new JScrollPane(list));
    informationPanel.add(iqProvidersPanel);
    // Add the list of installed Extension Providers
    JPanel extensionProvidersPanel = new JPanel();
    extensionProvidersPanel.setLayout(new GridLayout(1, 1));
    extensionProvidersPanel.setBorder(BorderFactory.createTitledBorder("Installed Extension Providers"));
    providers = new Vector<String>();
    for (Object provider : ProviderManager.getExtensionProviders()) {
        if (provider.getClass() == Class.class) {
            providers.add(((Class<?>) provider).getName());
        } else {
            providers.add(provider.getClass().getName());
        }
    }
    // Sort the collection of providers
    Collections.sort(providers);
    list = new JList(providers);
    extensionProvidersPanel.add(new JScrollPane(list));
    informationPanel.add(extensionProvidersPanel);
    tabbedPane.add("Smack Info", informationPanel);
    // Add pop-up menu.
    JPopupMenu menu = new JPopupMenu();
    // Add a menu item that allows to close the current selected tab
    JMenuItem menuItem = new JMenuItem("Close");
    menuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // Remove the selected tab pane if it's not the Smack info pane
            if (tabbedPane.getSelectedIndex() < tabbedPane.getComponentCount() - 1) {
                int index = tabbedPane.getSelectedIndex();
                // Notify to the debugger to stop debugging
                EnhancedDebugger debugger = debuggers.get(index);
                debugger.cancel();
                // Remove the debugger from the root window
                tabbedPane.remove(debugger.tabbedPane);
                debuggers.remove(debugger);
                // Update the root window title
                frame.setTitle("Smack Debug Window -- Total connections: " + (tabbedPane.getComponentCount() - 1));
            }
        }
    });
    menu.add(menuItem);
    // Add a menu item that allows to close all the tabs that have their connections closed
    menuItem = new JMenuItem("Close All Not Active");
    menuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ArrayList<EnhancedDebugger> debuggersToRemove = new ArrayList<EnhancedDebugger>();
            // Remove all the debuggers of which their connections are no longer valid
            for (int index = 0; index < tabbedPane.getComponentCount() - 1; index++) {
                EnhancedDebugger debugger = debuggers.get(index);
                if (!debugger.isConnectionActive()) {
                    // Notify to the debugger to stop debugging
                    debugger.cancel();
                    debuggersToRemove.add(debugger);
                }
            }
            for (EnhancedDebugger debugger : debuggersToRemove) {
                // Remove the debugger from the root window
                tabbedPane.remove(debugger.tabbedPane);
                debuggers.remove(debugger);
            }
            // Update the root window title
            frame.setTitle("Smack Debug Window -- Total connections: " + (tabbedPane.getComponentCount() - 1));
        }
    });
    menu.add(menuItem);
    // Add listener to the text area so the popup menu can come up.
    tabbedPane.addMouseListener(new PopupListener(menu));
    frame.getContentPane().add(tabbedPane);
    frame.setSize(650, 400);
    if (!PERSISTED_DEBUGGER) {
        frame.setVisible(true);
    }
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) JTabbedPane(javax.swing.JTabbedPane) BoxLayout(javax.swing.BoxLayout) ArrayList(java.util.ArrayList) WindowAdapter(java.awt.event.WindowAdapter) GridLayout(java.awt.GridLayout) JFrame(javax.swing.JFrame) JMenuItem(javax.swing.JMenuItem) Vector(java.util.Vector) JScrollPane(javax.swing.JScrollPane) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JPopupMenu(javax.swing.JPopupMenu) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) JList(javax.swing.JList)

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