bug fixing issue on Go to the Item

Added list box for selecting the geometry

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@178989 82a268e6-3cf1-43bd-a215-b396298e98cf
migrate-to-catalogue-util-library_#19764
Francesco Mangiacrapa 5 years ago
parent afa89e9b4c
commit 3a3ecfa66a

@ -10,6 +10,7 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.Met
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.DataTypeWrapper;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetadataFieldWrapper;
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.widgets.GeometryType;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ListBox;
@ -60,7 +61,7 @@ public class CKanMetadataPublisher implements EntryPoint {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
GeoJsonAreaSelectionDialog dialog=new GeoJsonAreaSelectionDialog();
GeoJsonAreaSelectionDialog dialog=new GeoJsonAreaSelectionDialog(GeometryType.LineString);
dialog.show();
}
});
@ -112,7 +113,7 @@ public class CKanMetadataPublisher implements EntryPoint {
// listLeft.add(new ResourceElementBean(null, "File I", false, null, "File I"));
//
// // test with folder and childs
// ArrayList<ResourceElementBean> childrenOfA = new ArrayList<ResourceElementBean>();
// ArrayList<ResourceElementBean> childrennameOfA = new ArrayList<ResourceElementBean>();
// ArrayList<ResourceElementBean> childrenOfW = new ArrayList<ResourceElementBean>();
//
// ResourceElementBean elementA = new ResourceElementBean(null, "Folder A", true, childrenOfA, "Folder A");

@ -9,6 +9,7 @@ import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaD
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.widgets.AreaSelectionDialog;
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.widgets.GeometryType;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsonUtils;
import com.google.gwt.json.client.JSONObject;
@ -27,12 +28,15 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
private String wktArea;
private Command onResponseCommand;
private ListBox geometries;
/**
* Instantiates a new geo json area selection dialog.
*
* @param geometry the geometry
*/
public GeoJsonAreaSelectionDialog() {
super(GeometryType.Polygon);
public GeoJsonAreaSelectionDialog(GeometryType geometry) {
super(geometry);
//THE HANDLER
SelectAreaDialogEventHandler handler = new SelectAreaDialogEventHandler() {
@ -90,7 +94,7 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
var geojson_format = new ol.format.GeoJSON(wkt_options);
console.log('geojson_format: '+geojson_format);
var geoJsonFeature = geojson_format.writeFeature(wktFeature);
//console.log('GeoJSON Feature: '+geoJsonFeature);
//console.log('GeoJSON Feature: '+geoJsnameonFeature);
return geoJsonFeature;
}catch(err) {
console.log(err.message);
@ -98,6 +102,12 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
}
}-*/;
/**
* Prints the.
*
* @param txt the txt
* @return the string
*/
public static native String print(String txt) /*-{
console.log(txt)
}-*/;
@ -154,4 +164,37 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
return wktArea;
}
/**
* Gets the geometries.
*
* @return the geometries
*/
public static ListBox getGeometries() {
ListBox geometries = new ListBox();
for (GeometryType geometry : GeometryType.values()) {
geometries.addItem(geometry.name(),geometry.name());
}
return geometries;
}
/**
* To geometry.
*
* @param name the name
* @return the geometry type
*/
public static GeometryType toGeometry(String name){
GeometryType theGeom = null;
try {
theGeom = GeometryType.valueOf(name);
}catch (Exception e) {
//silent
}
return theGeom;
}
}

