Package org.rssowl.ui.internal.editors.feed

Examples of org.rssowl.ui.internal.editors.feed.NewsColumn


    fNewsColumnViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    fNewsColumnViewer.setContentProvider(new ArrayContentProvider());
    fNewsColumnViewer.setLabelProvider(new LabelProvider() {
      @Override
      public String getText(Object element) {
        NewsColumn column = (NewsColumn) element;
        return column.getName();
      }
    });

    fNewsColumnViewer.addSelectionChangedListener(new ISelectionChangedListener() {
      public void selectionChanged(SelectionChangedEvent event) {
        updateMoveEnablement();
        updateRemoveEnablement();
      }
    });

    /* Right: Buttons to manage Columns */
    Composite buttonContainer = new Composite(this, SWT.None);
    buttonContainer.setLayout(LayoutUtils.createGridLayout(1, 0, 0));
    buttonContainer.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));

    /* Add */
    final Menu menu = new Menu(getShell(), SWT.POP_UP);
    menu.addMenuListener(new MenuListener() {
      public void menuShown(MenuEvent e) {
        MenuItem[] items = menu.getItems();
        for (MenuItem item : items) {
          item.dispose();
        }

        NewsColumn[] newsColumns = NewsColumn.values();
        for (final NewsColumn column : newsColumns) {
          if (column.isSelectable() && !fModel.contains(column)) {
            MenuItem item = new MenuItem(menu, SWT.PUSH);
            item.setText(column.getName());
            item.addSelectionListener(new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                fModel.addColumn(column);
                fNewsColumnViewer.add(column);
                updateRemoveEnablement();
                fNewsColumnViewer.setSelection(new StructuredSelection(column));
              }
            });
          }
        }
      }

      public void menuHidden(MenuEvent e) {}
    });

    final Button addButton = new Button(buttonContainer, SWT.DOWN);
    setButtonLayoutData(addButton);
    addButton.setText(Messages.NewsColumnSelectionControl_ADD);
    addButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        Rectangle rect = addButton.getBounds();
        Point pt = new Point(rect.x, rect.y + rect.height);
        pt = addButton.toDisplay(pt);
        menu.setLocation(pt.x, pt.y);
        menu.setVisible(true);
      }
    });

    addButton.addDisposeListener(new DisposeListener() {
      public void widgetDisposed(DisposeEvent e) {
        menu.dispose();
      }
    });

    /* Remove */
    fRemoveButton = new Button(buttonContainer, SWT.PUSH);
    setButtonLayoutData(fRemoveButton);
    fRemoveButton.setText(Messages.NewsColumnSelectionControl_REMOVE);
    fRemoveButton.setEnabled(false);
    fRemoveButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        onDelete();
      }
    });

    /* Move Up */
    fMoveUpButton = new Button(buttonContainer, SWT.PUSH);
    setButtonLayoutData(fMoveUpButton);
    fMoveUpButton.setText(Messages.NewsColumnSelectionControl_MOVE_UP);
    fMoveUpButton.setEnabled(false);
    fMoveUpButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        onMove(true);
      }
    });

    /* Move Down */
    fMoveDownButton = new Button(buttonContainer, SWT.PUSH);
    setButtonLayoutData(fMoveDownButton);
    fMoveDownButton.setText(Messages.NewsColumnSelectionControl_MOVE_DOWN);
    fMoveDownButton.setEnabled(false);
    fMoveDownButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        onMove(false);
      }
    });

    /* Bottom: Sort Column */
    Composite sortByContainer = new Composite(this, SWT.None);
    sortByContainer.setLayout(LayoutUtils.createGridLayout(3, 0, 0));
    sortByContainer.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));

    Label sortByLabel = new Label(sortByContainer, SWT.NONE);
    sortByLabel.setText(Messages.NewsColumnSelectionControl_SORT_BY);

    fSortByViewer = new ComboViewer(sortByContainer, SWT.READ_ONLY | SWT.BORDER);
    fSortByViewer.getCombo().setVisibleItemCount(20);
    fSortByViewer.setContentProvider(new ArrayContentProvider());
    fSortByViewer.setLabelProvider(new LabelProvider() {
      @Override
      public String getText(Object element) {
        NewsColumn column = (NewsColumn) element;
        return column.getName();
      }
    });
    fSortByViewer.addFilter(new ViewerFilter() {
      @Override
      public boolean select(Viewer viewer, Object parentElement, Object element) {
        if (element == NewsColumn.RELEVANCE)
          return false;

        return true;
      }
    });

    fSortByViewer.addSelectionChangedListener(new ISelectionChangedListener() {
      public void selectionChanged(SelectionChangedEvent event) {
        IStructuredSelection selection = (IStructuredSelection) event.getSelection();
        NewsColumn column = (NewsColumn) selection.getFirstElement();
        fModel.setSortColumn(column);
      }
    });

    fSortAscendingViewer = new ComboViewer(sortByContainer, SWT.READ_ONLY | SWT.BORDER);
