bug fix 1402152 http://sourceforge.net/tracker/index.php?func=detail&aid=1402152...
authorbananeweizen <bananeweizen>
Sun, 15 Jan 2006 15:00:34 +0000 (15:00 +0000)
committerbananeweizen <bananeweizen>
Sun, 15 Jan 2006 15:00:34 +0000 (15:00 +0000)
removed duplicate template page, cleaned template page, cleaned deprecated code

net.sourceforge.phpeclipse.ui/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaTemplatePreferencePage.java

index 37311ae..12e683a 100644 (file)
             class="net.sourceforge.phpeclipse.ui.preferences.EmptyPreferencePage"
             id="net.sourceforge.phpeclipse.ui.preferencePage">
       </page>
+<!-- removed templates page, because it also exists in net.sf.phpeclipse,
+     and has more features there
       <page
             name="Templates"
             category="net.sourceforge.phpeclipse.ui.preferencePage"
             class="net.sourceforge.phpeclipse.ui.templates.preferences.TemplatesPreferencePage"
             id="net.sourceforge.phpeclipse.ui.templates.preferences.TemplatesPreferencePage">
       </page>
+-->
       <page
             category="net.sourceforge.phpeclipse.ui.preferencePage"
             name="Project Defaults"
index 3ad0e25..9968a9d 100644 (file)
@@ -1,10 +1,10 @@
 /*******************************************************************************
  * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
+ * 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
  *******************************************************************************/
@@ -33,116 +33,124 @@ import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
 import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.texteditor.templates.TemplatePreferencePage;
 
-public class JavaTemplatePreferencePage extends TemplatePreferencePage implements IWorkbenchPreferencePage {
+public class JavaTemplatePreferencePage extends TemplatePreferencePage
+               implements IWorkbenchPreferencePage {
 
        private TemplateVariableProcessor fTemplateProcessor;
-       
+
        public JavaTemplatePreferencePage() {
                setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
                setTemplateStore(PHPeclipsePlugin.getDefault().getTemplateStore());
-               setContextTypeRegistry(PHPeclipsePlugin.getDefault().getTemplateContextRegistry());
-               fTemplateProcessor= new TemplateVariableProcessor();
+               setContextTypeRegistry(PHPeclipsePlugin.getDefault()
+                               .getTemplateContextRegistry());
+               fTemplateProcessor = new TemplateVariableProcessor();
        }
-       
+
        /*
         * @see PreferencePage#createControl(Composite)
         */
        public void createControl(Composite parent) {
                super.createControl(parent);
-               WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
+                               IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
        }
 
-
        /*
         * @see org.eclipse.jface.preference.IPreferencePage#performOk()
         */
        public boolean performOk() {
-               boolean ok= super.performOk();
+               boolean ok = super.performOk();
 
                PHPeclipsePlugin.getDefault().savePluginPreferences();
-               
+
                return ok;
        }
-       
+
        /*
         * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#getFormatterPreferenceKey()
         */
        protected String getFormatterPreferenceKey() {
                return PreferenceConstants.TEMPLATES_USE_CODEFORMATTER;
        }
-       
+
        /*
-        * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createTemplateEditDialog(org.eclipse.jface.text.templates.Template, boolean, boolean)
+        * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createTemplateEditDialog(org.eclipse.jface.text.templates.Template,
+        *      boolean, boolean)
         */
-       protected Dialog createTemplateEditDialog(Template template, boolean edit, boolean isNameModifiable) {
-               return new EditTemplateDialog(getShell(), template, edit, isNameModifiable, getContextTypeRegistry());
+       protected Dialog createTemplateEditDialog(Template template, boolean edit,
+                       boolean isNameModifiable) {
+               return new EditTemplateDialog(getShell(), template, edit,
+                               isNameModifiable, getContextTypeRegistry());
        }
-       
-       
+
        /*
         * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createViewer(org.eclipse.swt.widgets.Composite)
         */
        protected SourceViewer createViewer(Composite parent) {
-               Label label= new Label(parent, SWT.NONE);
-               label.setText(PreferencesMessages.getString("CodeTemplateBlock.preview")); //$NON-NLS-1$
-               GridData data= new GridData();
-               label.setLayoutData(data);
-               
-               IDocument document= new Document();
-               JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
-               tools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
-               IPreferenceStore store= PHPeclipsePlugin.getDefault().getCombinedPreferenceStore();
-               SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
-               TemplateEditorSourceViewerConfiguration configuration= new TemplateEditorSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
+               GridData data = new GridData();
+               IDocument document = new Document();
+               JavaTextTools tools = PHPeclipsePlugin.getDefault().getJavaTextTools();
+               tools.setupJavaDocumentPartitioner(document,
+                               IPHPPartitions.PHP_PARTITIONING);
+               IPreferenceStore store = PHPeclipsePlugin.getDefault()
+                               .getCombinedPreferenceStore();
+               SourceViewer viewer = new JavaSourceViewer(parent, null, null, false,
+                               SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
+               TemplateEditorSourceViewerConfiguration configuration = new TemplateEditorSourceViewerConfiguration(
+                               tools.getColorManager(), store, null, fTemplateProcessor);
                viewer.configure(configuration);
                viewer.setEditable(false);
                viewer.setDocument(document);
-       
-               Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+
+               Font font = JFaceResources
+                               .getFont(PreferenceConstants.EDITOR_TEXT_FONT);
                viewer.getTextWidget().setFont(font);
                new JavaSourcePreviewerUpdater(viewer, configuration, store);
-               
-               Control control= viewer.getControl();
-               data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
+
+               Control control = viewer.getControl();
+               data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+                               | GridData.FILL_VERTICAL);
                control.setLayoutData(data);
-               
+
                return viewer;
        }
-       
-       
+
        /*
         * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#updateViewerInput()
         */
        protected void updateViewerInput() {
-               IStructuredSelection selection= (IStructuredSelection) getTableViewer().getSelection();
-               SourceViewer viewer= getViewer();
-               
-               if (selection.size() == 1 && selection.getFirstElement() instanceof TemplatePersistenceData) {
-                       TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
-                       Template template= data.getTemplate();
-                       String contextId= template.getContextTypeId();
-                       TemplateContextType type= PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(contextId);
+               IStructuredSelection selection = (IStructuredSelection) getTableViewer()
+                               .getSelection();
+               SourceViewer viewer = getViewer();
+
+               if (selection.size() == 1
+                               && selection.getFirstElement() instanceof TemplatePersistenceData) {
+                       TemplatePersistenceData data = (TemplatePersistenceData) selection
+                                       .getFirstElement();
+                       Template template = data.getTemplate();
+                       String contextId = template.getContextTypeId();
+                       TemplateContextType type = PHPeclipsePlugin.getDefault()
+                                       .getTemplateContextRegistry().getContextType(contextId);
                        fTemplateProcessor.setContextType(type);
-                       
-                       IDocument doc= viewer.getDocument();
-                       
-                       String start= null;
+
+                       IDocument doc = viewer.getDocument();
+
+                       String start = null;
                        if ("javadoc".equals(contextId)) { //$NON-NLS-1$
-                               start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$
+                               start = "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$
                        } else
-                               start= ""; //$NON-NLS-1$
-                       
+                               start = ""; //$NON-NLS-1$
+
                        doc.set(start + template.getPattern());
-                       int startLen= start.length();
+                       int startLen = start.length();
                        viewer.setDocument(doc, startLen, doc.getLength() - startLen);
 
                } else {
                        viewer.getDocument().set(""); //$NON-NLS-1$
-               }               
+               }
        }
 }