chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1819875 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench: RepositoryInfoFrame.java swing/InfoPanel.java
Date Tue, 02 Jan 2018 19:52:05 GMT
Author: fmui
Date: Tue Jan  2 19:52:04 2018
New Revision: 1819875

URL: http://svn.apache.org/viewvc?rev=1819875&view=rev
Log:
Workbench: added reload button to repository info window

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoPanel.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java?rev=1819875&r1=1819874&r2=1819875&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java
Tue Jan  2 19:52:04 2018
@@ -20,13 +20,22 @@ package org.apache.chemistry.opencmis.wo
 
 import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNotEmpty;
 
+import java.awt.BorderLayout;
 import java.awt.Component;
+import java.awt.Cursor;
 import java.awt.Dimension;
+import java.awt.FlowLayout;
 import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.GregorianCalendar;
 import java.util.Map;
 
 import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
 import javax.swing.JFrame;
+import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
 import javax.swing.JTree;
@@ -36,6 +45,7 @@ import javax.swing.tree.DefaultTreeCellR
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreeSelectionModel;
 
+import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.data.AclCapabilities;
 import org.apache.chemistry.opencmis.commons.data.ExtensionFeature;
 import org.apache.chemistry.opencmis.commons.data.PermissionMapping;
@@ -56,6 +66,7 @@ public class RepositoryInfoFrame extends
     private static final String WINDOW_TITLE = "CMIS Repository Info";
 
     private final ClientModel model;
+    private JComponent infoPanel;
 
     public RepositoryInfoFrame(ClientModel model) {
         super();
@@ -72,6 +83,8 @@ public class RepositoryInfoFrame extends
         setPreferredSize(new Dimension((int) (screenSize.getWidth() / 2.5), (int) (screenSize.getHeight()
/ 1.5)));
         setMinimumSize(new Dimension(200, 60));
 
+        setLayout(new BorderLayout());
+
         RepositoryInfo repInfo = null;
         try {
             repInfo = model.getRepositoryInfo();
@@ -81,7 +94,36 @@ public class RepositoryInfoFrame extends
             return;
         }
 
-        add(new JScrollPane(new RepositoryInfoPanel(model, repInfo)));
+        infoPanel = new JScrollPane(new RepositoryInfoPanel(model, repInfo, -1));
+        add(infoPanel, BorderLayout.CENTER);
+
+        final JPanel inputPanel = new JPanel(new FlowLayout());
+        add(inputPanel, BorderLayout.PAGE_END);
+
+        JButton reloadButton = new JButton("Reload");
+        reloadButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                try {
+                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+                    Session session = model.getClientSession().getSession();
+                    String repId = session.getRepositoryInfo().getId();
+                    RepositoryInfo repInfo = session.getBinding().getRepositoryService().getRepositoryInfo(repId,
null);
+
+                    remove(infoPanel);
+                    infoPanel = new JScrollPane(new RepositoryInfoPanel(model, repInfo, System.currentTimeMillis()));
+                    add(infoPanel, BorderLayout.CENTER);
+
+                    validate();
+                } finally {
+                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+                }
+            }
+        });
+        inputPanel.add(reloadButton, BorderLayout.LINE_END);
+
+        getRootPane().setDefaultButton(reloadButton);
 
         ClientHelper.installEscapeBinding(this, getRootPane(), true);
 
@@ -97,11 +139,18 @@ public class RepositoryInfoFrame extends
         private static final long serialVersionUID = 1L;
 
         private final RepositoryInfo repInfo;
+        private final GregorianCalendar lastUpdate;
 
-        public RepositoryInfoPanel(ClientModel model, RepositoryInfo repInfo) {
+        public RepositoryInfoPanel(ClientModel model, RepositoryInfo repInfo, long lastUpdate)
{
             super(model);
 
             this.repInfo = repInfo;
+            if (lastUpdate >= 0) {
+                this.lastUpdate = new GregorianCalendar();
+                this.lastUpdate.setTimeInMillis(lastUpdate);
+            } else {
+                this.lastUpdate = null;
+            }
             createGUI();
         }
 
@@ -242,7 +291,7 @@ public class RepositoryInfoFrame extends
                     JTable permTable = new JTable(data, new String[] { "Permission", "Description"
});
                     permTable.setFillsViewportHeight(true);
                     permTable.setRowHeight((int) (getFontMetrics(getFont()).getHeight() *
1.1));
-                    addComponent("Permissions:", new JScrollPane(permTable));
+                    addComponent("Permissions:", createScrollePane(permTable));
                 }
 
                 if (cap.getPermissionMapping() != null) {
@@ -258,7 +307,7 @@ public class RepositoryInfoFrame extends
                     JTable permMapTable = new JTable(data, new String[] { "Key", "Permissions"
});
                     permMapTable.setFillsViewportHeight(true);
                     permMapTable.setRowHeight((int) (getFontMetrics(getFont()).getHeight()
* 1.1));
-                    addComponent("Permission mapping:", new JScrollPane(permMapTable));
+                    addComponent("Permission mapping:", createScrollePane(permMapTable));
                 }
             }
 
@@ -302,15 +351,25 @@ public class RepositoryInfoFrame extends
 
                 extensionFeaturesTree.setModel(new DefaultTreeModel(extFeatRootNode));
 
-                addComponent("Extension Features:", new JScrollPane(extensionFeaturesTree));
+                addComponent("Extension Features:", createScrollePane(extensionFeaturesTree));
             }
 
             if (isNotEmpty(repInfo.getExtensions())) {
-                addComponent("Extensions:", new JScrollPane(new ExtensionsTree(repInfo.getExtensions())));
+                addComponent("Extensions:", createScrollePane(new ExtensionsTree(repInfo.getExtensions())));
             }
 
+            addSeparator();
+            addLine("Last update:").setText(lastUpdate != null ? ClientHelper.getDateString(lastUpdate)
: "(session)");
+
             regenerateGUI();
         }
+        
+        private JScrollPane createScrollePane(Component comp) {
+            JScrollPane pane = new JScrollPane(comp);
+            pane.setPreferredSize(new Dimension(pane.getPreferredSize().width, WorkbenchScale.scaleInt(200)));
+            
+            return pane;
+        }
 
         private void appendToString(StringBuilder sb, String str) {
             if (sb.length() > 0) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoPanel.java?rev=1819875&r1=1819874&r2=1819875&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoPanel.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoPanel.java
Tue Jan  2 19:52:04 2018
@@ -251,15 +251,17 @@ public abstract class InfoPanel extends
 
             Component comp = parent.getComponent(r * cols + 1);
             if (comp instanceof JTextField || comp instanceof JLabel) {
-                labelConstraints.setHeight(height);
                 valueConstraints.setConstraint(SpringLayout.BASELINE,
                         labelConstraints.getConstraint(SpringLayout.BASELINE));
             } else if (comp instanceof JSeparator) {
                 height = Spring.scale(height, 0.5f);
                 valueConstraints.setHeight(height);
-                valueConstraints.setY(Spring.sum(y, Spring.constant(minHeight / 4)));
+                valueConstraints.setY(Spring.sum(y, Spring.sum(Spring.scale(height, 0.5f),
+                        Spring.minus(Spring.constant((int) comp.getPreferredSize().getHeight()
/ 2)))));
             }
 
+            labelConstraints.setHeight(height);
+
             y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
         }
 



Mime
View raw message