enhancements

This commit is contained in:
Francesco Mangiacrapa 2021-03-12 12:37:40 +01:00
parent f4846b0a66
commit 9e5f98f1ba
9 changed files with 351 additions and 186 deletions

View File

@ -1,7 +1,6 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.legend-style {
width: 100%;
@ -29,68 +28,61 @@
.control-group {
margin-bottom: 0px !important;
}
.custom-input {
}
</ui:style>
<g:HTMLPanel addStyleNames="{style.panel-style}">
<b:Form type="HORIZONTAL" width="100%">
<b:Fieldset addStyleNames="{style.custom-input}">
<b:Legend addStyleNames="{style.legend-style}">
<b>Resource Information</b>
<b:Button ui:field="closeButton" type="LINK"
title="Close details"></b:Button>
</b:Legend>
<b:ControlGroup ui:field="controlName">
<b:ControlLabel for="name"
title="The name the resource will have on the catalogue">
<b>Name:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox placeholder="Resource name" b:id="name"
enabled="true"
title="The name the resource will have on the catalogue"
ui:field="resourceName" />
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="path" title="Resource path">
<b>Path:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox placeholder="Resource path" b:id="path"
readOnly="true" title="Resource path" ui:field="resourcePath" />
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="description"
title="The description the resource will have on the catalogue">
<b>Description:</b>
</b:ControlLabel>
<b:Controls>
<b:TextArea placeholder="Resource description"
b:id="description"
title="The description the resource will have on the catalogue"
ui:field="resourceDescription"></b:TextArea>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup visible="false">
<b:ControlLabel for="format" title="The MIME type">
<b>Format:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox placeholder="Resource format" b:id="format"
title="The MIME type" ui:field="resourceFormat" readOnly="true" />
</b:Controls>
</b:ControlGroup>
<g:HorizontalPanel width="100%"
ui:field="commandPanel">
<!-- <b:Button ui:field="cancelButton">Cancel</b:Button> -->
<b:Button ui:field="updateResourceButton" type="PRIMARY">Update</b:Button>
</g:HorizontalPanel>
</b:Fieldset>
<g:HTMLPanel styleName="{style.panel-style}">
<b:Form type="VERTICAL" width="100%">
<!-- <b:Fieldset styleName="{style.fieldset-border-style}"> -->
<b:Legend styleName="{style.legend-style}">
<b>Resource Information</b>
<b:Button ui:field="closeButton" type="LINK" title="Close details"></b:Button>
</b:Legend>
<b:ControlGroup ui:field="controlName" styleName="{style.control-group}">
<b:ControlLabel for="name" styleName="{style.labels-style}"
title="The name the resource will have on the catalogue">
<b>Name:</b>
</b:ControlLabel>
<b:Controls styleName="{style.controls-style}">
<b:TextBox placeholder="Resource name" b:id="name"
enabled="true" title="The name the resource will have on the catalogue"
ui:field="resourceName" />
</b:Controls>
</b:ControlGroup>
<b:ControlGroup styleName="{style.control-group}">
<b:ControlLabel for="path" title="Resource path"
styleName="{style.labels-style}">
<b>Path:</b>
</b:ControlLabel>
<b:Controls styleName="{style.controls-style}">
<b:TextBox placeholder="Resource path" b:id="path"
readOnly="true" title="Resource path" ui:field="resourcePath" />
</b:Controls>
</b:ControlGroup>
<b:ControlGroup styleName="{style.control-group}">
<b:ControlLabel for="description" styleName="{style.labels-style}"
title="The description the resource will have on the catalogue">
<b>Description:</b>
</b:ControlLabel>
<b:Controls styleName="{style.controls-style}">
<b:TextArea placeholder="Resource description" b:id="description"
title="The description the resource will have on the catalogue"
ui:field="resourceDescription"></b:TextArea>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup styleName="{style.control-group}">
<b:ControlLabel for="format" styleName="{style.labels-style}"
title="The MIME type">
<b>Format:</b>
</b:ControlLabel>
<b:Controls styleName="{style.controls-style}">
<b:TextBox placeholder="Resource format" b:id="format"
title="The MIME type" ui:field="resourceFormat" readOnly="true" />
</b:Controls>
</b:ControlGroup>
<g:HorizontalPanel width="100%" ui:field="commandPanel">
<!-- <b:Button ui:field="cancelButton">Cancel</b:Button> -->
<b:Button ui:field="updateResourceButton" type="PRIMARY">Update</b:Button>
</g:HorizontalPanel>
<!-- </b:Fieldset> -->
</b:Form>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -1,62 +0,0 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
import com.google.gwt.event.shared.GwtEvent;
// TODO: Auto-generated Javadoc
/**
* The Class EditPublishingResourceEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Mar 9, 2021
*/
public class EditPublishingResourceEvent extends GwtEvent<EditPublishingResourceEventHandler> {
/** The type. */
public static Type<EditPublishingResourceEventHandler> TYPE = new Type<EditPublishingResourceEventHandler>();
/** The resource. */
private ResourceElementBean resource;
/**
* Instantiates a new edits the publishing resource event.
*
* @param resource the resource
*/
public EditPublishingResourceEvent(ResourceElementBean resource) {
this.resource = resource;
}
/**
* Gets the resource.
*
* @return the resource
*/
public ResourceElementBean getResource() {
return resource;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<EditPublishingResourceEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(EditPublishingResourceEventHandler handler) {
handler.onEditResource(this);
}
}

View File

@ -1,22 +0,0 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace;
import com.google.gwt.event.shared.EventHandler;
// TODO: Auto-generated Javadoc
/**
* The Interface EditPublishingResourceEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Mar 9, 2021
*/
public interface EditPublishingResourceEventHandler extends EventHandler {
/**
* On edit resource.
*
* @param editResourceEvent the edit resource event
*/
void onEditResource(EditPublishingResourceEvent editResourceEvent);
}

View File

@ -0,0 +1,138 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.TextArea;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Float;
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.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* A resource information form panel
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class ResourceInfoForm extends Composite{
@UiField
public TextBox resourceName;
@UiField
public TextBox resourcePath;
@UiField
public TextBox resourceFormat;
@UiField
public TextArea resourceDescription;
@UiField
public Button updateResourceButton;
@UiField
Button closeButton;
@UiField
HorizontalPanel commandPanel;
@UiField
ControlGroup controlName;
private ResourceElementBean resourceBean;
private static ResourceInfoFormUiBinder uiBinder = GWT
.create(ResourceInfoFormUiBinder.class);
interface ResourceInfoFormUiBinder extends
UiBinder<Widget, ResourceInfoForm> {
}
public ResourceInfoForm(final ResourceElementBean resource) {
initWidget(uiBinder.createAndBindUi(this));
resourceBean = resource;
resourceDescription.setText(resource.getDescription());
resourceFormat.setText(resource.getMimeType() == null? "Unavailable" : resource.getMimeType());
resourceName.setText(resource.getEditableName());
resourcePath.setText(resource.getFullPath());
closeButton.getElement().getStyle().setFloat(Float.RIGHT);
closeButton.setIcon(IconType.REMOVE_CIRCLE);
commandPanel.setCellHorizontalAlignment(updateResourceButton, HasHorizontalAlignment.ALIGN_RIGHT);
commandPanel.getElement().getStyle().setMarginTop(10, Unit.PX);
updateResourceButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
resourceBean.setDescription(resourceDescription.getText());
removeError(controlName);
String newName = resourceName.getText();
if(newName == null || newName.isEmpty()){
showError(controlName);
}else{
resourceBean.setEditableName(newName);
clearPanel();
}
}
});
closeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
clearPanel();
}
});
}
public String getResourceName() {
return resourceName.getText();
}
public void setResourceName(String resourceName) {
this.resourceName.setText(resourceName);
}
public String getResourcePath() {
return resourcePath.getText();
}
public void setResourcePath(String resourcePath) {
this.resourcePath.setText(resourcePath);
}
public String getResourceFormat() {
return resourceFormat.getText();
}
public void setResourceFormat(String resourceFormat) {
this.resourceFormat.setText(resourceFormat);
}
public String getResourceDescription() {
return resourceDescription.getText();
}
public void removeError(ControlGroup control) {
control.setType(ControlGroupType.NONE);
}
public void showError(ControlGroup control) {
control.setType(ControlGroupType.ERROR);
}
protected void clearPanel() {
this.removeFromParent();
}
public ResourceElementBean getResourceBean() {
return resourceBean;
}
}