@ -65,6 +65,7 @@ import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
@ -110,7 +111,7 @@ public class CreateDatasetForm extends Composite{
@UiField Button goBackButtonSecondStep;
@UiField Paragraph selectedProfile;
@UiField Button goToDatasetButton;
@UiField FlowPanel goToDatasetButtonPanel;
@UiField HorizontalPanel goToDatasetButtonPanel;
@UiField Button addResourcesButton;
@UiField SimplePanel workspaceResourcesContainer;
@UiField Button continueThirdStep;
@ -1004,19 +1005,27 @@ public class CreateDatasetForm extends Composite{
@Override
public void onSuccess(final DatasetBean createdDatasetBean) {
GWT.log("Created the dataset: "+createdDatasetBean);
if(createdDatasetBean != null){
final String datasetUrl = createdDatasetBean.getSource();
alertOnCreate(PRODUCT_CREATED_OK, AlertType.SUCCESS, false);
try {
// disable dataset fields
disableDatasetFields();
disableDatasetFields();
}catch (Exception e) {
// TODO: handle exception
}
// disable reset
resetButton.setEnabled(false);
// show the go to dataset button
final String datasetUrl = createdDatasetBean.getSource();
goToDatasetButtonPanel.setVisible(true);
goToDatasetButton.setVisible(true);
goToDatasetButton.setText(
@ -1032,58 +1041,59 @@ public class CreateDatasetForm extends Composite{
//Window.Location.assign(datasetUrl);
}
});
// set hidden the create button
createButton.setVisible(false);
// if we are in the "general case" we need to show a form for adding resources
if(isWorkspaceRequest){
// leave to back button, but remove create and add go to dataset
createButton.removeFromParent();
}else{
// remove create button
createButton.removeFromParent();
// show the add resources button
addResourcesButton.setVisible(true);
addResourcesButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// remove content of the main panel
createDatasetMainPanel.clear();
// TabPanel
tabPanel = new TabPanel(Tabs.ABOVE);
tabPanel.setWidth("100%");
// add the form
resourceForm = new AddResourceToDataset(eventBus, createdDatasetBean.getId(), createdDatasetBean.getSelectedOrganization(), owner, datasetUrl);
// tab for the form
Tab formContainer = new Tab();
formContainer.add(resourceForm);
formContainer.setHeading("Add New Resource");
tabPanel.add(formContainer);
// tab for the added resources
Tab addedResources = new Tab();
addedResources.add(new AddedResourcesSummary(eventBus));
addedResources.setHeading("Added Resource");
tabPanel.add(addedResources);
// add tabs to resources panel
tabPanel.selectTab(0);
// form container
AddResourceContainer container = new AddResourceContainer(datasetUrl);
container.add(tabPanel);
// add the new content of the main panel
createDatasetMainPanel.add(container);
}
});
if(!isWorkspaceRequest) {
try {
// show the add resources button
addResourcesButton.setVisible(true);
addResourcesButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// remove content of the main panel
createDatasetMainPanel.clear();
// TabPanelException
tabPanel = new TabPanel(Tabs.ABOVE);
tabPanel.setWidth("100%");
// add the form
resourceForm = new AddResourceToDataset(eventBus, createdDatasetBean.getId(), createdDatasetBean.getSelectedOrganization(), owner, datasetUrl);
// tab for the form
Tab formContainer = new Tab();
formContainer.add(resourceForm);
formContainer.setHeading("Add New Resource");
tabPanel.add(formContainer);
// tab for the added resources
Tab addedResources = new Tab();
addedResources.add(new AddedResourcesSummary(eventBus));
addedResources.setHeading("Added Resource");
tabPanel.add(addedResources);
// add tabs to resources panel
tabPanel.selectTab(0);
// form container
AddResourceContainer container = new AddResourceContainer(datasetUrl);
container.add(tabPanel);
// add the new content of the main panel
createDatasetMainPanel.add(container);
}
});
}catch (Exception e2) {
//silent
}
}
}else{

@ -44,6 +44,10 @@
vertical-align: middle;
font-weight: bold;
}
.the-margin-left{
margin-left: 5px;
}
</ui:style>
<g:HTMLPanel ui:field="createDatasetMainPanel">
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
@ -384,11 +388,11 @@
visible="false" ui:field="onCreateAlertBlock" styleName="{style.block-alert-style}">
</b:AlertBlock>
<g:FlowPanel ui:field="goToDatasetButtonPanel" visible="false">
<g:Label styleName="{style.label-go-to-product}">Go to the Item</g:Label>
<g:HorizontalPanel ui:field="goToDatasetButtonPanel" visible="false">
<g:Label>Go to the Item</g:Label>
<b:Button title="Go to the Item" ui:field="goToDatasetButton"
type="LINK" block="false" visible="false"></b:Button>
</g:FlowPanel>
type="LINK" visible="false" styleName="{style.the-margin-left}"></b:Button>
</g:HorizontalPanel>
<b:Button title="Add resources to the just created item"
block="true" type="PRIMARY" visible="false" ui:field="addResourcesButton">Add Resources</b:Button>

@ -32,6 +32,7 @@ import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.dom.client.Style.Display;
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.logical.shared.ResizeEvent;
@ -46,6 +47,8 @@ import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
@ -137,14 +140,24 @@ public class MetaDataFieldSkeleton extends Composite{
textArea.setText(field.getDefaultValue());
containerGeoJSON.add(textArea);
HorizontalPanel hp = new HorizontalPanel();
hp.getElement().getStyle().setMarginTop(10, Unit.PX);
final ListBox geometries = GeoJsonAreaSelectionDialog.getGeometries();
Button butt = new Button();
butt.setIcon(IconType.MAP_MARKER);
butt.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final GeoJsonAreaSelectionDialog dialog=new GeoJsonAreaSelectionDialog();
String geometrySelected = geometries.getSelectedItemText();
if(geometrySelected==null) {
containerGeoJSON.add(new Alert("Please, select one geometry", AlertType.WARNING, true));
}
final GeoJsonAreaSelectionDialog dialog=new GeoJsonAreaSelectionDialog(GeoJsonAreaSelectionDialog.toGeometry(geometrySelected));
Command fillGeoJSONArea = new Command() {
public void execute() {
@ -169,7 +182,14 @@ public class MetaDataFieldSkeleton extends Composite{
});
geoJsonList.add(textArea);
containerGeoJSON.add(butt);
Label label = new Label("Draw a");
label.getElement().getStyle().setMarginRight(5, Unit.PX);
hp.add(label);
geometries.getElement().getStyle().setMarginRight(5, Unit.PX);
hp.add(geometries);
hp.add(butt);
geometries.setItemSelected(0, true);
containerGeoJSON.add(hp);
holder = containerGeoJSON;
break;

@ -10,8 +10,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datacatalogue.ckanutillibrary.server.utils.SessionCatalogueAttributes;
import org.gcube.datacatalogue.ckanutillibrary.server.utils.CatalogueUtilMethods;
import org.gcube.datacatalogue.ckanutillibrary.server.utils.SessionCatalogueAttributes;
import org.gcube.datacatalogue.metadatadiscovery.DataCalogueMetadataFormatReader;
import org.gcube.datacatalogue.metadatadiscovery.bean.MetadataProfile;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataField;

Loading…
Cancel
Save