Search in sources :

Example 56 with ActionEvent

use of java.awt.event.ActionEvent in project gitblit by gitblit.

the class UsersPanel method initialize.

private void initialize() {
    JButton refreshUsers = new JButton(Translation.get("gb.refresh"));
    refreshUsers.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            refreshUsers();
        }
    });
    JButton createUser = new JButton(Translation.get("gb.create"));
    createUser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            createUser();
        }
    });
    final JButton editUser = new JButton(Translation.get("gb.edit"));
    editUser.setEnabled(false);
    editUser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            editUser(getSelectedUsers().get(0));
        }
    });
    final JButton delUser = new JButton(Translation.get("gb.delete"));
    delUser.setEnabled(false);
    delUser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            deleteUsers(getSelectedUsers());
        }
    });
    NameRenderer nameRenderer = new NameRenderer();
    tableModel = new UsersTableModel();
    defaultSorter = new TableRowSorter<UsersTableModel>(tableModel);
    table = Utils.newTable(tableModel, Utils.DATE_FORMAT);
    String name = table.getColumnName(UsersTableModel.Columns.Name.ordinal());
    table.getColumn(name).setCellRenderer(nameRenderer);
    int w = 130;
    name = table.getColumnName(UsersTableModel.Columns.Type.ordinal());
    table.getColumn(name).setMinWidth(w);
    table.getColumn(name).setMaxWidth(w);
    name = table.getColumnName(UsersTableModel.Columns.Teams.ordinal());
    table.getColumn(name).setMinWidth(w);
    table.getColumn(name).setMaxWidth(w);
    name = table.getColumnName(UsersTableModel.Columns.Repositories.ordinal());
    table.getColumn(name).setMinWidth(w);
    table.getColumn(name).setMaxWidth(w);
    table.setRowSorter(defaultSorter);
    table.getRowSorter().toggleSortOrder(UsersTableModel.Columns.Name.ordinal());
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            boolean selected = table.getSelectedRow() > -1;
            boolean singleSelection = table.getSelectedRows().length == 1;
            editUser.setEnabled(singleSelection && selected);
            delUser.setEnabled(selected);
        }
    });
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                editUser(getSelectedUsers().get(0));
            }
        }
    });
    filterTextfield = new JTextField();
    filterTextfield.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            filterUsers(filterTextfield.getText());
        }
    });
    filterTextfield.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            filterUsers(filterTextfield.getText());
        }
    });
    JPanel userFilterPanel = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN));
    userFilterPanel.add(new JLabel(Translation.get("gb.filter")), BorderLayout.WEST);
    userFilterPanel.add(filterTextfield, BorderLayout.CENTER);
    JPanel userTablePanel = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN));
    userTablePanel.add(userFilterPanel, BorderLayout.NORTH);
    userTablePanel.add(new JScrollPane(table), BorderLayout.CENTER);
    JPanel userControls = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
    userControls.add(refreshUsers);
    userControls.add(createUser);
    userControls.add(editUser);
    userControls.add(delUser);
    setLayout(new BorderLayout(Utils.MARGIN, Utils.MARGIN));
    header = new HeaderPanel(Translation.get("gb.users"), "user_16x16.png");
    add(header, BorderLayout.NORTH);
    add(userTablePanel, BorderLayout.CENTER);
    add(userControls, BorderLayout.SOUTH);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) ListSelectionListener(javax.swing.event.ListSelectionListener) KeyEvent(java.awt.event.KeyEvent) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout)

Example 57 with ActionEvent

use of java.awt.event.ActionEvent in project gitblit by gitblit.

the class FeedsPanel method initialize.

