chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1692905 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench: ./ details/ swing/
Date Mon, 27 Jul 2015 16:08:28 GMT
Author: fmui
Date: Mon Jul 27 16:08:27 2015
New Revision: 1692905

URL: http://svn.apache.org/r1692905
Log:
Workbench improvements

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/DiscoverLoginTab.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/LoginDialog.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PropertyTable.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CollectionRenderer.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java?rev=1692905&r1=1692904&r2=1692905&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
Mon Jul 27 16:08:27 2015
@@ -642,6 +642,15 @@ public final class ClientHelper {
     }
 
     public static Console openConsole(final Component parent, final ClientModel model, final
URI file) {
+        return openConsole(parent, model, file, null);
+    }
+
+    public static Console openConsole(final Component parent, final ClientModel model, final
String soureCode) {
+        return openConsole(parent, model, null, soureCode);
+    }
+
+    public static Console openConsole(final Component parent, final ClientModel model, final
URI file,
+            final String soureCode) {
         try {
             parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
@@ -694,7 +703,11 @@ public final class ClientHelper {
             });
             cmisMenu.add(menuItem);
 
-            console.getInputArea().setText(readFileAndRemoveHeader(file));
+            if (file != null) {
+                console.getInputArea().setText(readFileAndRemoveHeader(file));
+            } else if (soureCode != null) {
+                console.getInputArea().setText(soureCode);
+            }
 
             return console;
         } catch (Exception ex) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/DiscoverLoginTab.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/DiscoverLoginTab.java?rev=1692905&r1=1692904&r2=1692905&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/DiscoverLoginTab.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/DiscoverLoginTab.java
Mon Jul 27 16:08:27 2015
@@ -44,6 +44,7 @@ import javax.swing.JScrollPane;
 import javax.swing.JTable;
 import javax.swing.JTextField;
 import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
 import javax.swing.table.AbstractTableModel;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.TableColumn;
@@ -130,10 +131,15 @@ public class DiscoverLoginTab extends Ab
     }
 
     @Override
+    public boolean transferSessionParametersToExpertTab() {
+        return true;
+    }
+
+    @Override
     public Map<String, String> getSessionParameters() {
         int row = authTable.getSelectedRow();
         if (row < 0) {
-            return null;
+            return Collections.emptyMap();
         }
 
         // compile session parameters
@@ -184,6 +190,19 @@ public class DiscoverLoginTab extends Ab
 
             final JPopupMenu popup = new JPopupMenu();
 
+            // copy to expert login
+            JMenuItem expertLoginMenuItem = new JMenuItem("Transfer to expert login tab");
+            popup.add(expertLoginMenuItem);
+
+            expertLoginMenuItem.addActionListener(new ActionListener() {
+                @Override
+                public void actionPerformed(ActionEvent e) {
+                    ((LoginDialog) SwingUtilities.getRoot(CmisAuthenticationTable.this)).switchToExpertTab();
+                }
+            });
+
+            popup.addSeparator();
+
             // copy all endpoints to clipboard
             JMenuItem allEnpointsMenuItem = new JMenuItem("Copy all endpoints to clipboard");
             popup.add(allEnpointsMenuItem);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/LoginDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/LoginDialog.java?rev=1692905&r1=1692904&r2=1692905&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/LoginDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/LoginDialog.java
Mon Jul 27 16:08:27 2015
@@ -31,7 +31,6 @@ import java.awt.event.ActionListener;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
-import java.util.Map;
 import java.util.ServiceLoader;
 
 import javax.swing.BorderFactory;
@@ -115,18 +114,6 @@ public class LoginDialog extends JDialog
             public void actionPerformed(ActionEvent e) {
                 repositoryBox.removeAllItems();
 
-                if (currentTab == discoverLoginTab) {
-                    Map<String, String> paramters = currentTab.getSessionParameters();
-                    if (paramters == null) {
-                        JOptionPane.showMessageDialog(LoginDialog.this, "Select an endpoint.",
"No endpoint selected",
-                                JOptionPane.INFORMATION_MESSAGE);
-                    } else {
-                        expertLoginTab.setSessionParameters(paramters);
-                        loginTabs.setSelectedComponent(expertLoginTab);
-                    }
-                    return;
-                }
-
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
@@ -254,6 +241,12 @@ public class LoginDialog extends JDialog
                     }
                 }
 
+                if (loginTabs.getSelectedComponent() == discoverLoginTab) {
+                    loadRepositoryButton.setEnabled(false);
+                } else {
+                    loadRepositoryButton.setEnabled(true);
+                }
+
                 currentTab = (AbstractLoginTab) loginTabs.getSelectedComponent();
             }
         });
@@ -318,6 +311,21 @@ public class LoginDialog extends JDialog
         return clientSession;
     }
 
