From 2ff9cbaf35ee8358777040765a355c31246bd553 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 10 Jul 2020 18:14:15 +0200 Subject: [PATCH] building the GUI --- .../client/AppControllerExplorer.java | 1 - .../view/windows/DialogEditProperties.java | 41 +++-- .../view/windows/DialogGetInfoBootstrap.java | 149 +++++++++++++++--- .../windows/DialogGetInfoBootstrap.ui.xml | 31 +++- .../accounting/AccoutingInfoContainer.java | 1 - 5 files changed, 172 insertions(+), 51 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index 4b4d4d9..7993b0b 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -118,7 +118,6 @@ import org.gcube.portlets.user.workspace.client.view.tree.AsyncTreePanel; import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart; import org.gcube.portlets.user.workspace.client.view.windows.DialogAddFolderAndSmart.AddType; import org.gcube.portlets.user.workspace.client.view.windows.DialogAddUrl; -import org.gcube.portlets.user.workspace.client.view.windows.DialogGetInfo; import org.gcube.portlets.user.workspace.client.view.windows.DialogGetInfoBootstrap; import org.gcube.portlets.user.workspace.client.view.windows.DialogGetLink; import org.gcube.portlets.user.workspace.client.view.windows.DialogGetLink.Link_Type; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogEditProperties.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogEditProperties.java index 43edd4b..1b4e7c4 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogEditProperties.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogEditProperties.java @@ -19,7 +19,6 @@ import com.extjs.gxt.ui.client.event.Listener; import com.extjs.gxt.ui.client.widget.Dialog; import com.extjs.gxt.ui.client.widget.form.TextField; import com.extjs.gxt.ui.client.widget.layout.FormLayout; -import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -82,7 +81,7 @@ public class DialogEditProperties extends Dialog { @Override public void show() { resetForm(); - loadGcubeItemProperties(); + //loadGcubeItemProperties(); super.show(); } @@ -121,26 +120,26 @@ public class DialogEditProperties extends Dialog { } - private void loadGcubeItemProperties() { - // mask("Loading properties..."); - AppControllerExplorer.rpcWorkspaceService.loadGcubeItemProperties(item.getIdentifier(), - new AsyncCallback>() { +// private void loadGcubeItemProperties() { +// // mask("Loading properties..."); +// AppControllerExplorer.rpcWorkspaceService.loadGcubeItemProperties(item.getIdentifier(), +// new AsyncCallback>() { +// +// @Override +// public void onSuccess(Map result) { +// // unmask(); +// setProperties(result); +// } +// +// @Override +// public void onFailure(Throwable caught) { +// // unmask(); +// GWT.log("an error occured in loadGcubeItemProperties " + item + " " + caught.getMessage()); +// } +// }); +// } - @Override - public void onSuccess(Map result) { - // unmask(); - setProperties(result); - } - - @Override - public void onFailure(Throwable caught) { - // unmask(); - GWT.log("an error occured in loadGcubeItemProperties " + item + " " + caught.getMessage()); - } - }); - } - - private void setProperties(Map result) { + public void setProperties(Map result) { fields = new ArrayList>(result.size()); for (String key : result.keySet()) { TextField field = new TextField(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java index f87e9b3..b148c6a 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java @@ -1,11 +1,13 @@ package org.gcube.portlets.user.workspace.client.view.windows; import java.util.List; +import java.util.Map; import org.gcube.portlets.user.workspace.client.AppControllerExplorer; import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; import org.gcube.portlets.user.workspace.client.model.FileModel; +import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.ControlGroup; import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.TextArea; @@ -14,8 +16,12 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.KeyPressEvent; +import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTML; @@ -34,10 +40,12 @@ public class DialogGetInfoBootstrap extends Composite { } public static final String UNKNOWN = "unknown"; + + private Map gCubeProperties; @UiField HorizontalPanel hpItemType; - + @UiField HTML txtName; @@ -53,8 +61,28 @@ public class DialogGetInfoBootstrap extends Composite { @UiField HTML txtIsPublic; + @UiField + ControlGroup cgThreddsSynched; + + @UiField + HTML txtThreddsSynched; + + @UiField + ControlGroup cgGcubeProperties; + + @UiField + TextArea txtAreaGcubeProperties; + @UiField TextArea txtAreaDescription; + + @UiField + Button buttonUpdateDescription; + + @UiField + Button buttonUpdateGcubeProperties; + + private FileModel fileModel; /* * TextField txtType = new TextField(); private @@ -76,21 +104,27 @@ public class DialogGetInfoBootstrap extends Composite { public DialogGetInfoBootstrap(final FileModel fileModel) { initWidget(uiBinder.createAndBindUi(this)); - + this.fileModel = fileModel; + hpItemType.add(fileModel.getIcon()); Label labelItemType = new Label(); labelItemType.setType(LabelType.INFO); labelItemType.getElement().getStyle().setMarginLeft(10, Unit.PX); String label = null; - + GXTFolderItemTypeEnum typeEnum = fileModel.getGXTFolderItemType(); - if(typeEnum!=null) { + if (typeEnum != null) { label = typeEnum.getLabel(); label = label.replace("External ", ""); - }else { + + //loading gcube properties + if(typeEnum.equals(GXTFolderItemTypeEnum.GCUBE_ITEM)) + loadGcubeItemProperties(); + + } else { label = fileModel.getType(); } - + labelItemType.setText(label); hpItemType.add(labelItemType); @@ -106,17 +140,14 @@ public class DialogGetInfoBootstrap extends Composite { if (fileModel.isDirectory()) { cgTxtIsPublic.setVisible(true); - txtIsPublic.setHTML(fileModel.isPublic() + ""); + htmlSetValue(txtIsPublic, fileModel.isPublic() + ""); - /* - * if (fileModel.getSynchedThreddsStatus() != null) { txtThreddsSynched = new - * TextField(); txtThreddsSynched.setFieldLabel("Thredds Sync"); - * txtThreddsSynched.setReadOnly(true); - * txtThreddsSynched.setValue(fileModel.getSynchedThreddsStatus() + ""); - * add(txtThreddsSynched); - * - * } - */ + if (fileModel.getSynchedThreddsStatus() != null) { + txtThreddsSynched.setVisible(true); + htmlSetValue(txtThreddsSynched, fileModel.getSynchedThreddsStatus() + ""); + txtThreddsSynched.setHTML(fileModel.getSynchedThreddsStatus() + ""); + + } } @@ -125,15 +156,54 @@ public class DialogGetInfoBootstrap extends Composite { // add(txtAreaDescription); } else loadDescription(fileModel.getIdentifier()); - + addHandlers(); } - + private void addHandlers() { - txtAreaDescription.addClickHandler(new ClickHandler() { + + txtAreaDescription.addKeyPressHandler(new KeyPressHandler() { + + @Override + public void onKeyPress(KeyPressEvent event) { + + GWT.log(event.getUnicodeCharCode()+""); + + if(event.getUnicodeCharCode()==13) { + txtAreaDescription.setReadOnly(true); + Window.alert("Updating description"); + } + + } + }); + + buttonUpdateDescription.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { + txtAreaDescription.setReadOnly(false); + txtAreaDescription.setFocus(true); + } + }); + + final Command cmdReloadProperties = new Command() { + + @Override + public void execute() { + loadGcubeItemProperties(); + } + }; + + buttonUpdateGcubeProperties.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + + DialogEditProperties editProperties = new DialogEditProperties(fileModel, cmdReloadProperties); + editProperties.setProperties(gCubeProperties); + editProperties.setZIndex(99999); + editProperties.show(); + } }); } @@ -157,13 +227,13 @@ public class DialogGetInfoBootstrap extends Composite { GWT.log("failure get list parents by item identifier " + caught); removePlaceHolder(txtLocation); txtLocation.setHTML(UNKNOWN); - //txtLocation.set(false); + // txtLocation.set(false); } @Override public void onSuccess(List result) { removePlaceHolder(txtLocation); - + String location = ""; if (result != null) { for (FileModel fileModel : result) { @@ -179,7 +249,7 @@ public class DialogGetInfoBootstrap extends Composite { }); } - + /** * @param identifier */ @@ -207,17 +277,46 @@ public class DialogGetInfoBootstrap extends Composite { }); } + + private void loadGcubeItemProperties() { + // mask("Loading properties..."); + AppControllerExplorer.rpcWorkspaceService.loadGcubeItemProperties(fileModel.getIdentifier(), + new AsyncCallback>() { + + @Override + public void onSuccess(Map result) { + txtAreaGcubeProperties.setText(""); + GWT.log("Gcube Item Properties: "+result); + gCubeProperties = result; + // unmask(); + if(result!=null && result.size()>0) { + for (String key : result.keySet()) { + String text = txtAreaGcubeProperties.getText(); + text+=key+"="+result.get(key)+";\n"; + txtAreaGcubeProperties.setText(text); + } + cgGcubeProperties.setVisible(true); + } + } + + @Override + public void onFailure(Throwable caught) { + // unmask(); + cgGcubeProperties.setVisible(false); + GWT.log("an error occured in loadGcubeItemProperties " + fileModel.getIdentifier() + " " + caught.getMessage()); + } + }); + } - + private void setPlaceholder(HTML html, String placeholder) { html.setHTML(placeholder); html.getElement().getStyle().setColor("#E8E8E8"); } - + private void removePlaceHolder(HTML html) { html.setHTML(""); html.getElement().getStyle().setColor("#000"); } - } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml index 177373d..027cbd4 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml @@ -56,6 +56,15 @@ + + Thredds Sync + + + + + Description @@ -63,15 +72,31 @@ - + + + Gcube Properties + + + + + + + + + + - \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/accounting/AccoutingInfoContainer.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/accounting/AccoutingInfoContainer.java index 39fe098..a089d53 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/accounting/AccoutingInfoContainer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/accounting/AccoutingInfoContainer.java @@ -13,7 +13,6 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel import com.extjs.gxt.ui.client.Style.ButtonScale; import com.extjs.gxt.ui.client.Style.HorizontalAlignment; -import com.extjs.gxt.ui.client.data.BaseModel; import com.extjs.gxt.ui.client.data.BaseModelData; import com.extjs.gxt.ui.client.data.ModelData; import com.extjs.gxt.ui.client.event.ButtonEvent;