View Full Code Here


      for (final TableColumn column : columns) {
        column.addSelectionListener(new SelectionAdapter() {
          @SuppressWarnings("unchecked")
          @Override
          public void widgetSelected(SelectionEvent e) {
            NewsColumn oldSortBy = fNewsSorter.getSortBy();
            NewsColumn newSortBy = (NewsColumn) column.getData(NewsColumnViewModel.COL_ID);
            boolean defaultAscending = newSortBy.prefersAscending();
            boolean ascending = (oldSortBy != newSortBy) ? defaultAscending : !fNewsSorter.isAscending();

            fNewsSorter.setSortBy(newSortBy);
            fNewsSorter.setAscending(ascending);

            fColumnModel.setSortColumn(newSortBy);
            fColumnModel.setAscending(ascending);

            /* Indicate Sort-Column in UI for Columns that have a certain width */
            if (newSortBy.showSortIndicator()) {
              fResultViewer.getTable().setSortColumn(column);
              fResultViewer.getTable().setSortDirection(ascending ? SWT.UP : SWT.DOWN);
            } else {
              fResultViewer.getTable().setSortColumn(null);
            }
View Full Code Here

     * @see org.eclipse.jface.viewers.OwnerDrawLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
     */
    @Override
    public void update(ViewerCell cell) {
      ScoredNews scoredNews = (ScoredNews) cell.getElement();
      NewsColumn column = fColumnModel.getColumn(cell.getColumnIndex());

      /* Text */
      cell.setText(getColumnText(scoredNews.getNews(), column, cell.getColumnIndex()));

      /* Image */
 
View Full Code Here

      for (final TableColumn column : columns) {
        column.addSelectionListener(new SelectionAdapter() {
          @SuppressWarnings("unchecked")
          @Override
          public void widgetSelected(SelectionEvent e) {
            NewsColumn oldSortBy = fNewsSorter.getSortBy();
            NewsColumn newSortBy = (NewsColumn) column.getData(NewsColumnViewModel.COL_ID);
            boolean defaultAscending = newSortBy.prefersAscending();
            boolean ascending = (oldSortBy != newSortBy) ? defaultAscending : !fNewsSorter.isAscending();

            fNewsSorter.setSortBy(newSortBy);
            fNewsSorter.setAscending(ascending);

            fColumnModel.setSortColumn(newSortBy);
            fColumnModel.setAscending(ascending);

            /* Indicate Sort-Column in UI for Columns that have a certain width */
            if (newSortBy.showSortIndicator()) {
              fResultViewer.getTable().setSortColumn(column);
              fResultViewer.getTable().setSortDirection(ascending ? SWT.UP : SWT.DOWN);
            } else {
              fResultViewer.getTable().setSortColumn(null);
            }
View Full Code Here

     * @see org.eclipse.jface.viewers.OwnerDrawLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
     */
    @Override
    public void update(ViewerCell cell) {
      ScoredNews scoredNews = (ScoredNews) cell.getElement();
      NewsColumn column = fColumnModel.getColumn(cell.getColumnIndex());

      /* Text */
      cell.setText(getColumnText(scoredNews.getNews(), column, cell.getColumnIndex()));

      /* Image */
 
View Full Code Here

    fNewsColumnViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    fNewsColumnViewer.setContentProvider(new ArrayContentProvider());
    fNewsColumnViewer.setLabelProvider(new LabelProvider() {
      @Override
      public String getText(Object element) {
        NewsColumn column = (NewsColumn) element;
        return column.getName();
      }
    });

    fNewsColumnViewer.addSelectionChangedListener(new ISelectionChangedListener() {
      public void selectionChanged(SelectionChangedEvent event) {
        updateMoveEnablement();
        updateRemoveEnablement();
      }
    });

    /* Right: Buttons to manage Columns */
    Composite buttonContainer = new Composite(this, SWT.None);
    buttonContainer.setLayout(LayoutUtils.createGridLayout(1, 0, 0));
    buttonContainer.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));

    /* Add */
    final Menu menu = new Menu(getShell(), SWT.POP_UP);
    menu.addMenuListener(new MenuListener() {
      public void menuShown(MenuEvent e) {
        MenuItem[] items = menu.getItems();
        for (MenuItem item : items) {
          item.dispose();
        }

        NewsColumn[] newsColumns = NewsColumn.values();
        for (final NewsColumn column : newsColumns) {
          if (column.isSelectable() && !fModel.contains(column)) {
            MenuItem item = new MenuItem(menu, SWT.PUSH);
            item.setText(column.getName());
            item.addSelectionListener(new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                fModel.addColumn(column);
                fNewsColumnViewer.add(column);
                updateRemoveEnablement();
                fNewsColumnViewer.setSelection(new StructuredSelection(column));
              }
            });
          }
        }
      }

      public void menuHidden(MenuEvent e) {}
    });

    final Button addButton = new Button(buttonContainer, SWT.DOWN);
    setButtonLayoutData(addButton);
    addButton.setText(Messages.NewsColumnSelectionControl_ADD);
    addButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        Rectangle rect = addButton.getBounds();
        Point pt = new Point(rect.x, rect.y + rect.height);
        pt = addButton.toDisplay(pt);
        menu.setLocation(pt.x, pt.y);
        menu.setVisible(true);
      }
    });

    addButton.addDisposeListener(new DisposeListener() {
      public void widgetDisposed(DisposeEvent e) {
        OwlUI.safeDispose(menu);
      }
    });

    /* Remove */
    fRemoveButton = new Button(buttonContainer, SWT.PUSH);
    setButtonLayoutData(fRemoveButton);
    fRemoveButton.setText(Messages.NewsColumnSelectionControl_REMOVE);
    fRemoveButton.setEnabled(false);
    fRemoveButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        onDelete();
      }
    });

    /* Move Up */
    fMoveUpButton = new Button(buttonContainer, SWT.PUSH);
    setButtonLayoutData(fMoveUpButton);
    fMoveUpButton.setText(Messages.NewsColumnSelectionControl_MOVE_UP);
    fMoveUpButton.setEnabled(false);
    fMoveUpButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        onMove(true);
      }
    });

    /* Move Down */
    fMoveDownButton = new Button(buttonContainer, SWT.PUSH);
    setButtonLayoutData(fMoveDownButton);
    fMoveDownButton.setText(Messages.NewsColumnSelectionControl_MOVE_DOWN);
    fMoveDownButton.setEnabled(false);
    fMoveDownButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        onMove(false);
      }
    });

    /* Bottom: Sort Column */
    Composite sortByContainer = new Composite(this, SWT.None);
    sortByContainer.setLayout(LayoutUtils.createGridLayout(3, 0, 0));
    sortByContainer.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));

    Label sortByLabel = new Label(sortByContainer, SWT.NONE);
    sortByLabel.setText(Messages.NewsColumnSelectionControl_SORT_BY);

    fSortByViewer = new ComboViewer(sortByContainer, SWT.READ_ONLY | SWT.BORDER);
    fSortByViewer.getCombo().setVisibleItemCount(20);
    fSortByViewer.setContentProvider(new ArrayContentProvider());
    fSortByViewer.setLabelProvider(new LabelProvider() {
      @Override
      public String getText(Object element) {
        NewsColumn column = (NewsColumn) element;
        return column.getName();
      }
    });
    fSortByViewer.addFilter(new ViewerFilter() {
      @Override
      public boolean select(Viewer viewer, Object parentElement, Object element) {
        if (element == NewsColumn.RELEVANCE)
          return false;

        return true;
      }
    });

    fSortByViewer.addSelectionChangedListener(new ISelectionChangedListener() {
      public void selectionChanged(SelectionChangedEvent event) {
        IStructuredSelection selection = (IStructuredSelection) event.getSelection();
        NewsColumn column = (NewsColumn) selection.getFirstElement();
        fModel.setSortColumn(column);
      }
    });

    fSortAscendingViewer = new ComboViewer(sortByContainer, SWT.READ_ONLY | SWT.BORDER);
View Full Code Here

TOP

Related Classes of org.rssowl.ui.internal.editors.feed.NewsColumn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.