From 0e44acbb2fec928a1606dc60f427a148fff405c9 Mon Sep 17 00:00:00 2001
From: Mohamed Ragab <moragab@gmail.com>
Date: Wed, 02 May 2012 11:15:01 -0400
Subject: [PATCH] Added a script to facilitate setting the proxy host and port and no proxy hosts, and then it concatenates all the java system properties for setting the java proxy configurations and puts the resulting string in an environment variable JAVA_PROXY_CONFIG, modified the scirpts gitblit, gitblit-ubuntu, and gitblit-centos to source the java-proxy-config.sh script and then include the resulting java proxy configuration in the java command
---
src/com/gitblit/client/GitblitPanel.java | 248 ++++++++++++++++++++++++++++++++++++-------------
1 files changed, 182 insertions(+), 66 deletions(-)
diff --git a/src/com/gitblit/client/GitblitPanel.java b/src/com/gitblit/client/GitblitPanel.java
index 911ec0c..f14ce79 100644
--- a/src/com/gitblit/client/GitblitPanel.java
+++ b/src/com/gitblit/client/GitblitPanel.java
@@ -17,96 +17,212 @@
import java.awt.BorderLayout;
import java.awt.Component;
+import java.awt.Insets;
import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
+import java.util.List;
import javax.swing.JPanel;
-import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
-import javax.swing.JTable;
-import javax.swing.table.DefaultTableColumnModel;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
-import com.gitblit.models.RepositoryModel;
-import com.gitblit.utils.RpcUtils;
+import com.gitblit.client.ClosableTabComponent.CloseTabListener;
+import com.gitblit.models.FeedModel;
-public class GitblitPanel extends JPanel {
+/**
+ * GitblitPanel is a container for the repository, users, settings, etc panels.
+ *
+ * @author James Moger
+ *
+ */
+public class GitblitPanel extends JPanel implements CloseTabListener {
private static final long serialVersionUID = 1L;
- String url;
- String account;
- char[] password;
+ private final RegistrationsDialog.RegistrationListener listener;
- JTabbedPane tabs;
+ private GitblitClient gitblit;
- private JTable repositoriesTable;
+ private JTabbedPane tabs;
- public GitblitPanel(String url, String account, char[] password) {
- this.url = url;
- this.account = account;
- this.password = password;
+ private RepositoriesPanel repositoriesPanel;
- tabs = new JTabbedPane(JTabbedPane.TOP);
- repositoriesTable = new JTable();
- repositoriesTable.setDefaultRenderer(Date.class, new DateCellRenderer(null));
+ private FeedsPanel feedsPanel;
- tabs.addTab("Repositories", new JScrollPane(repositoriesTable));
+ private UsersPanel usersPanel;
+
+ private TeamsPanel teamsPanel;
+
+ private SettingsPanel settingsPanel;
+
+ private StatusPanel statusPanel;
+
+ public GitblitPanel(GitblitRegistration reg, RegistrationsDialog.RegistrationListener listener) {
+ this.gitblit = new GitblitClient(reg);
+ this.listener = listener;
+
+ tabs = new JTabbedPane(JTabbedPane.BOTTOM);
+ tabs.addTab(Translation.get("gb.repositories"), createRepositoriesPanel());
+ tabs.addTab(Translation.get("gb.activity"), createFeedsPanel());
+ tabs.addTab(Translation.get("gb.teams"), createTeamsPanel());
+ tabs.addTab(Translation.get("gb.users"), createUsersPanel());
+ tabs.addTab(Translation.get("gb.settings"), createSettingsPanel());
+ tabs.addTab(Translation.get("gb.status"), createStatusPanel());
+ tabs.addChangeListener(new ChangeListener() {
+ public void stateChanged(ChangeEvent e) {
+ tabs.getSelectedComponent().requestFocus();
+ }
+ });
setLayout(new BorderLayout());
add(tabs, BorderLayout.CENTER);
}
+ private JPanel createRepositoriesPanel() {
+ repositoriesPanel = new RepositoriesPanel(gitblit) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void subscribeFeeds(List<FeedModel> feeds) {
+ GitblitPanel.this.subscribeFeeds(feeds);
+ }
+
+ @Override
+ protected void updateUsersTable() {
+ usersPanel.updateTable(false);
+ }
+
+ @Override
+ protected void updateTeamsTable() {
+ teamsPanel.updateTable(false);
+ }
+
+ };
+ return repositoriesPanel;
+ }
+
+ private JPanel createFeedsPanel() {
+ feedsPanel = new FeedsPanel(gitblit) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void subscribeFeeds(List<FeedModel> feeds) {
+ GitblitPanel.this.subscribeFeeds(feeds);
+ }
+ };
+ return feedsPanel;
+ }
+
+ private JPanel createUsersPanel() {
+ usersPanel = new UsersPanel(gitblit) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void updateTeamsTable() {
+ teamsPanel.updateTable(false);
+ }
+ };
+ return usersPanel;
+ }
+
+ private JPanel createTeamsPanel() {
+ teamsPanel = new TeamsPanel(gitblit) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void updateUsersTable() {
+ usersPanel.updateTable(false);
+ }
+ };
+ return teamsPanel;
+ }
+
+ private JPanel createSettingsPanel() {
+ settingsPanel = new SettingsPanel(gitblit);
+ return settingsPanel;
+ }
+
+ private JPanel createStatusPanel() {
+ statusPanel = new StatusPanel(gitblit);
+ return statusPanel;
+ }
+
public void login() throws IOException {
- refreshRepositoriesTable();
- }
+ gitblit.login();
- private void refreshRepositoriesTable() throws IOException {
- Map<String, RepositoryModel> repositories = RpcUtils
- .getRepositories(url, account, password);
- repositoriesTable.setModel(new RepositoriesModel(repositories));
+ repositoriesPanel.updateTable(true);
+ feedsPanel.updateTable(true);
- packColumns(repositoriesTable, 2);
- }
+ if (gitblit.allowManagement()) {
+ if (gitblit.getProtocolVersion() >= 2) {
+ // refresh teams panel
+ teamsPanel.updateTable(false);
+ } else {
+ // remove teams panel
+ String teams = Translation.get("gb.teams");
+ for (int i = 0; i < tabs.getTabCount(); i++) {
+ if (teams.equals(tabs.getTitleAt(i))) {
+ tabs.removeTabAt(i);
+ break;
+ }
+ }
+ }
+ usersPanel.updateTable(false);
+ } else {
+ // user does not have administrator privileges
+ // hide admin repository buttons
+ repositoriesPanel.disableManagement();
- private void packColumns(JTable table, int margin) {
- for (int c = 0; c < table.getColumnCount(); c++) {
- packColumn(table, c, 4);
+ while (tabs.getTabCount() > 2) {
+ // remove all management/administration tabs
+ tabs.removeTabAt(2);
+ }
+ }
+
+ if (gitblit.allowAdministration()) {
+ settingsPanel.updateTable(true);
+ statusPanel.updateTable(false);
+ } else {
+ // remove the settings and status tab
+ String[] titles = { Translation.get("gb.settings"), Translation.get("gb.status") };
+ for (String title : titles) {
+ for (int i = 0; i < tabs.getTabCount(); i++) {
+ if (tabs.getTitleAt(i).equals(title)) {
+ tabs.removeTabAt(i);
+ break;
+ }
+ }
+ }
}
}
- // Sets the preferred width of the visible column specified by vColIndex.
- // The column will be just wide enough to show the column head and the
- // widest cell in the column. margin pixels are added to the left and right
- // (resulting in an additional width of 2*margin pixels).
- private void packColumn(JTable table, int vColIndex, int margin) {
- DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
- TableColumn col = colModel.getColumn(vColIndex);
- int width = 0;
-
- // Get width of column header
- TableCellRenderer renderer = col.getHeaderRenderer();
- if (renderer == null) {
- renderer = table.getTableHeader().getDefaultRenderer();
- }
- Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false,
- false, 0, 0);
- width = comp.getPreferredSize().width;
-
- // Get maximum width of column data
- for (int r = 0; r < table.getRowCount(); r++) {
- renderer = table.getCellRenderer(r, vColIndex);
- comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, vColIndex),
- false, false, r, vColIndex);
- width = Math.max(width, comp.getPreferredSize().width);
- }
-
- // Add margin
- width += 2 * margin;
-
- // Set the width
- col.setPreferredWidth(width);
+ @Override
+ public Insets getInsets() {
+ return Utils.INSETS;
}
-}
+
+ @Override
+ public void closeTab(Component c) {
+ gitblit = null;
+ }
+
+ protected void subscribeFeeds(final List<FeedModel> feeds) {
+ SubscriptionsDialog dialog = new SubscriptionsDialog(feeds) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void save() {
+ gitblit.updateSubscribedFeeds(feeds);
+ listener.saveRegistration(gitblit.reg.name, gitblit.reg);
+ setVisible(false);
+ repositoriesPanel.updateTable(false);
+ }
+ };
+ dialog.setLocationRelativeTo(GitblitPanel.this);
+ dialog.setVisible(true);
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.1