/** * Create page links "Previous 1 2 ...10 Next" with SWT Link. * * @param parent */ private void createRightContainer(Composite parent) { Composite right = createComposite(parent, SWT.NONE); right.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = new GridLayout(3, false); layout.marginHeight = 0; right.setLayout(layout); // Previous link previousLink = createHyperlink(right, SWT.NONE); setLinkText( previousLink, Resources.getText(Resources.PaginationRenderer_previous, getLocale())); previousLink.setLayoutData(new GridData(SWT.RIGHT)); previousLink.addSelectionListener(this); // Page links pageLinks = createHyperlink(right, SWT.NONE); pageLinks.setForeground(getColor()); pageLinks.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); pageLinks.addSelectionListener(this); // Next link nextLink = createHyperlink(right, SWT.NONE); setLinkText(nextLink, Resources.getText(Resources.PaginationRenderer_next, getLocale())); nextLink.setLayoutData(new GridData(SWT.LEFT)); nextLink.addSelectionListener(this); }
@Override public void setLocale(Locale locale) { super.setLocale(locale); // Local has changed, update the Previous/Next link text. setLinkText( previousLink, Resources.getText(Resources.PaginationRenderer_previous, getLocale())); setLinkText(nextLink, Resources.getText(Resources.PaginationRenderer_next, getLocale())); resultLabel.setText(PaginationHelper.getResultsText(getController(), getLocale())); }
/** * Returns the string links. * * @param indexes array of indexes. * @param newPageNumber page number. * @return */ private String rebuildLinks(int[] indexes, int newPageNumber) { StringBuilder s = new StringBuilder(); for (int i = 0; i < indexes.length; i++) { int j = indexes[i]; if (i > 0) { s.append(' '); } if (j == PaginationHelper.SEPARATOR) { s.append(Resources.getText(Resources.PaginationRenderer_separator, getLocale())); } else if (j == newPageNumber) s.append(String.valueOf((j + 1))); else { addA(String.valueOf(j), String.valueOf(j + 1), s); } } return s.toString(); }
/** * Returns the link Color. * * @return */ protected Color getColor() { return Resources.getColor(RED_COLOR); }