changes for new Action
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / PHPSyntaxEditorPreferencePage.java
index 22b06ff..7b9ba11 100644 (file)
@@ -7,8 +7,8 @@ import java.util.Map;
 import net.sourceforge.phpeclipse.preferences.ColorEditor;
 import net.sourceforge.phpeclipse.preferences.OverlayPreferenceStore;
 import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages;
+
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.preference.BooleanFieldEditor;
 import org.eclipse.jface.preference.FileFieldEditor;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.PreferenceConverter;
@@ -75,7 +75,27 @@ public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWo
       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_BOLD),
       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_ITALIC),
       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_UNDERLINE),
-      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_USERDEF_XMLFILE)};
+      
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_KEYWORD),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_KEYWORD_BOLD),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_KEYWORD_ITALIC),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_KEYWORD_UNDERLINE),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_TAG),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_TAG_BOLD),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_TAG_ITALIC),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_TAG_UNDERLINE),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_LINK),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_LINK_BOLD),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_LINK_ITALIC),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_LINK_UNDERLINE),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHPDOC_DEFAULT),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_DEFAULT_BOLD),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_DEFAULT_ITALIC),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHPDOC_DEFAULT_UNDERLINE),
+      
+      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_USERDEF_XMLFILE),
+  //    new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_EDITOR_BACKGROUND)
+  };
 
   private final String[][] SyntaxColorListModel =
     new String[][] {
@@ -92,7 +112,11 @@ public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWo
       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.functions"), IPreferenceConstants.PHP_FUNCTIONNAME }, {
       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.constants"), IPreferenceConstants.PHP_CONSTANT }, {
       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.strings"), IPreferenceConstants.PHP_STRING }, {
-      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.others"), IPreferenceConstants.PHP_DEFAULT }
+      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.others"), IPreferenceConstants.PHP_DEFAULT }, {
+                       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_keywords"), IPreferenceConstants.PHPDOC_KEYWORD }, {
+                       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_tags"), IPreferenceConstants.PHPDOC_TAG }, {
+                       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_links"), IPreferenceConstants.PHPDOC_LINK }, {
+                       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_others"), IPreferenceConstants.PHPDOC_DEFAULT }
   };
 
   private OverlayPreferenceStore OverlayStore;
@@ -118,11 +142,15 @@ public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWo
   };
 
   private List SyntaxColorList;
+  /** The ColorEditor that choose the foreground color. */
   private ColorEditor SyntaxForegroundColorEditor;
   private Button BoldCheckBox;
   private Button ItalicCheckBox;
   private Button UnderlineCheckBox;
   private FileFieldEditor userdefPHPSyntaxFileFFE;
