/* Menu: View */
private void createViewMenu(IMenuManager menuBar) {
final IPreferenceScope preferences = Owl.getPreferenceService().getGlobalScope();
final IPreferenceScope eclipsePrefs = Owl.getPreferenceService().getEclipseScope();
MenuManager viewMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_VIEW, M_VIEW);
viewMenu.setRemoveAllWhenShown(true);
menuBar.add(viewMenu);
/* Add dummy action to show the top level menu */
viewMenu.add(new Action("") { //$NON-NLS-1$
@Override
public void run() {}
});
/* Build Menu dynamically */
viewMenu.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
manager.add(new GroupMarker(M_VIEW_START));
/* Layout */
MenuManager layoutMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_LAYOUT);
layoutMenu.add(new Action(Messages.ApplicationActionBarAdvisor_CLASSIC_VIEW, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
preferences.putBoolean(DefaultPreferences.FV_LAYOUT_CLASSIC, true);
preferences.putBoolean(DefaultPreferences.FV_BROWSER_MAXIMIZED, false);
List<FeedView> feedViews = OwlUI.getFeedViews();
for (FeedView feedView : feedViews) {
feedView.updateLayout();
}
}
@Override
public boolean isChecked() {
return preferences.getBoolean(DefaultPreferences.FV_LAYOUT_CLASSIC) && !preferences.getBoolean(DefaultPreferences.FV_BROWSER_MAXIMIZED);
}
});
layoutMenu.add(new Action(Messages.ApplicationActionBarAdvisor_VERTICAL_VIEW, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
preferences.putBoolean(DefaultPreferences.FV_LAYOUT_CLASSIC, false);
preferences.putBoolean(DefaultPreferences.FV_BROWSER_MAXIMIZED, false);
List<FeedView> feedViews = OwlUI.getFeedViews();
for (FeedView feedView : feedViews) {
feedView.updateLayout();
}
}
@Override
public boolean isChecked() {
return !preferences.getBoolean(DefaultPreferences.FV_LAYOUT_CLASSIC) && !preferences.getBoolean(DefaultPreferences.FV_BROWSER_MAXIMIZED);
}
});
layoutMenu.add(new Action(Messages.ApplicationActionBarAdvisor_NEWSPAPER_VIEW, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
preferences.putBoolean(DefaultPreferences.FV_BROWSER_MAXIMIZED, true);
List<FeedView> feedViews = OwlUI.getFeedViews();
for (FeedView feedView : feedViews) {
feedView.updateLayout();
}
}
@Override
public boolean isChecked() {
return preferences.getBoolean(DefaultPreferences.FV_BROWSER_MAXIMIZED);
}
});
layoutMenu.add(new Separator());
layoutMenu.add(new Action(Messages.ApplicationActionBarAdvisor_TABBED_BROWSING, IAction.AS_CHECK_BOX) {
@Override
public void run() {
boolean tabbedBrowsingEnabled = isChecked();
/* Disable Tabbed Browsing */
if (tabbedBrowsingEnabled) {
/* Close other Tabs if necessary */
boolean doit = true;
IWorkbenchPage page = OwlUI.getPage();
if (page != null) {
IEditorReference[] editorReferences = page.getEditorReferences();
if (editorReferences.length > 1) {
MessageBox confirmDialog = new MessageBox(page.getWorkbenchWindow().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
confirmDialog.setText(Messages.ApplicationActionBarAdvisor_DISABLE_TABBED_BROWSING);
confirmDialog.setMessage(NLS.bind(Messages.ApplicationActionBarAdvisor_TABS_MESSAGE, editorReferences.length));
if (confirmDialog.open() == SWT.YES)
OwlUI.closeOtherEditors();
else
doit = false;
}
}
/* Update Preferences */
if (doit) {
eclipsePrefs.putBoolean(DefaultPreferences.ECLIPSE_MULTIPLE_TABS, false);
eclipsePrefs.putBoolean(DefaultPreferences.ECLIPSE_AUTOCLOSE_TABS, true);
eclipsePrefs.putInteger(DefaultPreferences.ECLIPSE_AUTOCLOSE_TABS_THRESHOLD, 1);
}
}
/* Enable Tabbed Browsing */
else {
eclipsePrefs.putBoolean(DefaultPreferences.ECLIPSE_MULTIPLE_TABS, true);
eclipsePrefs.putBoolean(DefaultPreferences.ECLIPSE_AUTOCLOSE_TABS, false);
eclipsePrefs.putInteger(DefaultPreferences.ECLIPSE_AUTOCLOSE_TABS_THRESHOLD, 5);
}
}
@Override
public boolean isChecked() {
boolean autoCloseTabs = eclipsePrefs.getBoolean(DefaultPreferences.ECLIPSE_AUTOCLOSE_TABS);
int autoCloseTabsThreshold = eclipsePrefs.getInteger(DefaultPreferences.ECLIPSE_AUTOCLOSE_TABS_THRESHOLD);
return !autoCloseTabs || autoCloseTabsThreshold > 1;
}
});
manager.add(layoutMenu);
/* Zoom (In, Out, Reset) */
final MenuManager zoomMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_ZOOM);
zoomMenu.setRemoveAllWhenShown(true);
zoomMenu.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
FeedView activeFeedView = OwlUI.getActiveFeedView();
final boolean isZoomingEnabled = (activeFeedView != null && activeFeedView.isBrowserShowingNews());
/* Zoom In */
zoomMenu.add(new Action(Messages.ApplicationActionBarAdvisor_ZOOM_IN) {
@Override
public void run() {
OwlUI.zoomNewsText(true, false);
}
@Override
public String getId() {
return "org.rssowl.ui.ZoomInCommand"; //$NON-NLS-1$
}
@Override
public String getActionDefinitionId() {
return "org.rssowl.ui.ZoomInCommand"; //$NON-NLS-1$
}
@Override
public boolean isEnabled() {
return isZoomingEnabled;
}
});
/* Zoom Out */
zoomMenu.add(new Action(Messages.ApplicationActionBarAdvisor_ZOOM_OUT) {
@Override
public void run() {
OwlUI.zoomNewsText(false, false);
}
@Override
public String getId() {
return "org.rssowl.ui.ZoomOutCommand"; //$NON-NLS-1$
}
@Override
public String getActionDefinitionId() {
return "org.rssowl.ui.ZoomOutCommand"; //$NON-NLS-1$
}
@Override
public boolean isEnabled() {
return isZoomingEnabled;
}
});
/* Reset */
zoomMenu.add(new Separator());
zoomMenu.add(new Action(Messages.ApplicationActionBarAdvisor_RESET) {
@Override
public void run() {
OwlUI.zoomNewsText(false, true);
}