added handler for enabling confirmation button on changes
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/grsf-manage-widget@162960 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f394bf2ff7
commit
597a1095a4
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.datacatalogue.grsf_manage_widget.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
public class EnableConfirmButtonEvent extends GwtEvent<EnableConfirmButtonEventHandler> {
|
||||
public static Type<EnableConfirmButtonEventHandler> TYPE = new Type<EnableConfirmButtonEventHandler>();
|
||||
|
||||
public EnableConfirmButtonEvent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<EnableConfirmButtonEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(EnableConfirmButtonEventHandler handler) {
|
||||
handler.onEvent(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.gcube.datacatalogue.grsf_manage_widget.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
public interface EnableConfirmButtonEventHandler extends EventHandler {
|
||||
|
||||
void onEvent(EnableConfirmButtonEvent event);
|
||||
|
||||
}
|
|
@ -9,6 +9,8 @@ import java.util.Set;
|
|||
import org.gcube.datacatalogue.common.enums.Status;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetService;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetServiceAsync;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.events.EnableConfirmButtonEvent;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.events.EnableConfirmButtonEventHandler;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.events.HideManagementPanelEvent;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.ConnectToWidget;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets.SimilarGRSFRecordWidget;
|
||||
|
@ -35,7 +37,10 @@ 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.dom.client.SelectElement;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
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;
|
||||
|
@ -181,6 +186,19 @@ public class ManageProductWidget extends Composite{
|
|||
|
||||
// async request to fetch the product
|
||||
retrieveProductBean(productIdentifier);
|
||||
|
||||
listenEvents(this.eventBus);
|
||||
}
|
||||
|
||||
|
||||
private void listenEvents(HandlerManager eventBus) {
|
||||
eventBus.addHandler(EnableConfirmButtonEvent.TYPE, new EnableConfirmButtonEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onEvent(EnableConfirmButtonEvent event) {
|
||||
confirmButton.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -227,12 +245,30 @@ public class ManageProductWidget extends Composite{
|
|||
// top: more or less fixed information
|
||||
GRSFNameTexBox.setText(bean.getTitle());
|
||||
shortNameTextBox.setText(bean.getShortName());
|
||||
shortNameTextBox.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
eventBus.fireEvent(new EnableConfirmButtonEvent());
|
||||
}
|
||||
});
|
||||
|
||||
semanticIdentifierTextBox.setText(bean.getSemanticIdentifier());
|
||||
productGrsfType.setText(bean.getGrsfType());
|
||||
currentStatus.setText(bean.getCurrentStatus().toString());
|
||||
traceabilityFlag.setValue(bean.isTraceabilityFlag());
|
||||
traceabilityFlag.setText("Traceability");
|
||||
traceabilityFlag.setTitle("Current value for this flag in the Knowledge Base is " + bean.isTraceabilityFlag());
|
||||
|
||||
traceabilityFlag.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
eventBus.fireEvent(new EnableConfirmButtonEvent());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// manage sources
|
||||
List<SourceRecord> availableSources = bean.getSources();
|
||||
|
@ -241,17 +277,17 @@ public class ManageProductWidget extends Composite{
|
|||
// manage similar GRSF records, if any
|
||||
if(bean.getSimilarGrsfRecords() != null && !bean.getSimilarGrsfRecords().isEmpty()){
|
||||
List<SimilarGRSFRecord> availableGRSFSimilarRecords = bean.getSimilarGrsfRecords();
|
||||
similarRecordPanel = new SimilarGRSFRecordWidget(availableGRSFSimilarRecords);
|
||||
similarRecordPanel = new SimilarGRSFRecordWidget(availableGRSFSimilarRecords, eventBus);
|
||||
panelForSimilarGRSFRecords.add(similarRecordPanel);
|
||||
}else
|
||||
similarGRSFRecordGroup.setVisible(false);
|
||||
|
||||
// further suggested merges
|
||||
suggestedMergesPanel = new SuggestMerges(service, bean.getDomain());
|
||||
suggestedMergesPanel = new SuggestMerges(service, bean.getDomain(), eventBus);
|
||||
panelForFurtherMerges.add(suggestedMergesPanel);
|
||||
|
||||
// prepare "connect" panel
|
||||
connectWidget = new ConnectToWidget(bean, service);
|
||||
connectWidget = new ConnectToWidget(bean, service, eventBus);
|
||||
panelForConnectOtherRecords.add(connectWidget);
|
||||
|
||||
// check for new status box
|
||||
|
@ -270,6 +306,26 @@ public class ManageProductWidget extends Composite{
|
|||
}
|
||||
listBoxStatus.setSelectedIndex(0);
|
||||
|
||||
listBoxStatus.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
|
||||
eventBus.fireEvent(new EnableConfirmButtonEvent());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
annotationArea.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
|
||||
eventBus.fireEvent(new EnableConfirmButtonEvent());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
formUpdate.setVisible(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@
|
|||
<b:Icon type="GEAR" spin="true" ui:field="loaderIcon"
|
||||
visible="false" />
|
||||
<b:Button ui:field="cancelButton">Cancel</b:Button>
|
||||
<b:Button icon="FILE" type="PRIMARY" ui:field="confirmButton">Confirm</b:Button>
|
||||
<b:Button icon="FILE" type="PRIMARY" ui:field="confirmButton" enabled="false">Confirm</b:Button>
|
||||
</b:ModalFooter>
|
||||
</b:Modal>
|
||||
</g:HTMLPanel>
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
|
||||
import org.gcube.datacatalogue.common.enums.Product_Type;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetServiceAsync;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.events.EnableConfirmButtonEvent;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.shared.ConnectedBean;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.shared.ManageProductBean;
|
||||
|
||||
|
@ -21,6 +22,7 @@ import com.google.gwt.dom.client.Style.FontWeight;
|
|||
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.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -54,10 +56,13 @@ public class ConnectToWidget extends Composite{
|
|||
private List<ConnectedBean> suggestedByKnowledgeBase; // they can be "connected"
|
||||
private GRSFManageWidgetServiceAsync service;
|
||||
|
||||
public ConnectToWidget(final ManageProductBean bean, GRSFManageWidgetServiceAsync service) {
|
||||
private HandlerManager eventBus;
|
||||
|
||||
public ConnectToWidget(final ManageProductBean bean, GRSFManageWidgetServiceAsync service, final HandlerManager eventBus) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
|
||||
this.service = service;
|
||||
this.eventBus = eventBus;
|
||||
|
||||
// get already connected beans, and suggested ones
|
||||
currentlyConnected = bean.getCurrentConnections();
|
||||
|
@ -65,7 +70,7 @@ public class ConnectToWidget extends Composite{
|
|||
if(currentlyConnected != null){
|
||||
connectPanel.add(new HTML("<hr style=\"width:100%;\"/>"));
|
||||
for (ConnectedBean connected : currentlyConnected) {
|
||||
Widget widget = buildWidgetForConnected(connected, false);
|
||||
Widget widget = buildWidgetForConnected(connected, false, eventBus);
|
||||
connectPanel.add(widget);
|
||||
connectPanel.add(new HTML("<hr style=\"width:100%;\"/>"));
|
||||
}
|
||||
|
@ -76,7 +81,7 @@ public class ConnectToWidget extends Composite{
|
|||
|
||||
if(suggestedByKnowledgeBase != null){
|
||||
for (ConnectedBean connected : suggestedByKnowledgeBase) {
|
||||
Widget widget = buildWidgetForConnected(connected, true);
|
||||
Widget widget = buildWidgetForConnected(connected, true, eventBus);
|
||||
connectPanel.add(widget);
|
||||
connectPanel.add(new HTML("<hr style=\"width:100%;\"/>"));
|
||||
}
|
||||
|
@ -98,7 +103,7 @@ public class ConnectToWidget extends Composite{
|
|||
public void onClick(ClickEvent arg0) {
|
||||
|
||||
ConnectedBean cb = new ConnectedBean();
|
||||
Tuple t = buildWidgetConnect(cb, acceptedDomain);
|
||||
Tuple t = buildWidgetConnect(cb, acceptedDomain, eventBus);
|
||||
connectList.add(t);
|
||||
connectPanel.add(t.getW());
|
||||
|
||||
|
@ -112,7 +117,7 @@ public class ConnectToWidget extends Composite{
|
|||
* @param similarGRSFRecord
|
||||
* @return
|
||||
*/
|
||||
public static Widget buildWidgetForConnected(final ConnectedBean connected, boolean suggestedByKb){
|
||||
public static Widget buildWidgetForConnected(final ConnectedBean connected, boolean suggestedByKb, final HandlerManager eventBus){
|
||||
HorizontalPanel hp = new HorizontalPanel();
|
||||
hp.setWidth("95%");
|
||||
VerticalPanel leftPanel = new VerticalPanel();
|
||||
|
@ -149,6 +154,7 @@ public class ConnectToWidget extends Composite{
|
|||
@Override
|
||||
public void onClick(ClickEvent arg0) {
|
||||
connected.setRemove(removeExtra.getValue());
|
||||
eventBus.fireEvent(new EnableConfirmButtonEvent());
|
||||
}
|
||||
});
|
||||
rightPanel.add(removeExtra);
|
||||
|
@ -162,6 +168,7 @@ public class ConnectToWidget extends Composite{
|
|||
@Override
|
||||
public void onClick(ClickEvent arg0) {
|
||||
connected.setConnect(connect.getValue());
|
||||
eventBus.fireEvent(new EnableConfirmButtonEvent());
|
||||
}
|
||||
});
|
||||
rightPanel.add(connect);
|
||||
|
@ -178,7 +185,7 @@ public class ConnectToWidget extends Composite{
|
|||
* @param cb the connectBean.
|
||||
* @param acceptedDomain
|
||||
*/
|
||||
private Tuple buildWidgetConnect(final ConnectedBean cb, final String acceptedDomain){
|
||||
private Tuple buildWidgetConnect(final ConnectedBean cb, final String acceptedDomain, HandlerManager eventBus){
|
||||
|
||||
VerticalPanel main = new VerticalPanel();
|
||||
HorizontalPanel hp = new HorizontalPanel();
|
||||
|
@ -281,6 +288,7 @@ public class ConnectToWidget extends Composite{
|
|||
validateUUIDButton.setText("Accepted");
|
||||
validateUUIDButton.setType(ButtonType.SUCCESS);
|
||||
validateUUIDButton.setEnabled(false);
|
||||
eventBus.fireEvent(new EnableConfirmButtonEvent());
|
||||
}
|
||||
else{
|
||||
view.setVisible(false);
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.datacatalogue.grsf_manage_widget.client.view.subwidgets;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.events.EnableConfirmButtonEvent;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.shared.SimilarGRSFRecord;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
|
@ -15,6 +16,7 @@ import com.google.gwt.dom.client.Style.FontWeight;
|
|||
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.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
|
@ -48,9 +50,10 @@ public class SimilarGRSFRecordWidget extends Composite {
|
|||
/**
|
||||
* Get widget for available similar grsf records
|
||||
* @param availableGRSFSimilarRecords
|
||||
* @param eventBus
|
||||
* @param service
|
||||
*/
|
||||
public SimilarGRSFRecordWidget(List<SimilarGRSFRecord> availableGRSFSimilarRecords) {
|
||||
public SimilarGRSFRecordWidget(List<SimilarGRSFRecord> availableGRSFSimilarRecords, HandlerManager eventBus) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
|
||||
//this.service = service;
|
||||
|
@ -93,7 +96,7 @@ public class SimilarGRSFRecordWidget extends Composite {
|
|||
|
||||
int index = 0;
|
||||
for (final SimilarGRSFRecord similarGRSFRecord : availableGRSFSimilarRecords) {
|
||||
Widget widget = buildWidgetForSimilarRecord(similarGRSFRecord);
|
||||
Widget widget = buildWidgetForSimilarRecord(similarGRSFRecord, eventBus);
|
||||
similarGrsfRecordsPanel.add(widget);
|
||||
HTML separator = new HTML("<hr style=\"width:100%;\"/>");
|
||||
similarGrsfRecordsPanel.add(separator);
|
||||
|
@ -113,11 +116,12 @@ public class SimilarGRSFRecordWidget extends Composite {
|
|||
/**
|
||||
* Builds widget for already present similar GRSF records
|
||||
* @param similarGRSFRecord
|
||||
* @param eventBus
|
||||
* @param hideMore
|
||||
* @param index
|
||||
* @return a Widget (actually a VerticalPanel)
|
||||
*/
|
||||
public static Widget buildWidgetForSimilarRecord(final SimilarGRSFRecord similarGRSFRecord){
|
||||
public static Widget buildWidgetForSimilarRecord(final SimilarGRSFRecord similarGRSFRecord, final HandlerManager eventBus){
|
||||
|
||||
HorizontalPanel hp = new HorizontalPanel();
|
||||
hp.setWidth("95%");
|
||||
|
@ -160,6 +164,7 @@ public class SimilarGRSFRecordWidget extends Composite {
|
|||
@Override
|
||||
public void onClick(ClickEvent arg0) {
|
||||
similarGRSFRecord.setSuggestedMerge(mergeSuggested.getValue());
|
||||
eventBus.fireEvent(new EnableConfirmButtonEvent());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.GRSFManageWidgetServiceAsync;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.client.events.EnableConfirmButtonEvent;
|
||||
import org.gcube.datacatalogue.grsf_manage_widget.shared.SimilarGRSFRecord;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.AppendButton;
|
||||
|
@ -18,6 +19,7 @@ import com.google.gwt.dom.client.Style.FontWeight;
|
|||
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.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -46,9 +48,12 @@ public class SuggestMerges extends Composite {
|
|||
|
||||
private GRSFManageWidgetServiceAsync service;
|
||||
|
||||
public SuggestMerges(GRSFManageWidgetServiceAsync service, final String acceptedDomain) {
|
||||
private HandlerManager eventBus;
|
||||
|
||||
public SuggestMerges(GRSFManageWidgetServiceAsync service, final String acceptedDomain, final HandlerManager eventBus) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.service = service;
|
||||
this.eventBus = eventBus;
|
||||
|
||||
// manage the "suggest button"
|
||||
addSimilarRecord.setText("Add Merge");
|
||||
|
@ -62,10 +67,10 @@ public class SuggestMerges extends Composite {
|
|||
@Override
|
||||
public void onClick(ClickEvent arg0) {
|
||||
SimilarGRSFRecord s = new SimilarGRSFRecord();
|
||||
Widget w = buildWidgetForExtraSimilarRecord(s, acceptedDomain);
|
||||
Widget w = buildWidgetForExtraSimilarRecord(s, acceptedDomain, eventBus);
|
||||
extraSimilarRecordsList.add(new Tuple(s, w, null));
|
||||
similarGrsfRecordsSuggestedPanel.add(w);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -73,8 +78,9 @@ public class SuggestMerges extends Composite {
|
|||
* Builds up a widget for suggested similar grsf records. Changes are performed in place with respect to w and s.
|
||||
* @param w the widget
|
||||
* @param s the similar record.
|
||||
* @param eventBus
|
||||
*/
|
||||
private Widget buildWidgetForExtraSimilarRecord(final SimilarGRSFRecord s, final String acceptedDomain){
|
||||
private Widget buildWidgetForExtraSimilarRecord(final SimilarGRSFRecord s, final String acceptedDomain, final HandlerManager eventBus){
|
||||
|
||||
VerticalPanel main = new VerticalPanel();
|
||||
main.getElement().getStyle().setMarginTop(10, Unit.PX);
|
||||
|
@ -110,7 +116,7 @@ public class SuggestMerges extends Composite {
|
|||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
validateUUID(box, s, view, validateUUIDButton, acceptedDomain);
|
||||
validateUUID(box, s, view, validateUUIDButton, acceptedDomain, eventBus);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -166,8 +172,9 @@ public class SuggestMerges extends Composite {
|
|||
* @param s
|
||||
* @param icon
|
||||
* @param view
|
||||
* @param eventBus2
|
||||
*/
|
||||
protected void validateUUID(final TextBox box, final SimilarGRSFRecord s, final Anchor view, final Button validateUUIDButton, final String acceptedDomain) {
|
||||
protected void validateUUID(final TextBox box, final SimilarGRSFRecord s, final Anchor view, final Button validateUUIDButton, final String acceptedDomain, HandlerManager eventBus2) {
|
||||
|
||||
validateUUIDButton.setText("Validating...");
|
||||
validateUUIDButton.setEnabled(false);
|
||||
|
@ -193,6 +200,7 @@ public class SuggestMerges extends Composite {
|
|||
validateUUIDButton.setText("Accepted");
|
||||
validateUUIDButton.setType(ButtonType.SUCCESS);
|
||||
validateUUIDButton.setEnabled(false);
|
||||
eventBus.fireEvent(new EnableConfirmButtonEvent());
|
||||
}
|
||||
else{
|
||||
view.setVisible(false);
|
||||
|
|
|
@ -468,7 +468,7 @@ public class Utils {
|
|||
uuid,
|
||||
(String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_DESCRIPTION),
|
||||
(String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_NAME),
|
||||
dataset.getTitle(), // no title
|
||||
dataset.getTitle(),
|
||||
(String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_URL),
|
||||
(String)object.get(Constants.SIMILAR_RECORDS_BEAN_FIELD_IDENTIFIER),
|
||||
dataset.getExtrasAsHashMap().get(Constants.DOMAIN_CUSTOM_KEY)
|
||||
|
|
Loading…
Reference in New Issue