+    public void switchToBasicTab() {
+        loginTabs.setSelectedComponent(basicLoginTab);
+    }
+
+    public void switchToExpertTab() {
+        if (currentTab.transferSessionParametersToExpertTab()) {
+            expertLoginTab.setSessionParameters(currentTab.getSessionParameters());
+        }
+        loginTabs.setSelectedComponent(expertLoginTab);
+    }
+
+    public void switchToDiscoverTab() {
+        loginTabs.setSelectedComponent(discoverLoginTab);
+    }
+
     public boolean isCanceled() {
         return canceled;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.java?rev=1692905&r1=1692904&r2=1692905&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.java
Mon Jul 27 16:08:27 2015
@@ -86,6 +86,7 @@ public class ObjectPanel extends InfoPan
     private JPanel buttonPanel;
     private JButton refreshButton;
     private JButton checkButton;
+    private JButton consoleButton;
     private JPanel scriptPanel;
     private JButton scriptOpenButton;
     private JButton scriptRunButton;
@@ -126,6 +127,7 @@ public class ObjectPanel extends InfoPan
                     aclExactField.setText("");
                     refreshButton.setEnabled(false);
                     checkButton.setEnabled(false);
+                    consoleButton.setEnabled(false);
                     scriptPanel.setVisible(false);
                 } else {
                     try {
@@ -220,6 +222,7 @@ public class ObjectPanel extends InfoPan
 
                         refreshButton.setEnabled(true);
                         checkButton.setEnabled(true);
+                        consoleButton.setEnabled(true);
 
                         if (object instanceof Document) {
                             String name = object.getName().toLowerCase(Locale.ENGLISH);
@@ -266,6 +269,9 @@ public class ObjectPanel extends InfoPan
         checkButton = new JButton("Check specification compliance");
         checkButton.setEnabled(false);
         buttonPanel.add(checkButton);
+        consoleButton = new JButton("Open console");
+        consoleButton.setEnabled(false);
+        buttonPanel.add(consoleButton);
 
         scriptPanel = addComponent("", new JPanel(new BorderLayout()));
         scriptPanel.setOpaque(false);
@@ -325,6 +331,21 @@ public class ObjectPanel extends InfoPan
             }
         });
 
