X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/SwitchBrowserWorkbenchAction.java b/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/SwitchBrowserWorkbenchAction.java index 7b93cea..33e1e68 100644 --- a/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/SwitchBrowserWorkbenchAction.java +++ b/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/internal/SwitchBrowserWorkbenchAction.java @@ -4,7 +4,7 @@ * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * + �* * Contributors: * IBM - Initial API and implementation */ @@ -14,24 +14,27 @@ import java.util.Iterator; import net.sourceforge.phpeclipse.webbrowser.IWebBrowser; -import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.events.MenuAdapter; import org.eclipse.swt.events.MenuEvent; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.ui.*; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; + /** * Action to open the Web broswer. */ -public class SwitchBrowserWorkbenchAction implements IWorkbenchWindowPulldownDelegate2 { +public class SwitchBrowserWorkbenchAction implements + IWorkbenchWindowPulldownDelegate2 { /** * The menu created by this action */ private Menu fMenu; - + protected boolean recreateMenu = false; /** @@ -44,11 +47,12 @@ public class SwitchBrowserWorkbenchAction implements IWorkbenchWindowPulldownDel public void dispose() { setMenu(null); } - + /** * Sets this action's drop-down menu, disposing the previous menu. * - * @param menu the new menu + * @param menu + * the new menu */ private void setMenu(Menu menu) { if (fMenu != null) { @@ -57,43 +61,51 @@ public class SwitchBrowserWorkbenchAction implements IWorkbenchWindowPulldownDel fMenu = menu; } - public void init(IWorkbenchWindow window) { } - + public void init(IWorkbenchWindow window) { + } + /** * Adds the given action to the specified menu with an accelerator specified * by the given number. * - * @param menu the menu to add the action to - * @param action the action to add - * @param accelerator the number that should appear as an accelerator + * @param menu + * the menu to add the action to + * @param action + * the action to add + * @param accelerator + * the number that should appear as an accelerator */ protected void addToMenu(Menu menu, IAction action, int accelerator) { - StringBuffer label= new StringBuffer(); + StringBuffer label = new StringBuffer(); if (accelerator >= 0 && accelerator < 10) { - //add the numerical accelerator + // add the numerical accelerator label.append('&'); label.append(accelerator); label.append(' '); } label.append(action.getText()); action.setText(label.toString()); - ActionContributionItem item= new ActionContributionItem(action); + ActionContributionItem item = new ActionContributionItem(action); item.fill(menu, -1); } - + /** - * Fills the drop-down menu with favorites and launch history, - * launch shortcuts, and an action to open the launch configuration dialog. - * - * @param menu the menu to fill + * Fills the drop-down menu with favorites and launch history, launch + * shortcuts, and an action to open the launch configuration dialog. + * + * @param menu + * the menu to fill */ protected void fillMenu(Menu menu) { - IWebBrowser current = BrowserManager.getInstance().getCurrentWebBrowser(); - Iterator iterator = BrowserManager.getInstance().getWebBrowsers().iterator(); + IWebBrowser current = BrowserManager.getInstance() + .getCurrentWebBrowser(); + Iterator iterator = BrowserManager.getInstance().getWebBrowsers() + .iterator(); int i = 0; while (iterator.hasNext()) { IWebBrowser browser = (IWebBrowser) iterator.next(); - addToMenu(menu, new SwitchDefaultBrowserAction(browser, browser.equals(current)), i++); + addToMenu(menu, new SwitchDefaultBrowserAction(browser, browser + .equals(current)), i++); } } @@ -105,33 +117,35 @@ public class SwitchBrowserWorkbenchAction implements IWorkbenchWindowPulldownDel // it is shown because of dynamic history list fMenu.addMenuListener(new MenuAdapter() { public void menuShown(MenuEvent e) { - //if (recreateMenu) { - Menu m = (Menu) e.widget; - MenuItem[] items = m.getItems(); - for (int i = 0; i < items.length; i++) { - items[i].dispose(); - } - fillMenu(m); - recreateMenu = false; - //} + // if (recreateMenu) { + Menu m = (Menu) e.widget; + MenuItem[] items = m.getItems(); + for (int i = 0; i < items.length; i++) { + items[i].dispose(); + } + fillMenu(m); + recreateMenu = false; + // } } }); } - public void selectionChanged(IAction action, ISelection selection) { } - - public void run(IAction action) { } + public void selectionChanged(IAction action, ISelection selection) { + } + + public void run(IAction action) { + } public Menu getMenu(Menu parent) { setMenu(new Menu(parent)); - //fillMenu(fMenu); + // fillMenu(fMenu); initMenu(); return fMenu; } public Menu getMenu(Control parent) { setMenu(new Menu(parent)); - //fillMenu(fMenu); + // fillMenu(fMenu); initMenu(); return fMenu; }