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

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


  @Test
  public void testNewsColumnViewModel() throws Exception {
    IFolder root = DynamicDAO.save(fFactory.createFolder(null, null, "Root"));
    IPreferenceScope prefs = Owl.getPreferenceService().getEntityScope(root);

    NewsColumnViewModel model = NewsColumnViewModel.createFrom(new int[] { 5, 4, 3, 6, 1 }, 3, true);
    model.saveTo(prefs);

    NewsColumnViewModel loadedModel = NewsColumnViewModel.loadFrom(prefs);
    assertTrue(loadedModel.isAscending());
    assertEquals(3, loadedModel.getSortColumn().ordinal());
    List<NewsColumn> columns = loadedModel.getColumns();
    assertEquals(NewsColumn.values()[5], columns.get(0));
    assertEquals(NewsColumn.values()[4], columns.get(1));
    assertEquals(NewsColumn.values()[3], columns.get(2));
    assertEquals(NewsColumn.values()[6], columns.get(3));
    assertEquals(NewsColumn.values()[1], columns.get(4));
View Full Code Here


    if (fAttachmentsMenu != null)
      fAttachmentsMenu.dispose();

    /* Store Column Model */
    if (!fResultViewer.getTable().isDisposed()) {
      NewsColumnViewModel model = NewsColumnViewModel.initializeFrom(fResultViewer.getTable());
      model.setSortColumn(fNewsSorter.getSortBy());
      model.setAscending(fNewsSorter.isAscending());
      model.saveTo(fPreferences, true);
    }

    /* Store Preferences */
    fPreferences.putBoolean(DefaultPreferences.SEARCH_DIALOG_PREVIEW_VISIBLE, fIsPreviewVisible);
    if (fCachedWeights != null)
View Full Code Here

        MenuItem restoreDefaults = new MenuItem(menu, SWT.None);
        restoreDefaults.setText(Messages.SearchNewsDialog_RESTORE_DEFAULT_COLUMNS);
        restoreDefaults.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            NewsColumnViewModel defaultModel = NewsColumnViewModel.createDefault(true);
            if (!defaultModel.equals(fColumnModel))
              showColumns(defaultModel, true);
          }
        });

        new MenuItem(menu, SWT.SEPARATOR);
View Full Code Here

    /* Apply ContentProvider */
    fResultViewer.setContentProvider(getContentProvider());

    /* Create LabelProvider */
    NewsColumnViewModel model = NewsColumnViewModel.loadFrom(fPreferences, true);
    fNewsTableLabelProvider = new ScoredNewsLabelProvider(model);
    if (!OwlUI.isHighContrast()) {
      fResultViewer.getControl().addListener(SWT.EraseItem, new Listener() {
        public void handleEvent(Event event) {
          Object element = event.item.getData();
View Full Code Here

    }
  }

  private boolean updatePreferences(IPreferenceScope scope) {
    boolean changed = false;
    NewsColumnViewModel model = fColumnSelectionControl.getModel();

    /* Columns */
    List<NewsColumn> columns = model.getColumns();
    int[] columnsInt = new int[columns.size()];
    for (int i = 0; i < columns.size(); i++) {
      columnsInt[i] = columns.get(i).ordinal();
    }

    if (!Arrays.equals(fPrefSelectedColumns, columnsInt))
      changed = true;

    /* Sort Column */
    int sortColumn = model.getSortColumn().ordinal();
    if (fPrefSortColumn != sortColumn)
      changed = true;

    /* Sort Order */
    boolean ascending = model.isAscending();
    if (fPrefAscending != ascending)
      changed = true;

    /* Save if changed */
    if (changed)
      model.saveTo(scope);

    return changed;
  }
View Full Code Here

    if (fAttachmentsMenu != null)
      OwlUI.safeDispose(fAttachmentsMenu);

    /* Store Column Model */
    if (!fResultViewer.getTable().isDisposed()) {
      NewsColumnViewModel model = NewsColumnViewModel.initializeFrom(fResultViewer.getTable());
      model.setSortColumn(fNewsSorter.getSortBy());
      model.setAscending(fNewsSorter.isAscending());
      model.saveTo(fPreferences, true);
    }

    /* Store Preferences */
    fPreferences.putBoolean(DefaultPreferences.SEARCH_DIALOG_PREVIEW_VISIBLE, fIsPreviewVisible);
    if (fCachedWeights != null)
View Full Code Here

        MenuItem restoreDefaults = new MenuItem(menu, SWT.None);
        restoreDefaults.setText(Messages.SearchNewsDialog_RESTORE_DEFAULT_COLUMNS);
        restoreDefaults.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            NewsColumnViewModel defaultModel = NewsColumnViewModel.createDefault(true);
            if (!defaultModel.equals(fColumnModel))
              showColumns(defaultModel, true);
          }
        });

        new MenuItem(menu, SWT.SEPARATOR);