+  // private BooleanFieldEditor showLineNumber;
+  // private IntegerFieldEditor formatterTabSize;
+  // private BooleanFieldEditor spacesForTabs;
 
   public PHPSyntaxEditorPreferencePage() {
     setDescription(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.description")); //$NON-NLS-1$
@@ -147,6 +175,38 @@ public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWo
     UnderlineCheckBox.setSelection(OverlayStore.getBoolean(key + "_underline"));
   }
 
+  /**
+   * Create the group of options for other parameters (background color for example).
+   * @param parent the parent component
+   */
+  private void backgroundOptionPage(Composite parent) {
+    Label label = new Label(parent, SWT.LEFT);
+    label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.color")); //$NON-NLS-1$
+    GridData gd = new GridData();
+    gd.horizontalAlignment = GridData.BEGINNING;
+    label.setLayoutData(gd);
+//    final ColorEditor syntaxBackgroundColorEditor = new ColorEditor(parent);
+//    RGB rgb = PreferenceConverter.getColor(OverlayStore, IPreferenceConstants.PHP_EDITOR_BACKGROUND);
+//    syntaxBackgroundColorEditor.setColorValue(rgb);
+//    Button backgroundColorButton = syntaxBackgroundColorEditor.getButton();
+//    gd = new GridData(GridData.FILL_HORIZONTAL);
+//    gd.horizontalAlignment = GridData.BEGINNING;
+//    backgroundColorButton.setLayoutData(gd);
+//    backgroundColorButton.addSelectionListener(new SelectionListener() {
+//      public void widgetDefaultSelected(SelectionEvent e) {
+//        // do nothing
+//      }
+//      public void widgetSelected(SelectionEvent e) {
+//        PreferenceConverter.setValue(OverlayStore, IPreferenceConstants.PHP_EDITOR_BACKGROUND, syntaxBackgroundColorEditor.getColorValue());
+//      }
+//    });
+  }
+
+  /**
+   * Create the group of options for the syntax parameters.
+   * @param parent the parent component
+   * @return
+   */
   private Control createSyntaxPage(Composite parent) {
 
     Composite colorComposite = new Composite(parent, SWT.NULL);
@@ -196,7 +256,7 @@ public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWo
     gd.horizontalAlignment = GridData.BEGINNING;
     gd.horizontalSpan = 2;
     BoldCheckBox.setLayoutData(gd);
-    
+
     ItalicCheckBox = new Button(stylesComposite, SWT.CHECK);
     ItalicCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.italic")); //$NON-NLS-1$
     ItalicCheckBox.setEnabled(false);
@@ -204,7 +264,7 @@ public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWo
     gd.horizontalAlignment = GridData.BEGINNING;
     gd.horizontalSpan = 2;
     ItalicCheckBox.setLayoutData(gd);
-    
+
     UnderlineCheckBox = new Button(stylesComposite, SWT.CHECK);
     UnderlineCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.underline")); //$NON-NLS-1$
     UnderlineCheckBox.setEnabled(false);
@@ -353,8 +413,37 @@ public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWo
     syntaxGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
     syntaxGroup.setLayout(layout);
     createSyntaxPage(syntaxGroup);
-    
+
+    Composite backgroundOptions = new Composite(composite,SWT.NULL);
+    backgroundOptions.setLayout(new GridLayout());
+    layout = new GridLayout();
+    layout.numColumns = 3;
+    Group backgroundOptionsGroup = new Group(backgroundOptions,SWT.NONE);
+    backgroundOptionsGroup.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.background"));
+    backgroundOptionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+    backgroundOptionsGroup.setLayout(layout);
+    backgroundOptionPage(backgroundOptionsGroup);
+
     initialize();
+    
+   
+//    showLineNumber = new BooleanFieldEditor(PHPeclipsePlugin.LINE_NUMBER_RULER, 
+//    "Show line numbers", composite);
+//    showLineNumber.setPreferencePage(this);
+//    showLineNumber.setPreferenceStore(getPreferenceStore());
+//    showLineNumber.load();
+    
+//    formatterTabSize = new IntegerFieldEditor(PHPeclipsePlugin.FORMATTER_TAB_SIZE, 
+//    "Displayed tab width", composite, 3);
+//    formatterTabSize.setPreferencePage(this);
+//    formatterTabSize.setPreferenceStore(getPreferenceStore());
+//    formatterTabSize.load();
+//    
+//    spacesForTabs = new BooleanFieldEditor(PHPeclipsePlugin.SPACES_FOR_TABS, 
+//    "Spaces for Tabs", composite);
+//    spacesForTabs.setPreferencePage(this);
+//    spacesForTabs.setPreferenceStore(getPreferenceStore());
+//    spacesForTabs.load();
     return composite;
   }
 
@@ -395,6 +484,9 @@ public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWo
     IPreferenceStore store = getPreferenceStore();
     PHPeclipsePlugin.getDefault().savePluginPreferences();
     userdefPHPSyntaxFileFFE.store();
+   // showLineNumber.store();
+   // spacesForTabs.store();
+   // formatterTabSize.store();
     return true;
   }
 
@@ -403,6 +495,10 @@ public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWo
     initializeFields();
     handleSyntaxColorListSelection();
     userdefPHPSyntaxFileFFE.loadDefault();
+  //  showLineNumber.loadDefault();
+  //  spacesForTabs.loadDefault();
+  //  showLineNumber.loadDefault();
+  //  formatterTabSize.loadDefault();
     super.performDefaults();
   }