diff options
8 files changed, 412 insertions, 51 deletions
diff --git a/plugins/org.eclipse.osee.ats.presenter.mock/src/org/eclipse/osee/ats/presenter/mock/internal/MockAtsWebSearchPresenter.java b/plugins/org.eclipse.osee.ats.presenter.mock/src/org/eclipse/osee/ats/presenter/mock/internal/MockAtsWebSearchPresenter.java index a57f2875914..0095828bd2f 100644 --- a/plugins/org.eclipse.osee.ats.presenter.mock/src/org/eclipse/osee/ats/presenter/mock/internal/MockAtsWebSearchPresenter.java +++ b/plugins/org.eclipse.osee.ats.presenter.mock/src/org/eclipse/osee/ats/presenter/mock/internal/MockAtsWebSearchPresenter.java @@ -90,6 +90,15 @@ public class MockAtsWebSearchPresenter implements AtsSearchPresenter<AtsSearchHe artifact.setAttr_Subsystm("Communications"); artifact.setAttr_TechPerfParam("False"); } + + //Generate large data set + for (int i = 5; i < 150; i++) { + WebArtifact art = + new WebArtifact(String.format("bulkArt_GUID_%d", i), String.format("Bulk Artifact %d", i), + "Software Requirement", Arrays.asList(swreqs, defaultroot), new WebId(String.format("branch_id%d", i), + String.format("branch_id%d", i))); + artifacts.put(art.getGuid(), art); + } } @Override diff --git a/plugins/org.eclipse.osee.ats.view.web/src/org/eclipse/osee/ats/view/web/AtsWindowFactory.java b/plugins/org.eclipse.osee.ats.view.web/src/org/eclipse/osee/ats/view/web/AtsWindowFactory.java index 002e1baf51a..79252550a7c 100644 --- a/plugins/org.eclipse.osee.ats.view.web/src/org/eclipse/osee/ats/view/web/AtsWindowFactory.java +++ b/plugins/org.eclipse.osee.ats.view.web/src/org/eclipse/osee/ats/view/web/AtsWindowFactory.java @@ -34,6 +34,9 @@ public class AtsWindowFactory { VerticalLayout layout = new VerticalLayout(); final Window w = new Window("OSEE", layout); + for (final Class<?> viewClass : provider.getViews()) { + navigator.addView(viewClass.getSimpleName(), viewClass); + } w.addComponent(createNavigationBar(navigator, provider)); w.addComponent(navigator); w.addComponent(createFooter()); @@ -48,7 +51,7 @@ public class AtsWindowFactory { public void navigatorViewChange(View previous, View current) { Window mainWindow = w.getApplication().getMainWindow(); mainWindow.setCaption("OSEE - " + current.getClass().getSimpleName()); - mainWindow.showNotification("Navigated to " + current.getClass().getName()); + // mainWindow.showNotification("Navigated to " + current.getClass().getName()); } }); return w; @@ -66,16 +69,6 @@ public class AtsWindowFactory { menu.setWidth("100%"); layout.setWidth("100%"); - for (final Class<?> viewClass : provider.getViews()) { - navigator.addView(viewClass.getSimpleName(), viewClass); - // menu.addItem(viewClass.getSimpleName(), new MenuBar.Command() { - // - // @Override - // public void menuSelected(MenuBar.MenuItem selectedItem) { - // navigator.navigateTo(viewClass); - // } - // }); - } MenuBar menuBar = new AccountMenuBar(); layout.addComponent(menuBar); 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 new file mode 100644 index 00000000000..7e8e9404e56 --- /dev/null +++ b/plugins/org.eclipse.osee.display.api/src/org/eclipse/osee/display/api/components/PagingComponent.java @@ -0,0 +1,24 @@ +/* + * Created on Oct 11, 2011 + * + * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE + */ +package org.eclipse.osee.display.api.components; + +import java.util.Collection; + +public interface PagingComponent { + //How many items are in your collection? i.e. Collection<T>.size() + public void setManyItemsTotal(int manyItemsTotal); + + public void gotoFirstPage(); + + public void gotoPrevPage(); + + public void gotoNextPage(); + + public void gotoLastPage(); + + public Collection<Integer> getCurrentVisibleItemIndices(); + +} diff --git a/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/CssConstants.java b/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/CssConstants.java index f88e7265c07..69226052cab 100644 --- a/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/CssConstants.java +++ b/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/CssConstants.java @@ -52,4 +52,6 @@ public final class CssConstants { public static final String OSEE_ATTRIBUTESTITLELABEL = "osee-attributestitlelabel"; public static final String OSEE_ATTRIBUTESBORDER = "osee-attributesborder"; + public static final String OSEE_CURRENTPAGELABEL = "osee-currentpagelabel"; + } 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 new file mode 100644 index 00000000000..e10afec8ed5 --- /dev/null +++ b/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/components/OseePagingComponent.java @@ -0,0 +1,287 @@ +/******************************************************************************* + * Copyright (c) 2011 Boeing. + * All rightsimport com.vaadin.Application; +import com.vaadin.service.ApplicationContext.TransactionListener; +he Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.display.view.web.components; + +import java.io.Serializable; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import org.eclipse.osee.display.api.components.PagingComponent; +import org.eclipse.osee.display.view.web.CssConstants; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Component; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; + +/** + * @author Shawn F. Cook + */ +@SuppressWarnings("serial") +public class OseePagingComponent extends HorizontalLayout implements PagingComponent { + + private int manyItemsTotal = 0; + private final int manyItemsPerPage = 10; + private int manyPages = 0; + private int currentPage = 0; + private final int MAX_PAGE_NUMBERS_SHOWN = 10; + + public OseePagingComponent() { + super(); + createLayout(); + } + + private void updateManyPages() { + if (manyItemsPerPage > 0) { + manyPages = manyItemsTotal / manyItemsPerPage; + int remainder = manyItemsTotal % manyItemsPerPage; + if (remainder > 0) { + manyPages += 1; //round up. + } + } + } + + @Override + public void setManyItemsTotal(int manyItemsTotal) { + this.manyItemsTotal = manyItemsTotal; + updateManyPages(); + createLayout(); + } + + public void setCurrentPage(int currentPage) { + this.currentPage = currentPage; + if (this.currentPage < 0) { + this.currentPage = 0; + } + + if (this.currentPage >= manyPages) { + this.currentPage = manyPages - 1; + } + + if (manyPages == 0) { + this.currentPage = 0; + } + } + + 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("..."); + this.addComponent(pageLabel); + + Label spacer = new Label(); + spacer.setWidth(7, UNITS_PIXELS); + this.addComponent(spacer); + } + + 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)); + } + }); + } + + 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); + } + } + + private void createLayout() { + this.removeAllComponents(); + this.setSizeUndefined(); + + Button firstButton = new Button("<<first"); + this.addComponent(firstButton); + + Label spacer1 = new Label(); + spacer1.setWidth(15, UNITS_PIXELS); + this.addComponent(spacer1); + + Button previousButton = new Button("<prev"); + this.addComponent(previousButton); + + Label spacer2 = new Label(); + spacer2.setWidth(15, UNITS_PIXELS); + this.addComponent(spacer2); + + createPageNumberLayout(); + + Label spacer3 = new Label(); + spacer3.setWidth(15, UNITS_PIXELS); + this.addComponent(spacer3); + + Button nextButton = new Button("next>"); + this.addComponent(nextButton); + + Label spacer4 = new Label(); + spacer4.setWidth(15, UNITS_PIXELS); + this.addComponent(spacer4); + + Button lastButton = new Button("last>>"); + this.addComponent(lastButton); + + if (manyPages <= 0) { + firstButton.setEnabled(false); + previousButton.setEnabled(false); + nextButton.setEnabled(false); + lastButton.setEnabled(false); + } + + if (currentPage <= 0) { + firstButton.setEnabled(false); + previousButton.setEnabled(false); + } + + if (currentPage >= manyPages - 1) { + nextButton.setEnabled(false); + lastButton.setEnabled(false); + } + + firstButton.addListener(new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + OseePagingComponent.this.setCurrentPage(0); + fireEvent(new PageSelectedEvent(OseePagingComponent.this)); + } + }); + + previousButton.addListener(new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + OseePagingComponent.this.setCurrentPage(currentPage - 1); + fireEvent(new PageSelectedEvent(OseePagingComponent.this)); + } + }); + + nextButton.addListener(new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + OseePagingComponent.this.setCurrentPage(currentPage + 1); + fireEvent(new PageSelectedEvent(OseePagingComponent.this)); + } + }); + + lastButton.addListener(new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + OseePagingComponent.this.setCurrentPage(manyPages - 1); + fireEvent(new PageSelectedEvent(OseePagingComponent.this)); + } + }); + } + + public interface PageSelectedListener extends Serializable { + public void pageSelected(PageSelectedEvent source); + } + + public class PageSelectedEvent extends Component.Event { + + public PageSelectedEvent(Component source) { + super(source); + } + } + + private static Method PAGE_SELECTED_METHOD; + + static { + try { + PAGE_SELECTED_METHOD = PageSelectedListener.class.getDeclaredMethod("pageSelected", PageSelectedEvent.class); + } catch (final java.lang.NoSuchMethodException e) { + // This should never happen + throw new java.lang.RuntimeException("Internal error finding methods in PageSelectedListener"); + } + } + + public void addListener(PageSelectedListener listener) { + addListener(PageSelectedEvent.class, listener, PAGE_SELECTED_METHOD); + } + + public void removeListener(PageSelectedListener listener) { + removeListener(PageSelectedEvent.class, listener, PAGE_SELECTED_METHOD); + } + + @Override + public void gotoFirstPage() { + this.setCurrentPage(0); + createLayout(); + } + + @Override + public void gotoPrevPage() { + this.setCurrentPage(currentPage - 1); + createLayout(); + } + + @Override + public void gotoNextPage() { + this.setCurrentPage(currentPage + 1); + createLayout(); + } + + @Override + public void gotoLastPage() { + this.setCurrentPage(manyPages - 1); + createLayout(); + } + + @Override + public Collection<Integer> getCurrentVisibleItemIndices() { + Collection<Integer> ret = new ArrayList<Integer>(); + if (currentPage <= manyPages) { + for (int i = 0; i < manyItemsPerPage; i++) { + int itemIndex = (currentPage * manyItemsPerPage) + i; + if (itemIndex < manyItemsTotal) { + ret.add(new Integer(itemIndex)); + } + } + } + return ret; + } +} 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 a1deace92b1..6a5bdfe83a1 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 @@ -14,9 +14,12 @@ package org.eclipse.osee.display.view.web.components; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; +import java.util.List; import org.eclipse.osee.display.api.components.SearchResultComponent; import org.eclipse.osee.display.api.components.SearchResultsListComponent; import org.eclipse.osee.display.view.web.CssConstants; +import org.eclipse.osee.display.view.web.components.OseePagingComponent.PageSelectedEvent; +import org.eclipse.osee.display.view.web.components.OseePagingComponent.PageSelectedListener; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -27,73 +30,107 @@ import com.vaadin.ui.VerticalLayout; * @author Shawn F. Cook */ @SuppressWarnings("serial") -public class OseeSearchResultsListComponent extends Panel implements SearchResultsListComponent { +public class OseeSearchResultsListComponent extends VerticalLayout implements SearchResultsListComponent, PageSelectedListener { - VerticalLayout mainLayout = new VerticalLayout(); - VerticalLayout bottomSpacer = new VerticalLayout(); - HorizontalLayout manySearchResultsHorizLayout = new HorizontalLayout(); + private VerticalLayout mainLayout = new VerticalLayout(); + private VerticalLayout bottomSpacer = new VerticalLayout(); + private HorizontalLayout manySearchResultsHorizLayout = new HorizontalLayout(); + private OseePagingComponent pagingComponent = new OseePagingComponent(); + private List<OseeSearchResultComponent> resultList = new ArrayList<OseeSearchResultComponent>(); public OseeSearchResultsListComponent() { this.setSizeFull(); - this.setScrollable(true); - this.setContent(mainLayout); - mainLayout.setMargin(false, false, false, true); - mainLayout.addComponent(manySearchResultsHorizLayout); - Label spacer2 = new Label(""); - spacer2.setHeight(15, UNITS_PIXELS); - mainLayout.addComponent(spacer2); + this.addComponent(manySearchResultsHorizLayout); + manySearchResultsHorizLayout.setSizeUndefined(); + + mainLayout.setMargin(false, false, false, true); + Panel mainLayoutPanel = new Panel(); + mainLayoutPanel.setScrollable(true); + mainLayoutPanel.getContent().setSizeUndefined(); + mainLayoutPanel.setContent(mainLayout); + this.addComponent(mainLayoutPanel); + mainLayoutPanel.setSizeFull(); + this.setExpandRatio(mainLayoutPanel, 1.0f); bottomSpacer.setSizeFull(); mainLayout.addComponent(bottomSpacer); mainLayout.setExpandRatio(bottomSpacer, 1.0f); + + this.addComponent(pagingComponent); + pagingComponent.addListener(this); } @Override public void clearAll() { - Collection<Component> removeTheseComponents = new ArrayList<Component>(); - for (Iterator<Component> iter = mainLayout.getComponentIterator(); iter.hasNext();) { - Component component = iter.next(); - if (component.getClass() == OseeSearchResultComponent.class) { - removeTheseComponents.add(component); - } - } - - //Remove the components - for (Component component : removeTheseComponents) { - mainLayout.removeComponent(component); - } - } - - private int getManySearchResultComponents() { - int many = 0; - for (Iterator<Component> iter = mainLayout.getComponentIterator(); iter.hasNext();) { - Component component = iter.next(); - if (component.getClass() == OseeSearchResultComponent.class) { - many++; - } - } - return many; + resultList.clear(); + pagingComponent.gotoFirstPage(); + updateManySearchResultsLabel(); + updateSearchResultsLayout(); } private void updateManySearchResultsLabel() { - int manySearchResultComponents = getManySearchResultComponents(); + int manySearchResultComponents = resultList.size(); manySearchResultsHorizLayout.removeAllComponents(); Label manySearchResults = new Label(String.format("[%d] ", manySearchResultComponents)); Label manySearchResults_suffix = new Label("search result(s) found."); manySearchResultsHorizLayout.addComponent(manySearchResults); manySearchResultsHorizLayout.addComponent(manySearchResults_suffix); + manySearchResults.setSizeUndefined(); + manySearchResults_suffix.setSizeUndefined(); manySearchResults.setStyleName(CssConstants.OSEE_SEARCHRESULT_MATCH_MANY); + pagingComponent.setManyItemsTotal(manySearchResultComponents); + + } + + private Collection<Integer> prevResultListIndices = new ArrayList<Integer>(); + + private void updateSearchResultsLayout() { + //if the list of currently visible items has not changed, then don't bother updating the layout + pagingComponent.setManyItemsTotal(resultList.size()); + Collection<Integer> resultListIndices = pagingComponent.getCurrentVisibleItemIndices(); + if (!resultListIndices.equals(prevResultListIndices)) { + //First, get a list of all the search results components currently in the layout + Collection<Component> removeTheseComponents = new ArrayList<Component>(); + for (Iterator<Component> iter = mainLayout.getComponentIterator(); iter.hasNext();) { + Component component = iter.next(); + if (component.getClass() == OseeSearchResultComponent.class) { + removeTheseComponents.add(component); + } + } + + //Second, remove the search result components + for (Component component : removeTheseComponents) { + mainLayout.removeComponent(component); + } + + //Next, add the result components to the layout that are on the current 'page' + int spacerIndex = mainLayout.getComponentIndex(bottomSpacer); + for (Integer i : resultListIndices) { + try { + OseeSearchResultComponent searchResultComp = resultList.get(i); + mainLayout.addComponent(searchResultComp, 0); + } catch (IndexOutOfBoundsException e) { + System.out.println("OseeSearchResultsListComponent.updateSearchResultsLayout - CRITICAL ERROR: IndexOutOfBoundsException e"); + } + } + + //Update prevResultListIndices + prevResultListIndices.clear(); + prevResultListIndices.addAll(resultListIndices); + } } @Override public SearchResultComponent createSearchResult() { OseeSearchResultComponent searchResultComp = new OseeSearchResultComponent(); - int spacerIndex = mainLayout.getComponentIndex(bottomSpacer); - mainLayout.addComponent(searchResultComp, spacerIndex); + resultList.add(searchResultComp); + // int spacerIndex = mainLayout.getComponentIndex(bottomSpacer); + // mainLayout.addComponent(searchResultComp, spacerIndex); updateManySearchResultsLabel(); + updateSearchResultsLayout(); return searchResultComp; } @@ -102,4 +139,9 @@ public class OseeSearchResultsListComponent extends Panel implements SearchResul public void setErrorMessage(String message) { //TODO: } + + @Override + public void pageSelected(PageSelectedEvent source) { + updateSearchResultsLayout(); + } } diff --git a/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/search/OseeSearchResultsView.java b/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/search/OseeSearchResultsView.java index 3b13a7dabbf..7349d45faec 100644 --- a/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/search/OseeSearchResultsView.java +++ b/plugins/org.eclipse.osee.display.view.web/src/org/eclipse/osee/display/view/web/search/OseeSearchResultsView.java @@ -37,7 +37,6 @@ public class OseeSearchResultsView extends CustomComponent implements Navigator. leftMarginSpace.setWidth(80, UNITS_PIXELS); leftMarginAndBody.addComponent(leftMarginSpace); - VerticalLayout bodyVertLayout = new VerticalLayout(); leftMarginAndBody.addComponent(searchResultsListComponent); searchResultsListComponent.setSizeFull(); leftMarginAndBody.setExpandRatio(searchResultsListComponent, 1.0f); diff --git a/plugins/org.eclipse.osee.vaadin.themes/src/VAADIN/themes/osee/styles.css b/plugins/org.eclipse.osee.vaadin.themes/src/VAADIN/themes/osee/styles.css index 4d426655ee7..38ecde96e9a 100644 --- a/plugins/org.eclipse.osee.vaadin.themes/src/VAADIN/themes/osee/styles.css +++ b/plugins/org.eclipse.osee.vaadin.themes/src/VAADIN/themes/osee/styles.css @@ -79,7 +79,7 @@ } .osee-search-header-component { - background-color: #00ff00; + background: blue; } .osee-title-large { @@ -116,7 +116,8 @@ .osee-searchresult-match-many { font-size: 12px; - color: red; + font-weight: bold; + color: black; } .osee-horizontal-line { @@ -144,5 +145,9 @@ border-width:1px; } +.osee-currentpagelabel { + font-weight:bold; + font-size: 14px; +} |