View Full Code Here

    /* Apply ContentProvider */
    fResultViewer.setContentProvider(getContentProvider());

    /* Create LabelProvider */
    NewsColumnViewModel model = NewsColumnViewModel.loadFrom(fPreferences, true);
    fNewsTableLabelProvider = new ScoredNewsLabelProvider(model);
    if (!OwlUI.isHighContrast()) {
      fResultViewer.getControl().addListener(SWT.EraseItem, new Listener() {
        public void handleEvent(Event event) {
          Object element = event.item.getData();
View Full Code Here

  @Test
  public void testNewsColumnViewModel() throws Exception {
    IFolder root = DynamicDAO.save(fFactory.createFolder(null, null, "Root"));
    IPreferenceScope prefs = Owl.getPreferenceService().getEntityScope(root);

    NewsColumnViewModel model = NewsColumnViewModel.createFrom(new int[] { 5, 4, 3, 6, 1 }, 3, true);
    model.saveTo(prefs);

    NewsColumnViewModel loadedModel = NewsColumnViewModel.loadFrom(prefs);
    assertTrue(loadedModel.isAscending());
    assertEquals(3, loadedModel.getSortColumn().ordinal());
    List<NewsColumn> columns = loadedModel.getColumns();
    assertEquals(NewsColumn.values()[5], columns.get(0));
    assertEquals(NewsColumn.values()[4], columns.get(1));
    assertEquals(NewsColumn.values()[3], columns.get(2));
    assertEquals(NewsColumn.values()[6], columns.get(3));
    assertEquals(NewsColumn.values()[1], columns.get(4));
View Full Code Here

        manager.add(layoutMenu);

        /* Columns */
        final boolean isColumnsEnabled = (layout != Layout.NEWSPAPER && layout != Layout.HEADLINES);
        MenuManager columnsMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_COLUMNS);
        final NewsColumnViewModel model = NewsColumnViewModel.loadFrom(entityPreferences != null ? entityPreferences : globalPreferences);
        NewsColumn[] columns = NewsColumn.values();
        for (final NewsColumn column : columns) {
          if (column.isSelectable()) {
            columnsMenu.add(new Action(column.getName(), IAction.AS_CHECK_BOX) {
              @Override
              public void run() {
                if (model.contains(column))
                  model.removeColumn(column);
                else
                  model.addColumn(column);

                updateColumnsPreferences(globalPreferences, entityPreferences, model, DefaultPreferences.BM_NEWS_COLUMNS);
              }

              @Override
              public boolean isChecked() {
                return model.contains(column);
              }

              @Override
              public boolean isEnabled() {
                return isColumnsEnabled;
              };
            });
          }
        }
        columnsMenu.add(new Separator());
        columnsMenu.add(new Action(Messages.ApplicationActionBarAdvisor_RESTORE_DEFAULT_COLUMNS) {
          @Override
          public void run() {
            NewsColumnViewModel defaultModel = NewsColumnViewModel.createDefault(false);
            updateColumnsPreferences(globalPreferences, entityPreferences, defaultModel, DefaultPreferences.BM_NEWS_COLUMNS, DefaultPreferences.BM_NEWS_SORT_COLUMN, DefaultPreferences.BM_NEWS_SORT_ASCENDING);
          }

          @Override
          public boolean isEnabled() {
View Full Code Here

TOP

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

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.