Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckInPanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckInPanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckInPanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckInPanel.java Sun Sep 25 10:29:02 2016 @@ -65,7 +65,7 @@ public class CheckInPanel extends Action } @Override - public boolean doAction() throws FileNotFoundException { + public void doAction() throws FileNotFoundException { ContentStream content = getClientModel().createContentStream(filenameField.getText()); try { @@ -74,6 +74,6 @@ public class CheckInPanel extends Action IOUtils.closeQuietly(content); } - return false; + reload(false); } } \ No newline at end of file
Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckOutPanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckOutPanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckOutPanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckOutPanel.java Sun Sep 25 10:29:02 2016 @@ -50,8 +50,8 @@ public class CheckOutPanel extends Actio } @Override - public boolean doAction() { + public void doAction() { ((Document) getObject()).checkOut(); - return true; + reload(true); } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CopyPanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CopyPanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CopyPanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CopyPanel.java Sun Sep 25 10:29:02 2016 @@ -64,9 +64,10 @@ public class CopyPanel extends ActionPan } @Override - public boolean doAction() { + public void doAction() { ObjectId targetFolderId = new ObjectIdImpl(targetFolderField.getText()); ((Document) getObject()).copy(targetFolderId); - return true; + + reload(true); } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteContentStreamPanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteContentStreamPanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteContentStreamPanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteContentStreamPanel.java Sun Sep 25 10:29:02 2016 @@ -50,8 +50,8 @@ public class DeleteContentStreamPanel ex } @Override - public boolean doAction() { + public void doAction() { ((Document) getObject()).deleteContentStream(false); - return true; + reload(true); } } \ No newline at end of file Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeletePanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeletePanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeletePanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeletePanel.java Sun Sep 25 10:29:02 2016 @@ -23,6 +23,7 @@ import javax.swing.JCheckBox; import org.apache.chemistry.opencmis.commons.enums.Action; import org.apache.chemistry.opencmis.workbench.model.ClientModel; import org.apache.chemistry.opencmis.workbench.swing.ActionPanel; +import org.apache.chemistry.opencmis.workbench.worker.DeleteWorker; public class DeletePanel extends ActionPanel { @@ -55,8 +56,14 @@ public class DeletePanel extends ActionP } @Override - public boolean doAction() { - getObject().delete(allVersionsBox.isSelected()); - return false; + public void doAction() { + DeleteWorker worker = new DeleteWorker(this, getObject(), allVersionsBox.isSelected()) { + @Override + protected void done() { + super.done(); + reload(false); + } + }; + worker.executeTask(); } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteTreePanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteTreePanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteTreePanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DeleteTreePanel.java Sun Sep 25 10:29:02 2016 @@ -18,17 +18,15 @@ */ package org.apache.chemistry.opencmis.workbench.actions; -import java.util.List; - import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JOptionPane; import org.apache.chemistry.opencmis.client.api.Folder; import org.apache.chemistry.opencmis.commons.enums.Action; import org.apache.chemistry.opencmis.commons.enums.UnfileObject; import org.apache.chemistry.opencmis.workbench.model.ClientModel; import org.apache.chemistry.opencmis.workbench.swing.ActionPanel; +import org.apache.chemistry.opencmis.workbench.worker.DeleteWorker; public class DeleteTreePanel extends ActionPanel { @@ -71,22 +69,15 @@ public class DeleteTreePanel extends Act } @Override - public boolean doAction() { - List<String> ids = ((Folder) getObject()).deleteTree(allVersionsBox.isSelected(), - (UnfileObject) unfileObjectsBox.getSelectedItem(), continueOnFailureBox.isSelected()); - - if (ids != null && !ids.isEmpty()) { - StringBuilder sb = new StringBuilder(128); - - sb.append("Delete tree failed! At least the following objects could not be deleted:\n"); - - for (String id : ids) { - sb.append('\n'); - sb.append(id); + public void doAction() { + DeleteWorker worker = new DeleteWorker(this, (Folder) getObject(), allVersionsBox.isSelected(), + (UnfileObject) unfileObjectsBox.getSelectedItem(), continueOnFailureBox.isSelected()) { + @Override + protected void done() { + super.done(); + reload(false); } - - JOptionPane.showMessageDialog(this, sb.toString(), "Delete Tree", JOptionPane.ERROR_MESSAGE); - } - return false; + }; + worker.executeTask(); } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DownloadPanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DownloadPanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DownloadPanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/DownloadPanel.java Sun Sep 25 10:29:02 2016 @@ -69,13 +69,12 @@ public class DownloadPanel extends Actio } @Override - public boolean doAction() { + public void doAction() { String streamId = streamIdField.getText().trim(); if (streamId.length() == 0) { streamId = null; } ClientHelper.download(this, getObject(), streamId); - return true; } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/MovePanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/MovePanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/MovePanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/MovePanel.java Sun Sep 25 10:29:02 2016 @@ -70,10 +70,11 @@ public class MovePanel extends ActionPan } @Override - public boolean doAction() { + public void doAction() { ObjectId targetFolderId = new ObjectIdImpl(targetFolderField.getText()); FileableCmisObject before = (FileableCmisObject) getObject(); FileableCmisObject after = before.move(getClientModel().getCurrentFolder(), targetFolderId); - return before.getId().equals(after.getId()); + + reload(before.getId().equals(after.getId())); } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/PropertyUpdatePanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/PropertyUpdatePanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/PropertyUpdatePanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/PropertyUpdatePanel.java Sun Sep 25 10:29:02 2016 @@ -50,8 +50,7 @@ public class PropertyUpdatePanel extends } @Override - public boolean doAction() { + public void doAction() { new PropertyEditorFrame(getClientModel(), getObject()); - return false; } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemoveObjectFromFolderPanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemoveObjectFromFolderPanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemoveObjectFromFolderPanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemoveObjectFromFolderPanel.java Sun Sep 25 10:29:02 2016 @@ -82,9 +82,10 @@ public class RemoveObjectFromFolderPanel } @Override - public boolean doAction() { + public void doAction() { ObjectId folderId = getClientModel().getClientSession().getSession().createObjectId(folderField.getText()); ((FileableCmisObject) getObject()).removeFromFolder(folderId); - return true; + + reload(true); } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java Sun Sep 25 10:29:02 2016 @@ -68,8 +68,8 @@ public class RemovePolicyPanel extends A } @Override - public boolean doAction() { + public void doAction() { getObject().removePolicy(new ObjectIdImpl(policyField.getText()), false); - return true; + reload(true); } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java Sun Sep 25 10:29:02 2016 @@ -65,7 +65,7 @@ public class SetContentStreamPanel exten } @Override - public boolean doAction() throws FileNotFoundException { + public void doAction() throws FileNotFoundException { ContentStream content = getClientModel().createContentStream(filenameField.getText()); try { @@ -75,6 +75,7 @@ public class SetContentStreamPanel exten IOUtils.closeQuietly(content); } } - return true; + + reload(true); } } \ No newline at end of file Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ACLTable.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/ACLTable.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ACLTable.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ACLTable.java Sun Sep 25 10:29:02 2016 @@ -18,7 +18,6 @@ */ package org.apache.chemistry.opencmis.workbench.details; -import java.awt.Cursor; import java.awt.event.MouseEvent; import java.util.Collection; @@ -26,8 +25,9 @@ import org.apache.chemistry.opencmis.com import org.apache.chemistry.opencmis.commons.data.AllowableActions; import org.apache.chemistry.opencmis.commons.enums.Action; import org.apache.chemistry.opencmis.workbench.AclEditorFrame; -import org.apache.chemistry.opencmis.workbench.ClientHelper; import org.apache.chemistry.opencmis.workbench.model.ClientModel; +import org.apache.chemistry.opencmis.workbench.worker.LoadFolderWorker; +import org.apache.chemistry.opencmis.workbench.worker.LoadObjectWorker; public class ACLTable extends AbstractDetailsTable { @@ -49,15 +49,8 @@ public class ACLTable extends AbstractDe || aa.getAllowableActions().contains(Action.CAN_APPLY_ACL)) { new AclEditorFrame(getClientModel(), getObject()); - try { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - getClientModel().reloadObject(); - getClientModel().reloadFolder(); - } catch (Exception ex) { - ClientHelper.showError(null, ex); - } finally { - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } + LoadObjectWorker.reloadObject(this, getClientModel()); + LoadFolderWorker.reloadFolder(this, getClientModel()); } } 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=1762181&r1=1762180&r2=1762181&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 Sun Sep 25 10:29:02 2016 @@ -29,6 +29,7 @@ import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; import java.io.Writer; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -65,6 +66,8 @@ import org.apache.chemistry.opencmis.wor import org.apache.chemistry.opencmis.workbench.model.ObjectListener; import org.apache.chemistry.opencmis.workbench.swing.BaseTypeLabel; import org.apache.chemistry.opencmis.workbench.swing.InfoPanel; +import org.apache.chemistry.opencmis.workbench.worker.LoadObjectWorker; +import org.apache.chemistry.opencmis.workbench.worker.TempFileContentWorker; public class ObjectPanel extends InfoPanel implements ObjectListener { @@ -80,6 +83,8 @@ public class ObjectPanel extends InfoPan private InfoList secondaryTypesList; private JTextField versionLabelField; private JTextField pwcField; + private JTextField mimeTypeField; + private JTextField sizeField; private JTextField contentUrlField; private InfoList pathsList; private InfoList allowableActionsList; @@ -126,6 +131,8 @@ public class ObjectPanel extends InfoPan versionLabelField.setText(""); pwcField.setText(""); pathsList.removeAll(); + mimeTypeField.setText(""); + sizeField.setText(""); contentUrlField.setText(""); allowableActionsList.removeAll(); aclExactField.setText(""); @@ -169,10 +176,18 @@ public class ObjectPanel extends InfoPan } else { pwcField.setText("(not checked out)"); } + + sizeField.setText(doc.getContentStreamLength() >= 0 ? NumberFormat.getInstance().format( + doc.getContentStreamLength()) + + " bytes" : ""); + mimeTypeField.setText(doc.getContentStreamMimeType() != null ? doc + .getContentStreamMimeType() : ""); } else { latestAccessibleStateIdField.setText(""); pwcField.setText(""); versionLabelField.setText(""); + mimeTypeField.setText(""); + sizeField.setText(""); } if (object instanceof FileableCmisObject) { @@ -247,7 +262,7 @@ public class ObjectPanel extends InfoPan } } - revalidate(); + regenerateGUI(); } }); } @@ -256,15 +271,21 @@ public class ObjectPanel extends InfoPan setupGUI(); nameField = addLine("Name:", true); + addSeparator(); idField = addId("Object ID:"); latestAccessibleStateIdField = addId("Latest State ID:"); typeField = addLine("Type:"); basetypeField = addBaseTypeLabel("Base Type:"); secondaryTypesList = addComponent("Secondary Types:", new InfoList()); + addSeparator(); pathsList = addComponent("Paths:", new InfoList()); + addSeparator(); + mimeTypeField = addLine("MIME Type:"); + sizeField = addLine("Size:"); versionLabelField = addLine("Version Label:"); pwcField = addId("PWC:"); contentUrlField = addLink("Content URL:"); + addSeparator(); allowableActionsList = addComponent("Allowable Actions:", new InfoList()); aclExactField = addLine("ACL:"); @@ -305,14 +326,7 @@ public class ObjectPanel extends InfoPan refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - try { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - getClientModel().reloadObject(); - } catch (Exception ex) { - ClientHelper.showError(null, ex); - } finally { - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } + LoadObjectWorker.reloadObject(ObjectPanel.this, getClientModel()); } }); @@ -367,11 +381,18 @@ 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(), (String) null); - if (console != null) { - console.loadScriptFile(file); - } + // download and execute Groovy file + TempFileContentWorker worker = new TempFileContentWorker(ObjectPanel.this, doc) { + @Override + protected void processTempFile(File file) { + Console console = ClientHelper.openConsole(ObjectPanel.this, getClientModel(), + (String) null); + if (console != null) { + console.loadScriptFile(file); + } + } + }; + worker.executeTask(); } else { ClientHelper.open(ObjectPanel.this, doc, null); } @@ -386,26 +407,25 @@ public class ObjectPanel extends InfoPan scriptRunButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - try { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - Document doc = (Document) getClientModel().getCurrentObject(); - File file = ClientHelper.createTempFileFromDocument(doc, null); - String name = doc.getName().toLowerCase(Locale.ENGLISH); - String ext = name.substring(name.lastIndexOf('.') + 1); + final Document doc = (Document) getClientModel().getCurrentObject(); + TempFileContentWorker worker = new TempFileContentWorker(ObjectPanel.this, doc) { + @Override + protected void processTempFile(File file) { + String name = doc.getName().toLowerCase(Locale.ENGLISH); + String ext = name.substring(name.lastIndexOf('.') + 1); + + scriptOutput.setText(""); + scriptOutput.setVisible(true); + scriptOutput.invalidate(); - scriptOutput.setText(""); - scriptOutput.setVisible(true); - scriptOutput.invalidate(); - - ClientHelper.runJSR223Script(ObjectPanel.this, getClientModel(), file, ext, scriptOutputWriter); - } catch (Exception ex) { - ClientHelper.showError(null, ex); - } finally { - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } + ClientHelper.runJSR223Script(ObjectPanel.this, getClientModel(), file, ext, scriptOutputWriter); + } + }; + worker.executeTask(); } }); + regenerateGUI(); } private String getDocumentURL(final CmisObject document, final Session session) { Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PolicyTable.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/PolicyTable.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PolicyTable.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/PolicyTable.java Sun Sep 25 10:29:02 2016 @@ -22,8 +22,8 @@ import java.awt.event.MouseEvent; import org.apache.chemistry.opencmis.client.api.ObjectId; import org.apache.chemistry.opencmis.client.api.Policy; -import org.apache.chemistry.opencmis.workbench.ClientHelper; import org.apache.chemistry.opencmis.workbench.model.ClientModel; +import org.apache.chemistry.opencmis.workbench.worker.LoadObjectWorker; public class PolicyTable extends AbstractDetailsTable { @@ -43,13 +43,9 @@ public class PolicyTable extends Abstrac return; } - try { - getClientModel().loadObject( - getObject().getPolicies().get(getRowSorter().convertRowIndexToModel(rowIndex)).getId()); - setTab(0); - } catch (Exception ex) { - ClientHelper.showError(this, ex); - } + LoadObjectWorker.loadObject(this, getClientModel(), + getObject().getPolicies().get(getRowSorter().convertRowIndexToModel(rowIndex)).getId()); + setTab(0); } @Override Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/RelationshipTable.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/RelationshipTable.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/RelationshipTable.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/RelationshipTable.java Sun Sep 25 10:29:02 2016 @@ -22,8 +22,8 @@ import java.awt.event.MouseEvent; import org.apache.chemistry.opencmis.client.api.ObjectId; import org.apache.chemistry.opencmis.client.api.Relationship; -import org.apache.chemistry.opencmis.workbench.ClientHelper; import org.apache.chemistry.opencmis.workbench.model.ClientModel; +import org.apache.chemistry.opencmis.workbench.worker.LoadObjectWorker; public class RelationshipTable extends AbstractDetailsTable { @@ -48,12 +48,8 @@ public class RelationshipTable extends A return; } - try { - getClientModel().loadObject(id.getId()); - setTab(0); - } catch (Exception ex) { - ClientHelper.showError(this, ex); - } + LoadObjectWorker.loadObject(this, getClientModel(), id.getId()); + setTab(0); } @Override Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/VersionTable.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/VersionTable.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/VersionTable.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/VersionTable.java Sun Sep 25 10:29:02 2016 @@ -33,6 +33,7 @@ import org.apache.chemistry.opencmis.com import org.apache.chemistry.opencmis.workbench.ClientHelper; import org.apache.chemistry.opencmis.workbench.model.ClientModel; import org.apache.chemistry.opencmis.workbench.model.ClientModelEvent; +import org.apache.chemistry.opencmis.workbench.worker.LoadObjectWorker; public class VersionTable extends AbstractDetailsTable { @@ -67,7 +68,7 @@ public class VersionTable extends Abstra boolean fetchVersions = (getObject().getAllowableActions() == null) || (getObject().getAllowableActions().getAllowableActions() == null) || doc.hasAllowableAction(Action.CAN_GET_ALL_VERSIONS); - + if (fetchVersions) { SwingUtilities.invokeLater(new Runnable() { @Override @@ -113,12 +114,8 @@ public class VersionTable extends Abstra lock.readLock().unlock(); } - try { - getClientModel().loadObject(versionId); - setTab(0); - } catch (Exception ex) { - ClientHelper.showError(this, ex); - } + LoadObjectWorker.loadObject(this, getClientModel(), versionId); + setTab(0); } @Override Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java Sun Sep 25 10:29:02 2016 @@ -78,19 +78,19 @@ public class ClientModel { public ClientModel() { } - public void addFolderListener(FolderListener listener) { + public synchronized void addFolderListener(FolderListener listener) { listenerList.add(FolderListener.class, listener); } - public void removeFolderListener(FolderListener listener) { + public synchronized void removeFolderListener(FolderListener listener) { listenerList.remove(FolderListener.class, listener); } - public void addObjectListener(ObjectListener listener) { + public synchronized void addObjectListener(ObjectListener listener) { listenerList.add(ObjectListener.class, listener); } - public void removeObjectListener(ObjectListener listener) { + public synchronized void removeObjectListener(ObjectListener listener) { listenerList.remove(ObjectListener.class, listener); } @@ -106,12 +106,12 @@ public class ClientModel { return clientSession; } - public synchronized RepositoryInfo getRepositoryInfo() { - Session session = clientSession.getSession(); + public RepositoryInfo getRepositoryInfo() { + Session session = getClientSession().getSession(); return session.getRepositoryInfo(); } - public synchronized String getRepositoryName() { + public String getRepositoryName() { try { return getRepositoryInfo().getName(); } catch (Exception e) { @@ -119,7 +119,7 @@ public class ClientModel { } } - public synchronized boolean supportsQuery() { + public boolean supportsQuery() { try { RepositoryCapabilities cap = getRepositoryInfo().getCapabilities(); if (cap == null) { @@ -132,7 +132,7 @@ public class ClientModel { } } - public synchronized boolean supportsChangeLog() { + public boolean supportsChangeLog() { try { RepositoryCapabilities cap = getRepositoryInfo().getCapabilities(); if (cap == null) { @@ -145,21 +145,19 @@ public class ClientModel { } } - private synchronized void loadBaseTypes() { - if (baseTypes != null) { - return; + private synchronized List<ObjectType> getBaseTypes() { + if (baseTypes == null) { + baseTypes = new ArrayList<ObjectType>(); + for (ObjectType type : clientSession.getSession().getTypeChildren(null, false)) { + baseTypes.add(type); + } } - baseTypes = new ArrayList<ObjectType>(); - for (ObjectType type : clientSession.getSession().getTypeChildren(null, false)) { - baseTypes.add(type); - } + return baseTypes; } - public synchronized boolean supportsItems() { - loadBaseTypes(); - - for (ObjectType type : baseTypes) { + public boolean supportsItems() { + for (ObjectType type : getBaseTypes()) { if (type.getBaseTypeId() == BaseTypeId.CMIS_ITEM) { return true; } @@ -168,10 +166,8 @@ public class ClientModel { return false; } - public synchronized boolean supportsRelationships() { - loadBaseTypes(); - - for (ObjectType type : baseTypes) { + public boolean supportsRelationships() { + for (ObjectType type : getBaseTypes()) { if (type.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP) { return true; } @@ -180,10 +176,8 @@ public class ClientModel { return false; } - public synchronized boolean supportsPolicies() { - loadBaseTypes(); - - for (ObjectType type : baseTypes) { + public boolean supportsPolicies() { + for (ObjectType type : getBaseTypes()) { if (type.getBaseTypeId() == BaseTypeId.CMIS_POLICY) { return true; } @@ -192,9 +186,10 @@ public class ClientModel { return false; } - public synchronized ObjectId loadFolder(String folderId, boolean byPath) { + public ObjectId loadFolder(final String folderId, final boolean byPath) { try { - Session session = clientSession.getSession(); + ClientSession myClientSession = getClientSession(); + Session session = myClientSession.getSession(); CmisObject selectedObject = null; CmisObject folderObject = null; @@ -214,23 +209,24 @@ public class ClientModel { } if (folderObject == null) { - // selected object is unfiled, a relationship object, or the - // user is not allowed to see the parent folder + // selected object is unfiled, a relationship object, or + // the user is not allowed to see the parent folder setCurrentFolder(null, Collections.<CmisObject> emptyList()); return selectedObject; } List<CmisObject> children = new ArrayList<CmisObject>(); - if (clientSession.getMaxChildren() != 0) { + int maxChildren = myClientSession.getMaxChildren(); + if (maxChildren != 0) { // if maxChildren == 0 don't call getChildren() - ItemIterable<CmisObject> iter = ((Folder) folderObject).getChildren(clientSession + ItemIterable<CmisObject> iter = ((Folder) folderObject).getChildren(myClientSession .getFolderOperationContext()); - if (clientSession.getMaxChildren() > 0) { + if (myClientSession.getMaxChildren() > 0) { // if maxChildren > 0 restrict number of children // otherwise load all - iter = iter.getPage(clientSession.getMaxChildren()); + iter = iter.getPage(maxChildren); } for (CmisObject child : iter) { @@ -247,16 +243,10 @@ public class ClientModel { } } - public synchronized void reloadFolder() { - if (currentFolder != null) { - loadFolder(currentFolder.getId(), false); - } - } - - public synchronized void loadObject(String objectId) { + public void loadObject(final String objectId) { try { - Session session = clientSession.getSession(); - CmisObject object = session.getObject(objectId, clientSession.getObjectOperationContext()); + Session session = getClientSession().getSession(); + CmisObject object = session.getObject(objectId, getClientSession().getObjectOperationContext()); object.refreshIfOld(OLD); setCurrentObject(object); @@ -267,13 +257,15 @@ public class ClientModel { } public synchronized void reloadObject() { - if (currentObject == null) { + CmisObject myCurrentObject = getCurrentObject(); + if (myCurrentObject == null) { return; } + ClientSession myClientSession = getClientSession(); try { - Session session = clientSession.getSession(); - CmisObject object = session.getObject(currentObject, clientSession.getObjectOperationContext()); + Session session = myClientSession.getSession(); + CmisObject object = session.getObject(myCurrentObject, myClientSession.getObjectOperationContext()); object.refresh(); setCurrentObject(object); @@ -283,16 +275,16 @@ public class ClientModel { } } - public synchronized ItemIterable<QueryResult> query(String q, boolean searchAllVersions, int maxHits) { + public ItemIterable<QueryResult> query(String q, boolean searchAllVersions, int maxHits) { OperationContext queryContext = new OperationContextImpl(null, false, false, false, IncludeRelationships.NONE, null, false, null, false, maxHits > 0 ? maxHits : 1); - Session session = clientSession.getSession(); + Session session = getClientSession().getSession(); return session.query(q, searchAllVersions, queryContext); } - public synchronized List<Tree<ObjectType>> getTypeDescendants() { - Session session = clientSession.getSession(); + public List<Tree<ObjectType>> getTypeDescendants() { + Session session = getClientSession().getSession(); return session.getTypeDescendants(null, -1, true); } @@ -303,16 +295,15 @@ public class ClientModel { InputStream stream = new LoggingInputStream(new BufferedInputStream(new FileInputStream(file), 512 * 1024), file.getName()); - content = clientSession.getSession().getObjectFactory() + content = getClientSession().getSession().getObjectFactory() .createContentStream(file.getName(), file.length(), MimeTypes.getMIMEType(file), stream); } return content; } - public synchronized ObjectId createDocument(String name, String type, String filename, - Map<String, Object> additionalProperties, VersioningState versioningState, boolean unfiled) - throws FileNotFoundException { + public ObjectId createDocument(String name, String type, String filename, Map<String, Object> additionalProperties, + VersioningState versioningState, boolean unfiled) throws FileNotFoundException { Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.NAME, name); properties.put(PropertyIds.OBJECT_TYPE_ID, type); @@ -324,15 +315,15 @@ public class ClientModel { ContentStream content = createContentStream(filename); try { - return clientSession.getSession().createDocument(properties, (unfiled ? null : currentFolder), content, - versioningState, null, null, null); + return getClientSession().getSession().createDocument(properties, (unfiled ? null : getCurrentFolder()), + content, versioningState, null, null, null); } finally { IOUtils.closeQuietly(content); } } public ContentStream createContentStream(String name, long length, long seed) { - return clientSession + return getClientSession() .getSession() .getObjectFactory() .createContentStream(name, length, "application/octet-stream", @@ -351,8 +342,8 @@ public class ClientModel { ContentStream content = createContentStream(name, length, seed); try { - return clientSession.getSession().createDocument(properties, (unfiled ? null : currentFolder), content, - versioningState, null, null, null); + return clientSession.getSession().createDocument(properties, (unfiled ? null : getCurrentFolder()), + content, versioningState, null, null, null); } finally { IOUtils.closeQuietly(content); } @@ -368,7 +359,8 @@ public class ClientModel { properties.putAll(additionalProperties); } - return clientSession.getSession().createItem(properties, (unfiled ? null : currentFolder), null, null, null); + return getClientSession().getSession().createItem(properties, (unfiled ? null : getCurrentFolder()), null, + null, null); } public synchronized ObjectId createFolder(String name, String type, Map<String, Object> additionalProperties) { @@ -380,7 +372,7 @@ public class ClientModel { properties.putAll(additionalProperties); } - return clientSession.getSession().createFolder(properties, currentFolder, null, null, null); + return getClientSession().getSession().createFolder(properties, getCurrentFolder(), null, null, null); } public synchronized ObjectId createRelationship(String name, String type, String sourceId, String targetId, @@ -395,7 +387,7 @@ public class ClientModel { properties.putAll(additionalProperties); } - return clientSession.getSession().createRelationship(properties, null, null, null); + return getClientSession().getSession().createRelationship(properties, null, null, null); } public synchronized ObjectId createPolicy(String name, String type, String policyText, @@ -411,20 +403,23 @@ public class ClientModel { properties.putAll(additionalProperties); } - return clientSession.getSession().createPolicy(properties, (unfiled ? null : currentFolder), null, null, null); + return getClientSession().getSession().createPolicy(properties, (unfiled ? null : getCurrentFolder()), null, + null, null); } public synchronized List<ObjectType> getTypesAsList(String rootTypeId, boolean creatableOnly) { + Session session = getClientSession().getSession(); + List<ObjectType> result = new ArrayList<ObjectType>(); ObjectType rootType = null; try { - rootType = clientSession.getSession().getTypeDefinition(rootTypeId); + rootType = session.getTypeDefinition(rootTypeId); } catch (CmisBaseException e) { return result; } - List<Tree<ObjectType>> types = clientSession.getSession().getTypeDescendants(rootTypeId, -1, true); + List<Tree<ObjectType>> types = session.getTypeDescendants(rootTypeId, -1, true); addType(types, result, creatableOnly); if (creatableOnly) { Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java Sun Sep 25 10:29:02 2016 @@ -244,7 +244,7 @@ public class ClientSession { authenticationProvider, cache, typeDefCache); } - public List<Repository> getRepositories() { + public synchronized List<Repository> getRepositories() { return repositories; } @@ -256,7 +256,7 @@ public class ClientSession { return getSession(); } - public Session getSession() { + public synchronized Session getSession() { return session; } @@ -264,11 +264,11 @@ public class ClientSession { return Collections.unmodifiableMap(sessionParameters); } - public void setStartFolderId(String startFolderId) { + public synchronized void setStartFolderId(String startFolderId) { this.startFolderId = startFolderId; } - public String getStartFolderId() { + public synchronized String getStartFolderId() { if (startFolderId != null) { return startFolderId; } else { @@ -276,7 +276,7 @@ public class ClientSession { } } - public int getMaxChildren() { + public synchronized int getMaxChildren() { return maxChildren; } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ActionPanel.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/ActionPanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ActionPanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ActionPanel.java Sun Sep 25 10:29:02 2016 @@ -20,7 +20,6 @@ package org.apache.chemistry.opencmis.wo import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Cursor; import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionEvent; @@ -30,7 +29,6 @@ import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JComponent; -import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; @@ -41,6 +39,7 @@ import org.apache.chemistry.opencmis.com import org.apache.chemistry.opencmis.workbench.ClientHelper; import org.apache.chemistry.opencmis.workbench.WorkbenchScale; import org.apache.chemistry.opencmis.workbench.model.ClientModel; +import org.apache.chemistry.opencmis.workbench.worker.LoadObjectWorker; public abstract class ActionPanel extends JPanel implements ActionListener { @@ -118,16 +117,31 @@ public abstract class ActionPanel extend @Override public void actionPerformed(ActionEvent e) { try { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); ((JButton) e.getSource()).requestFocusInWindow(); - if (doAction()) { - model.reloadObject(); - } - model.reloadFolder(); + doAction(); } catch (Exception ex) { ClientHelper.showError(null, ex); - } finally { - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + } + + protected void reload(final boolean reloadObject) { + final ClientModel model = getClientModel(); + + if (model.getCurrentFolder() != null) { + LoadObjectWorker worker = new LoadObjectWorker(ActionPanel.this, model, model.getCurrentFolder().getId()) { + @Override + protected void done() { + super.done(); + if (reloadObject) { + LoadObjectWorker.reloadObject(ActionPanel.this, model); + } + } + }; + worker.executeTask(); + } else { + if (reloadObject) { + LoadObjectWorker.reloadObject(ActionPanel.this, model); + } } } @@ -135,10 +149,7 @@ public abstract class ActionPanel extend public abstract boolean isAllowed(); - /** - * @return <code>true</code> if object should be reloaded. - */ - public abstract boolean doAction() throws Exception; + public abstract void doAction() throws Exception; protected JPanel createFilenamePanel(final JTextField filenameField) { JPanel filePanel = new JPanel(new BorderLayout()); @@ -152,9 +163,9 @@ public abstract class ActionPanel extend browseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { - JFileChooser fileChooser = new JFileChooser(); + WorkbenchFileChooser fileChooser = new WorkbenchFileChooser(); int chooseResult = fileChooser.showDialog(filenameField, "Select"); - if (chooseResult == JFileChooser.APPROVE_OPTION) { + if (chooseResult == WorkbenchFileChooser.APPROVE_OPTION) { if (fileChooser.getSelectedFile().isFile()) { filenameField.setText(fileChooser.getSelectedFile().getAbsolutePath()); } 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=1762181&r1=1762180&r2=1762181&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 Sun Sep 25 10:29:02 2016 @@ -21,15 +21,12 @@ package org.apache.chemistry.opencmis.wo import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNullOrEmpty; import java.awt.Color; +import java.awt.Component; +import java.awt.Container; import java.awt.Cursor; import java.awt.Desktop; -import java.awt.FlowLayout; +import java.awt.Dimension; import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; @@ -39,6 +36,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.font.TextAttribute; import java.net.URI; import java.util.Collection; import java.util.EnumMap; @@ -53,7 +51,10 @@ import javax.swing.JLabel; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JPopupMenu; +import javax.swing.JSeparator; import javax.swing.JTextField; +import javax.swing.Spring; +import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -61,6 +62,7 @@ import javax.swing.UIManager; import org.apache.chemistry.opencmis.workbench.ClientHelper; import org.apache.chemistry.opencmis.workbench.WorkbenchScale; import org.apache.chemistry.opencmis.workbench.model.ClientModel; +import org.apache.chemistry.opencmis.workbench.worker.LoadObjectWorker; import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; @@ -75,8 +77,7 @@ public abstract class InfoPanel extends private final ClientModel model; - private JPanel gridPanel; - private GridBagConstraints gbc; + private int rows; private Font boldFont; public InfoPanel(ClientModel model) { @@ -88,23 +89,30 @@ public abstract class InfoPanel extends } protected void setupGUI() { - setLayout(new FlowLayout(FlowLayout.LEFT)); + setLayout(new SpringLayout()); setBackground(Color.WHITE); - gridPanel = new JPanel(new GridBagLayout()); - gridPanel.setBackground(Color.WHITE); - add(gridPanel); - - gbc = new GridBagConstraints(); - - gbc.fill = GridBagConstraints.BOTH; - gbc.gridy = 0; - gbc.insets = WorkbenchScale.scaleInsets(new Insets(3, 3, 3, 3)); + rows = 0; Font labelFont = UIManager.getFont("Label.font"); boldFont = labelFont.deriveFont(Font.BOLD, labelFont.getSize2D() * 1.2f); } + protected void regenerateGUI() { + SpringLayout layout = (SpringLayout) getLayout(); + + for (int c = 0; c < 2; c++) { + for (int r = 0; r < rows; r++) { + Component comp = getComponent(r * 2 + c); + layout.removeLayoutComponent(comp); + } + } + + makeCompactGrid(this, rows, 2, WorkbenchScale.scaleInt(5), WorkbenchScale.scaleInt(10), + WorkbenchScale.scaleInt(10), WorkbenchScale.scaleInt(5), WorkbenchScale.scaleInt(18)); + revalidate(); + } + protected JTextField addLine(final String label) { return addLine(label, false); } @@ -115,26 +123,21 @@ public abstract class InfoPanel extends protected JTextField addLine(final String label, final boolean bold, JTextField textField) { textField.setEditable(false); - textField.setBorder(WorkbenchScale.scaleBorder(BorderFactory.createEmptyBorder())); + textField.setBorder(BorderFactory.createEmptyBorder()); if (bold) { textField.setFont(boldFont); } - JLabel textLable = new JLabel(label); - textLable.setLabelFor(textField); + JLabel textLabel = new JLabel(label); + textLabel.setLabelFor(textField); if (bold) { - textLable.setFont(boldFont); + textLabel.setFont(boldFont); } - gbc.gridy++; - - gbc.gridx = 0; - gbc.anchor = GridBagConstraints.BASELINE_TRAILING; - gridPanel.add(textLable, gbc); + rows++; - gbc.gridx = 1; - gbc.anchor = GridBagConstraints.BASELINE_LEADING; - gridPanel.add(textField, gbc); + add(textLabel); + add(textField); return textField; } @@ -153,15 +156,10 @@ public abstract class InfoPanel extends JLabel textLable = new JLabel(label); textLable.setLabelFor(ynl); - gbc.gridy++; + rows++; - gbc.gridx = 0; - gbc.anchor = GridBagConstraints.BASELINE_TRAILING; - gridPanel.add(textLable, gbc); - - gbc.gridx = 1; - gbc.anchor = GridBagConstraints.BASELINE_LEADING; - gridPanel.add(ynl, gbc); + add(textLable); + add(ynl); return ynl; } @@ -172,42 +170,104 @@ public abstract class InfoPanel extends JLabel textLable = new JLabel(label); textLable.setLabelFor(btl); - gbc.gridy++; + rows++; - gbc.gridx = 0; - gbc.anchor = GridBagConstraints.BASELINE_TRAILING; - gridPanel.add(textLable, gbc); - - gbc.gridx = 1; - gbc.anchor = GridBagConstraints.BASELINE_LEADING; - gridPanel.add(btl, gbc); + add(textLable); + add(btl); return btl; } + protected JSeparator addSeparator() { + JPanel panel = new JPanel(); + panel.setOpaque(false); + panel.setMaximumSize(new Dimension(1, 1)); + + JSeparator separator = new JSeparator(); + + rows++; + + add(panel); + add(separator); + + return separator; + } + protected <T extends JComponent> T addComponent(String label, T comp) { JLabel textLable = new JLabel(label); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS)); - panel.setBorder(WorkbenchScale.scaleBorder(BorderFactory.createEmptyBorder())); + panel.setBorder(BorderFactory.createEmptyBorder()); panel.setOpaque(false); panel.add(comp); textLable.setLabelFor(panel); - gbc.gridy++; + rows++; - gbc.gridx = 0; - gbc.anchor = GridBagConstraints.BASELINE_TRAILING; - gridPanel.add(textLable, gbc); - - gbc.gridx = 1; - gbc.anchor = GridBagConstraints.BASELINE_LEADING; - gridPanel.add(panel, gbc); + add(textLable); + add(panel); return comp; } + private SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols) { + SpringLayout layout = (SpringLayout) parent.getLayout(); + Component c = parent.getComponent(row * cols + col); + return layout.getConstraints(c); + } + + protected void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, + int yPad, int minHeight) { + SpringLayout layout = (SpringLayout) parent.getLayout(); + + Spring x = Spring.constant(initialX); + for (int c = 0; c < cols; c++) { + Spring width = Spring.constant(0); + for (int r = 0; r < rows; r++) { + width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth()); + } + for (int r = 0; r < rows; r++) { + SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols); + constraints.setX(x); + constraints.setWidth(width); + } + x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad))); + } + + Spring y = Spring.constant(initialY); + for (int r = 0; r < rows; r++) { + Spring height = Spring.constant(minHeight); + for (int c = 0; c < cols; c++) { + height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight()); + } + + SpringLayout.Constraints labelConstraints = getConstraintsForCell(r, 0, parent, cols); + SpringLayout.Constraints valueConstraints = getConstraintsForCell(r, 1, parent, cols); + + labelConstraints.setY(y); + valueConstraints.setY(y); + valueConstraints.setHeight(height); + + 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))); + } + + y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad))); + } + + layout.getConstraints(parent).setConstraint(SpringLayout.EAST, x); + layout.getConstraints(parent).setConstraint(SpringLayout.NORTH, y); + parent.setPreferredSize(new Dimension(x.getPreferredValue(), y.getPreferredValue())); + } + public static class InfoList extends JPanel { private static final long serialVersionUID = 1L; @@ -306,11 +366,13 @@ public abstract class InfoPanel extends setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); popup.setEnabled(false); link = null; + setUnderline(false); } else { setForeground(getLinkColor(text)); setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); popup.setEnabled(true); link = text; + setUnderline(true); } updated = true; @@ -318,6 +380,24 @@ public abstract class InfoPanel extends super.setText(text); } + @SuppressWarnings({ "unchecked", "rawtypes" }) + private void setUnderline(boolean underline) { + Font font = getFont(); + Map attributes = font.getAttributes(); + + Object isUnderlined = attributes.get(TextAttribute.UNDERLINE); + + if (TextAttribute.UNDERLINE_ON.equals(isUnderlined) && !underline) { + attributes.put(TextAttribute.UNDERLINE, -1); + setFont(font.deriveFont(attributes)); + } + + if ((isUnderlined == null || Integer.valueOf(-1).equals(isUnderlined)) && underline) { + attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); + setFont(font.deriveFont(attributes)); + } + } + @Override public void validate() { } @@ -337,20 +417,6 @@ public abstract class InfoPanel extends @Override public void repaint(Rectangle r) { } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - - if (link != null) { - FontMetrics fm = getFontMetrics(getFont()); - - int y1 = fm.getHeight() - 2; - int x2 = fm.stringWidth(link); - g.setColor(getLinkColor(link)); - g.drawLine(0, y1, x2, y1); - } - } } private class IdTextField extends ClickableTextField { @@ -372,11 +438,7 @@ public abstract class InfoPanel extends @Override public void linkAction(String link) { - try { - getClientModel().loadObject(link); - } catch (Exception ex) { - ClientHelper.showError(InfoPanel.this, ex); - } + LoadObjectWorker.loadObject(InfoPanel.this, model, link); } } Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/WorkbenchFileChooser.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/WorkbenchFileChooser.java?rev=1762181&view=auto ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/WorkbenchFileChooser.java (added) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/WorkbenchFileChooser.java Sun Sep 25 10:29:02 2016 @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.workbench.swing; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.HeadlessException; +import java.awt.Toolkit; +import java.io.File; +import java.util.prefs.Preferences; + +import javax.swing.JFileChooser; + +public class WorkbenchFileChooser extends JFileChooser { + + private static final long serialVersionUID = 1L; + + private static final String PREFS_DIRECTORY = "directory"; + + private final Preferences prefs = Preferences.userNodeForPackage(this.getClass()); + + public WorkbenchFileChooser() { + super(); + load(); + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + setPreferredSize(new Dimension((int) (screenSize.getWidth() / 2), (int) (screenSize.getHeight() / 2))); + } + + @Override + public int showDialog(Component parent, String approveButtonText) throws HeadlessException { + int state = super.showDialog(parent, approveButtonText); + + if (state == JFileChooser.APPROVE_OPTION) { + save(); + } + + return state; + } + + private synchronized void load() { + String fileChooserDirectory = prefs.get(PREFS_DIRECTORY, null); + if (fileChooserDirectory != null) { + setCurrentDirectory(new File(fileChooserDirectory)); + } + } + + private synchronized void save() { + File selectedFile = getSelectedFile(); + if (selectedFile != null) { + prefs.put(PREFS_DIRECTORY, selectedFile.getParent()); + } + } +} Propchange: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/WorkbenchFileChooser.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/PropertyDefinitionsSplitPane.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/PropertyDefinitionsSplitPane.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/PropertyDefinitionsSplitPane.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/PropertyDefinitionsSplitPane.java Sun Sep 25 10:29:02 2016 @@ -422,7 +422,7 @@ public class PropertyDefinitionsSplitPan extensionsTree.setData(null); } - revalidate(); + regenerateGUI(); } private boolean is(Boolean b) { @@ -460,6 +460,8 @@ public class PropertyDefinitionsSplitPan dateTimeResolutionField = addLine("DateTime Resolution:"); extensionsTree = addComponent("Extensions:", new InfoTreePane<List<CmisExtensionElement>>( new ExtensionsTree())); + + regenerateGUI(); } } } Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeDefinitionInfoPanel.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeDefinitionInfoPanel.java?rev=1762181&r1=1762180&r2=1762181&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeDefinitionInfoPanel.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeDefinitionInfoPanel.java Sun Sep 25 10:29:02 2016 @@ -155,7 +155,7 @@ public class TypeDefinitionInfoPanel ext extensionsTree.setData(null); } - revalidate(); + regenerateGUI(); } private void createGUI() { @@ -181,6 +181,8 @@ public class TypeDefinitionInfoPanel ext allowedSourceTypesField = addLine("Allowed Source Types:"); allowedTargetTypesField = addLine("Allowed Target Types:"); extensionsTree = addComponent("Extensions:", new InfoTreePane<List<CmisExtensionElement>>(new ExtensionsTree())); + + regenerateGUI(); } private boolean is(Boolean b) {
