import java.util.Iterator;
import java.util.List;
+import net.sourceforge.phpdt.internal.ui.actions.ActionMessages;
import net.sourceforge.phpdt.internal.ui.actions.AddTaskAction;
import net.sourceforge.phpdt.ui.IContextMenuConstants;
import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
-import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
public class GenerateActionGroup extends ActionGroup {
private PHPEditor fEditor;
- private boolean fEditorIsOwner;
+// private boolean fEditorIsOwner;
private IWorkbenchSite fSite;
private String fGroupName= IContextMenuConstants.GROUP_SOURCE;
private List fRegisteredSelectionListeners;
*/
public GenerateActionGroup(PHPEditor editor, String groupName) {
fSite= editor.getSite();
- fEditor= editor;
- fEditorIsOwner= true;
+ fEditor= editor;
fGroupName= groupName;
+
ISelectionProvider provider= fSite.getSelectionProvider();
ISelection selection= provider.getSelection();
* Note: This method is for internal use only. Clients should not call this method.
*/
public void editorStateChanged() {
- Assert.isTrue(fEditorIsOwner);
+ Assert.isTrue(isEditorOwner());
// http://dev.eclipse.org/bugs/show_bug.cgi?id=17709
fConvertToMac.update();
/* (non-Javadoc)
* Method declared in ActionGroup
*/
+// public void fillContextMenu(IMenuManager menu) {
+// super.fillContextMenu(menu);
+// if (fEditorIsOwner) {
+// IMenuManager subMenu= createEditorSubMenu(menu);
+// if (subMenu != null)
+// menu.appendToGroup(fGroupName, subMenu);
+// } else {
+//// appendToGroup(menu, fOrganizeImports);
+//// appendToGroup(menu, fOverrideMethods);
+//// appendToGroup(menu, fAddGetterSetter);
+//// appendToGroup(menu, fAddUnimplementedConstructors);
+//// appendToGroup(menu, fAddJavaDocStub);
+// appendToGroup(menu, fAddBookmark);
+// }
+// }
+ /* (non-Javadoc)
+ * Method declared in ActionGroup
+ */
public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(menu);
- if (fEditorIsOwner) {
- IMenuManager subMenu= createEditorSubMenu(menu);
- if (subMenu != null)
- menu.appendToGroup(fGroupName, subMenu);
+ IMenuManager subMenu= null;
+ if (isEditorOwner()) {
+ subMenu= createEditorSubMenu(menu);
} else {
-// appendToGroup(menu, fOrganizeImports);
-// appendToGroup(menu, fOverrideMethods);
-// appendToGroup(menu, fAddGetterSetter);
-// appendToGroup(menu, fAddUnimplementedConstructors);
-// appendToGroup(menu, fAddJavaDocStub);
- appendToGroup(menu, fAddBookmark);
+ // subMenu= createViewSubMenu(menu);
}
+ if (subMenu != null)
+ menu.appendToGroup(fGroupName, subMenu);
}
private IMenuManager createEditorSubMenu(IMenuManager mainMenu) {
int added= 0;
added+= addEditorAction(result, "Comment"); //$NON-NLS-1$
added+= addEditorAction(result, "Uncomment"); //$NON-NLS-1$
+ added+= addEditorAction(result, "Format"); //$NON-NLS-1$
// result.add(new Separator());
// added+= addAction(result, fOrganizeImports);
// added+= addAction(result, fAddImport);
- result.add(new Separator());
+// result.add(new Separator());
// added+= addAction(result, fOverrideMethods);
// added+= addAction(result, fAddGetterSetter);
// added+= addAction(result, fAddUnimplementedConstructors);
// added+= addAction(result, fAddJavaDocStub);
- added+= addAction(result, fAddBookmark);
+// added+= addAction(result, fAddBookmark);
// result.add(new Separator());
// added+= addAction(result, fSurroundWithTryCatch);
// added+= addAction(result, fExternalizeStrings);
actionBar.setGlobalActionHandler(PHPdtActionConstants.CONVERT_LINE_DELIMITERS_TO_WINDOWS, fConvertToWindows);
actionBar.setGlobalActionHandler(PHPdtActionConstants.CONVERT_LINE_DELIMITERS_TO_UNIX, fConvertToUNIX);
actionBar.setGlobalActionHandler(PHPdtActionConstants.CONVERT_LINE_DELIMITERS_TO_MAC, fConvertToMac);
- if (!fEditorIsOwner) {
+ if (!isEditorOwner()) {
// editor provides its own implementation of these actions.
actionBar.setGlobalActionHandler(IWorkbenchActionConstants.BOOKMARK, fAddBookmark);
actionBar.setGlobalActionHandler(IWorkbenchActionConstants.ADD_TASK, fAddTaskAction);