View File

@ -0,0 +1,97 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.legend-style {
width: 100%;
padding: 10px;
margin-bottom: 0px;
font-size: 14px;
}
.panel-style {
padding: 5px;
border: 1px solid #bbb;
border-radius: 5px;
height: 320px;
width: 700px;
margin-left: 70px;
margin-bottom: 20px;
}
.labels-style {
color: #999;
}
.controls-style {
margin-left: 10px !important;
}
.control-group {
margin-bottom: 0px !important;
}
.custom-input input, textarea {
width: 350px;
}
</ui:style>
<g:HTMLPanel addStyleNames="{style.panel-style}">
<b:Form type="HORIZONTAL" width="100%">
<b:Fieldset addStyleNames="{style.custom-input}">
<b:Legend addStyleNames="{style.legend-style}">
<b>Resource Information</b>
<b:Button ui:field="closeButton" type="LINK"
title="Close details"></b:Button>
</b:Legend>
<b:ControlGroup ui:field="controlName">
<b:ControlLabel for="name"
title="The name the resource will have on the catalogue">
<b>Name:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox placeholder="Resource name" b:id="name"
enabled="true"
title="The name the resource will have on the catalogue"
ui:field="resourceName" />
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="path" title="Resource path">
<b>Path:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox placeholder="Resource path" b:id="path"
readOnly="true" title="Resource path" ui:field="resourcePath" />
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="description"
title="The description the resource will have on the catalogue">
<b>Description:</b>
</b:ControlLabel>
<b:Controls>
<b:TextArea placeholder="Resource description"
b:id="description"
title="The description the resource will have on the catalogue"
ui:field="resourceDescription"></b:TextArea>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup visible="false">
<b:ControlLabel for="format" title="The MIME type">
<b>Format:</b>
</b:ControlLabel>
<b:Controls>
<b:TextBox placeholder="Resource format" b:id="format"
title="The MIME type" ui:field="resourceFormat" readOnly="true" />
</b:Controls>
</b:ControlGroup>
<g:HorizontalPanel width="100%"
ui:field="commandPanel">
<!-- <b:Button ui:field="cancelButton">Cancel</b:Button> -->
<b:Button ui:field="updateResourceButton" type="PRIMARY">Update</b:Button>
</g:HorizontalPanel>
</b:Fieldset>
</b:Form>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -3,7 +3,6 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace;
import java.util.HashMap;
import java.util.Map;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.TwinColumnSelection.ResourceInfoForm;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanel;
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
@ -19,7 +18,6 @@ import com.github.gwtbootstrap.client.ui.constants.LabelType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasAllDragAndDropHandlers;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
@ -72,7 +70,7 @@ public class SelectResourceByWEMainPanel extends Composite {
public final static HandlerManager eventBus = new HandlerManager(null);
Map<String, SelectResourceWidget> mapSelectedResources = new HashMap<String, SelectResourceWidget>();
Map<String, SelectedResourceWidget> mapSelectedResources = new HashMap<String, SelectedResourceWidget>();
/**
* The Interface SelectResourceByWEMainPanelUiBinder.
@ -190,35 +188,13 @@ public class SelectResourceByWEMainPanel extends Composite {
});
eventBus.addHandler(EditPublishingResourceEvent.TYPE, new EditPublishingResourceEventHandler() {
@Override
public void onEditResource(EditPublishingResourceEvent editResourceEvent) {
if(editResourceEvent.getResource()!=null) {
editPublishingResource(editResourceEvent.getResource());
}
}
});
}
private void editPublishingResource(ResourceElementBean resource) {
SelectResourceWidget theRW = mapSelectedResources.get(resource.getOriginalIdInWorkspace());
if(theRW!=null) {
ResourceInfoForm rif = new ResourceInfoForm(resource, null);
editPanel.add(rif);
}
}
private void removePublishingResource(ResourceElementBean resource) {
SelectResourceWidget theRW = mapSelectedResources.get(resource.getOriginalIdInWorkspace());
SelectedResourceWidget theRW = mapSelectedResources.get(resource.getOriginalIdInWorkspace());
if(theRW!=null) {
selectResourcesContainer.remove(theRW);
mapSelectedResources.remove(resource.getOriginalIdInWorkspace());
@ -229,7 +205,7 @@ public class SelectResourceByWEMainPanel extends Composite {
public void addSelectResource(String wsItemId, String name, String path) {
SelectResourceWidget selWidg = mapSelectedResources.get(wsItemId);
SelectedResourceWidget selWidg = mapSelectedResources.get(wsItemId);
if (selWidg != null) {
showAlertMsg(AlertType.WARNING,"Item '" + name + "' already selected",true);
return;
@ -240,7 +216,7 @@ public class SelectResourceByWEMainPanel extends Composite {
rb.setName(name);
rb.setFullPath(path);
rb.setEditableName(name);
selWidg = new SelectResourceWidget(rb);
selWidg = new SelectedResourceWidget(rb);
mapSelectedResources.put(wsItemId, selWidg);
selectResourcesContainer.add(selWidg);

View File

@ -37,7 +37,7 @@
<g:HTMLPanel>
<b:PageHeader addStyleNames="{style.custom-header}">Publishing Resources</b:PageHeader>
<b:Alert ui:field="showAlert" visible="false"></b:Alert>
<g:VerticalPanel ui:field="selectResourcesContainer">
<g:VerticalPanel ui:field="selectResourcesContainer" width="100%">
<b:Label ui:field="labelNothing">Nothing</b:Label>
</g:VerticalPanel>
<g:HTMLPanel ui:field="editPanel">

View File

@ -10,32 +10,64 @@ import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
public class SelectResourceWidget extends Composite {
/**
* The Class SelectResourceWidget.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Mar 12, 2021
*/
public class SelectedResourceWidget extends Composite {
private static SelectResourceWidgetUiBinder uiBinder = GWT.create(SelectResourceWidgetUiBinder.class);
/** The ui binder. */
private static SelectedResourceWidgetUiBinder uiBinder = GWT.create(SelectedResourceWidgetUiBinder.class);
interface SelectResourceWidgetUiBinder extends UiBinder<Widget, SelectResourceWidget> {
/**
* The Interface SelectResourceWidgetUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Mar 12, 2021
*/
interface SelectedResourceWidgetUiBinder extends UiBinder<Widget, SelectedResourceWidget> {
}
public SelectResourceWidget() {
/**
* Instantiates a new select resource widget.
*/
public SelectedResourceWidget() {
initWidget(uiBinder.createAndBindUi(this));
}
/** The button delete. */
@UiField
Button buttonDelete;
/** The button edit. */
@UiField
Button buttonEdit;
/** The field name. */
@UiField
Label fieldName;
/** The edit panel. */
@UiField
HTMLPanel editPanel;
/** The resource bean. */
private ResourceElementBean resourceBean;
public SelectResourceWidget(ResourceElementBean rb) {
/**
* Instantiates a new select resource widget.
*
* @param rb the rb
*/
public SelectedResourceWidget(ResourceElementBean rb) {
initWidget(uiBinder.createAndBindUi(this));
this.resourceBean = rb;
@ -50,14 +82,18 @@ public class SelectResourceWidget extends Composite {
}
/**
* Adds the handlers.
*/
private void addHandlers() {
buttonEdit.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
SelectResourceByWEMainPanel.eventBus.fireEvent(new EditPublishingResourceEvent(resourceBean));
ResourceInfoForm rif = new ResourceInfoForm(resourceBean);
editPanel.add(rif);
}
});
@ -71,6 +107,11 @@ public class SelectResourceWidget extends Composite {
}
/**
* Gets the resource bean.
*
* @return the resource bean
*/
public ResourceElementBean getResourceBean() {
return resourceBean;
}

View File

@ -6,7 +6,9 @@
.important {
font-weight: bold;
}
.selected-resources {
}
.selected-resources td {
@ -14,10 +16,13 @@
}
</ui:style>
<g:HTMLPanel>
<g:HorizontalPanel addStyleNames="{style.selected-resources}">
<b:Button ui:field="buttonDelete" icon="TRASH" title="Remove this resource" />
<b:Button ui:field="buttonEdit" icon="PENCIL" title="Edit the resource title"/>
<g:FlowPanel addStyleNames="{style.selected-resources}">
<b:Button ui:field="buttonDelete" icon="TRASH"
title="Remove this resource" />
<b:Button ui:field="buttonEdit" icon="PENCIL"
title="Edit the resource title" />
<b:Label ui:field="fieldName"></b:Label>
</g:HorizontalPanel>
</g:FlowPanel>
<g:HTMLPanel ui:field="editPanel"></g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>