private void initialize() {
    prev = new JButton("<");
    prev.setToolTipText(Translation.get("gb.pagePrevious"));
    prev.setEnabled(false);
    prev.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            refreshFeeds(--page);
        }
    });
    next = new JButton(">");
    next.setToolTipText(Translation.get("gb.pageNext"));
    next.setEnabled(false);
    next.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            refreshFeeds(++page);
        }
    });
    JButton refreshFeeds = new JButton(Translation.get("gb.refresh"));
    refreshFeeds.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            refreshFeeds(0);
        }
    });
    final JButton viewCommit = new JButton(Translation.get("gb.view"));
    viewCommit.setEnabled(false);
    viewCommit.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            viewCommit();
        }
    });
    final JButton viewCommitDiff = new JButton(Translation.get("gb.commitdiff"));
    viewCommitDiff.setEnabled(false);
    viewCommitDiff.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            viewCommitDiff();
        }
    });
    final JButton viewTree = new JButton(Translation.get("gb.tree"));
    viewTree.setEnabled(false);
    viewTree.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            viewTree();
        }
    });
    JButton subscribeFeeds = new JButton(Translation.get("gb.subscribe") + "...");
    subscribeFeeds.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            subscribeFeeds(gitblit.getAvailableFeeds());
        }
    });
    JPanel controls = new JPanel(new FlowLayout(FlowLayout.CENTER, Utils.MARGIN, 0));
    controls.add(refreshFeeds);
    controls.add(subscribeFeeds);
    controls.add(viewCommit);
    controls.add(viewCommitDiff);
    controls.add(viewTree);
    NameRenderer nameRenderer = new NameRenderer();
    tableModel = new FeedEntryTableModel();
    header = new HeaderPanel(Translation.get("gb.activity"), "feed_16x16.png");
    table = Utils.newTable(tableModel, Utils.DATE_FORMAT);
    defaultSorter = new TableRowSorter<FeedEntryTableModel>(tableModel);
    String name = table.getColumnName(FeedEntryTableModel.Columns.Author.ordinal());
    table.getColumn(name).setCellRenderer(nameRenderer);
    name = table.getColumnName(FeedEntryTableModel.Columns.Repository.ordinal());
    table.getColumn(name).setCellRenderer(nameRenderer);
    name = table.getColumnName(FeedEntryTableModel.Columns.Branch.ordinal());
    table.getColumn(name).setCellRenderer(new BranchRenderer());
    name = table.getColumnName(FeedEntryTableModel.Columns.Message.ordinal());
    table.getColumn(name).setCellRenderer(new MessageRenderer(gitblit));
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                if (e.isControlDown()) {
                    viewCommitDiff();
                } else {
                    viewCommit();
                }
            }
        }
    });
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            boolean singleSelection = table.getSelectedRowCount() == 1;
            viewCommit.setEnabled(singleSelection);
            viewCommitDiff.setEnabled(singleSelection);
            viewTree.setEnabled(singleSelection);
        }
    });
    repositoryChoices = new DefaultComboBoxModel();
    repositorySelector = new JComboBox(repositoryChoices);
    repositorySelector.setRenderer(nameRenderer);
    repositorySelector.setForeground(nameRenderer.getForeground());
    repositorySelector.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            // repopulate the author list based on repository selection
            // preserve author selection, if possible
            String selectedAuthor = null;
            if (authorSelector.getSelectedIndex() > -1) {
                selectedAuthor = authorSelector.getSelectedItem().toString();
            }
            updateAuthors();
            if (selectedAuthor != null) {
                if (authorChoices.getIndexOf(selectedAuthor) > -1) {
                    authorChoices.setSelectedItem(selectedAuthor);
                }
            }
            filterFeeds();
        }
    });
    authorChoices = new DefaultComboBoxModel();
    authorSelector = new JComboBox(authorChoices);
    authorSelector.setRenderer(nameRenderer);
    authorSelector.setForeground(nameRenderer.getForeground());
    authorSelector.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            filterFeeds();
        }
    });
    JPanel northControls = new JPanel(new FlowLayout(FlowLayout.LEFT, Utils.MARGIN, 0));
    northControls.add(new JLabel(Translation.get("gb.repository")));
    northControls.add(repositorySelector);
    northControls.add(new JLabel(Translation.get("gb.author")));
    northControls.add(authorSelector);
    //		northControls.add(prev);
    //		northControls.add(next);
    JPanel northPanel = new JPanel(new BorderLayout(0, Utils.MARGIN));
    northPanel.add(header, BorderLayout.NORTH);
    northPanel.add(northControls, BorderLayout.CENTER);
    setLayout(new BorderLayout(Utils.MARGIN, Utils.MARGIN));
    add(northPanel, BorderLayout.NORTH);
    add(new JScrollPane(table), BorderLayout.CENTER);
    add(controls, BorderLayout.SOUTH);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) MouseEvent(java.awt.event.MouseEvent) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JLabel(javax.swing.JLabel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout)

Example 58 with ActionEvent

use of java.awt.event.ActionEvent in project gitblit by gitblit.

the class EditUserDialog method createRootPane.

@Override
protected JRootPane createRootPane() {
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JRootPane rootPane = new JRootPane();
    rootPane.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) JRootPane(javax.swing.JRootPane)

Example 59 with ActionEvent

use of java.awt.event.ActionEvent in project gitblit by gitblit.

the class EditRegistrationDialog method createRootPane.

@Override
protected JRootPane createRootPane() {
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JRootPane rootPane = new JRootPane();
    rootPane.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) JRootPane(javax.swing.JRootPane)

Example 60 with ActionEvent

use of java.awt.event.ActionEvent in project gitblit by gitblit.

the class GitblitManager method rebuildRecentMenu.

private void rebuildRecentMenu() {
    recentMenu.removeAll();
    ImageIcon icon = new ImageIcon(getClass().getResource("/gitblt-favicon.png"));
    List<GitblitRegistration> list = new ArrayList<GitblitRegistration>(registrations.values());
    Collections.sort(list, new Comparator<GitblitRegistration>() {

        @Override
        public int compare(GitblitRegistration o1, GitblitRegistration o2) {
            return o2.lastLogin.compareTo(o1.lastLogin);
        }
    });
    if (list.size() > maxRecentCount) {
        list = list.subList(0, maxRecentCount);
    }
    for (int i = 0; i < list.size(); i++) {
        final GitblitRegistration reg = list.get(i);
        JMenuItem item = new JMenuItem(reg.name, icon);
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1 + i, KeyEvent.CTRL_DOWN_MASK, false));
        item.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                login(reg);
            }
        });
        recentMenu.add(item);
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) JMenuItem(javax.swing.JMenuItem) Point(java.awt.Point)

Aggregations

ActionEvent (java.awt.event.ActionEvent)1619 ActionListener (java.awt.event.ActionListener)1289 JButton (javax.swing.JButton)417 JPanel (javax.swing.JPanel)391 JLabel (javax.swing.JLabel)253 JMenuItem (javax.swing.JMenuItem)219 BoxLayout (javax.swing.BoxLayout)172 AbstractAction (javax.swing.AbstractAction)166 FlowLayout (java.awt.FlowLayout)130 Insets (java.awt.Insets)129 GridBagConstraints (java.awt.GridBagConstraints)127 Dimension (java.awt.Dimension)126 GridBagLayout (java.awt.GridBagLayout)120 JMenu (javax.swing.JMenu)118 JScrollPane (javax.swing.JScrollPane)117 JCheckBox (javax.swing.JCheckBox)109 BorderLayout (java.awt.BorderLayout)108 JTextField (javax.swing.JTextField)85 JComboBox (javax.swing.JComboBox)77 ButtonGroup (javax.swing.ButtonGroup)72