added Deletion of content of the first entry
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@95021 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c90f6b7818
commit
bf7563b76c
|
@ -137,6 +137,14 @@ public class ClientImage extends Composite {
|
|||
});
|
||||
}
|
||||
|
||||
public void resetImage() {
|
||||
titleTB.setText("");
|
||||
descTB.setText("");
|
||||
sourceTB.setText("");
|
||||
showImage(new Image(TemplateComponent.DEFAULT_IMAGE_NAME), DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||
imagePanel.addStyleName("imageEmptyPanel");
|
||||
}
|
||||
|
||||
private HorizontalPanel getControlPanel(boolean isRemovable, final TextTableImage owner) {
|
||||
final HorizontalPanel toReturn = new HorizontalPanel();
|
||||
|
||||
|
@ -152,11 +160,7 @@ public class ClientImage extends Composite {
|
|||
resetB.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
titleTB.setText("");
|
||||
descTB.setText("");
|
||||
sourceTB.setText("");
|
||||
showImage(new Image(TemplateComponent.DEFAULT_IMAGE_NAME), DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||
imagePanel.addStyleName("imageEmptyPanel");
|
||||
resetImage();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -38,9 +38,16 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
|
|||
SequenceWidget seqW = new SequenceWidget(p, this, originalSequence, true, false);
|
||||
myPanel.add(seqW);
|
||||
|
||||
for (RepeatableSequence repeatSeq : getRepeats()) {
|
||||
ArrayList<RepeatableSequence> repeats = getRepeats();
|
||||
if (repeats == null || repeats.size() == 0) {
|
||||
seqW.showResetFields(true);
|
||||
}
|
||||
for (RepeatableSequence repeatSeq : repeats) {
|
||||
addAnother(repeatSeq);
|
||||
}
|
||||
|
||||
|
||||
|
||||
initWidget(myPanel);
|
||||
}
|
||||
|
||||
|
@ -246,6 +253,11 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
|
|||
public boolean add(String id, RepeatableSequence sequence, boolean isSingleRelation) {
|
||||
SequenceWidget seqW = new SequenceWidget(p, this, sequence, false, true);
|
||||
myPanel.add(seqW);
|
||||
//disable clear content
|
||||
if (myPanel.getWidgetCount() > 1) {
|
||||
SequenceWidget first = (SequenceWidget) myPanel.getWidget(0);
|
||||
first.showResetFields(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -255,6 +267,11 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
|
|||
for (TemplateComponent tc : toRemove.getSeqGroupedComponents()) {
|
||||
groupedComponents.remove(tc);
|
||||
}
|
||||
//enable clear content
|
||||
if (myPanel.getWidgetCount() == 1) {
|
||||
SequenceWidget first = (SequenceWidget) myPanel.getWidget(0);
|
||||
first.showResetFields(true);
|
||||
}
|
||||
return toRemove;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.google.gwt.core.client.GWT;
|
|||
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.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HasAlignment;
|
||||
|
@ -31,6 +32,7 @@ public class SequenceWidget extends Composite {
|
|||
|
||||
private VerticalPanel myPanel;
|
||||
|
||||
private Button clearEntryB = new Button("Remove Content");
|
||||
private Button addAnotherB = new Button("Add another Entry");
|
||||
private Button removeThisB = new Button("Remove Entry");
|
||||
private Button selectNewB = new Button("Add Source");
|
||||
|
@ -264,6 +266,63 @@ public class SequenceWidget extends Composite {
|
|||
}
|
||||
}
|
||||
|
||||
public void showResetFields(boolean show) {
|
||||
clearEntryB.setVisible(show);
|
||||
|
||||
if (buttonsWrapperPanel.getWidgetIndex(clearEntryB) == -1) {
|
||||
buttonsWrapperPanel.insert(clearEntryB, 0);
|
||||
clearEntryB.getElement().getStyle().setWidth(130, Unit.PX);
|
||||
clearEntryB.getElement().getStyle().setMargin(10, Unit.PX);
|
||||
clearEntryB.addStyleName("deleteAssociationButton");
|
||||
|
||||
clearEntryB.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
clearContent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void clearContent() {
|
||||
int widgetsCount = myPanel.getWidgetCount();
|
||||
for (int i = 0; i < widgetsCount; i++) {
|
||||
if (myPanel.getWidget(i) instanceof ClientReportReference) {
|
||||
ClientReportReference toClear = (ClientReportReference) myPanel.getWidget(i);
|
||||
toClear.clear();
|
||||
toClear.cleanInModel();
|
||||
}
|
||||
else if (myPanel.getWidget(i) instanceof D4sRichTextarea) {
|
||||
D4sRichTextarea toClear = (D4sRichTextarea) myPanel.getWidget(i);
|
||||
toClear.setHTML("");
|
||||
}
|
||||
else if (myPanel.getWidget(i) instanceof BasicTextArea) {
|
||||
BasicTextArea toClear = (BasicTextArea) myPanel.getWidget(i);
|
||||
toClear.setText("");
|
||||
}
|
||||
else if (myPanel.getWidget(i) instanceof ClientImage) {
|
||||
ClientImage toClear = (ClientImage) myPanel.getWidget(i);
|
||||
toClear.resetImage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//clean the fields in the model
|
||||
int size = repSequence.getGroupedComponents().size();
|
||||
//GWT.log("SequenceWidget Size = " + size);
|
||||
for (int j = 0; j < size; j++) {
|
||||
BasicComponent sComp = repSequence.getGroupedComponents().get(j);
|
||||
//if is not locked and is of type BODY then put fields to blank
|
||||
if ((!sComp.isLocked()) && (sComp.getType() == ComponentType.BODY || sComp.getType() == ComponentType.BODY_NOT_FORMATTED ||
|
||||
sComp.getType() == ComponentType.DYNA_IMAGE) ) {
|
||||
sComp.setPossibleContent("");
|
||||
sComp.setMetadata(setPropertiesForRSG(sComp.getMetadata()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<TemplateComponent> getSeqGroupedComponents() {
|
||||
return seqGroupedComponents;
|
||||
}
|
||||
|
|
Reference in New Issue