Fixed: 1760857 - Avoid refreshing the preview when phpeditor got focus.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / CompilationUnitEditorActionContributor.java
index 6eea5b8..b77af3e 100644 (file)
@@ -1,32 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation 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
+/***********************************************************************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation 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.phpeclipse.phpeditor;
 
 import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.ui.editor.ShowExternalPreviewAction;
 
 import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IFileEditorInput;
 import org.eclipse.ui.texteditor.ITextEditor;
 
-public class CompilationUnitEditorActionContributor
-               extends
-                       BasicEditorActionContributor {
-       protected ShowExternalPreviewAction fShowExternalPreviewAction;
+public class CompilationUnitEditorActionContributor extends
+               BasicEditorActionContributor {
        public CompilationUnitEditorActionContributor() {
                super();
-               fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
        }
 
        /*
@@ -49,12 +44,12 @@ public class CompilationUnitEditorActionContributor
                                getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
                bars.setGlobalActionHandler(PHPdtActionConstants.FORMAT, getAction(
                                textEditor, "Format")); //$NON-NLS-1$
-//             bars.setGlobalActionHandler(PHPdtActionConstants.ADD_BLOCK_COMMENT,
-//                             getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
-//             bars.setGlobalActionHandler(PHPdtActionConstants.REMOVE_BLOCK_COMMENT,
-//                             getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
-//             bars.setGlobalActionHandler(PHPdtActionConstants.INDENT, getAction(
-//                             textEditor, "Indent")); //$NON-NLS-1$ //$NON-NLS-2$
+               bars.setGlobalActionHandler(PHPdtActionConstants.ADD_BLOCK_COMMENT,
+                               getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.REMOVE_BLOCK_COMMENT,
+                               getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
+               // bars.setGlobalActionHandler(PHPdtActionConstants.INDENT, getAction(
+               // textEditor, "Indent")); //$NON-NLS-1$ //$NON-NLS-2$
 
                if (textEditor != null) {
                        IFile file = null;
@@ -66,13 +61,16 @@ public class CompilationUnitEditorActionContributor
 
                        PHPeclipsePlugin.getDefault().setLastEditorFile(file);
 
+                       ShowExternalPreviewAction fShowExternalPreviewAction = ShowExternalPreviewAction
+                                       .getInstance();
                        fShowExternalPreviewAction.setEditor(textEditor);
                        fShowExternalPreviewAction.update();
-                       IPreferenceStore store = PHPeclipsePlugin.getDefault()
-                                       .getPreferenceStore();
-                       IAction a = ShowExternalPreviewAction.getInstance();
-                       if (a != null)
-                               a.run();
+                       // if (fShowExternalPreviewAction != null) {
+                       // fShowExternalPreviewAction
+                       // .doRun(ShowExternalPreviewAction.PHP_TYPE);
+                       // }
+                       fShowExternalPreviewAction
+                                       .refresh(ShowExternalPreviewAction.PHP_TYPE);
                }
        }
 }
\ No newline at end of file