summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshawn.f.cook2011-10-19 11:37:00 (EDT)
committerRoberto E. Escobar2011-10-19 11:37:00 (EDT)
commit2944006c097acea980c1448264c6f6ebb8ef93f0 (patch)
treef40082221cb15a2bd2b64a8c6e467678d346ed67
parentc590eb29073c815c99f6b93ebf59c301c3f4a89e (diff)
downloadorg.eclipse.osee-2944006c097acea980c1448264c6f6ebb8ef93f0.zip
org.eclipse.osee-2944006c097acea980c1448264c6f6ebb8ef93f0.tar.gz
org.eclipse.osee-2944006c097acea980c1448264c6f6ebb8ef93f0.tar.bz2
feature[ats_E6W8N]: Change ManyPerPage to combobox
-rw-r--r--plugins/org.eclipse.osee.display.api/src/org/eclipse/osee/display/api/components/PagingComponent.java2
-rw-r--r--plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/components/OseePagingComponent.java110
-rw-r--r--plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/components/OseeSearchResultsListComponent.java36
3 files changed, 93 insertions, 55 deletions
diff --git a/plugins/org.eclipse.osee.display.api/src/org/eclipse/osee/display/api/components/PagingComponent.java b/plugins/org.eclipse.osee.display.api/src/org/eclipse/osee/display/api/components/PagingComponent.java
index e006f5e..c720c93 100644
--- a/plugins/org.eclipse.osee.display.api/src/org/eclipse/osee/display/api/components/PagingComponent.java
+++ b/plugins/org.eclipse.osee.display.api/src/org/eclipse/osee/display/api/components/PagingComponent.java
@@ -23,6 +23,8 @@ public interface PagingComponent {
public void setManyItemsPerPage(int manyItemsPerPage);
+ public void setAllItemsPerPage();
+
public int getManyItemsPerPage();
}
diff --git a/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/components/OseePagingComponent.java b/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/components/OseePagingComponent.java
index ec572c7..e331875 100644
--- a/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/components/OseePagingComponent.java
+++ b/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/components/OseePagingComponent.java
@@ -31,6 +31,7 @@ public class OseePagingComponent extends HorizontalLayout implements PagingCompo
private int manyItemsTotal = 0;
private int manyItemsPerPage = 15;
+ private boolean allItemsPerPage = false;//If TRUE then manyItemsPerPage is ignored.
private int manyPages = 0;
private int currentPage = 0;
private final int MAX_PAGE_NUMBERS_SHOWN = 4;
@@ -73,63 +74,73 @@ public class OseePagingComponent extends HorizontalLayout implements PagingCompo
}
private void createPageNumberLayout() {
- int startPage = 0;
- int endPage = manyPages - 1;
-
- //If there are more pages than MAX_PAGE_NUMBERS_SHOWN, then we need to reduce
- // the number of pages shown.
- // if (manyPages > 0 && manyPages > currentPage && MAX_PAGE_NUMBERS_SHOWN > (manyPages - currentPage)) {
- int pageSetIndex = currentPage / MAX_PAGE_NUMBERS_SHOWN;
- startPage = pageSetIndex * MAX_PAGE_NUMBERS_SHOWN;
- endPage = startPage + MAX_PAGE_NUMBERS_SHOWN;
- // }
-
- if (endPage >= manyPages) {
- endPage = manyPages - 1;
- }
-
- if (startPage != 0) {
- Label pageLabel = new Label("...");
+ if (this.allItemsPerPage) {
+ Label pageLabel = new Label(String.format("1"));
this.addComponent(pageLabel);
+ pageLabel.setStyleName(CssConstants.OSEE_CURRENTPAGELABEL);
Label spacer = new Label();
spacer.setWidth(7, UNITS_PIXELS);
this.addComponent(spacer);
- }
+ } else {
+ int startPage = 0;
+ int endPage = manyPages - 1;
+
+ //If there are more pages than MAX_PAGE_NUMBERS_SHOWN, then we need to reduce
+ // the number of pages shown.
+ // if (manyPages > 0 && manyPages > currentPage && MAX_PAGE_NUMBERS_SHOWN > (manyPages - currentPage)) {
+ int pageSetIndex = currentPage / MAX_PAGE_NUMBERS_SHOWN;
+ startPage = pageSetIndex * MAX_PAGE_NUMBERS_SHOWN;
+ endPage = startPage + MAX_PAGE_NUMBERS_SHOWN;
+ // }
+
+ if (endPage >= manyPages) {
+ endPage = manyPages - 1;
+ }
- for (int i = startPage; i <= endPage; i++) {
- if (i == currentPage) {
- Label pageLabel = new Label(String.format("%d", i + 1));
+ if (startPage != 0) {
+ Label pageLabel = new Label("...");
this.addComponent(pageLabel);
- pageLabel.setStyleName(CssConstants.OSEE_CURRENTPAGELABEL);
- } else {
- Button pageButton = new Button(String.format("%d", i + 1));
- pageButton.setStyleName("link");
- this.addComponent(pageButton);
- final int index = i;//needs to be 'final' for use with listener below
- pageButton.addListener(new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- OseePagingComponent.this.setCurrentPage(index);
- fireEvent(new PageSelectedEvent(OseePagingComponent.this));
- }
- });
- }
- if (i <= endPage) {
Label spacer = new Label();
spacer.setWidth(7, UNITS_PIXELS);
this.addComponent(spacer);
}
- }
- if (endPage != manyPages - 1) {
- Label pageLabel = new Label("...");
- this.addComponent(pageLabel);
+ for (int i = startPage; i <= endPage; i++) {
+ if (i == currentPage) {
+ Label pageLabel = new Label(String.format("%d", i + 1));
+ this.addComponent(pageLabel);
+ pageLabel.setStyleName(CssConstants.OSEE_CURRENTPAGELABEL);
+ } else {
+ Button pageButton = new Button(String.format("%d", i + 1));
+ pageButton.setStyleName("link");
+ this.addComponent(pageButton);
+ final int index = i;//needs to be 'final' for use with listener below
+ pageButton.addListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ OseePagingComponent.this.setCurrentPage(index);
+ fireEvent(new PageSelectedEvent(OseePagingComponent.this));
+ }
+ });
+ }
- Label spacer = new Label();
- spacer.setWidth(7, UNITS_PIXELS);
- this.addComponent(spacer);
+ if (i <= endPage) {
+ Label spacer = new Label();
+ spacer.setWidth(7, UNITS_PIXELS);
+ this.addComponent(spacer);
+ }
+ }
+
+ if (endPage != manyPages - 1) {
+ Label pageLabel = new Label("...");
+ this.addComponent(pageLabel);
+
+ Label spacer = new Label();
+ spacer.setWidth(7, UNITS_PIXELS);
+ this.addComponent(spacer);
+ }
}
}
@@ -274,7 +285,11 @@ public class OseePagingComponent extends HorizontalLayout implements PagingCompo
@Override
public Collection<Integer> getCurrentVisibleItemIndices() {
Collection<Integer> ret = new ArrayList<Integer>();
- if (currentPage <= manyPages) {
+ if (allItemsPerPage) {
+ for (int i = 0; i < manyItemsTotal; i++) {
+ ret.add(new Integer(i));
+ }
+ } else if (currentPage <= manyPages) {
for (int i = 0; i < manyItemsPerPage; i++) {
int itemIndex = (currentPage * manyItemsPerPage) + i;
if (itemIndex < manyItemsTotal) {
@@ -288,6 +303,7 @@ public class OseePagingComponent extends HorizontalLayout implements PagingCompo
@Override
public void setManyItemsPerPage(int manyItemsPerPage) {
this.manyItemsPerPage = manyItemsPerPage;
+ this.allItemsPerPage = false;
createLayout();
}
@@ -295,4 +311,10 @@ public class OseePagingComponent extends HorizontalLayout implements PagingCompo
public int getManyItemsPerPage() {
return this.manyItemsPerPage;
}
+
+ @Override
+ public void setAllItemsPerPage() {
+ this.allItemsPerPage = true;
+ createLayout();
+ }
}
diff --git a/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/components/OseeSearchResultsListComponent.java b/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/components/OseeSearchResultsListComponent.java
index 2bc749b..46dfe95 100644
--- a/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/components/OseeSearchResultsListComponent.java
+++ b/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/components/OseeSearchResultsListComponent.java
@@ -26,11 +26,11 @@ import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
-import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Window.Notification;
@@ -48,7 +48,9 @@ public class OseeSearchResultsListComponent extends VerticalLayout implements Se
private List<OseeSearchResultComponent> resultList = new ArrayList<OseeSearchResultComponent>();
private SearchHeaderComponent searchHeaderComponent;
private final CheckBox showVerboseCheckBox = new CheckBox("Show Detailed Results", false);
- private final TextField manyResultsTextField = new TextField();
+ // private final TextField manyResultsTextField = new TextField();
+ private final ComboBox manyResultsComboBox = new ComboBox();
+ private final int INIT_MANY_RES_PER_PAGE = 15;
public OseeSearchResultsListComponent() {
this(null);
@@ -95,16 +97,28 @@ public class OseeSearchResultsListComponent extends VerticalLayout implements Se
}
});
- manyResultsTextField.setImmediate(true);
- manyResultsTextField.setStyleName(CssConstants.OSEE_SEARCHRESULTS_MANYRESULTSFIELD);
- manyResultsTextField.setValue(pagingComponent.getManyItemsPerPage());
- manyResultsTextField.addListener(new Property.ValueChangeListener() {
+ manyResultsComboBox.setImmediate(true);
+ manyResultsComboBox.setTextInputAllowed(false);
+ manyResultsComboBox.setNullSelectionAllowed(false);
+ manyResultsComboBox.addItem("5");
+ manyResultsComboBox.addItem("15");
+ manyResultsComboBox.addItem("50");
+ manyResultsComboBox.addItem("100");
+ manyResultsComboBox.addItem("All");
+ manyResultsComboBox.setValue((new Integer(INIT_MANY_RES_PER_PAGE)).toString());
+ pagingComponent.setManyItemsPerPage(INIT_MANY_RES_PER_PAGE);
+ manyResultsComboBox.setWidth(50, UNITS_PIXELS);
+ manyResultsComboBox.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (pagingComponent != null) {
- String manyItemsPerPage_str = manyResultsTextField.toString();
- int manyItemsPerPage = Integer.parseInt(manyItemsPerPage_str);
- pagingComponent.setManyItemsPerPage(manyItemsPerPage);
+ String manyItemsPerPage_str = (String) manyResultsComboBox.getValue();
+ if (manyItemsPerPage_str.equalsIgnoreCase("All")) {
+ pagingComponent.setAllItemsPerPage();
+ } else {
+ int manyItemsPerPage = Integer.parseInt(manyItemsPerPage_str);
+ pagingComponent.setManyItemsPerPage(manyItemsPerPage);
+ }
updateSearchResultsLayout();
}
}
@@ -149,8 +163,8 @@ public class OseeSearchResultsListComponent extends VerticalLayout implements Se
spacer3.setWidth(5, UNITS_PIXELS);
Label manyResultsLabel = new Label("Results Per Page");
manySearchResultsHorizLayout.addComponent(spacer2);
- manySearchResultsHorizLayout.addComponent(manyResultsTextField);
- manySearchResultsHorizLayout.setComponentAlignment(manyResultsTextField, Alignment.TOP_CENTER);
+ manySearchResultsHorizLayout.addComponent(manyResultsComboBox);
+ manySearchResultsHorizLayout.setComponentAlignment(manyResultsComboBox, Alignment.TOP_CENTER);
manySearchResultsHorizLayout.addComponent(spacer3);
manySearchResultsHorizLayout.addComponent(manyResultsLabel);