Added actions Comment, Uncommnet, AddBookmark, AddTask
authorkhartlage <khartlage>
Wed, 8 Jan 2003 19:16:32 +0000 (19:16 +0000)
committerkhartlage <khartlage>
Wed, 8 Jan 2003 19:16:32 +0000 (19:16 +0000)
19 files changed:
net.sourceforge.phpeclipse/plugin.properties
net.sourceforge.phpeclipse/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/ContextType.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/AddTaskAction.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/CompositeActionGroup.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/IContextMenuConstants.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/GenerateActionGroup.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/PHPEditorActionDefinitionIds.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/PHPdtActionConstants.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/SelectionDispatchAction.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionGroup.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/PHPConsole.java

index 66559cb..b4f9b2e 100644 (file)
@@ -1,7 +1,7 @@
 #########################################
 #
 #########################################
-pluginName=PHP Plugin
+pluginName=PHPEclipse Tools Core
 providerName=EclipseProject.de
 naturePHP.name=PHP Project
 
@@ -24,11 +24,18 @@ php3FileExtension=php3
 php4FileExtension=php4
 incFileExtension=inc
 phtmlFileExtension=phtml
-
+htmlFileExtension=html
+htmFileExtension=htm
+xmlFileExtension=xml
 #
 # Action sets
 #
 
+AddBookmark.label=Add Boo&kmark
+AddBookmark.tooltip=Add Bookmark...
+
+AddTask.label=Add &Task
+AddTask.tooltip=Add Task...
 php.menu.label=&Source
 phpActionSet.label=PHP Source Actions
 phpUncommentAction.label=&Uncomment@Ctrl+\\
index 63b226c..e99b66f 100644 (file)
@@ -93,7 +93,7 @@
          </description>
       </wizard>
    </extension>
-<!--   <extension
+   <extension
          point="org.eclipse.ui.newWizards">
       <category
             name="%newWizardCategory.name"
             Create a basic PHP file.
          </description>
       </wizard>
-   </extension> -->
+   </extension>
    <extension
          point="org.eclipse.ui.projectNatureImages">
       <image
             icon="icons/obj16/php.gif"
             natureId="net.sourceforge.phpeclipse.phpnature"
-            id="net.sourceforge.phpeclipse..ProjectNatureImagePHP">
+            id="net.sourceforge.phpeclipse.ProjectNatureImagePHP">
       </image>
    </extension>
    <extension
                id="net.sourceforge.phpeclipse.actions.PHPStartMySQLAction">
          </action>
       </actionSet>
-  <!--    <actionSet
+      <actionSet
                id="net.sourceforge.phpeclipse.ui.CodingActionSet"
         label="%phpActionSet.label"
                visible="false"
             path="edit">
                <separator name="editGroup"/>
        </menu>
-       <action id="net.sourceforge.phpeclipse.ui.actions.Uncomment"
+       <action id="net.sourceforge.phpdt.ui.actions.Uncomment"
                menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
                label="%phpUncommentAction.label"
                        retarget="true" />
                        
-               <action id="net.sourceforge.phpeclipse.ui.actions.Comment"
+               <action id="net.sourceforge.phpdt.ui.actions.Comment"
                menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
                label="%phpCommentAction.label"
                        retarget="true" />
-         </actionSet> -->
+         </actionSet> 
    </extension>
-  <!-- <extension
+   <extension
          point="org.eclipse.ui.actionDefinitions">
       <actionDefinition
-            id="net.sourceforge.phpeclipse.phpeditor.comment">
+            id="net.sourceforge.phpdt.ui.actions.comment">
       </actionDefinition>
       <actionDefinition
-            id="net.sourceforge.phpeclipse.phpeditor.uncomment">
+            id="net.sourceforge.phpdt.ui.actions.uncomment">
       </actionDefinition>
    </extension> 
    <extension
             configurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
          <accelerator
                key="Ctrl+/"
-               id="net.sourceforge.phpeclipse.phpeditor.comment">
+               id="net.sourceforge.phpdt.ui.actions.comment">
          </accelerator>
          <accelerator
                key="Ctrl+\\"
-               id="net.sourceforge.phpeclipse.phpeditor.uncomment">
+               id="net.sourceforge.phpdt.ui.actions.uncomment">
          </accelerator>
       </acceleratorSet>
-   </extension> -->
+   </extension> 
    <extension
          point="org.eclipse.ui.editors">
       <editor
                id="net.sourceforge.phpeclipse.actions.showAction">
          </action>
       </objectContribution>
+       
+         <viewerContribution 
+               id="net.sourceforge.phpdt.ui.PHPEditorPopupActions" 
+               targetID="#PHPRulerContext">
+               <action
+                       id="org.eclipse.ui.texteditor.TaskRulerAction"
+                       menubarPath="add"
+                       label="%AddTask.label"
+                       tooltip="%AddTask.tooltip"
+            helpContextId="org.eclipse.ui.AddTask_action_context"
+                       class="org.eclipse.ui.texteditor.TaskRulerAction">
+               </action>
+               <action
+                       id="org.eclipse.ui.texteditor.BookmarkRulerAction"
+                       menubarPath="add"
+                       label="%AddBookmark.label"
+                       tooltip="%AddBookmark.tooltip"
+            helpContextId="org.eclipse.ui.bookmark_action_context"
+                       class="org.eclipse.ui.texteditor.BookmarkRulerAction">
+               </action>
+         </viewerContribution>
+   </extension>
+   <extension point="org.eclipse.ui.editorActions">
+       <editorContribution
+               id="org.eclipse.ui.texteditor.ruler.actions"
+               targetID="net.sourceforge.phpeclipse.PHPEditor">
+
+               <action
+                       id="org.eclipse.ui.texteditor.BookmarkRulerAction"
+                       actionID="RulerDoubleClick"
+                       label="%Dummy.label"
+            helpContextId="org.eclipse.ui.bookmark_action_context"
+                       class="org.eclipse.ui.texteditor.BookmarkRulerAction">
+               </action>
+       </editorContribution>
    </extension>
    <extension
          point="org.eclipse.ui.preferencePages">
       </provider>
    </extension>
    <extension
+         point="org.eclipse.ui.documentProviders">
+      <provider
+            extensions="%htmlFileExtension"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
+            id="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider">
+      </provider>
+   </extension>
+   <extension
+         point="org.eclipse.ui.documentProviders">
+      <provider
+            extensions="%htmFileExtension"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
+            id="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider">
+      </provider>
+   </extension>
+   <extension
+         point="org.eclipse.ui.documentProviders">
+      <provider
+            extensions="%xmlFileExtension"
+            class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
+            id="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider">
+      </provider>
+   </extension>
+   <extension
          point="org.eclipse.ui.views">
       <view
             name="%phpConsoleView"
index c6c96e3..2b37af3 100644 (file)
@@ -17,6 +17,8 @@ import net.sourceforge.phpdt.internal.corext.textmanipulation.TextBufferEditor;
 import net.sourceforge.phpdt.internal.corext.textmanipulation.TextEdit;
 import org.eclipse.core.runtime.CoreException;
 
