Configured to call the metadata-profile-form-builder widget
parent
be65092445
commit
b0c95d161a
@ -1,4 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
lastWarOutDir=/home/francesco/git/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.0-SNAPSHOT
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/home/francesco-mangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
entryPointModules=
|
||||
gwtSyncCodeServer=true
|
@ -1,150 +1,42 @@
|
||||
package org.gcube.portlets.user.geoportaldataentry.client;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.FieldVerifier;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
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.KeyCodes;
|
||||
import com.google.gwt.event.dom.client.KeyUpEvent;
|
||||
import com.google.gwt.event.dom.client.KeyUpHandler;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.DialogBox;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
/**
|
||||
* Entry point classes define <code>onModuleLoad()</code>.
|
||||
*/
|
||||
public class GeoPortalDataEntryApp implements EntryPoint {
|
||||
/**
|
||||
* The message displayed to the user when the server cannot be reached or
|
||||
* returns an error.
|
||||
*/
|
||||
private static final String SERVER_ERROR = "An error occurred while "
|
||||
+ "attempting to contact the server. Please check your network "
|
||||
+ "connection and try again.";
|
||||
|
||||
/**
|
||||
* Create a remote service proxy to talk to the server-side Greeting service.
|
||||
*/
|
||||
private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
|
||||
|
||||
private final Messages messages = GWT.create(Messages.class);
|
||||
|
||||
/**
|
||||
* This is the entry point method.
|
||||
*/
|
||||
public void onModuleLoad() {
|
||||
final Button sendButton = new Button( messages.sendButton() );
|
||||
final TextBox nameField = new TextBox();
|
||||
nameField.setText( messages.nameField() );
|
||||
final Label errorLabel = new Label();
|
||||
|
||||
// We can add style names to widgets
|
||||
sendButton.addStyleName("sendButton");
|
||||
|
||||
// Add the nameField and sendButton to the RootPanel
|
||||
// Use RootPanel.get() to get the entire body element
|
||||
RootPanel.get("nameFieldContainer").add(nameField);
|
||||
RootPanel.get("sendButtonContainer").add(sendButton);
|
||||
RootPanel.get("errorLabelContainer").add(errorLabel);
|
||||
|
||||
// Focus the cursor on the name field when the app loads
|
||||
nameField.setFocus(true);
|
||||
nameField.selectAll();
|
||||
|
||||
// Create the popup dialog box
|
||||
final DialogBox dialogBox = new DialogBox();
|
||||
dialogBox.setText("Remote Procedure Call");
|
||||
dialogBox.setAnimationEnabled(true);
|
||||
final Button closeButton = new Button("Close");
|
||||
// We can set the id of a widget by accessing its Element
|
||||
closeButton.getElement().setId("closeButton");
|
||||
final Label textToServerLabel = new Label();
|
||||
final HTML serverResponseLabel = new HTML();
|
||||
VerticalPanel dialogVPanel = new VerticalPanel();
|
||||
dialogVPanel.addStyleName("dialogVPanel");
|
||||
dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
|
||||
dialogVPanel.add(textToServerLabel);
|
||||
dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
|
||||
dialogVPanel.add(serverResponseLabel);
|
||||
dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
|
||||
dialogVPanel.add(closeButton);
|
||||
dialogBox.setWidget(dialogVPanel);
|
||||
|
||||
// Add a handler to close the DialogBox
|
||||
closeButton.addClickHandler(new ClickHandler() {
|
||||
public void onClick(ClickEvent event) {
|
||||
dialogBox.hide();
|
||||
sendButton.setEnabled(true);
|
||||
sendButton.setFocus(true);
|
||||
}
|
||||
});
|
||||
|
||||
// Create a handler for the sendButton and nameField
|
||||
class MyHandler implements ClickHandler, KeyUpHandler {
|
||||
/**
|
||||
* Fired when the user clicks on the sendButton.
|
||||
*/
|
||||
public void onClick(ClickEvent event) {
|
||||
sendNameToServer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the user types in the nameField.
|
||||
*/
|
||||
public void onKeyUp(KeyUpEvent event) {
|
||||
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
|
||||
sendNameToServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the name from the nameField to the server and wait for a response.
|
||||
*/
|
||||
private void sendNameToServer() {
|
||||
// First, we validate the input.
|
||||
errorLabel.setText("");
|
||||
String textToServer = nameField.getText();
|
||||
if (!FieldVerifier.isValidName(textToServer)) {
|
||||
errorLabel.setText("Please enter at least four characters");
|
||||
return;
|
||||
}
|
||||
|
||||
// Then, we send the input to the server.
|
||||
sendButton.setEnabled(false);
|
||||
textToServerLabel.setText(textToServer);
|
||||
serverResponseLabel.setText("");
|
||||
greetingService.greetServer(textToServer, new AsyncCallback<String>() {
|
||||
public void onFailure(Throwable caught) {
|
||||
// Show the RPC error message to the user
|
||||
dialogBox.setText("Remote Procedure Call - Failure");
|
||||
serverResponseLabel.addStyleName("serverResponseLabelError");
|
||||
serverResponseLabel.setHTML(SERVER_ERROR);
|
||||
dialogBox.center();
|
||||
closeButton.setFocus(true);
|
||||
}
|
||||
|
||||
public void onSuccess(String result) {
|
||||
dialogBox.setText("Remote Procedure Call");
|
||||
serverResponseLabel.removeStyleName("serverResponseLabelError");
|
||||
serverResponseLabel.setHTML(result);
|
||||
dialogBox.center();
|
||||
closeButton.setFocus(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Add a handler to send the name to the server
|
||||
MyHandler handler = new MyHandler();
|
||||
sendButton.addClickHandler(handler);
|
||||
nameField.addKeyUpHandler(handler);
|
||||
}
|
||||
/**
|
||||
* The message displayed to the user when the server cannot be reached or
|
||||
* returns an error.
|
||||
*/
|
||||
private static final String SERVER_ERROR = "An error occurred while "
|
||||
+ "attempting to contact the server. Please check your network " + "connection and try again.";
|
||||
|
||||
private static final String DIV_PORTLET_ID = "geoportal-data-entry";
|
||||
|
||||
/**
|
||||
* Create a remote service proxy to talk to the server-side Greeting service.
|
||||
*/
|
||||
private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
|
||||
|
||||
private final Messages messages = GWT.create(Messages.class);
|
||||
|
||||
/**
|
||||
* This is the entry point method.
|
||||
*/
|
||||
public void onModuleLoad() {
|
||||
|
||||
String scope = "/gcube/devsec/devVRE";
|
||||
String secondaryType = "GeoNaMetadata";
|
||||
HandlerManager eventBus = new HandlerManager(null);
|
||||
CreateMetadataForm baseForm = new CreateMetadataForm(scope, secondaryType, eventBus);
|
||||
RootPanel.get(DIV_PORTLET_ID).add(baseForm);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
package org.gcube.portlets.user.geoportaldataentry.portlet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.portlet.GenericPortlet;
|
||||
import javax.portlet.PortletException;
|
||||
import javax.portlet.PortletRequestDispatcher;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeoPortalDataEntryApp.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Oct 8, 2020
|
||||
*/
|
||||
public class GeoPortalDataEntryApp extends GenericPortlet{
|
||||
|
||||
/**
|
||||
* JSP folder name
|
||||
*/
|
||||
public static final String JSP_FOLDER = "/WEB-INF/jsp/";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String VIEW_JSP = JSP_FOLDER + "GeoPortalDataEntryApp_view.jsp";
|
||||
|
||||
/**
|
||||
* Do view.
|
||||
*
|
||||
* @param request .
|
||||
* @param response .
|
||||
* @throws PortletException .
|
||||
* @throws IOException .
|
||||
*/
|
||||
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
||||
//System.out.println("LOADING ********* FROM "+VIEW_JSP);
|
||||
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);
|
||||
rd.include(request,response);
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
sendButton = Envoyer
|
||||
nameField = Entrez votre nom
|
@ -0,0 +1,38 @@
|
||||
<%@page contentType="text/html"%>
|
||||
<%@page pageEncoding="UTF-8"%>
|
||||
|
||||
<%-- Uncomment below lines to add portlet taglibs to jsp
|
||||
<%@ page import="javax.portlet.*"%>
|
||||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
|
||||
|
||||
<portlet:defineObjects />
|
||||
--%>
|
||||
<script
|
||||
src='<%=request.getContextPath()%>/GeoPortalDataEntryApp/js/jquery-1.10.1.min.js'></script>
|
||||
|
||||
<script
|
||||
src='<%=request.getContextPath()%>/GeoPortalDataEntryApp/js/bootstrap.min.js'></script>
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="<%=request.getContextPath()%>/GeoPortalDataEntryApp.css"
|
||||
type="text/css">
|
||||
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="<%=request.getContextPath()%>/GeoPortalDataEntryApp/css/ol.css">
|
||||
|
||||
<script type="text/javascript"
|
||||
src="<%=request.getContextPath()%>/GeoPortalDataEntryApp/js/ol.js"></script>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="GeoPortalDataEntryApp/GeoPortalDataEntryApp.nocache.js"></script>
|
||||
</head>
|
||||
|
||||
|
||||
<!-- <script type="text/javascript" -->
|
||||
<%-- src='<%=request.getContextPath()%>/js/jquery.min.js'></script> --%>
|
||||
|
||||
<script type="text/javascript"
|
||||
src='<%=request.getContextPath()%>/js/jquery.autosize.js'></script>
|
||||
|
||||
|
||||
<div id="geoportal-data-entry"></div>
|
@ -0,0 +1,5 @@
|
||||
<display>
|
||||
<category name="gCube Applications">
|
||||
<portlet id="GeoPortalDataEntryApp" />
|
||||
</category>
|
||||
</display>
|
@ -0,0 +1,9 @@
|
||||
name=GeoPortalDataEntryApp
|
||||
module-group-id=liferay
|
||||
module-incremental-version=2
|
||||
tags=
|
||||
short-description=
|
||||
change-log=
|
||||
page-url=http://www.gcube-system.org
|
||||
author=gCube
|
||||
licenses=EUPL
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_5_2_0.dtd">
|
||||
|
||||
<liferay-portlet-app>
|
||||
<portlet>
|
||||
<portlet-name>GeoPortalDataEntryApp</portlet-name>
|
||||
<layout-cacheable>false</layout-cacheable>
|
||||
<instanceable>false</instanceable>
|
||||
<ajaxable>false</ajaxable>
|
||||
</portlet>
|
||||
</liferay-portlet-app>
|
@ -0,0 +1,25 @@
|
||||
<?xml version='1.0' encoding='UTF-8' ?>
|
||||
<portlet-app>
|
||||
<portlet>
|
||||
<description>GeoPortalDataEntryApp Portlet</description>
|
||||
<portlet-name>GeoPortalDataEntryApp</portlet-name>
|
||||
<display-name>GeoPortal Data Entry Portlet</display-name>
|
||||
<portlet-class>org.gcube.portlets.user.geoportaldataentry.portlet.GeoPortalDataEntryApp
|
||||
</portlet-class>
|
||||
<expiration-cache>0</expiration-cache>
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
<portlet-mode>VIEW</portlet-mode>
|
||||
</supports>
|
||||
<portlet-info>
|
||||
<title>GeoPortal Data Entry Portlet</title>
|
||||
<short-title>GeoPortal Data Entry Portlet</short-title>
|
||||
</portlet-info>
|
||||
<portlet-preferences>
|
||||
<preference>
|
||||
<name>portletSetupShowBorders</name>
|
||||
<value>false</value>
|
||||
</preference>
|
||||
</portlet-preferences>
|
||||
</portlet>
|
||||
</portlet-app>
|
@ -0,0 +1,8 @@
|
||||
/devNext.gcubekey
|
||||
/devVRE.gcubekey
|
||||
/devsec.gcubekey
|
||||
/gCubeApps.gcubekey
|
||||
/gcube.gcubekey
|
||||
/log4j.properties
|
||||
/pred4s.gcubekey
|
||||
/preprod.gcubekey
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module rename-to="GeoPortalDataEntryApp">
|
||||
<!-- Inherit our applications main module. -->
|
||||
<inherits name='org.gcube.portlets.user.geoportaldataentry.GeoPortalDataEntryApp' />
|
||||
|
||||
<!-- Specify the path to any remote services. -->
|
||||
<servlet path="/GeoPortalDataEntryApp/greet" class="org.gcube.portlets.user.geoportaldataentry.server.GreetingServiceImpl" />
|
||||
|
||||
</module>
|
Loading…
Reference in New Issue