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

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


  }

  private void internalRun() {

    /* Only consider Entities */
    FeedView feedView = null;
    List<IEntity> entities;
    if (fSelection.size() == 1 && fSelection.getFirstElement() instanceof FeedView) {
      feedView = (FeedView) fSelection.getFirstElement();
      FeedViewInput input = (FeedViewInput) feedView.getEditorInput();
      entities = ModelUtils.getEntities(new StructuredSelection(input.getMark()));
    } else {
      entities = ModelUtils.getEntities(fSelection);
    }

View Full Code Here


        });

    /* Build Menu dynamically */
    viewMenu.addMenuListener(new IMenuListener() {
      public void menuAboutToShow(IMenuManager manager) {
        final FeedView activeFeedView = OwlUI.getActiveFeedView();
        final IPreferenceScope entityPreferences = OwlUI.getActiveFeedViewPreferences();
        final Layout layout = OwlUI.getLayout(entityPreferences != null ? entityPreferences : globalPreferences);
        final PageSize pageSize = OwlUI.getPageSize(entityPreferences != null ? entityPreferences : globalPreferences);

        manager.add(new GroupMarker(M_VIEW_START));

        /* Layout */
        MenuManager layoutMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_LAYOUT);
        layoutMenu.add(new Action(Messages.ApplicationActionBarAdvisor_CLASSIC_LAYOUT, IAction.AS_RADIO_BUTTON) {
          @Override
          public void run() {
            if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
              updateLayoutPreferences(globalPreferences, entityPreferences, Layout.CLASSIC);
          }

          @Override
          public boolean isChecked() {
            return layout == Layout.CLASSIC;
          }
        });

        layoutMenu.add(new Action(Messages.ApplicationActionBarAdvisor_VERTICAL_LAYOUT, IAction.AS_RADIO_BUTTON) {
          @Override
          public void run() {
            if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
              updateLayoutPreferences(globalPreferences, entityPreferences, Layout.VERTICAL);
          }

          @Override
          public boolean isChecked() {
            return layout == Layout.VERTICAL;
          }
        });

        layoutMenu.add(new Action(Messages.ApplicationActionBarAdvisor_LIST_LAYOUT, IAction.AS_RADIO_BUTTON) {
          @Override
          public void run() {
            if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
              updateLayoutPreferences(globalPreferences, entityPreferences, Layout.LIST);
          }

          @Override
          public boolean isChecked() {
            return layout == Layout.LIST;
          }
        });

        layoutMenu.add(new Action(Messages.ApplicationActionBarAdvisor_NEWSPAPER_LAYOUT, IAction.AS_RADIO_BUTTON) {
          @Override
          public void run() {
            if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
              updateLayoutPreferences(globalPreferences, entityPreferences, Layout.NEWSPAPER);
          }

          @Override
          public boolean isChecked() {
            return layout == Layout.NEWSPAPER;
          }
        });

        layoutMenu.add(new Action(Messages.ApplicationActionBarAdvisor_HEADLINES_LAYOUT, IAction.AS_RADIO_BUTTON) {
          @Override
          public void run() {
            if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
              updateLayoutPreferences(globalPreferences, entityPreferences, Layout.HEADLINES);
          }

          @Override
          public boolean isChecked() {
            return layout == Layout.HEADLINES;
          }
        });

        /* Add the Page Size if using Newspaper or Headlines layout */
        if (layout == Layout.NEWSPAPER || layout == Layout.HEADLINES) {
          layoutMenu.add(new Separator());

          MenuManager pageMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_PAGE_SIZE);

          pageMenu.add(new Action(Messages.ApplicationActionBarAdvisor_T_ARTICLES, IAction.AS_RADIO_BUTTON) {
            @Override
            public void run() {
              if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
                updatePageSizePreferences(globalPreferences, entityPreferences, PageSize.TEN);
            }

            @Override
            public boolean isChecked() {
              return pageSize == PageSize.TEN;
            }
          });

          pageMenu.add(new Action(Messages.ApplicationActionBarAdvisor_TF_ARTICLES, IAction.AS_RADIO_BUTTON) {
            @Override
            public void run() {
              if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
                updatePageSizePreferences(globalPreferences, entityPreferences, PageSize.TWENTY_FIVE);
            }

            @Override
            public boolean isChecked() {
              return pageSize == PageSize.TWENTY_FIVE;
            }
          });

          pageMenu.add(new Action(Messages.ApplicationActionBarAdvisor_F_ARTICLES, IAction.AS_RADIO_BUTTON) {
            @Override
            public void run() {
              if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
                updatePageSizePreferences(globalPreferences, entityPreferences, PageSize.FIFTY);
            }

            @Override
            public boolean isChecked() {
              return pageSize == PageSize.FIFTY;
            }
          });

          pageMenu.add(new Action(Messages.ApplicationActionBarAdvisor_H_ARTICLES, IAction.AS_RADIO_BUTTON) {
            @Override
            public void run() {
              if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
                updatePageSizePreferences(globalPreferences, entityPreferences, PageSize.HUNDRED);
            }

            @Override
            public boolean isChecked() {
              return pageSize == PageSize.HUNDRED;
            }
          });

          pageMenu.add(new Separator());

          pageMenu.add(new Action(Messages.ApplicationActionBarAdvisor_ALL_ARTICLES, IAction.AS_RADIO_BUTTON) {
            @Override
            public void run() {
              if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
                updatePageSizePreferences(globalPreferences, entityPreferences, PageSize.NO_PAGING);
            }

            @Override
            public boolean isChecked() {
              return pageSize == PageSize.NO_PAGING;
            }
          });

          layoutMenu.add(pageMenu);
        }

        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() {
            return isColumnsEnabled;
          };
        });

        manager.add(columnsMenu);

        /* Sorting */
        MenuManager sortingMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_SORT_BY);
        for (final NewsColumn column : columns) {
          if (column.isSelectable()) {
            sortingMenu.add(new Action(column.getName(), IAction.AS_RADIO_BUTTON) {
              @Override
              public void run() {
                if (super.isChecked()) { //Need to use parent scope to get real selection state from UI and not Model
                  model.setSortColumn(column);
                  updateColumnsPreferences(globalPreferences, entityPreferences, model, DefaultPreferences.BM_NEWS_SORT_COLUMN);
                }
              }

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

        sortingMenu.add(new Separator());

        sortingMenu.add(new Action(Messages.ApplicationActionBarAdvisor_ASCENDING, IAction.AS_RADIO_BUTTON) {
          @Override
          public void run() {
            if (super.isChecked()) { //Need to use parent scope to get real selection state from UI and not Model
              model.setAscending(true);
              updateColumnsPreferences(globalPreferences, entityPreferences, model, DefaultPreferences.BM_NEWS_SORT_ASCENDING);
            }
          }

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

        sortingMenu.add(new Action(Messages.ApplicationActionBarAdvisor_DESCENDING, IAction.AS_RADIO_BUTTON) {
          @Override
          public void run() {
            if (super.isChecked()) { //Need to use parent scope to get real selection state from UI and not Model
              model.setAscending(false);
              updateColumnsPreferences(globalPreferences, entityPreferences, model, DefaultPreferences.BM_NEWS_SORT_ASCENDING);
            }
          }

          @Override
          public boolean isChecked() {
            return !model.isAscending();
          }
        });

        manager.add(sortingMenu);

        /* News Filter */
        manager.add(new Separator());
        MenuManager filterMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_FILTER_NEWS);

        int selectedFilterIndex;
        if (entityPreferences != null)
          selectedFilterIndex = ModelUtils.loadIntegerValueWithFallback(entityPreferences, DefaultPreferences.BM_NEWS_FILTERING, globalPreferences, DefaultPreferences.FV_FILTER_TYPE);
        else
          selectedFilterIndex = ModelUtils.loadIntegerValueWithFallback(globalPreferences, DefaultPreferences.BM_NEWS_FILTERING, globalPreferences, DefaultPreferences.FV_FILTER_TYPE);

        final NewsFilter.Type selectedFilter = NewsFilter.Type.values()[selectedFilterIndex];
        NewsFilter.Type[] filters = new NewsFilter.Type[] { NewsFilter.Type.SHOW_ALL, NewsFilter.Type.SHOW_NEW, NewsFilter.Type.SHOW_UNREAD, NewsFilter.Type.SHOW_STICKY, NewsFilter.Type.SHOW_LABELED, NewsFilter.Type.SHOW_RECENT, NewsFilter.Type.SHOW_LAST_5_DAYS };
        for (final NewsFilter.Type filter : filters) {
          filterMenu.add(new Action(filter.getName(), IAction.AS_RADIO_BUTTON) {
            @Override
            public void run() {
              if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
                updateFilterAndGroupingPreferences(globalPreferences, entityPreferences, filter, null);
            };

            @Override
            public boolean isChecked() {
              return filter == selectedFilter;
            };
          });

          /* Add Separators to improve readability of filter options */
          if (filter == NewsFilter.Type.SHOW_ALL || filter == NewsFilter.Type.SHOW_UNREAD || filter == NewsFilter.Type.SHOW_LABELED)
            filterMenu.add(new Separator());
        }

        manager.add(filterMenu);

        /* News Grouping */
        MenuManager groupMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_GROUP_NEWS);

        int selectedGroupIndex;
        if (entityPreferences != null)
          selectedGroupIndex = ModelUtils.loadIntegerValueWithFallback(entityPreferences, DefaultPreferences.BM_NEWS_GROUPING, globalPreferences, DefaultPreferences.FV_GROUP_TYPE);
        else
          selectedGroupIndex = ModelUtils.loadIntegerValueWithFallback(globalPreferences, DefaultPreferences.BM_NEWS_GROUPING, globalPreferences, DefaultPreferences.FV_GROUP_TYPE);

        final NewsGrouping.Type selectedGroup = NewsGrouping.Type.values()[selectedGroupIndex];
        NewsGrouping.Type[] groups = new NewsGrouping.Type[] { NewsGrouping.Type.NO_GROUPING, NewsGrouping.Type.GROUP_BY_DATE, NewsGrouping.Type.GROUP_BY_AUTHOR, NewsGrouping.Type.GROUP_BY_CATEGORY, NewsGrouping.Type.GROUP_BY_TOPIC, NewsGrouping.Type.GROUP_BY_FEED, NewsGrouping.Type.GROUP_BY_STATE, NewsGrouping.Type.GROUP_BY_STICKY, NewsGrouping.Type.GROUP_BY_LABEL };
        for (final NewsGrouping.Type group : groups) {
          groupMenu.add(new Action(group.getName(), IAction.AS_RADIO_BUTTON) {
            @Override
            public void run() {
              if (super.isChecked()) //Need to use parent scope to get real selection state from UI and not Model
                updateFilterAndGroupingPreferences(globalPreferences, entityPreferences, null, group);
            };

            @Override
            public boolean isChecked() {
              return group == selectedGroup;
            };
          });

          /* Add Separators to improve readability of grouping options */
          if (group == NewsGrouping.Type.NO_GROUPING || group == NewsGrouping.Type.GROUP_BY_FEED || group == NewsGrouping.Type.GROUP_BY_STICKY)
            groupMenu.add(new Separator());
        }

        manager.add(groupMenu);

        /* Zoom (In, Out, Reset) */
        final boolean isZoomingEnabled = (activeFeedView != null && activeFeedView.isBrowserShowingNews());
        manager.add(new Separator());
        MenuManager zoomMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_ZOOM);

        /* Zoom In */
        zoomMenu.add(new Action(Messages.ApplicationActionBarAdvisor_ZOOM_IN) {
View Full Code Here

    newsMenu.addMenuListener(new IMenuListener() {
      public void menuAboutToShow(IMenuManager manager) {
        final IStructuredSelection selection;

        FeedView activeFeedView = OwlUI.getActiveFeedView();
        FeedViewInput activeInput = null;
        if (activeFeedView != null) {
          selection = (IStructuredSelection) activeFeedView.getSite().getSelectionProvider().getSelection();
          activeInput = (FeedViewInput) activeFeedView.getEditorInput();
        } else
          selection = StructuredSelection.EMPTY;

        boolean isEntityGroupSelected = ModelUtils.isEntityGroupSelected(selection);
View Full Code Here

      }
    });

    /* Set Selection to Input if Empty */
    if (fSelection.isEmpty()) {
      FeedView activeFeedView = OwlUI.getActiveFeedView();
      if (activeFeedView != null) {
        FeedViewInput input = (FeedViewInput) activeFeedView.getEditorInput();
        fSelection = new StructuredSelection(input.getMark());
      }
    }

    /* Run Update */
 
View Full Code Here

  /*
   * @see org.eclipse.jface.action.Action#run()
   */
  @Override
  public void run() {
    FeedView activeFeedView = OwlUI.getActiveFeedView();
    if (activeFeedView != null)
      new MarkTypesReadAction(new StructuredSelection(activeFeedView)).run();
  }
View Full Code Here

  /*
   * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
   */
  public void run(IAction action) {
    FeedView activeFeedView = OwlUI.getActiveFeedView();
    if (activeFeedView != null) {
      IStructuredSelection selection = (IStructuredSelection) activeFeedView.getSite().getSelectionProvider().getSelection();
      if (selection != null && !selection.isEmpty())
        internalRun(selection, shouldMarkRead(selection));
    }
  }
View Full Code Here

      }

        /* Open */
      case OPEN: {
        IStructuredSelection selection = OwlUI.getActiveFeedViewSelection();
        FeedView feedView = OwlUI.getActiveFeedView();
        if (selection != null && !selection.isEmpty() && feedView != null) {
          OpenInBrowserAction action = new OpenInBrowserAction(selection, WebBrowserContext.createFrom(selection, feedView));
          action.run();
        }
        break;
      }

        /* Save As */
      case SAVE_AS: {
        FeedView activeFeedView = OwlUI.getActiveFeedView();
        if (activeFeedView != null)
          activeFeedView.doSaveAs();
        break;
      }

        /* Print */
      case PRINT: {
        FeedView activeFeedView = OwlUI.getActiveFeedView();
        if (activeFeedView != null)
          activeFeedView.print();
        break;
      }

        /* Fullscreen */
      case FULLSCREEN: {
View Full Code Here

TOP

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

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.