+
 /**
  * A context type is a context factory.
  */
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/AddTaskAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/AddTaskAction.java
new file mode 100644 (file)
index 0000000..bb4749b
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2002 International Business Machines Corp. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v0.5 
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.actions;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.InputDialog;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.texteditor.MarkerUtilities;
+import org.eclipse.ui.views.tasklist.TaskPropertiesDialog;
+
+//import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
+import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
+
+import net.sourceforge.phpdt.ui.actions.SelectionDispatchAction;
+
+public class AddTaskAction extends SelectionDispatchAction {
+
+       public AddTaskAction(IWorkbenchSite site) {
+               super(site);
+               setEnabled(false);
+       //      WorkbenchHelp.setHelp(this, IJavaHelpContextIds.ADD_TASK_ACTION);
+       }
+
+       protected void selectionChanged(IStructuredSelection selection) {
+               setEnabled(getElement(selection) != null);
+       }
+
+       protected void run(IStructuredSelection selection) {
+               IResource resource= getElement(selection);
+               if (resource == null)
+                       return;
+
+               TaskPropertiesDialog dialog= new TaskPropertiesDialog(getShell());
+               dialog.setResource(resource);
+               dialog.open();
+       }
+       
+       private IResource getElement(IStructuredSelection selection) {
+               if (selection.size() != 1)
+                       return null;
+
+               Object element= selection.getFirstElement();
+               if (!(element instanceof IAdaptable))
+                       return null;
+               return (IResource)((IAdaptable)element).getAdapter(IResource.class);
+       }       
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/CompositeActionGroup.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/CompositeActionGroup.java
new file mode 100644 (file)
index 0000000..2936a6d
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2002 International Business Machines Corp. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v0.5 
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.actions;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.util.Assert;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionGroup;
+
+public class CompositeActionGroup extends ActionGroup {
+
+       private ActionGroup[] fGroups;
+       
+       public CompositeActionGroup() {
+       }
+       
+       public CompositeActionGroup(ActionGroup[] groups) {
+               setGroups(groups);
+       }
+
+       protected void setGroups(ActionGroup[] groups) {
+               Assert.isTrue(fGroups == null);
+               Assert.isNotNull(groups);
+               fGroups= groups;                
+       }
+               
+       public ActionGroup get(int index) {
+               if (fGroups == null)
+                       return null;
+               return fGroups[index];
+       }
+       
+       public void addGroup(ActionGroup group) {
+               if (fGroups == null) {
+                       fGroups= new ActionGroup[] { group };
+               } else {
+                       ActionGroup[] newGroups= new ActionGroup[fGroups.length + 1];
+                       System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
+                       newGroups[fGroups.length]= group;
+                       fGroups= newGroups;
+               }
+       }
+       
+       public void dispose() {
+               super.dispose();
+               if (fGroups == null)
+                       return;
+               for (int i= 0; i < fGroups.length; i++) {
+                       fGroups[i].dispose();
+               }
+       }
+
+       public void fillActionBars(IActionBars actionBars) {
+               super.fillActionBars(actionBars);
+               if (fGroups == null)
+                       return;
+               for (int i= 0; i < fGroups.length; i++) {
+                       fGroups[i].fillActionBars(actionBars);
+               }
+       }
+
+       public void fillContextMenu(IMenuManager menu) {
+               super.fillContextMenu(menu);
+               if (fGroups == null)
+                       return;
+               for (int i= 0; i < fGroups.length; i++) {
+                       fGroups[i].fillContextMenu(menu);
+               }
+       }
+
+       public void setContext(ActionContext context) {
+               super.setContext(context);
+               if (fGroups == null)
+                       return;
+               for (int i= 0; i < fGroups.length; i++) {
+                       fGroups[i].setContext(context);
+               }
+       }
+
+       public void updateActionBars() {
+               super.updateActionBars();
+               if (fGroups == null)
+                       return;
+               for (int i= 0; i < fGroups.length; i++) {
+                       fGroups[i].updateActionBars();
+               }
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/IContextMenuConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/IContextMenuConstants.java
new file mode 100644 (file)
index 0000000..03de9a1
--- /dev/null
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2002 International Business Machines Corp. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * 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 Corporation - initial API and implementation
+ ******************************************************************************/
+package net.sourceforge.phpdt.ui;
+
+import org.eclipse.ui.IWorkbenchActionConstants;
+
+/**
+ * Constants for menu groups used in context menus for Java views and editors.
+ * <p>
+ * This interface declares constants only; it is not intended to be implemented.
+ * </p>
+ */
+public interface IContextMenuConstants {
+       
+       
+//     /**
+//      * Type hierarchy view part: pop-up menu target ID for type hierarchy viewer
+//      * (value <code>"org.eclipse.jdt.ui.TypeHierarchy.typehierarchy"</code>).
+//      * 
+//      * @since 2.0
+//      */
+//     public static final String TARGET_ID_HIERARCHY_VIEW= JavaUI.ID_TYPE_HIERARCHY + ".typehierarchy"; //$NON-NLS-1$ 
+//
+//     /**
+//      * Type hierarchy view part: pop-up menu target ID for supertype hierarchy viewer
+//      * (value <code>"org.eclipse.jdt.ui.TypeHierarchy.supertypes"</code>).
+//      * 
+//      * @since 2.0
+//      */
+//     public static final String TARGET_ID_SUPERTYPES_VIEW= JavaUI.ID_TYPE_HIERARCHY + ".supertypes"; //$NON-NLS-1$   
+//
+//     /**
+//      * Type hierarchy view part: Pop-up menu target ID for the subtype hierarchy viewer
+//      * (value <code>"org.eclipse.jdt.ui.TypeHierarchy.subtypes"</code>).
+//      * 
+//      * @since 2.0
+//      */
+//     public static final String TARGET_ID_SUBTYPES_VIEW= JavaUI.ID_TYPE_HIERARCHY + ".subtypes"; //$NON-NLS-1$       
+//
+//     /**
+//      * Type hierarchy view part: pop-up menu target ID for the meber viewer
+//      * (value <code>"org.eclipse.jdt.ui.TypeHierarchy.members"</code>).
+//      * 
+//      * @since 2.0
+//      */
+//     public static final String TARGET_ID_MEMBERS_VIEW= JavaUI.ID_TYPE_HIERARCHY + ".members"; //$NON-NLS-1$ 
+//     
+
+       /**
+        * Pop-up menu: name of group for goto actions (value <code>"group.open"</code>).
+        * <p>
+        * Examples for open actions are:
+        * <ul>
+        *  <li>Go Into</li>
+        *  <li>Go To</li>
+        * </ul>
+        * </p>
+        */
+       public static final String GROUP_GOTO=          "group.goto"; //$NON-NLS-1$
+       /**
+        * Pop-up menu: name of group for open actions (value <code>"group.open"</code>).
+        * <p>
+        * Examples for open actions are:
+        * <ul>
+        *  <li>Open To</li>
+        *  <li>Open With</li>
+        * </ul>
+        * </p>
+        */
+       public static final String GROUP_OPEN=          "group.open"; //$NON-NLS-1$
+       
+       /**
+        * Pop-up menu: name of group for show actions (value <code>"group.show"</code>).
+        * <p>
+        * Examples for show actions are:
+        * <ul>
+        *  <li>Show in Navigator</li>
+        *  <li>Show in Type Hierarchy</li>
+        * </ul>
+        * </p>
+        */
+       public static final String GROUP_SHOW=          "group.show"; //$NON-NLS-1$
+       
+       /**
+        * Pop-up menu: name of group for new actions (value <code>"group.new"</code>).
+        * <p>
+        * Examples for new actions are:
+        * <ul>
+        *  <li>Create new class</li>
+        *  <li>Create new interface</li>
+        * </ul>
+        * </p>
+        */
+       public static final String GROUP_NEW=           "group.new"; //$NON-NLS-1$
+
+       /**
+        * Pop-up menu: name of group for build actions (value <code>"group.build"</code>).
+        */
+       public static final String GROUP_BUILD=         "group.build"; //$NON-NLS-1$
+       
+       /**
+        * Pop-up menu: name of group for reorganize actions (value <code>"group.reorganize"</code>).
+        */     
+       public static final String GROUP_REORGANIZE=    IWorkbenchActionConstants.GROUP_REORGANIZE;     
+       
+       /**
+        * Pop-up menu: name of group for code generation actions (
+        * value <code>"group.generate"</code>).
+        */     
+       public static final String GROUP_GENERATE=      "group.generate"; //$NON-NLS-1$
+
+       /**
+        * Pop-up menu: name of group for source actions. This is an alias for
+        * <code>GROUP_GENERATE</code> to be more consistent with main menu
+        * bar structure.
+        * 
+        * @since 2.0
+        */     
+       public static final String GROUP_SOURCE=        GROUP_GENERATE;
+
+       /**
+        * Pop-up menu: name of group for search actions (value <code>"group.search"</code>).
+        */     
+       public static final String GROUP_SEARCH=                "group.search"; //$NON-NLS-1$
+       
+       /**
+        * Pop-up menu: name of group for additional actions (value <code>"additions"</code>).
+        */     
+       public static final String GROUP_ADDITIONS=     "additions"; //$NON-NLS-1$
+
+       /**
+        * Pop-up menu: name of group for viewer setup actions (value <code>"group.viewerSetup"</code>).
+        */     
+       public static final String GROUP_VIEWER_SETUP=  "group.viewerSetup"; //$NON-NLS-1$
+
+       /**
+        * Pop-up menu: name of group for properties actions (value <code>"group.properties"</code>).
+        */     
+       public static final String GROUP_PROPERTIES=    "group.properties"; //$NON-NLS-1$
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/GenerateActionGroup.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/GenerateActionGroup.java
new file mode 100644 (file)
index 0000000..fa14ba5
--- /dev/null
@@ -0,0 +1,325 @@
+/*******************************************************************************
+ * Copyright (c) 2002 International Business Machines Corp. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v0.5 
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package net.sourceforge.phpdt.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+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.util.Assert;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.AddBookmarkAction;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.texteditor.ConvertLineDelimitersAction;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+/**
+ * Action group that adds the source and generate actions to a part's context
+ * menu and installs handlers for the corresponding global menu actions.
+ * 
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @since 2.0
+ */
+public class GenerateActionGroup extends ActionGroup {
+       
+       private boolean fEditorIsOwner;
+       private IWorkbenchSite fSite;
+       private String fGroupName= IContextMenuConstants.GROUP_SOURCE;
+       private List fRegisteredSelectionListeners;
+       
+//     private AddImportOnSelectionAction fAddImport;
+//     private OverrideMethodsAction fOverrideMethods;
+//     private AddGetterSetterAction fAddGetterSetter;
+//     private AddUnimplementedConstructorsAction fAddUnimplementedConstructors;
+//     private AddJavaDocStubAction fAddJavaDocStub;
+       private AddBookmarkAction fAddBookmark;
+       private AddTaskAction fAddTaskAction;
+//     private ExternalizeStringsAction fExternalizeStrings;
+//     private FindStringsToExternalizeAction fFindStringsToExternalize;
+//     private SurroundWithTryCatchAction fSurroundWithTryCatch;
+       
+       // private OrganizeImportsAction fOrganizeImports;
+
+       private ConvertLineDelimitersAction fConvertToWindows;
+       private ConvertLineDelimitersAction fConvertToUNIX;
+       private ConvertLineDelimitersAction fConvertToMac;
+       
+       /**
+        * Note: This constructor is for internal use only. Clients should not call this constructor.
+        */
+       public GenerateActionGroup(PHPEditor editor, String groupName) {
+               fSite= editor.getSite();
+               fEditorIsOwner= true;
+               fGroupName= groupName;
+               ISelectionProvider provider= fSite.getSelectionProvider();
+               ISelection selection= provider.getSelection();
+
+//             fAddImport= new AddImportOnSelectionAction(editor);
+//             fAddImport.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_IMPORT);
+//             fAddImport.update();
+//             editor.setAction("AddImport", fAddImport); //$NON-NLS-1$
+               
+//             fOrganizeImports= new OrganizeImportsAction(editor);
+//             fOrganizeImports.setActionDefinitionId(IJavaEditorActionDefinitionIds.ORGANIZE_IMPORTS);
+//             fOrganizeImports.editorStateChanged();
+//             editor.setAction("OrganizeImports", fOrganizeImports); //$NON-NLS-1$
+
+//             fOverrideMethods= new OverrideMethodsAction(editor);
+//             fOverrideMethods.setActionDefinitionId(IJavaEditorActionDefinitionIds.OVERRIDE_METHODS);
+//             fOverrideMethods.editorStateChanged();
+//             editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$
+               
+//             fAddGetterSetter= new AddGetterSetterAction(editor);
+//             fAddGetterSetter.setActionDefinitionId(IJavaEditorActionDefinitionIds.CREATE_GETTER_SETTER);
+//             fAddGetterSetter.editorStateChanged();
+//             editor.setAction("AddGetterSetter", fAddGetterSetter); //$NON-NLS-1$
+               
+//             fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(editor);
+//             fAddUnimplementedConstructors.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS);
+//             fAddUnimplementedConstructors.editorStateChanged();
+//             editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors); //$NON-NLS-1$          
+               
+//             fAddJavaDocStub= new AddJavaDocStubAction(editor);
+//             fAddJavaDocStub.editorStateChanged();
+//             
+//             fSurroundWithTryCatch= new SurroundWithTryCatchAction(editor);
+//             fSurroundWithTryCatch.setActionDefinitionId(IJavaEditorActionDefinitionIds.SURROUND_WITH_TRY_CATCH);
+//             fSurroundWithTryCatch.update(selection);
+//             provider.addSelectionChangedListener(fSurroundWithTryCatch);
+//             editor.setAction("SurroundWithTryCatch", fSurroundWithTryCatch); //$NON-NLS-1$          
+//             
+//             fExternalizeStrings= new ExternalizeStringsAction(editor);
+//             fExternalizeStrings.setActionDefinitionId(IJavaEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
+//             fExternalizeStrings.editorStateChanged();
+//             editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$              
+               
+               fConvertToWindows= new ConvertLineDelimitersAction(editor, "\r\n"); //$NON-NLS-1$
+               fConvertToWindows.setActionDefinitionId( ITextEditorActionDefinitionIds .CONVERT_LINE_DELIMITERS_TO_WINDOWS);
+               editor.setAction("ConvertLineDelimitersToWindows", fConvertToWindows); //$NON-NLS-1$            
+               
+               fConvertToUNIX= new ConvertLineDelimitersAction(editor, "\n"); //$NON-NLS-1$
+               fConvertToUNIX.setActionDefinitionId( ITextEditorActionDefinitionIds .CONVERT_LINE_DELIMITERS_TO_UNIX);
+               editor.setAction("ConvertLineDelimitersToUNIX", fConvertToUNIX); //$NON-NLS-1$          
+
+               fConvertToMac= new ConvertLineDelimitersAction(editor, "\r"); //$NON-NLS-1$
+               fConvertToMac.setActionDefinitionId( ITextEditorActionDefinitionIds .CONVERT_LINE_DELIMITERS_TO_MAC);
+               editor.setAction("ConvertLineDelimitersToMac", fConvertToMac); //$NON-NLS-1$            
+       }
+       
+       /**
+        * Creates a new <code>GenerateActionGroup</code>. The group 
+        * requires that the selection provided by the page's selection provider 
+        * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
+        * 
+        * @param page the page that owns this action group
+        */
+       public GenerateActionGroup(Page page) {
+               this(page.getSite());
+       }
+
+       /**
+        * Creates a new <code>GenerateActionGroup</code>. The group 
+        * requires that the selection provided by the part's selection provider 
+        * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
+        * 
+        * @param part the view part that owns this action group
+        */
+       public GenerateActionGroup(IViewPart part) {
+               this(part.getSite());
+       }
+       
+       private GenerateActionGroup(IWorkbenchSite site) {
+               fSite= site;
+               ISelectionProvider provider= fSite.getSelectionProvider();
+               ISelection selection= provider.getSelection();
+               
+//             fOverrideMethods= new OverrideMethodsAction(site);
+//             fAddGetterSetter= new AddGetterSetterAction(site);
+//             fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(site);
+//             fAddJavaDocStub= new AddJavaDocStubAction(site);
+               fAddBookmark= new AddBookmarkAction(site.getShell());
+               fAddTaskAction= new AddTaskAction(site);
+//             fExternalizeStrings= new ExternalizeStringsAction(site);
+//             fFindStringsToExternalize= new FindStringsToExternalizeAction(site);
+//             fOrganizeImports= new OrganizeImportsAction(site);
+//             
+//             fOverrideMethods.update(selection);
+//             fAddGetterSetter.update(selection);
+//             fAddUnimplementedConstructors.update(selection);        
+//             fAddJavaDocStub.update(selection);
+//             fExternalizeStrings.update(selection);
+//             fFindStringsToExternalize.update(selection);
+               fAddTaskAction.update(selection);
+//             fOrganizeImports.update(selection);
+               if (selection instanceof IStructuredSelection) {
+                       IStructuredSelection ss= (IStructuredSelection)selection;
+                       fAddBookmark.selectionChanged(ss);
+               } else {
+                       fAddBookmark.setEnabled(false);
+               }
+               
+//             registerSelectionListener(provider, fOverrideMethods);
+//             registerSelectionListener(provider, fAddGetterSetter);
+//             registerSelectionListener(provider, fAddUnimplementedConstructors);
+//             registerSelectionListener(provider, fAddJavaDocStub);
+               registerSelectionListener(provider, fAddBookmark);
+//             registerSelectionListener(provider, fExternalizeStrings);
+//             registerSelectionListener(provider, fFindStringsToExternalize);
+//             registerSelectionListener(provider, fOrganizeImports);
+               registerSelectionListener(provider, fAddTaskAction);
+       }
+       
+       private void registerSelectionListener(ISelectionProvider provider, ISelectionChangedListener listener) {
+               if (fRegisteredSelectionListeners == null)
+                       fRegisteredSelectionListeners= new ArrayList(12);
+               provider.addSelectionChangedListener(listener);
+               fRegisteredSelectionListeners.add(listener);
+       }
+       
+       /*
+        * The state of the editor owning this action group has changed. 
+        * This method does nothing if the group's owner isn't an
+        * editor.
+        */
+       /**
+        * Note: This method is for internal use only. Clients should not call this method.
+        */
+       public void editorStateChanged() {
+               Assert.isTrue(fEditorIsOwner);
+//             fAddImport.update();
+//             fExternalizeStrings.editorStateChanged();
+//             fOrganizeImports.editorStateChanged();
+//             fOverrideMethods.editorStateChanged();
+//             fAddUnimplementedConstructors.editorStateChanged();
+//             fAddJavaDocStub.editorStateChanged();
+//             fSurroundWithTryCatch.editorStateChanged();
+//             fAddGetterSetter.editorStateChanged();
+               
+               // http://dev.eclipse.org/bugs/show_bug.cgi?id=17709
+               fConvertToMac.update();
+               fConvertToUNIX.update();
+               fConvertToWindows.update();
+       }
+
+       /* (non-Javadoc)
+        * Method declared in ActionGroup
+        */
+       public void fillActionBars(IActionBars actionBar) {
+               super.fillActionBars(actionBar);
+               setGlobalActionHandlers(actionBar);
+       }
+       
+       /* (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);
+               }
+       }
+       
+       private IMenuManager createEditorSubMenu(IMenuManager mainMenu) {
+               IMenuManager result= new MenuManager(ActionMessages.getString("SourceMenu.label")); //$NON-NLS-1$
+               int added= 0;
+//             added+= addAction(result, fOrganizeImports);
+//             added+= addAction(result, fAddImport);
+//             result.add(new Separator());
+//             added+= addAction(result, fOverrideMethods);
+//             added+= addAction(result, fAddGetterSetter);
+//             added+= addAction(result, fAddUnimplementedConstructors);
+//             added+= addAction(result, fAddJavaDocStub);
+               added+= addAction(result, fAddBookmark);
+//             result.add(new Separator());            
+//             added+= addAction(result, fSurroundWithTryCatch);
+//             added+= addAction(result, fExternalizeStrings);
+               if (added == 0)
+                       result= null;
+               return result;
+       }
+
+       /* (non-Javadoc)
+        * Method declared in ActionGroup
+        */
+       public void dispose() {
+               if (fRegisteredSelectionListeners != null) {
+                       ISelectionProvider provider= fSite.getSelectionProvider();
+                       for (Iterator iter= fRegisteredSelectionListeners.iterator(); iter.hasNext();) {
+                               ISelectionChangedListener listener= (ISelectionChangedListener) iter.next();
+                               provider.removeSelectionChangedListener(listener);
+                       }
+               }
+               super.dispose();
+       }
+       
+       private void setGlobalActionHandlers(IActionBars actionBar) {
+//             actionBar.setGlobalActionHandler(JdtActionConstants.ADD_IMPORT, fAddImport);
+//             actionBar.setGlobalActionHandler(JdtActionConstants.SURROUND_WITH_TRY_CATCH, fSurroundWithTryCatch);
+//             actionBar.setGlobalActionHandler(JdtActionConstants.OVERRIDE_METHODS, fOverrideMethods);
+//             actionBar.setGlobalActionHandler(JdtActionConstants.GENERATE_GETTER_SETTER, fAddGetterSetter);
+//             actionBar.setGlobalActionHandler(JdtActionConstants.ADD_CONSTRUCTOR_FROM_SUPERCLASS, fAddUnimplementedConstructors);
+//             actionBar.setGlobalActionHandler(JdtActionConstants.ADD_JAVA_DOC_COMMENT, fAddJavaDocStub);
+//             actionBar.setGlobalActionHandler(JdtActionConstants.EXTERNALIZE_STRINGS, fExternalizeStrings);
+//             actionBar.setGlobalActionHandler(JdtActionConstants.FIND_STRINGS_TO_EXTERNALIZE, fFindStringsToExternalize);
+//             actionBar.setGlobalActionHandler(JdtActionConstants.ORGANIZE_IMPORTS, fOrganizeImports);
+//             actionBar.setGlobalActionHandler(JdtActionConstants.CONVERT_LINE_DELIMITERS_TO_WINDOWS, fConvertToWindows);
+//             actionBar.setGlobalActionHandler(JdtActionConstants.CONVERT_LINE_DELIMITERS_TO_UNIX, fConvertToUNIX);
+//             actionBar.setGlobalActionHandler(JdtActionConstants.CONVERT_LINE_DELIMITERS_TO_MAC, fConvertToMac);
+               if (!fEditorIsOwner) {
+                       // editor provides its own implementation of these actions.
+                       actionBar.setGlobalActionHandler(IWorkbenchActionConstants.BOOKMARK, fAddBookmark);
+                       actionBar.setGlobalActionHandler(IWorkbenchActionConstants.ADD_TASK, fAddTaskAction);
+               }
+       }
+       
+       private int appendToGroup(IMenuManager menu, IAction action) {
+               if (action != null && action.isEnabled()) {
+                       menu.appendToGroup(fGroupName, action);
+                       return 1;
+               }
+               return 0;
+       }       
+
+       private int addAction(IMenuManager menu, IAction action) {
+               if (action != null && action.isEnabled()) {
+                       menu.add(action);
+                       return 1;
+               }
+               return 0;
+       }       
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/PHPEditorActionDefinitionIds.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/PHPEditorActionDefinitionIds.java
new file mode 100644 (file)
index 0000000..aab8e47
--- /dev/null
@@ -0,0 +1,12 @@
+package net.sourceforge.phpdt.ui.actions;
+
+public interface PHPEditorActionDefinitionIds {
+       /**
+        * Value: net.sourceforge.phpeclipse.phpeditor.comment\r  */
+       public static final String COMMENT= "net.sourceforge.phpdt.ui.actions.comment";
+
+       /**
+        * Value: net.sourceforge.phpeclipse.phpeditor.uncomment
+        */
+       public static final String UNCOMMENT = "net.sourceforge.phpdt.ui.actions.uncomment";
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/PHPdtActionConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/PHPdtActionConstants.java
new file mode 100644 (file)
index 0000000..436dc6a
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2002 International Business Machines Corp. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v0.5 
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package net.sourceforge.phpdt.ui.actions;
+
+/**
+ * Action ids for standard actions, for groups in the menu bar, and
+ * for actions in context menus of PHPDT views.
+ * 
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @since 2.0
+ */
+public class PHPdtActionConstants {
+
+       // Source menu  
+       
+       /**
+        * Source menu: name of standard Comment global action
+        * (value <code>"net.sourceforge.phpdt.ui.actions.Comment"</code>).
+        */
+       public static final String COMMENT= "net.sourceforge.phpdt.ui.actions.Comment"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Uncomment global action
+        * (value <code>"net.sourceforge.phpdt.ui.actions.Uncomment"</code>).
+        */
+       public static final String UNCOMMENT= "net.sourceforge.phpdt.ui.actions.Uncomment"; //$NON-NLS-1$
+       
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/SelectionDispatchAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/SelectionDispatchAction.java
new file mode 100644 (file)
index 0000000..891c48e
--- /dev/null
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2002 International Business Machines Corp. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v0.5 
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package net.sourceforge.phpdt.ui.actions;
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.texteditor.IUpdate;
+
+//import org.eclipse.jdt.internal.ui.actions.ActionMessages;
+import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * Action that dispatches the <code>IAction#run()</code> and the 
+ * <code>ISelectionChangedListener#selectionChanged</code> 
+ * according to the type of the selection. 
+ * 
+ * <ul>
+ *     <li>if selection is of type <code>ITextSelection</code> then
+ *     <code>run(ITextSelection)</code> and <code>selectionChanged(ITextSelection)</code>
+ *     is called.</li> 
+ *     <li>if selection is of type <code>IStructuredSelection</code> then
+ *     <code>run(IStructuredSelection)</code> and <code>
+ *     selectionChanged(IStructuredSelection)</code> is called.</li>
+ *     <li>default is to call <code>run(ISelection)</code> and <code>
+ *     selectionChanged(ISelection)</code>.</li>
+ * </ul>
+ * 
+ * <p>
+ * Note: This class is not intended to be subclassed outside the JDT UI plugin.
+ * </p>
+ * 
+ * @since 2.0
+ */
+public abstract class SelectionDispatchAction extends Action implements ISelectionChangedListener {
+       
+       private IWorkbenchSite fSite;
+       
+       /**
+        * Creates a new action with no text and no image.
+        * <p>
+        * Configure the action later using the set methods.
+        * </p>
+        * 
+        * @param site the site this action is working on
+        */
+       protected SelectionDispatchAction(IWorkbenchSite site) {
+               Assert.isNotNull(site);
+               fSite= site;
+       }
+
+       /**
+        * Returns the site owning this action.
+        * 
+        * @return the site owning this action
+        */
+       public IWorkbenchSite getSite() {
+               return fSite;
+       }
+
+       /**
+        * Returns the selection provided by the site owning this action.
+        * 
+        * @return the site's selection
+        */     
+       public ISelection getSelection() {
+               return getSelectionProvider().getSelection();
+       }
+
+       /**
+        * Returns the shell provided by the site owning this action.
+        * 
+        * @return the site's shell     
+        */
+       public  Shell getShell() {
+               return fSite.getShell();
+       }
+       
+       /**
+        * Returns the selection provider managed by the site owning this action.
+        * 
+        * @return the site's selection provider        
+        */
+       public ISelectionProvider getSelectionProvider() {
+               return fSite.getSelectionProvider();
+       }
+
+       /**
+        * Updates the action's enablement state according to the given selection. This
+        * default implementation calls one of the <code>selectionChanged</code>
+        * methods depending on the type of the passed selection.
+        * 
+        * @param selection the selection this action is working on
+        */
+       public void update(ISelection selection) {
+               dispatchSelectionChanged(selection);
+       }
+
+       /**
+        * Notifies this action that the given structured selection has changed. This default
+        * implementation calls <code>selectionChanged(ISelection selection)</code>.
+        * 
+        * @param selection the new selection
+        */
+       protected void selectionChanged(IStructuredSelection selection) {
+               selectionChanged((ISelection)selection);
+       }
+
+       /**
+        * Executes this actions with the given structured selection. This default implementation
+        * calls <code>run(ISelection selection)</code>.
+        */
+       protected void run(IStructuredSelection selection) {
+               run((ISelection)selection);
+       }
+       
+       /**
+        * Notifies this action that the given text selection has changed.  This default
+        * implementation calls <code>selectionChanged(ISelection selection)</code>.
+        * 
+        * @param selection the new selection
+        */
+       protected void selectionChanged(ITextSelection selection) {
+               selectionChanged((ISelection)selection);
+       }
+       
+       /**
+        * Executes this actions with the given text selection. This default implementation
+        * calls <code>run(ISelection selection)</code>.
+        */
+       protected void run(ITextSelection selection) {
+               run((ISelection)selection);
+       }
+       
+       /**
+        * Notifies this action that the given selection has changed.  This default
+        * implementation sets the action's enablement state to <code>false</code>.
+        * 
+        * @param selection the new selection
+        */
+       protected void selectionChanged(ISelection selection) {
+               setEnabled(false);
+       }
+       
+       /**
+        * Executes this actions with the given selection. This default implementation
+        * does nothing.
+        */
+       protected void run(ISelection selection) {
+       }
+
+       /* (non-Javadoc)
+        * Method declared on IAction.
+        */
+       public void run() {
+               dispatchRun(getSelection());
+       }
+       
+       /* (non-Javadoc)
+        * Method declared on ISelectionChangedListener.
+        */
+       public void selectionChanged(SelectionChangedEvent event) {
+               dispatchSelectionChanged(event.getSelection());
+       }
+
+       private void dispatchSelectionChanged(ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       selectionChanged((IStructuredSelection)selection);
+               } else if (selection instanceof ITextSelection) {
+                       selectionChanged((ITextSelection)selection);
+               } else {
+                       selectionChanged(selection);
+               }
+       }
+
+       private void dispatchRun(ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       run((IStructuredSelection)selection);
+               } else if (selection instanceof ITextSelection) {
+                       run((ITextSelection)selection);
+               } else {
+                       run(selection);
+               }
+       }
+}
\ No newline at end of file
index 6a4051e..c44cc36 100644 (file)
@@ -35,6 +35,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
  * The main plugin class to be used in the desktop.
  */
 public interface IPreferenceConstants {
+  
        public static final String LOCALHOST_PREF = "_localhost"; //$NON-NLS-1$
        public static final String DOCUMENTROOT_PREF = "_documentroot"; //$NON-NLS-1$
        public static final String USE_EXTERNAL_BROWSER_PREF = "_use_external_browser"; //$NON-NLS-1$
@@ -66,6 +67,9 @@ public interface IPreferenceConstants {
   /** Preference key for the foreground color of the line numbers */
   public final static String LINE_NUMBER_COLOR= "_lineNumberColor"; //$NON-NLS-1$
   
+  public final static String FORMATTER_TAB_SIZE= "_formatterTabSize"; //$NON-NLS-1$
+  public final static String SPACES_FOR_TABS = "false";
+  
   public final static String PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT = "_defaultBackgroundColor"; //$NON-NLS-1$
   public final static String PREFERENCE_COLOR_BACKGROUND = "backgroundColor"; //$NON-NLS-1$
   
index 6b508d2..cc41bb1 100644 (file)
@@ -25,7 +25,7 @@ public class PHPPerspectiveFactory implements IPerspectiveFactory {
                
                consoleArea.addView(IPageLayout.ID_TASK_LIST);
     consoleArea.addView(IDebugUIConstants.ID_CONSOLE_VIEW);
-    consoleArea.addPlaceholder(IPageLayout.ID_BOOKMARKS);
+    consoleArea.addView(IPageLayout.ID_BOOKMARKS);
     
     layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, (float)0.75, editorArea);
     
@@ -38,6 +38,7 @@ public class PHPPerspectiveFactory implements IPerspectiveFactory {
     // views - standard workbench
     layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
     layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
+    layout.addShowViewShortcut(IPageLayout.ID_BOOKMARKS);
     
     // new actions - PHP project creation wizards
     layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
index feb1c44..15c4c7a 100644 (file)
@@ -64,7 +64,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
   //The shared instance.
   private static PHPeclipsePlugin plugin;
   //Resource bundle.
-  private ResourceBundle resourceBundle;
+  //private ResourceBundle resourceBundle;
 
   private ImageDescriptorRegistry fImageDescriptorRegistry;
   private PHPDocumentProvider fCompilationUnitDocumentProvider;
@@ -100,11 +100,11 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     super(descriptor);
     plugin = this;
     setJVM();
-    try {
-      resourceBundle = ResourceBundle.getBundle("net.sourceforge.PHPeclipsePluginResources");
-    } catch (MissingResourceException x) {
-      resourceBundle = null;
-    }
+//    try {
+//      resourceBundle = ResourceBundle.getBundle("net.sourceforge.PHPeclipsePluginResources");
+//    } catch (MissingResourceException x) {
+//      resourceBundle = null;
+//    }
   }
 
   public static ImageDescriptorRegistry getImageDescriptorRegistry() {
@@ -229,21 +229,21 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
    * Returns the string from the plugin's resource bundle,
    * or 'key' if not found.
    */
-  public static String getResourceString(String key) {
-    ResourceBundle bundle = PHPeclipsePlugin.getDefault().getResourceBundle();
-    try {
-      return bundle.getString(key);
-    } catch (MissingResourceException e) {
-      return key;
-    }
-  }
+//  public static String getResourceString(String key) {
+//    ResourceBundle bundle = PHPeclipsePlugin.getDefault().getResourceBundle();
+//    try {
+//      return bundle.getString(key);
+//    } catch (MissingResourceException e) {
+//      return key;
+//    }
+//  }
 
   /**
    * Returns the plugin's resource bundle,
    */
-  public ResourceBundle getResourceBundle() {
-    return resourceBundle;
-  }
+//  public ResourceBundle getResourceBundle() {
+//    return resourceBundle;
+//  }
 
   protected void initializeDefaultPreferences(IPreferenceStore store) {
     // windows preferences:
@@ -284,6 +284,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     
     // show line numbers:
     store.setDefault(LINE_NUMBER_RULER, "false");
+    store.setDefault(FORMATTER_TAB_SIZE, "4");
     
     // php syntax highlighting
     PreferenceConverter.setDefault(store, PHP_MULTILINE_COMMENT, PHPColorProvider.MULTI_LINE_COMMENT);
index 84fdf1c..f90cf80 100644 (file)
@@ -12,23 +12,21 @@ Contributors:
     Klaus Hartlage - www.eclipseproject.de
 **********************************************************************/
 
-import java.util.ResourceBundle;
+import net.sourceforge.phpdt.ui.actions.*;
 import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.Separator;
 import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.editors.text.TextEditorActionContributor;
+import org.eclipse.ui.actions.ActionGroup;
 import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
 import org.eclipse.ui.texteditor.ITextEditor;
 import org.eclipse.ui.texteditor.RetargetTextEditorAction;
-import org.eclipse.ui.texteditor.TextEditorAction;
 
 /**
  * Contributes interesting PHP actions to the desktop's Edit menu and the toolbar.
  */
-public class PHPActionContributor extends BasicTextEditorActionContributor implements PHPEditorActionDefinitionIds {
+public class PHPActionContributor extends BasicTextEditorActionContributor   {
 
   protected RetargetTextEditorAction fContentAssistProposal;
   // protected RetargetTextEditorAction fContentAssistTip;
@@ -78,9 +76,15 @@ public class PHPActionContributor extends BasicTextEditorActionContributor imple
     //  fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$
 
     IActionBars bars = getActionBars();
-    bars.setGlobalActionHandler(COMMENT, getAction(textEditor, "Comment"));
-    bars.setGlobalActionHandler(UNCOMMENT, getAction(textEditor, "Uncomment"));
-
+    bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(textEditor, "Comment"));
+    bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment"));
+
+    if (part instanceof PHPEditor) {
+      PHPEditor cuEditor= (PHPEditor)part;
+      ActionGroup group= cuEditor.getActionGroup();
+      if (group != null)
+        group.fillActionBars(bars);
+    }
     //    fTogglePresentation.setEditor(editor);
     //    fTogglePresentation.update();
 
@@ -92,9 +96,7 @@ public class PHPActionContributor extends BasicTextEditorActionContributor imple
    * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
    */
   public void setActiveEditor(IEditorPart part) {
-    super.setActiveEditor(part);
-    doSetActiveEditor(part);
-
+    doSetActiveEditor(part);   
   }
 
   /*
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionGroup.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionGroup.java
deleted file mode 100644 (file)
index cc4f0c3..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package net.sourceforge.phpeclipse.phpeditor;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.ui.actions.ActionGroup;
-
-public class PHPActionGroup extends ActionGroup {
-  protected PHPEditor editor;
-  protected String menuGroupId;
-
-  public PHPActionGroup(PHPEditor editor, String menuGroupId) {
-    this.editor = editor;
-    this.menuGroupId = menuGroupId;
-  }
-
-  public void fillContextMenu(IMenuManager menu) {
-    super.fillContextMenu(menu);
-
-    menu.add(editor.getAction("Comment"));
-    menu.add(editor.getAction("Uncomment"));
-  }
-}
index 2d0b71d..b3e4656 100644 (file)
@@ -11,6 +11,9 @@ Contributors:
     IBM Corporation - Initial implementation
     Klaus Hartlage - www.eclipseproject.de
 **********************************************************************/
+import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
+import net.sourceforge.phpdt.ui.actions.*;
+import net.sourceforge.phpdt.ui.actions.GenerateActionGroup;
 import net.sourceforge.phpeclipse.IPreferenceConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
@@ -37,6 +40,8 @@ import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionGroup;
 import org.eclipse.ui.editors.text.TextEditor;
 import org.eclipse.ui.texteditor.DefaultRangeIndicator;
 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
@@ -45,9 +50,9 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
 /**
  * PHP specific text editor.
  */
-public class PHPEditor extends TextEditor  {
+public class PHPEditor extends TextEditor {
 
-  protected PHPActionGroup actionGroup;
+  // protected PHPActionGroup fActionGroups;
   /** The outline page */
   private PHPContentOutlinePage fOutlinePage;
   private IPreferenceStore phpPrefStore;
@@ -55,13 +60,25 @@ public class PHPEditor extends TextEditor  {
   /** The line number ruler column */
   private LineNumberRulerColumn fLineNumberRulerColumn;
 
+  protected CompositeActionGroup fActionGroups;
+  /** The standard action groups added to the menu */
+  private GenerateActionGroup fGenerateActionGroup;
+  private CompositeActionGroup fContextMenuGroup;
   /**
    * Default constructor.
    */
   public PHPEditor() {
     super();
+    setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
   }
 
+  /**
+   *  Returns the standard action group of this editor.
+   */
+  protected ActionGroup getActionGroup() {
+    return fActionGroups;
+  } 
+  
   public PHPContentOutlinePage getfOutlinePage() {
     return fOutlinePage;
   }
@@ -95,11 +112,23 @@ public class PHPEditor extends TextEditor  {
     action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT);
     setAction("Uncomment", action);
 
-    actionGroup = new PHPActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
+  //  fActionGroups = new PHPActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
 
     markAsStateDependentAction("Comment", true); //$NON-NLS-1$
     markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
+
+    fGenerateActionGroup= new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
+
+    fActionGroups= new CompositeActionGroup(
+      new ActionGroup[] { fGenerateActionGroup }
+      );
+  
     
+    // We have to keep the context menu group separate to have better control over positioning
+    fContextMenuGroup= new CompositeActionGroup(new ActionGroup[] {
+      fGenerateActionGroup });
+//      rg, 
+//      new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT)});
   }
 
   /** The <code>PHPEditor</code> implementation of this 
@@ -110,6 +139,10 @@ public class PHPEditor extends TextEditor  {
     PHPEditorEnvironment.disconnect(this);
     if (fOutlinePage != null)
       fOutlinePage.setInput(null);
+      
+    if (fActionGroups != null)
+      fActionGroups.dispose();  
+      
     super.dispose();
   }
 
@@ -168,9 +201,20 @@ public class PHPEditor extends TextEditor  {
     super.editorContextMenuAboutToShow(menu);
     //  addAction(menu, "ContentAssistProposal"); //$NON-NLS-1$
     //  addAction(menu, "ContentAssistTip"); //$NON-NLS-1$
-    actionGroup.fillContextMenu(menu);
+    
+    // fActionGroups.fillContextMenu(menu);
+    
+    ActionContext context= new ActionContext(getSelectionProvider().getSelection());
+    fContextMenuGroup.setContext(context);
+    fContextMenuGroup.fillContextMenu(menu);
+    fContextMenuGroup.setContext(null);
   }
 
+  protected void updateStateDependentActions() {
+    super.updateStateDependentActions();
+    fGenerateActionGroup.editorStateChanged();
+  }
+  
   /** The <code>PHPEditor</code> implementation of this 
    * <code>AbstractTextEditor</code> method performs gets
    * the java content outline page if request is for a an 
@@ -188,27 +232,27 @@ public class PHPEditor extends TextEditor  {
     return super.getAdapter(required);
   }
 
-//  public void openContextHelp() {
-//    IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput());
-//    ITextSelection selection = (ITextSelection) this.getSelectionProvider().getSelection();
-//    int pos = selection.getOffset();
-//    String word = getFunctionName(doc, pos);
-//    openContextHelp(word);
-//  }
-//
-//  private void openContextHelp(String word) {
-//    open(word);
-//  }
-//
-//  public static void open(String word) {
-//    IHelp help = WorkbenchHelp.getHelpSupport();
-//    if (help != null) {
-//      IHelpResource helpResource = new PHPFunctionHelpResource(word);
-//      WorkbenchHelp.getHelpSupport().displayHelpResource(helpResource);
-//    } else {
-//      //   showMessage(shell, dialogTitle, ActionMessages.getString("Open help not available"), false); //$NON-NLS-1$
-//    }
-//  }
+  //  public void openContextHelp() {
+  //    IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput());
+  //    ITextSelection selection = (ITextSelection) this.getSelectionProvider().getSelection();
+  //    int pos = selection.getOffset();
+  //    String word = getFunctionName(doc, pos);
+  //    openContextHelp(word);
+  //  }
+  //
+  //  private void openContextHelp(String word) {
+  //    open(word);
+  //  }
+  //
+  //  public static void open(String word) {
+  //    IHelp help = WorkbenchHelp.getHelpSupport();
+  //    if (help != null) {
+  //      IHelpResource helpResource = new PHPFunctionHelpResource(word);
+  //      WorkbenchHelp.getHelpSupport().displayHelpResource(helpResource);
+  //    } else {
+  //      //   showMessage(shell, dialogTitle, ActionMessages.getString("Open help not available"), false); //$NON-NLS-1$
+  //    }
+  //  }
 
   private String getFunctionName(IDocument doc, int pos) {
     Point word = PHPWordExtractor.findWord(doc, pos);
@@ -291,7 +335,10 @@ public class PHPEditor extends TextEditor  {
     IVerticalRuler v = getVerticalRuler();
     if (v instanceof CompositeRuler) {
       CompositeRuler c = (CompositeRuler) v;
-      c.removeDecorator(1);
+      try {
+        c.removeDecorator(1);
+      } catch (Throwable e) {
+      }
     }
   }
 
index fe08e43..5c0e7b1 100644 (file)
@@ -11,12 +11,16 @@ Contributors:
 **********************************************************************/
 package net.sourceforge.phpeclipse.phpeditor;
 
+import java.util.Vector;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.DefaultAutoIndentStrategy;
 import org.eclipse.jface.text.IAutoIndentStrategy;
 import org.eclipse.jface.text.IDocument;
@@ -100,11 +104,19 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
   /* (non-Javadoc)
    * Method declared on SourceViewerConfiguration
    */
-  public String getDefaultPrefix(ISourceViewer sourceViewer, String contentType) {
-    return (PHPPartitionScanner.PHP.equals(contentType) ? "//" : null); //$NON-NLS-1$
-    // return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" : null); //$NON-NLS-1$
+//  public String getDefaultPrefix(ISourceViewer sourceViewer, String contentType) {
+//    return (PHPPartitionScanner.PHP.equals(contentType) ? "//" : null); //$NON-NLS-1$
+//    // return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" : null); //$NON-NLS-1$
+//  }
+
+  /*
+   * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
+   * @since 2.0
+   */
+  public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) {
+    return new String[] { "//", "" }; //$NON-NLS-1$ //$NON-NLS-2$
   }
-
+  
   /* (non-Javadoc)
    * Method declared on SourceViewerConfiguration
    */
@@ -115,10 +127,48 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
   /* (non-Javadoc)
    * Method declared on SourceViewerConfiguration
    */
+//  public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
+//    return new String[] { "\t", "    " }; //$NON-NLS-1$ //$NON-NLS-2$
+//  }
+
+  /*
+   * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
+   */
   public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
-    return new String[] { "\t", "    " }; //$NON-NLS-1$ //$NON-NLS-2$
-  }
 
+    Vector vector= new Vector();
+
+    // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
+        
+    final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+
+    int tabWidth= store.getInt(PHPeclipsePlugin.FORMATTER_TAB_SIZE);
+    boolean useSpaces= store.getBoolean(PHPeclipsePlugin.SPACES_FOR_TABS);
+    
+    for (int i= 0; i <= tabWidth; i++) {
+        StringBuffer prefix= new StringBuffer();
+
+      if (useSpaces) {
+          for (int j= 0; j + i < tabWidth; j++)
+            prefix.append(' ');
+          
+        if (i != 0)
+            prefix.append('\t');        
+      } else {    
+          for (int j= 0; j < i; j++)
+            prefix.append(' ');
+          
+        if (i != tabWidth)
+            prefix.append('\t');
+      }
+      
+      vector.add(prefix.toString());
+    }
+
+    vector.add(""); //$NON-NLS-1$
+    
+    return (String[]) vector.toArray(new String[vector.size()]);
+  }
   /* (non-Javadoc)
    * Method declared on SourceViewerConfiguration
    */
index 8c0d37a..160925c 100644 (file)
@@ -161,10 +161,15 @@ public class PHPCodeScanner extends RuleBasedScanner implements IPreferenceConst
 //    //for (int i = 0; i < PHPFunctionNames.FUNCTION_NAMES.length; i++)
 //    //  wordRule.addWord(PHPFunctionNames.FUNCTION_NAMES[i], functionName);
 //    //<--choochter
-    for (int i = 0; i < PHPFunctionNames.FUNCTION_NAMES.length; i++)
+    for (int i = 0; i < PHPKeywords.PHP_KEYWORS.length; i++) {
+      wordRule.addWord(PHPKeywords.PHP_KEYWORS[i], keyword);
+    }
+    for (int i = 0; i < PHPFunctionNames.FUNCTION_NAMES.length; i++) {
       wordRule.addWord(PHPFunctionNames.FUNCTION_NAMES[i], functionName);
-    for (int i = 0; i < fgConstants.length; i++)
-      wordRule.addWord(fgConstants[i], functionName);
+    }
+    for (int i = 0; i < fgConstants.length; i++) {
+      wordRule.addWord(fgConstants[i], keyword);
+    }
     rules.add(wordRule);
 
     IRule[] result = new IRule[rules.size()];
index 40e2fce..cfceb5e 100644 (file)
@@ -14,29 +14,26 @@ Contributors:
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.text.MessageFormat;
 
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.actions.PHPActionMessages;
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.Document;
 import org.eclipse.jface.text.TextViewer;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.part.ViewPart;
-import sun.security.krb5.internal.crypto.e;
 
 /**
  * The PHPConsole is used to display the output if you start MySQL/Apache
@@ -64,6 +61,29 @@ public class PHPConsole extends ViewPart {
     GridData viewerData = new GridData(GridData.FILL_BOTH);
     viewer.getControl().setLayoutData(viewerData);
     viewer.setEditable(false);
+    
+    StyledText widget = viewer.getTextWidget();
+    widget.setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
+    Action cutAction = new Action() {
+      public void run() {
+        viewer.getTextWidget().cut();
+      }
+    };
+    Action copyAction = new Action() {
+      public void run() {
+        viewer.getTextWidget().copy();
+      }
+    };
+    Action pasteAction = new Action() {
+      public void run() {
+        viewer.getTextWidget().paste();
+      }
+    };
+
+    IActionBars bars = this.getViewSite().getActionBars();
+    bars.setGlobalActionHandler(IWorkbenchActionConstants.CUT, cutAction);
+    bars.setGlobalActionHandler(IWorkbenchActionConstants.COPY, copyAction);
+    bars.setGlobalActionHandler(IWorkbenchActionConstants.PASTE, pasteAction);
   }
 
   /**