From c75304637f5535e634e57d4ed933c0fdb594d890 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 28 Oct 2011 08:08:00 -0400 Subject: [PATCH] Added a list branches rpc --- src/com/gitblit/client/Utils.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/com/gitblit/client/Utils.java b/src/com/gitblit/client/Utils.java index c33c110..786eb9f 100644 --- a/src/com/gitblit/client/Utils.java +++ b/src/com/gitblit/client/Utils.java @@ -15,22 +15,49 @@ */ package com.gitblit.client; +import java.awt.Color; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.io.PrintWriter; +import java.io.StringWriter; import java.text.MessageFormat; +import java.util.Date; import javax.swing.JOptionPane; +import javax.swing.JScrollPane; import javax.swing.JTable; +import javax.swing.JTextArea; import javax.swing.table.DefaultTableColumnModel; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; import com.gitblit.Constants.RpcRequest; public class Utils { + public static JTable newTable(TableModel model) { + JTable table = new JTable(model); + table.setCellSelectionEnabled(false); + table.setRowSelectionAllowed(true); + table.getTableHeader().setReorderingAllowed(false); + table.setGridColor(new Color(0xd9d9d9)); + table.setBackground(Color.white); + table.setDefaultRenderer(Date.class, new DateCellRenderer(null, Color.orange.darker())); + return table; + } + + public static void explainNotAllowed(Component c, RpcRequest request) { + String msg = MessageFormat.format("The Gitblit server does not allow the request \"{0}\".", + request.name()); + JOptionPane.showMessageDialog(c, msg, "Not Allowed", JOptionPane.ERROR_MESSAGE); + } + public static void explainForbidden(Component c, RpcRequest request) { String msg = MessageFormat.format( - "The request \"{0}\" has been forbidden by the Gitblit server.", request.name()); + "The request \"{0}\" has been forbidden for the account by the Gitblit server.", + request.name()); JOptionPane.showMessageDialog(c, msg, "Forbidden", JOptionPane.ERROR_MESSAGE); } @@ -40,8 +67,26 @@ JOptionPane.showMessageDialog(c, msg, "Unauthorized", JOptionPane.ERROR_MESSAGE); } + public static void explainUnknown(Component c, RpcRequest request) { + String msg = MessageFormat.format( + "The request \"{0}\" is not recognized by the Gitblit server.", request.name()); + JOptionPane.showMessageDialog(c, msg, "Unknown Request", JOptionPane.ERROR_MESSAGE); + } + public static void showException(Component c, Throwable t) { - // TODO show the unexpected exception + StringWriter writer = new StringWriter(); + t.printStackTrace(new PrintWriter(writer)); + String stacktrace = writer.toString(); + try { + writer.close(); + } catch (Throwable x) { + } + JTextArea textArea = new JTextArea(stacktrace); + textArea.setFont(new Font("monospaced", Font.PLAIN, 11)); + JScrollPane jsp = new JScrollPane(textArea); + jsp.setPreferredSize(new Dimension(800, 400)); + JOptionPane.showMessageDialog(c, jsp, Translation.get("gb.error"), + JOptionPane.ERROR_MESSAGE); } public static void packColumns(JTable table, int margin) { -- Gitblit v1.9.1