78 lines
2.3 KiB
Java
78 lines
2.3 KiB
Java
package org.gcube.portlets.user.geoportaldataentry.client.ui;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.CloneProjectEvent;
|
|
|
|
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
|
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.shared.HandlerManager;
|
|
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.Widget;
|
|
|
|
public class CloneOperationPanel extends Composite {
|
|
|
|
private static CloneOperationPanelUiBinder uiBinder = GWT.create(CloneOperationPanelUiBinder.class);
|
|
|
|
interface CloneOperationPanelUiBinder extends UiBinder<Widget, CloneOperationPanel> {
|
|
}
|
|
|
|
private HandlerManager appManagerBus;
|
|
|
|
public CloneOperationPanel(HandlerManager eventBus, ConcessioneDV concessione) {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
GWT.log("Cloning the: " + concessione);
|
|
this.appManagerBus = eventBus;
|
|
this.selectedProject = concessione;
|
|
infoProjectName.setText(selectedProject.getNome());
|
|
projectNameTextBox.setText(selectedProject.getNome());
|
|
projectNameTextBox.setEnabled(false);
|
|
|
|
publishNewProjectButton.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
boolean isValid = checkIsValidForm();
|
|
|
|
if (isValid) {
|
|
appManagerBus.fireEvent(new CloneProjectEvent(selectedProject, projectNameTextBox.getText()));
|
|
publishNewProjectButton.setEnabled(false);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
@UiField
|
|
TextBox projectNameTextBox;
|
|
|
|
@UiField
|
|
AlertBlock infoBlock;
|
|
|
|
@UiField
|
|
AlertBlock infoProjectName;
|
|
|
|
@UiField
|
|
Button publishNewProjectButton;
|
|
|
|
private ConcessioneDV selectedProject;
|
|
|
|
protected boolean checkIsValidForm() {
|
|
String text = projectNameTextBox.getText();
|
|
if (text == null || text.isEmpty()) {
|
|
infoBlock.setVisible(true);
|
|
infoBlock.setText("The Project's name cannot be empty!");
|
|
infoBlock.setType(AlertType.ERROR);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
}
|