+        consoleButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                try {
+                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+                    ClientHelper.openConsole(ObjectPanel.this, getClientModel(),
+                            createGroovySourceCode(getClientModel().getCurrentObject()));
+                } catch (Exception ex) {
+                    ClientHelper.showError(null, ex);
+                } finally {
+                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+                }
+            }
+        });
+
         scriptOpenButton.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 try {
@@ -334,7 +355,7 @@ public class ObjectPanel extends InfoPan
                     String name = doc.getName().toLowerCase(Locale.ENGLISH);
                     if (name.endsWith(".groovy")) {
                         File file = ClientHelper.createTempFileFromDocument(doc, null);
-                        Console console = ClientHelper.openConsole(ObjectPanel.this, getClientModel(),
null);
+                        Console console = ClientHelper.openConsole(ObjectPanel.this, getClientModel(),
(String) null);
                         if (console != null) {
                             console.loadScriptFile(file);
                         }
@@ -381,6 +402,46 @@ public class ObjectPanel extends InfoPan
         return ((Document) document).getContentUrl();
     }
 
+    private String createGroovySourceCode(CmisObject object) {
+        StringBuilder sb = new StringBuilder(512);
+
+        sb.append("import org.apache.chemistry.opencmis.commons.*\n");
+        sb.append("import org.apache.chemistry.opencmis.commons.data.*\n");
+        sb.append("import org.apache.chemistry.opencmis.commons.enums.*\n");
+        sb.append("import org.apache.chemistry.opencmis.client.api.*\n\n");
+
+        sb.append("// ");
+        sb.append(object.getName());
+        sb.append('\n');
+
+        switch (object.getBaseTypeId()) {
+        case CMIS_DOCUMENT:
+            sb.append("Document doc = (Document)");
+            break;
+        case CMIS_FOLDER:
+            sb.append("Folder folder = (Folder)");
+            break;
+        case CMIS_POLICY:
+            sb.append("Policy policy = (Policy)");
+            break;
+        case CMIS_RELATIONSHIP:
+            sb.append("Relationship rel = (Relationship)");
+            break;
+        case CMIS_ITEM:
+            sb.append("Item item = (Item)");
+            break;
+        default:
+            sb.append("CmisObject obj =");
+            break;
+        }
+
+        sb.append(" session.getObject(\"");
+        sb.append(object.getId().replaceAll("\"", "\\\""));
+        sb.append("\");\n\n");
+
+        return sb.toString();
+    }
+
     private static class JTextAreaWriter extends Writer {
         private final JTextArea textArea;
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PropertyTable.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PropertyTable.java?rev=1692905&r1=1692904&r2=1692905&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PropertyTable.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PropertyTable.java
Mon Jul 27 16:08:27 2015
@@ -20,22 +20,27 @@ package org.apache.chemistry.opencmis.wo
 
 import java.awt.event.MouseEvent;
 import java.util.Collection;
+import java.util.List;
 
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.ObjectType;
 import org.apache.chemistry.opencmis.client.api.Property;
 import org.apache.chemistry.opencmis.commons.enums.Action;
 import org.apache.chemistry.opencmis.workbench.PropertyEditorFrame;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+import org.apache.chemistry.opencmis.workbench.swing.CollectionRenderer;
 
 public class PropertyTable extends AbstractDetailsTable {
 
     private static final long serialVersionUID = 1L;
 
-    private static final String[] COLUMN_NAMES = { "Name", "Id", "Type", "Value" };
-    private static final int[] COLUMN_WIDTHS = { 200, 200, 80, 300 };
+    private static final String[] COLUMN_NAMES = { "Name", "Type", "Value", "Property ID",
"Object Type ID" };
+    private static final int[] COLUMN_WIDTHS = { 200, 80, 400, 200, 200 };
 
     public PropertyTable(ClientModel model) {
         super();
         init(model, COLUMN_NAMES, COLUMN_WIDTHS);
+        setDefaultRenderer(Collection.class, new CollectionRenderer(true));
     }
 
     @Override
@@ -50,17 +55,20 @@ public class PropertyTable extends Abstr
     }
 
     public Object getDetailValueAt(int rowIndex, int columnIndex) {
-        Property<?> property = getObject().getProperties().get(rowIndex);
+        CmisObject obj = getObject();
+        Property<?> property = obj.getProperties().get(rowIndex);
 
         switch (columnIndex) {
         case 0:
             return property.getDefinition().getDisplayName();
         case 1:
-            return property.getId();
-        case 2:
             return property.getDefinition().getPropertyType().value();
-        case 3:
+        case 2:
             return property.getValues();
+        case 3:
+            return property.getId();
+        case 4:
+            return findObjectType(obj, property.getId());
         default:
         }
 
@@ -69,10 +77,28 @@ public class PropertyTable extends Abstr
 
     @Override
     public Class<?> getDetailColumClass(int columnIndex) {
-        if (columnIndex == 3) {
+        if (columnIndex == 2) {
             return Collection.class;
         }
 
         return super.getDetailColumClass(columnIndex);
     }
+
+    private String findObjectType(CmisObject obj, String propertyId) {
+        List<ObjectType> types = obj.findObjectType(propertyId);
+        if (types == null || types.isEmpty()) {
+            return "???";
+        }
+
+        StringBuilder sb = new StringBuilder(64);
+
+        for (ObjectType type : types) {
+            if (sb.length() > 0) {
+                sb.append(" ,");
+            }
+            sb.append(type.getId());
+        }
+
+        return sb.toString();
+    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CollectionRenderer.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/CollectionRenderer.java?rev=1692905&r1=1692904&r2=1692905&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CollectionRenderer.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CollectionRenderer.java
Mon Jul 27 16:08:27 2015
@@ -35,6 +35,8 @@ public class CollectionRenderer extends
 
     private static final String NOT_SET_COLOR;
 
+    private boolean bold = false;
+
     static {
         Color notSetColor = UIManager.getColor("Label.disabledText");
         if (notSetColor != null) {
@@ -49,6 +51,11 @@ public class CollectionRenderer extends
         super();
     }
 
+    public CollectionRenderer(boolean bold) {
+        super();
+        this.bold = bold;
+    }
+
     @Override
     public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus,
             int row, int column) {
@@ -69,7 +76,8 @@ public class CollectionRenderer extends
         Collection<?> col = (Collection<?>) value;
 
         if (col == null || col.isEmpty()) {
-            super.setValue("<html><span><font color=" + NOT_SET_COLOR + "><i>not
set</i></font></span>");
+            super.setValue("<html><span><font color=" + NOT_SET_COLOR + "><i>"
+ (bold ? "<b>" : "") + "not set</i>"
+                    + (bold ? "</b>" : "") + "</font></span>");
             return;
         }
 
@@ -80,6 +88,9 @@ public class CollectionRenderer extends
 
         for (Object o : col) {
             sb.append("<span>"); // workaround for a bug in Swing
+            if (bold) {
+                sb.append("<b>");
+            }
             if (o == null) {
                 sb.append("<i>null</i>");
             } else if (o instanceof GregorianCalendar) {
@@ -96,6 +107,9 @@ public class CollectionRenderer extends
             } else {
                 ClientHelper.encodeHtml(sb, o.toString());
             }
+            if (bold) {
+                sb.append("</b>");
+            }
             sb.append("</span><br/>");
         }
         // sb.append("</html>");



Mime
View raw message