Skip to content
Snippets Groups Projects
Commit 54758a20 authored by felmer's avatar felmer
Browse files

SP-298, BIS-210: '+' button added to allow adding sections before a section.

SVN: 26993
parent 585a3315
No related branches found
No related tags found
No related merge requests found
...@@ -82,7 +82,7 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements ...@@ -82,7 +82,7 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements
public static final int SECTION_DEFAULT_FIELD_WIDTH = DEFAULT_FIELD_WIDTH;// -15 public static final int SECTION_DEFAULT_FIELD_WIDTH = DEFAULT_FIELD_WIDTH;// -15
public static final int SECTION_WIDTH = SECTION_FIELD_WIDTH + SECTION_LABEL_WIDTH + 70;// +16 public static final int SECTION_WIDTH = SECTION_FIELD_WIDTH + SECTION_LABEL_WIDTH + 80;// +16
protected IMessageProvider messageProvider; protected IMessageProvider messageProvider;
......
...@@ -81,12 +81,12 @@ public class ManagedPropertyField extends Field<List<Map<String, String>>> ...@@ -81,12 +81,12 @@ public class ManagedPropertyField extends Field<List<Map<String, String>>>
@Override @Override
public void componentSelected(ButtonEvent ce) public void componentSelected(ButtonEvent ce)
{ {
addNewSection(); addNewSection(sections.size());
} }
}); });
addButton.setToolTip("Add a new section."); addButton.setToolTip("Add a new section.");
verticalPanel.add(addButton); verticalPanel.add(addButton);
addNewSection(); addNewSection(0);
} }
public Widget getWidget() public Widget getWidget()
...@@ -110,7 +110,7 @@ public class ManagedPropertyField extends Field<List<Map<String, String>>> ...@@ -110,7 +110,7 @@ public class ManagedPropertyField extends Field<List<Map<String, String>>>
return list; return list;
} }
private void addNewSection() private void addNewSection(int sectionIndex)
{ {
FormPanel formPanel = new FormPanel(); FormPanel formPanel = new FormPanel();
formPanel.setLabelWidth(AbstractRegistrationForm.DEFAULT_LABEL_WIDTH - SPACING - 2); formPanel.setLabelWidth(AbstractRegistrationForm.DEFAULT_LABEL_WIDTH - SPACING - 2);
...@@ -123,9 +123,21 @@ public class ManagedPropertyField extends Field<List<Map<String, String>>> ...@@ -123,9 +123,21 @@ public class ManagedPropertyField extends Field<List<Map<String, String>>>
final HorizontalPanel horizontalPanel = new HorizontalPanel(); final HorizontalPanel horizontalPanel = new HorizontalPanel();
horizontalPanel.setSpacing(SPACING); horizontalPanel.setSpacing(SPACING);
horizontalPanel.add(formPanel); horizontalPanel.add(formPanel);
final Section section = new Section(inputFieldsByCode);
Button addBeforeButton = new Button("+");
addBeforeButton.setToolTip("Add a new section before this section.");
addBeforeButton.addSelectionListener(new SelectionListener<ButtonEvent>()
{
@Override
public void componentSelected(ButtonEvent ce)
{
int index = sections.indexOf(section);
addNewSection(index);
}
});
horizontalPanel.add(addBeforeButton);
Button removeButton = new Button("-"); Button removeButton = new Button("-");
removeButton.setToolTip("Delete this section."); removeButton.setToolTip("Delete this section.");
final Section section = new Section(inputFieldsByCode);
removeButton.addSelectionListener(new SelectionListener<ButtonEvent>() removeButton.addSelectionListener(new SelectionListener<ButtonEvent>()
{ {
@Override @Override
...@@ -150,8 +162,8 @@ public class ManagedPropertyField extends Field<List<Map<String, String>>> ...@@ -150,8 +162,8 @@ public class ManagedPropertyField extends Field<List<Map<String, String>>>
} }
}); });
horizontalPanel.add(removeButton); horizontalPanel.add(removeButton);
sections.add(section); sections.add(sectionIndex, section);
verticalPanel.insert(horizontalPanel, verticalPanel.getItemCount() - 1); verticalPanel.insert(horizontalPanel, sectionIndex);
verticalPanel.layout(); verticalPanel.layout();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment