icon="icons/obj16/phpedit.gif"
extensions="php"
contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
- class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
+ class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
id="net.sourceforge.phpeclipse.PHPEditor"
default="true">
</editor>
icon="icons/obj16/phpedit.gif"
extensions="php3"
contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
- class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
+ class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
id="net.sourceforge.phpeclipse.PHPEditor"
default="true">
</editor>
icon="icons/obj16/phpedit.gif"
extensions="php4"
contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
- class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
+ class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
id="net.sourceforge.phpeclipse.PHPEditor"
default="true">
</editor>
icon="icons/obj16/phpedit.gif"
extensions="inc"
contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
- class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
+ class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
id="net.sourceforge.phpeclipse.PHPEditor"
default="true">
</editor>
icon="icons/obj16/phpedit.gif"
extensions="phtml"
contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
- class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
+ class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
id="net.sourceforge.phpeclipse.PHPEditor"
default="true">
</editor>
icon="icons/obj16/htmledit.gif"
extensions="htm"
contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
- class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
+ class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
id="net.sourceforge.phpeclipse.PHPEditor"
default="true">
</editor>
icon="icons/obj16/htmledit.gif"
extensions="html"
contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
- class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
+ class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
id="net.sourceforge.phpeclipse.PHPEditor"
default="true">
</editor>
icon="icons/obj16/xmledit.gif"
extensions="xml"
contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
- class="net.sourceforge.phpeclipse.phpeditor.PHPEditor"
+ class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
id="net.sourceforge.phpeclipse.PHPEditor"
default="true">
</editor>
id="net.sourceforge.phpeclipse.preference.PHPEclipsePreferencePage">
</page>
<page
- name="Editor"
+ name="Editor2"
category="net.sourceforge.phpeclipse.preference.PHPEclipsePreferencePage"
class="net.sourceforge.phpeclipse.PHPSyntaxEditorPreferencePage"
id="net.sourceforge.phpeclipse.preference.PHPSyntaxEditorPreferencePage">
class="net.sourceforge.phpdt.internal.ui.preferences.CodeFormatterPreferencePage"
category="net.sourceforge.phpeclipse.preference.PHPEclipsePreferencePage">
</page>
+ <page
+ name="Editor"
+ id="net.sourceforge.phpeclipse.preference.PHPEditorPreferencePage"
+ class="net.sourceforge.phpdt.internal.ui.preferences.PHPEditorPreferencePage"
+ category="net.sourceforge.phpeclipse.preference.PHPEclipsePreferencePage">
+ </page>
<page
name="Language Settings"
category="net.sourceforge.phpeclipse.preference.PHPEclipsePreferencePage"
AddMethodStubAction.OverridesPrivateDialog.message=This will override the private method ''{0}'' from ''{1}''\nOK to continue?
AddMethodStubAction.ReplaceExistingDialog.message=This will replace the existing method ''{0}''.\nOK to continue?
-AddJavaDocStubAction.label=Add &Javadoc Comment
-AddJavaDocStubAction.description=Add a Javadoc comment stub to the member element
-AddJavaDocStubAction.tooltip=Add a Javadoc comment stub to the member element
+AddJavaDocStubAction.label=Add &PHPDoc Comment
+AddJavaDocStubAction.description=Add a PHPDoc comment stub to the member element
+AddJavaDocStubAction.tooltip=Add a PHPDoc comment stub to the member element
-AddJavaDocStubsAction.error.dialogTitle=Add Javadoc Comment
+AddJavaDocStubsAction.error.dialogTitle=Add PHPDoc Comment
AddJavaDocStubsAction.error.noWorkingCopy=Could not find working copy.
AddJavaDocStubsAction.error.memberNotExisting=Member has been removed in editor.
-AddJavaDocStubsAction.error.actionFailed=Error while adding Javadoc comment
+AddJavaDocStubsAction.error.actionFailed=Error while adding PHPDoc comment
AddUnimplementedMethodsAction.label=&Override Methods...
AddUnimplementedMethodsAction.description=Override Methods from super types.
NewJavaProjectPreferencePage.error.decode=Error while decoding JRE entry
-JavaEditorPreferencePage.updatesOnNextChangeIinEditor.label=Note: Updates on next change in the editor
-JavaEditorPreferencePage.problemIndicationTab.title=Problem Indi&cation
-
-JavaEditorPreferencePage.description=Java Editor settings:
-JavaEditorPreferencePage.font=Text Font:
-JavaEditorPreferencePage.multiLineComment=Multi-line comment
-JavaEditorPreferencePage.singleLineComment=Single-line comment
-JavaEditorPreferencePage.keywords=Keywords
-JavaEditorPreferencePage.strings=Strings
-JavaEditorPreferencePage.others=Others
-JavaEditorPreferencePage.javaDocKeywords=Javadoc keywords
-JavaEditorPreferencePage.javaDocHtmlTags=Javadoc HTML tags
-JavaEditorPreferencePage.javaDocLinks=Javadoc links
-JavaEditorPreferencePage.javaDocOthers=Javadoc others
-JavaEditorPreferencePage.backgroundColor=Background color
-JavaEditorPreferencePage.systemDefault=S&ystem Default
-JavaEditorPreferencePage.custom=C&ustom:
-JavaEditorPreferencePage.foreground=Fo®round:
-JavaEditorPreferencePage.color=C&olor:
-JavaEditorPreferencePage.bold=&Bold
-JavaEditorPreferencePage.preview=Preview:
-JavaEditorPreferencePage.textFont=Text &font:
-JavaEditorPreferencePage.displayedTabWidth=Displayed &tab width:
-JavaEditorPreferencePage.insertSpaceForTabs=&Insert space for tabs (see Formatting preferences)
-JavaEditorPreferencePage.showProblemsBeforeCompiling=Show problems before c&ompiling
-JavaEditorPreferencePage.showOverviewRuler=Show overview &ruler
-JavaEditorPreferencePage.highlightMatchingBrackets=Highlight &matching brackets
-JavaEditorPreferencePage.matchingBracketsHighlightColor=Matching &brackets highlight color:
-JavaEditorPreferencePage.highlightCurrentLine=Hi&ghlight current line
-JavaEditorPreferencePage.currentLineHighlightColor=Current &line highlight color:
-JavaEditorPreferencePage.highlightProblems=Highlight &problems
-JavaEditorPreferencePage.problemHighlightColor=Prob&lem highlight color:
-JavaEditorPreferencePage.showPrintMargin=Sho&w print margin
-JavaEditorPreferencePage.printMarginColor=Print m&argin color:
-JavaEditorPreferencePage.printMarginColumn=Print margin col&umn:
-JavaEditorPreferencePage.findScopeColor=F&ind Scope Color:
-JavaEditorPreferencePage.linkedPositionColor=Lin&ked Position Color:
-JavaEditorPreferencePage.insertSingleProposalsAutomatically=Insert single &proposals automatically
-JavaEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext=Show only proposals &visible in the invocation context
-JavaEditorPreferencePage.presentProposalsInAlphabeticalOrder=Present proposals in a&lphabetical order
-JavaEditorPreferencePage.enableAutoActivation=&Enable auto activation
-JavaEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName=Automatically add &import instead of qualified name
-JavaEditorPreferencePage.fillArgumentNamesOnMethodCompletion=&Fill argument names on method completion
-JavaEditorPreferencePage.autoActivationDelay=Auto activation dela&y:
-JavaEditorPreferencePage.autoActivationTriggersForJava=Auto activation &triggers for Java:
-JavaEditorPreferencePage.autoActivationTriggersForJavaDoc=Auto activation triggers for &Javadoc:
-JavaEditorPreferencePage.backgroundForCompletionProposals=&Background for completion proposals:
-JavaEditorPreferencePage.foregroundForCompletionProposals=&Foreground for completion proposals:
-JavaEditorPreferencePage.backgroundForMethodParameters=Bac&kground for method parameters:
-JavaEditorPreferencePage.foregroundForMethodParameters=Fo®round for method parameters:
-JavaEditorPreferencePage.general=Appeara&nce
-JavaEditorPreferencePage.colors=Synta&x
-JavaEditorPreferencePage.codeAssist=Code A&ssist
-JavaEditorPreferencePage.change=C&hange...
-JavaEditorPreferencePage.empty_input=Empty input
-JavaEditorPreferencePage.invalid_input=''{0}'' is not a valid input.
-JavaEditorPreferencePage.showLineNumbers=Show &line numbers
-JavaEditorPreferencePage.lineNumberColor=Line number foreground color:
-JavaEditorPreferencePage.lineNumberForegroundColor=Line number foreground
-JavaEditorPreferencePage.matchingBracketsHighlightColor2=Matching brackets highlight
-JavaEditorPreferencePage.currentLineHighlighColor=Current line highlight
-JavaEditorPreferencePage.problemsHighlightColor=Problems highlight
-JavaEditorPreferencePage.printMarginColor2=Print margin
-JavaEditorPreferencePage.findScopeColor2=Find scope
-JavaEditorPreferencePage.linkedPositionColor2=Linked position
-JavaEditorPreferencePage.showQuickFixables=&Indicate problems solvable with Quick Fix in vertical ruler
-JavaEditorPreferencePage.synchronizeOnCursor=Synchroni&ze outline selection on cursor move (editor must be reopened)
-JavaEditorPreferencePage.appearanceOptions=Appearance co&lor options:
+PHPEditorPreferencePage.updatesOnNextChangeIinEditor.label=Note: Updates on next change in the editor
+PHPEditorPreferencePage.problemIndicationTab.title=Problem Indi&cation
+PHPEditorPreferencePage.showQuickFixables=&Indicate problems solvable with Quick Fix in vertical ruler
+PHPEditorPreferencePage.description=PHP Editor settings:
+PHPEditorPreferencePage.font=Text Font:
+PHPEditorPreferencePage.multiLineComment=Multi-line comment
+PHPEditorPreferencePage.singleLineComment=Single-line comment
+PHPEditorPreferencePage.keywords=Keywords
+PHPEditorPreferencePage.strings=Strings
+PHPEditorPreferencePage.others=Others
+PHPEditorPreferencePage.phpDocKeywords=PHPDoc keywords
+PHPEditorPreferencePage.phpDocHtmlTags=PHPDoc HTML tags
+PHPEditorPreferencePage.phpDocLinks=PHPDoc links
+PHPEditorPreferencePage.phpDocOthers=PHPDoc others
+PHPEditorPreferencePage.backgroundColor=Background color
+PHPEditorPreferencePage.systemDefault=S&ystem Default
+PHPEditorPreferencePage.custom=C&ustom:
+PHPEditorPreferencePage.foreground=Fo®round:
+PHPEditorPreferencePage.color=C&olor:
+PHPEditorPreferencePage.bold=&Bold
+PHPEditorPreferencePage.preview=Preview:
+PHPEditorPreferencePage.textFont=Text &font:
+PHPEditorPreferencePage.displayedTabWidth=Displayed &tab width:
+PHPEditorPreferencePage.insertSpaceForTabs=Ins&ert space for tabs (see Code Formatter preference page)
+PHPEditorPreferencePage.showOverviewRuler=Show overview &ruler
+PHPEditorPreferencePage.highlightMatchingBrackets=Highlight &matching brackets
+PHPEditorPreferencePage.matchingBracketsHighlightColor=Matching &brackets highlight color:
+PHPEditorPreferencePage.highlightCurrentLine=Hi&ghlight current line
+PHPEditorPreferencePage.currentLineHighlightColor=Current &line highlight color:
+PHPEditorPreferencePage.showPrintMargin=Sho&w print margin
+PHPEditorPreferencePage.printMarginColor=Print m&argin color:
+PHPEditorPreferencePage.printMarginColumn=Print margin col&umn:
+PHPEditorPreferencePage.findScopeColor=F&ind Scope Color:
+PHPEditorPreferencePage.linkedPositionColor=Lin&ked Position Color:
+PHPEditorPreferencePage.insertSingleProposalsAutomatically=Insert single &proposals automatically
+PHPEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext=Show only proposals &visible in the invocation context
+PHPEditorPreferencePage.presentProposalsInAlphabeticalOrder=Present proposals in a&lphabetical order
+PHPEditorPreferencePage.enableAutoActivation=&Enable auto activation
+PHPEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName=Automatically add &import instead of qualified name
+PHPEditorPreferencePage.insertCompletion=&Insert completion
+PHPEditorPreferencePage.fillArgumentNamesOnMethodCompletion=&Fill argument names on method completion
+PHPEditorPreferencePage.guessArgumentNamesOnMethodCompletion=&Guess filled argument names
+PHPEditorPreferencePage.autoActivationDelay=Auto activation dela&y:
+PHPEditorPreferencePage.autoActivationTriggersForPHP=Auto activation &triggers for PHP:
+PHPEditorPreferencePage.autoActivationTriggersForPHPDoc=Auto activation triggers for &PHPDoc:
+PHPEditorPreferencePage.backgroundForCompletionProposals=&Background for completion proposals:
+PHPEditorPreferencePage.foregroundForCompletionProposals=&Foreground for completion proposals:
+PHPEditorPreferencePage.backgroundForMethodParameters=Bac&kground for method parameters:
+PHPEditorPreferencePage.foregroundForMethodParameters=Fo®round for method parameters:
+PHPEditorPreferencePage.backgroundForCompletionReplacement=Back&ground for completion replacement:
+PHPEditorPreferencePage.foregroundForCompletionReplacement=Foregr&ound for completion replacement:
+PHPEditorPreferencePage.general=Appeara&nce
+PHPEditorPreferencePage.colors=Synta&x
+PHPEditorPreferencePage.codeAssist=Code A&ssist
+PHPEditorPreferencePage.change=C&hange...
+PHPEditorPreferencePage.empty_input=Empty input
+PHPEditorPreferencePage.invalid_input=''{0}'' is not a valid input.
+PHPEditorPreferencePage.showLineNumbers=Show lin&e numbers
+PHPEditorPreferencePage.lineNumberColor=Line number foreground color:
+PHPEditorPreferencePage.lineNumberForegroundColor=Line number foreground
+PHPEditorPreferencePage.matchingBracketsHighlightColor2=Matching brackets highlight
+PHPEditorPreferencePage.currentLineHighlighColor=Current line highlight
+PHPEditorPreferencePage.printMarginColor2=Print margin
+PHPEditorPreferencePage.findScopeColor2=Find scope
+PHPEditorPreferencePage.linkedPositionColor2=Linked position
+PHPEditorPreferencePage.linkColor2=Link
+PHPEditorPreferencePage.synchronizeOnCursor=Synchroni&ze outline selection on cursor move (editor must be reopened)
+PHPEditorPreferencePage.appearanceOptions=Appearance co&lor options:
+PHPEditorPreferencePage.behaviourTab.title=Be&havior
+PHPEditorPreferencePage.closeStrings=Automatically close str&ings
+PHPEditorPreferencePage.closeBrackets=Automatically close &brackets and parenthesis
+PHPEditorPreferencePage.closeBraces=Automatically close bra&ces
+PHPEditorPreferencePage.closeJavaDocs=Automatically close Java&Docs and comments
+PHPEditorPreferencePage.wrapStrings=Smart Java stri&ng wrapping
+PHPEditorPreferencePage.addJavaDocTags=Automatically add JavaDoc &tags
+PHPEditorPreferencePage.formatJavaDocs=Automatically format &JavaDocs and multi-line comments
+PHPEditorPreferencePage.smartPaste= Sma&rt pasting for correct indentation
+PHPEditorPreferencePage.smartHomeEnd= S&mart cursor positioning at line start and end
+PHPEditorPreferencePage.hoverTab.title= Ho&vers
JavaElementInfoPage.binary=binary
JavaElementInfoPage.variable_path=Variable path:
JavaElementInfoPage.location=Location:
-JavadocConfigurationPropertyPage.IsPackageFragmentRoot.description=Specify the location (URL) of the documentation generated by Javadoc. The Javadoc location will contain a file called 'package-list'. For example: \'http://www.sample-url.org/doc/\'
-JavadocConfigurationPropertyPage.IsIncorrectElement.description=Javadoc location can only be attached to JAR files in projects or Java projects
-JavadocConfigurationPropertyPage.IsJavaProject.description=Specify the location (URL) of the project\'s Javadoc documentation. This location is used by the Javadoc export wizard as default value and by the \'Open External Javadoc\' action. For example: \'file://c:/myworkspace/myproject/doc/\'.
+JavadocConfigurationPropertyPage.IsPackageFragmentRoot.description=Specify the location (URL) of the documentation generated by PHPDoc. The Javadoc location will contain a file called 'package-list'. For example: \'http://www.sample-url.org/doc/\'
+JavadocConfigurationPropertyPage.IsIncorrectElement.description=PHPDoc location can only be attached to JAR files in projects or Java projects
+JavadocConfigurationPropertyPage.IsJavaProject.description=Specify the location (URL) of the project\'s PHPDoc documentation. This location is used by the PHPDoc export wizard as default value and by the \'Open External PHPDoc\' action. For example: \'file://c:/myworkspace/myproject/doc/\'.
-JavadocConfigurationBlock.location.label=Javadoc &Location:
+JavadocConfigurationBlock.location.label=PHPDoc &Location:
JavadocConfigurationBlock.location.button=Bro&wse...
JavadocConfigurationBlock.error.invalidurl=Not a valid URL: {0}
JavadocConfigurationBlock.error.notafolder=Location does not exist.
JavadocConfigurationBlock.warning.packagelistnotfound=Location does not contain file 'package-list'.
-JavadocConfigurationBlock.javadocLocationDialog.label=Javadoc Location Selection
-JavadocConfigurationBlock.javadocLocationDialog.message=&Select Javadoc location:
+JavadocConfigurationBlock.javadocLocationDialog.label=PHPDoc Location Selection
+JavadocConfigurationBlock.javadocLocationDialog.message=&Select PHPDoc location:
JavadocConfigurationBlock.MalformedURL.error=Invalid URL
JavadocConfigurationBlock.InvalidLocation.message= Location is invalid. Location contains neither the file \'package-list\' nor \'index.html'.
JavadocConfigurationBlock.ValidLocation.message= Location is valid. Files \'package-list\' and \'index.html\' found. Click OK to open in browser.
JavadocConfigurationBlock.UnableToValidateLocation.message=Unable to validate location
-JavadocConfigurationBlock.MessageDialog.title=Validating Javadoc Location
+JavadocConfigurationBlock.MessageDialog.title=Validating PHPDoc Location
JavadocConfigurationBlock.EmptyJavadocLocation.warning=Enter a javadoc location
-JavadocPreferencePage.description=Specify the location of the Javadoc command to be used by the Javadoc export wizard. Location must be an absolute path.
-JavadocPreferencePage.command.label=&Javadoc command:
+JavadocPreferencePage.description=Specify the location of the PHPDoc command to be used by the PHPDoc export wizard. Location must be an absolute path.
+JavadocPreferencePage.command.label=&PHPDoc command:
JavadocPreferencePage.command.button=Bro&wse...
-JavadocPreferencePage.error.notexists=Javadoc command does not exist
+JavadocPreferencePage.error.notexists=PHPDoc command does not exist
-JavadocPreferencePage.browsedialog.title=Javadoc Command Selection
+JavadocPreferencePage.browsedialog.title=PHPDoc Command Selection
SourceAttachmentPropertyPage.error.title=Error Attaching Source
SourceAttachmentPropertyPage.error.message=An error occurred while associating the source
CodeGenerationPreferencePage.gettersetter.suffix.list=S&uffix list (comma separated):
CodeGenerationPreferencePage.comments.label=Comments Creation:
-CodeGenerationPreferencePage.javadoc_comment.label=Create &Javadoc comments for methods and types (template 'typecomment')
-CodeGenerationPreferencePage.see_comment.label=Create &non-Javadoc comments for overridden methods
+CodeGenerationPreferencePage.javadoc_comment.label=Create &PHPDoc comments for methods and types (template 'typecomment')
+CodeGenerationPreferencePage.see_comment.label=Create &non-PHPDoc comments for overridden methods
CodeGenerationPreferencePage.file_comment.label=Create &file comments for new files (template 'filecomment')
CodeGenerationPreferencePage.gettersetter.error.emptyprefix=Prefix strings can not contain an empty entry.
TypeInfoLabelProvider.default_package=(default package)
TypeInfoLabelProvider.dash=\ -
-JavaUIHelp.link.label=Javadoc for {0}
+JavaUIHelp.link.label=PHPDoc for {0}
#########
# DnD
+<?php
{
if (size < currentSize) {
--size;
}
-}
\ No newline at end of file
+}
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * This is about <code>ClassName</code>.
+ * {@link com.yourCompany.aPackage.SuperClass}
+ * @author author
+ */
+class ClassName extends SuperClass {
+ /* This comment may span multiple lines. */
+ $integer= 0;
+ // This comment may span only this line
+ $string= "zero";
+}
+?>
\ No newline at end of file
import net.sourceforge.phpdt.internal.ui.dialog.StatusInfo;
import net.sourceforge.phpdt.internal.ui.text.template.TemplateVariableProcessor;
import net.sourceforge.phpdt.internal.ui.util.SWTUtil;
+import net.sourceforge.phpdt.ui.text.JavaTextTools;
import net.sourceforge.phpeclipse.IPreferenceConstants;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.ITextViewer;
private final IContentAssistProcessor fProcessor;
// SimpleJavaSourceViewerConfiguration(JavaTextTools tools, ITextEditor editor, IContentAssistProcessor processor) {
- SimpleJavaSourceViewerConfiguration(IContentAssistProcessor processor) {
- super(null);
+ SimpleJavaSourceViewerConfiguration(JavaTextTools tools, IContentAssistProcessor processor) {
+ super(tools, null);
fProcessor= processor;
}
private SourceViewer createEditor(Composite parent) {
SourceViewer viewer= new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- // JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
+ JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
IDocument document= new Document(fTemplate.getPattern());
- // IDocumentPartitioner partitioner= tools.createDocumentPartitioner();
- // document.setDocumentPartitioner(partitioner);
- // partitioner.connect(document);
+ IDocumentPartitioner partitioner= tools.createDocumentPartitioner();
+ document.setDocumentPartitioner(partitioner);
+ partitioner.connect(document);
// viewer.configure(new SimpleJavaSourceViewerConfiguration(tools, null, fProcessor));
- viewer.configure(new SimpleJavaSourceViewerConfiguration(fProcessor));
+ viewer.configure(new SimpleJavaSourceViewerConfiguration(tools, fProcessor));
viewer.setEditable(true);
viewer.setDocument(document);
--- /dev/null
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+/**
+ * An overlaying preference store.
+ */
+public class OverlayPreferenceStore implements IPreferenceStore {
+
+
+ public static final class TypeDescriptor {
+ private TypeDescriptor() {
+ }
+ };
+
+ public static final TypeDescriptor BOOLEAN= new TypeDescriptor();
+ public static final TypeDescriptor DOUBLE= new TypeDescriptor();
+ public static final TypeDescriptor FLOAT= new TypeDescriptor();
+ public static final TypeDescriptor INT= new TypeDescriptor();
+ public static final TypeDescriptor LONG= new TypeDescriptor();
+ public static final TypeDescriptor STRING= new TypeDescriptor();
+
+ public static class OverlayKey {
+
+ TypeDescriptor fDescriptor;
+ String fKey;
+
+ public OverlayKey(TypeDescriptor descriptor, String key) {
+ fDescriptor= descriptor;
+ fKey= key;
+ }
+ };
+
+ private class PropertyListener implements IPropertyChangeListener {
+
+ /*
+ * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ OverlayKey key= findOverlayKey(event.getProperty());
+ if (key != null)
+ propagateProperty(fParent, key, fStore);
+ }
+ };
+
+
+ private IPreferenceStore fParent;
+ private IPreferenceStore fStore;
+ private OverlayKey[] fOverlayKeys;
+
+ private PropertyListener fPropertyListener;
+
+
+ public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
+ fParent= parent;
+ fOverlayKeys= overlayKeys;
+ fStore= new PreferenceStore();
+ }
+
+ private OverlayKey findOverlayKey(String key) {
+ for (int i= 0; i < fOverlayKeys.length; i++) {
+ if (fOverlayKeys[i].fKey.equals(key))
+ return fOverlayKeys[i];
+ }
+ return null;
+ }
+
+ private boolean covers(String key) {
+ return (findOverlayKey(key) != null);
+ }
+
+ private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {
+
+ if (orgin.isDefault(key.fKey)) {
+ if (!target.isDefault(key.fKey))
+ target.setToDefault(key.fKey);
+ return;
+ }
+
+ TypeDescriptor d= key.fDescriptor;
+ if (BOOLEAN == d) {
+
+ boolean originValue= orgin.getBoolean(key.fKey);
+ boolean targetValue= target.getBoolean(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (DOUBLE == d) {
+
+ double originValue= orgin.getDouble(key.fKey);
+ double targetValue= target.getDouble(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (FLOAT == d) {
+
+ float originValue= orgin.getFloat(key.fKey);
+ float targetValue= target.getFloat(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (INT == d) {
+
+ int originValue= orgin.getInt(key.fKey);
+ int targetValue= target.getInt(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (LONG == d) {
+
+ long originValue= orgin.getLong(key.fKey);
+ long targetValue= target.getLong(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (STRING == d) {
+
+ String originValue= orgin.getString(key.fKey);
+ String targetValue= target.getString(key.fKey);
+ if (targetValue != null && originValue != null && !targetValue.equals(originValue))
+ target.setValue(key.fKey, originValue);
+
+ }
+ }
+
+ public void propagate() {
+ for (int i= 0; i < fOverlayKeys.length; i++)
+ propagateProperty(fStore, fOverlayKeys[i], fParent);
+ }
+
+ private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) {
+ TypeDescriptor d= key.fDescriptor;
+ if (BOOLEAN == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, true);
+ target.setValue(key.fKey, orgin.getBoolean(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey));
+
+ } else if (DOUBLE == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1.0D);
+ target.setValue(key.fKey, orgin.getDouble(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey));
+
+ } else if (FLOAT == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1.0F);
+ target.setValue(key.fKey, orgin.getFloat(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey));
+
+ } else if (INT == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1);
+ target.setValue(key.fKey, orgin.getInt(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey));
+
+ } else if (LONG == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1L);
+ target.setValue(key.fKey, orgin.getLong(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey));
+
+ } else if (STRING == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, "1"); //$NON-NLS-1$
+ target.setValue(key.fKey, orgin.getString(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
+
+ }
+ }
+
+ public void load() {
+ for (int i= 0; i < fOverlayKeys.length; i++)
+ loadProperty(fParent, fOverlayKeys[i], fStore, true);
+ }
+
+ public void loadDefaults() {
+ for (int i= 0; i < fOverlayKeys.length; i++)
+ setToDefault(fOverlayKeys[i].fKey);
+ }
+
+ public void start() {
+ if (fPropertyListener == null) {
+ fPropertyListener= new PropertyListener();
+ fParent.addPropertyChangeListener(fPropertyListener);
+ }
+ }
+
+ public void stop() {
+ if (fPropertyListener != null) {
+ fParent.removePropertyChangeListener(fPropertyListener);
+ fPropertyListener= null;
+ }
+ }
+
+ /*
+ * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener)
+ */
+ public void addPropertyChangeListener(IPropertyChangeListener listener) {
+ fStore.addPropertyChangeListener(listener);
+ }
+
+ /*
+ * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener)
+ */
+ public void removePropertyChangeListener(IPropertyChangeListener listener) {
+ fStore.removePropertyChangeListener(listener);
+ }
+
+ /*
+ * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object)
+ */
+ public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
+ fStore.firePropertyChangeEvent(name, oldValue, newValue);
+ }
+
+ /*
+ * @see IPreferenceStore#contains(String)
+ */
+ public boolean contains(String name) {
+ return fStore.contains(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getBoolean(String)
+ */
+ public boolean getBoolean(String name) {
+ return fStore.getBoolean(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultBoolean(String)
+ */
+ public boolean getDefaultBoolean(String name) {
+ return fStore.getDefaultBoolean(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultDouble(String)
+ */
+ public double getDefaultDouble(String name) {
+ return fStore.getDefaultDouble(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultFloat(String)
+ */
+ public float getDefaultFloat(String name) {
+ return fStore.getDefaultFloat(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultInt(String)
+ */
+ public int getDefaultInt(String name) {
+ return fStore.getDefaultInt(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultLong(String)
+ */
+ public long getDefaultLong(String name) {
+ return fStore.getDefaultLong(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultString(String)
+ */
+ public String getDefaultString(String name) {
+ return fStore.getDefaultString(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDouble(String)
+ */
+ public double getDouble(String name) {
+ return fStore.getDouble(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getFloat(String)
+ */
+ public float getFloat(String name) {
+ return fStore.getFloat(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getInt(String)
+ */
+ public int getInt(String name) {
+ return fStore.getInt(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getLong(String)
+ */
+ public long getLong(String name) {
+ return fStore.getLong(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getString(String)
+ */
+ public String getString(String name) {
+ return fStore.getString(name);
+ }
+
+ /*
+ * @see IPreferenceStore#isDefault(String)
+ */
+ public boolean isDefault(String name) {
+ return fStore.isDefault(name);
+ }
+
+ /*
+ * @see IPreferenceStore#needsSaving()
+ */
+ public boolean needsSaving() {
+ return fStore.needsSaving();
+ }
+
+ /*
+ * @see IPreferenceStore#putValue(String, String)
+ */
+ public void putValue(String name, String value) {
+ if (covers(name))
+ fStore.putValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, double)
+ */
+ public void setDefault(String name, double value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, float)
+ */
+ public void setDefault(String name, float value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, int)
+ */
+ public void setDefault(String name, int value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, long)
+ */
+ public void setDefault(String name, long value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, String)
+ */
+ public void setDefault(String name, String value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, boolean)
+ */
+ public void setDefault(String name, boolean value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setToDefault(String)
+ */
+ public void setToDefault(String name) {
+ fStore.setToDefault(name);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, double)
+ */
+ public void setValue(String name, double value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, float)
+ */
+ public void setValue(String name, float value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, int)
+ */
+ public void setValue(String name, int value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, long)
+ */
+ public void setValue(String name, long value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, String)
+ */
+ public void setValue(String name, String value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, boolean)
+ */
+ public void setValue(String name, boolean value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM 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 implementation
+**********************************************************************/
+
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import net.sourceforge.phpdt.internal.ui.PHPUIMessages;
+import net.sourceforge.phpdt.internal.ui.dialog.StatusInfo;
+import net.sourceforge.phpdt.internal.ui.dialog.StatusUtil;
+import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout;
+import net.sourceforge.phpdt.ui.PreferenceConstants;
+import net.sourceforge.phpdt.ui.text.JavaTextTools;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.phpeditor.PHPEditorEnvironment;
+import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration;
+import net.sourceforge.phpeclipse.preferences.ColorEditor;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
+
+/*
+ * The page for setting the editor options.
+ */
+public class PHPEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ private static final String BOLD= PreferenceConstants.EDITOR_BOLD_SUFFIX;
+
+ public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] {
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOREGROUND_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BACKGROUND_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_TAB_WIDTH),
+
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR),
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD),
+//
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR),
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD),
+//
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR),
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD),
+//
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR),
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD),
+//
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR),
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD),
+//
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR),
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD),
+//
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD),
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD),
+//
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR),
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD),
+//
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR),
+// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MATCHING_BRACKETS),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CURRENT_LINE_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CURRENT_LINE),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PRINT_MARGIN),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FIND_SCOPE_COLOR),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINKED_POSITION_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PROBLEM_INDICATION),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WARNING_INDICATION),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_INDICATION_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BOOKMARK_INDICATION),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_UNKNOWN_INDICATION),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CORRECTION_INDICATION),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_OVERVIEW_RULER),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_LINE_NUMBER_RULER),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SPACES_FOR_TABS),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOACTIVATION),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_CASE_SENSITIVITY),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_INSERT_COMPLETION),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_JAVADOCS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FORMAT_JAVADOCS),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END),
+
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_DEFAULT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_NONE_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SHIFT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_ALT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_ALT_SHIFT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_ALT_SHIFT_HOVER),
+ };
+
+// private final String[][] fSyntaxColorListModel= new String[][] {
+// { PHPUIMessages.getString("PHPEditorPreferencePage.multiLineComment"), PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$
+// { PHPUIMessages.getString("PHPEditorPreferencePage.singleLineComment"), PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$
+// { PHPUIMessages.getString("PHPEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, //$NON-NLS-1$
+// { PHPUIMessages.getString("PHPEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$
+// { PHPUIMessages.getString("PHPEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
+// { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$
+// { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD }, //$NON-NLS-1$
+// { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$
+// { PHPUIMessages.getString("PHPEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
+// };
+
+ private final String[][] fAppearanceColorListModel= new String[][] {
+ {PHPUIMessages.getString("PHPEditorPreferencePage.lineNumberForegroundColor"), PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, //$NON-NLS-1$
+ {PHPUIMessages.getString("PHPEditorPreferencePage.matchingBracketsHighlightColor2"), PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR}, //$NON-NLS-1$
+ {PHPUIMessages.getString("PHPEditorPreferencePage.currentLineHighlighColor"), PreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, //$NON-NLS-1$
+ {PHPUIMessages.getString("PHPEditorPreferencePage.printMarginColor2"), PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, //$NON-NLS-1$
+ {PHPUIMessages.getString("PHPEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR}, //$NON-NLS-1$
+ {PHPUIMessages.getString("PHPEditorPreferencePage.linkedPositionColor2"), PreferenceConstants.EDITOR_LINKED_POSITION_COLOR}, //$NON-NLS-1$
+ {PHPUIMessages.getString("PHPEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR}, //$NON-NLS-1$
+ };
+
+ private final String[][] fProblemIndicationColorListModel= new String[][] {
+ {"Errors", PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR, PreferenceConstants.EDITOR_PROBLEM_INDICATION, PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER },
+ {"Warnings", PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR, PreferenceConstants.EDITOR_WARNING_INDICATION, PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER },
+ {"Tasks", PreferenceConstants.EDITOR_TASK_INDICATION_COLOR, PreferenceConstants.EDITOR_TASK_INDICATION, PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER },
+ {"Search Results", PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER },
+ {"Bookmarks", PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR, PreferenceConstants.EDITOR_BOOKMARK_INDICATION, PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER },
+ {"Others", PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR, PreferenceConstants.EDITOR_UNKNOWN_INDICATION, PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER }
+ };
+
+ private OverlayPreferenceStore fOverlayStore;
+ private JavaTextTools fJavaTextTools;
+// private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
+
+ private Map fColorButtons= new HashMap();
+ private SelectionListener fColorButtonListener= new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ public void widgetSelected(SelectionEvent e) {
+ ColorEditor editor= (ColorEditor) e.widget.getData();
+ PreferenceConverter.setValue(fOverlayStore, (String) fColorButtons.get(editor), editor.getColorValue());
+ }
+ };
+
+ private Map fCheckBoxes= new HashMap();
+ private SelectionListener fCheckBoxListener= new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ public void widgetSelected(SelectionEvent e) {
+ Button button= (Button) e.widget;
+ fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
+ }
+ };
+
+ private Map fTextFields= new HashMap();
+ private ModifyListener fTextFieldListener= new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ Text text= (Text) e.widget;
+ fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
+ }
+ };
+
+ private ArrayList fNumberFields= new ArrayList();
+ private ModifyListener fNumberFieldListener= new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ numberFieldChanged((Text) e.widget);
+ }
+ };
+
+ private WorkbenchChainedTextFontFieldEditor fFontEditor;
+ private List fSyntaxColorList;
+ private List fAppearanceColorList;
+ private List fProblemIndicationList;
+ private ColorEditor fSyntaxForegroundColorEditor;
+ private ColorEditor fAppearanceForegroundColorEditor;
+ private ColorEditor fProblemIndicationForegroundColorEditor;
+ private ColorEditor fBackgroundColorEditor;
+ private Button fBackgroundDefaultRadioButton;
+ private Button fBackgroundCustomRadioButton;
+ private Button fBackgroundColorButton;
+ private Button fBoldCheckBox;
+ // private Button fAddJavaDocTagsButton;
+ private Button fGuessMethodArgumentsButton;
+ private SourceViewer fPreviewViewer;
+ private Color fBackgroundColor;
+ private Control fAutoInsertDelayText;
+ private Control fAutoInsertJavaTriggerText;
+ private Control fAutoInsertJavaDocTriggerText;
+ private Button fShowInTextCheckBox;
+ private Button fShowInOverviewRulerCheckBox;
+
+ public PHPEditorPreferencePage() {
+ setDescription(PHPUIMessages.getString("PHPEditorPreferencePage.description")); //$NON-NLS-1$
+ setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
+ fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys);
+ }
+
+ /*
+ * @see IWorkbenchPreferencePage#init()
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+ /*
+ * @see PreferencePage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ // WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
+ }
+
+ private void handleSyntaxColorListSelection() {
+ int i= fSyntaxColorList.getSelectionIndex();
+// String key= fSyntaxColorListModel[i][1];
+// RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
+// fSyntaxForegroundColorEditor.setColorValue(rgb);
+// fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD));
+ }
+
+ private void handleAppearanceColorListSelection() {
+ int i= fAppearanceColorList.getSelectionIndex();
+ String key= fAppearanceColorListModel[i][1];
+ RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
+ fAppearanceForegroundColorEditor.setColorValue(rgb);
+ }
+
+ private void handleProblemIndicationColorListSelection() {
+ int i= fProblemIndicationList.getSelectionIndex();
+
+ String key= fProblemIndicationColorListModel[i][1];
+ RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
+ fProblemIndicationForegroundColorEditor.setColorValue(rgb);
+
+ key= fProblemIndicationColorListModel[i][2];
+ fShowInTextCheckBox.setSelection(fOverlayStore.getBoolean(key));
+
+ key= fProblemIndicationColorListModel[i][3];
+ fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key));
+ }
+
+ private Control createSyntaxPage(Composite parent) {
+
+ Composite colorComposite= new Composite(parent, SWT.NULL);
+ colorComposite.setLayout(new GridLayout());
+
+ Group backgroundComposite= new Group(colorComposite, SWT.SHADOW_ETCHED_IN);
+ backgroundComposite.setLayout(new RowLayout());
+ backgroundComposite.setText(PHPUIMessages.getString("PHPEditorPreferencePage.backgroundColor"));//$NON-NLS-1$
+
+ SelectionListener backgroundSelectionListener= new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ boolean custom= fBackgroundCustomRadioButton.getSelection();
+ fBackgroundColorButton.setEnabled(custom);
+ fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom);
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ };
+
+ fBackgroundDefaultRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
+ fBackgroundDefaultRadioButton.setText(PHPUIMessages.getString("PHPEditorPreferencePage.systemDefault")); //$NON-NLS-1$
+ fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener);
+
+ fBackgroundCustomRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT);
+ fBackgroundCustomRadioButton.setText(PHPUIMessages.getString("PHPEditorPreferencePage.custom")); //$NON-NLS-1$
+ fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener);
+
+ fBackgroundColorEditor= new ColorEditor(backgroundComposite);
+ fBackgroundColorButton= fBackgroundColorEditor.getButton();
+
+ Label label= new Label(colorComposite, SWT.LEFT);
+ label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.foreground")); //$NON-NLS-1$
+ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Composite editorComposite= new Composite(colorComposite, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 2;
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ editorComposite.setLayout(layout);
+ GridData gd= new GridData(GridData.FILL_BOTH);
+ editorComposite.setLayoutData(gd);
+
+ fSyntaxColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
+ gd= new GridData(GridData.FILL_BOTH);
+ gd.heightHint= convertHeightInCharsToPixels(5);
+ fSyntaxColorList.setLayoutData(gd);
+
+ Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
+ layout= new GridLayout();
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ layout.numColumns= 2;
+ stylesComposite.setLayout(layout);
+ stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ label= new Label(stylesComposite, SWT.LEFT);
+ label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.color")); //$NON-NLS-1$
+ gd= new GridData();
+ gd.horizontalAlignment= GridData.BEGINNING;
+ label.setLayoutData(gd);
+
+ fSyntaxForegroundColorEditor= new ColorEditor(stylesComposite);
+ Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton();
+ gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment= GridData.BEGINNING;
+ foregroundColorButton.setLayoutData(gd);
+
+ fBoldCheckBox= new Button(stylesComposite, SWT.CHECK);
+ fBoldCheckBox.setText(PHPUIMessages.getString("PHPEditorPreferencePage.bold")); //$NON-NLS-1$
+ gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment= GridData.BEGINNING;
+ gd.horizontalSpan= 2;
+ fBoldCheckBox.setLayoutData(gd);
+
+ label= new Label(colorComposite, SWT.LEFT);
+ label.setText(PHPUIMessages.getString("PHPEditorPreferencePage.preview")); //$NON-NLS-1$
+ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Control previewer= createPreviewer(colorComposite);
+ gd= new GridData(GridData.FILL_BOTH);
+ gd.widthHint= convertWidthInCharsToPixels(20);
+ gd.heightHint= convertHeightInCharsToPixels(5);
+ previewer.setLayoutData(gd);
+
+
+ fSyntaxColorList.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+ public void widgetSelected(SelectionEvent e) {
+ handleSyntaxColorListSelection();
+ }
+ });
+
+ foregroundColorButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+ public void widgetSelected(SelectionEvent e) {
+ int i= fSyntaxColorList.getSelectionIndex();
+// String key= fSyntaxColorListModel[i][1];
+//
+// PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue());
+ }
+ });
+
+ fBackgroundColorButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+ public void widgetSelected(SelectionEvent e) {
+ PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor.getColorValue());
+ }
+ });
+
+ fBoldCheckBox.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+ public void widgetSelected(SelectionEvent e) {
+ int i= fSyntaxColorList.getSelectionIndex();
+// String key= fSyntaxColorListModel[i][1];
+// fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection());
+ }
+ });
+
+ return colorComposite;
+ }
+
+ private Control createPreviewer(Composite parent) {
+
+ fJavaTextTools= new JavaTextTools(fOverlayStore);
+
+ fPreviewViewer= new SourceViewer(parent, null, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
+ fPreviewViewer.configure(new PHPSourceViewerConfiguration(fJavaTextTools, null));
+ fPreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
+ fPreviewViewer.setEditable(false);
+
+ initializeViewerColors(fPreviewViewer);
+
+ String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
+ IDocument document= new Document(content);
+ PHPEditorEnvironment pe;
+ IDocumentPartitioner partitioner= fJavaTextTools.createDocumentPartitioner();
+ partitioner.connect(document);
+ document.setDocumentPartitioner(partitioner);
+
+ fPreviewViewer.setDocument(document);
+
+ fOverlayStore.addPropertyChangeListener(new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ String p= event.getProperty();
+ if (p.equals(PreferenceConstants.EDITOR_BACKGROUND_COLOR) ||
+ p.equals(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR))
+ {
+ initializeViewerColors(fPreviewViewer);
+ }
+
+ fPreviewViewer.invalidateTextPresentation();
+ }
+ });
+
+ return fPreviewViewer.getControl();
+ }
+
+ /**
+ * Initializes the given viewer's colors.
+ *
+ * @param viewer the viewer to be initialized
+ */
+ private void initializeViewerColors(ISourceViewer viewer) {
+
+ IPreferenceStore store= fOverlayStore;
+ if (store != null) {
+
+ StyledText styledText= viewer.getTextWidget();
+
+ // ---------- background color ----------------------
+ Color color= store.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR)
+ ? null
+ : createColor(store, PreferenceConstants.EDITOR_BACKGROUND_COLOR, styledText.getDisplay());
+ styledText.setBackground(color);
+
+ if (fBackgroundColor != null)
+ fBackgroundColor.dispose();
+
+ fBackgroundColor= color;
+ }
+ }
+
+ /**
+ * Creates a color from the information stored in the given preference store.
+ * Returns <code>null</code> if there is no such information available.
+ */
+ private Color createColor(IPreferenceStore store, String key, Display display) {
+
+ RGB rgb= null;
+
+ if (store.contains(key)) {
+
+ if (store.isDefault(key))
+ rgb= PreferenceConverter.getDefaultColor(store, key);
+ else
+ rgb= PreferenceConverter.getColor(store, key);
+
+ if (rgb != null)
+ return new Color(display, rgb);
+ }
+
+ return null;
+ }
+
+ // sets enabled flag for a control and all its sub-tree
+ private static void setEnabled(Control control, boolean enable) {
+ control.setEnabled(enable);
+ if (control instanceof Composite) {
+ Composite composite= (Composite) control;
+ Control[] children= composite.getChildren();
+ for (int i= 0; i < children.length; i++)
+ setEnabled(children[i], enable);
+ }
+ }
+
+ private Control createAppearancePage(Composite parent) {
+
+ Composite appearanceComposite= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout(); layout.numColumns= 2;
+ appearanceComposite.setLayout(layout);
+
+ String label= PHPUIMessages.getString("PHPEditorPreferencePage.textFont"); //$NON-NLS-1$
+ addTextFontEditor(appearanceComposite, label, AbstractTextEditor.PREFERENCE_FONT);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
+ addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
+ addTextField(appearanceComposite, label, PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.synchronizeOnCursor"); //$NON-NLS-1$
+ addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
+ addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
+ addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$
+ addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
+ addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_CURRENT_LINE, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
+ addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_PRINT_MARGIN, 0);
+
+
+ Label l= new Label(appearanceComposite, SWT.LEFT );
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan= 2;
+ gd.heightHint= convertHeightInCharsToPixels(1) / 2;
+ l.setLayoutData(gd);
+
+ l= new Label(appearanceComposite, SWT.LEFT);
+ l.setText(PHPUIMessages.getString("PHPEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
+ gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan= 2;
+ l.setLayoutData(gd);
+
+ Composite editorComposite= new Composite(appearanceComposite, SWT.NONE);
+ layout= new GridLayout();
+ layout.numColumns= 2;
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ editorComposite.setLayout(layout);
+ gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
+ gd.horizontalSpan= 2;
+ editorComposite.setLayoutData(gd);
+
+ fAppearanceColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
+ gd= new GridData(GridData.FILL_BOTH);
+ gd.heightHint= convertHeightInCharsToPixels(5);
+ fAppearanceColorList.setLayoutData(gd);
+
+ Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
+ layout= new GridLayout();
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ layout.numColumns= 2;
+ stylesComposite.setLayout(layout);
+ stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ l= new Label(stylesComposite, SWT.LEFT);
+ l.setText(PHPUIMessages.getString("PHPEditorPreferencePage.color")); //$NON-NLS-1$
+ gd= new GridData();
+ gd.horizontalAlignment= GridData.BEGINNING;
+ l.setLayoutData(gd);
+
+ fAppearanceForegroundColorEditor= new ColorEditor(stylesComposite);
+ Button foregroundColorButton= fAppearanceForegroundColorEditor.getButton();
+ gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment= GridData.BEGINNING;
+ foregroundColorButton.setLayoutData(gd);
+
+ fAppearanceColorList.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+ public void widgetSelected(SelectionEvent e) {
+ handleAppearanceColorListSelection();
+ }
+ });
+ foregroundColorButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+ public void widgetSelected(SelectionEvent e) {
+ int i= fAppearanceColorList.getSelectionIndex();
+ String key= fAppearanceColorListModel[i][1];
+
+ PreferenceConverter.setValue(fOverlayStore, key, fAppearanceForegroundColorEditor.getColorValue());
+ }
+ });
+ return appearanceComposite;
+ }
+
+
+ private Control createProblemIndicationPage(Composite parent) {
+ Composite composite= new Composite(parent, SWT.NULL);
+ GridLayout layout= new GridLayout(); layout.numColumns= 2;
+ composite.setLayout(layout);
+
+ String text= "Analyse &problems while typing";
+ addCheckBox(composite, text, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
+
+ text= PHPUIMessages.getString("PHPEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$
+ addCheckBox(composite, text, PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0);
+
+ Label label= new Label(composite, SWT.LEFT );
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan= 2;
+ gd.heightHint= convertHeightInCharsToPixels(1) / 2;
+ label.setLayoutData(gd);
+
+ label= new Label(composite, SWT.LEFT);
+ label.setText("&Marker presentation options:");
+ gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan= 2;
+ label.setLayoutData(gd);
+
+ Composite editorComposite= new Composite(composite, SWT.NONE);
+ layout= new GridLayout();
+ layout.numColumns= 2;
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ editorComposite.setLayout(layout);
+ gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
+ gd.horizontalSpan= 2;
+ editorComposite.setLayoutData(gd);
+
+ fProblemIndicationList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
+ gd= new GridData(GridData.FILL_BOTH);
+ gd.heightHint= convertHeightInCharsToPixels(5);
+ fProblemIndicationList.setLayoutData(gd);
+
+ Composite optionsComposite= new Composite(editorComposite, SWT.NONE);
+ layout= new GridLayout();
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ layout.numColumns= 2;
+ optionsComposite.setLayout(layout);
+ optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fShowInTextCheckBox= new Button(optionsComposite, SWT.CHECK);
+ fShowInTextCheckBox.setText("Show in &text");
+ gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment= GridData.BEGINNING;
+ gd.horizontalSpan= 2;
+ fShowInTextCheckBox.setLayoutData(gd);
+
+ fShowInOverviewRulerCheckBox= new Button(optionsComposite, SWT.CHECK);
+ fShowInOverviewRulerCheckBox.setText("Show in overview &ruler");
+ gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment= GridData.BEGINNING;
+ gd.horizontalSpan= 2;
+ fShowInOverviewRulerCheckBox.setLayoutData(gd);
+
+ label= new Label(optionsComposite, SWT.LEFT);
+ label.setText("C&olor:");
+ gd= new GridData();
+ gd.horizontalAlignment= GridData.BEGINNING;
+ label.setLayoutData(gd);
+
+ fProblemIndicationForegroundColorEditor= new ColorEditor(optionsComposite);
+ Button foregroundColorButton= fProblemIndicationForegroundColorEditor.getButton();
+ gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment= GridData.BEGINNING;
+ foregroundColorButton.setLayoutData(gd);
+
+ fProblemIndicationList.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ handleProblemIndicationColorListSelection();
+ }
+ });
+
+ fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ int i= fProblemIndicationList.getSelectionIndex();
+ String key= fProblemIndicationColorListModel[i][2];
+ fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection());
+ }
+ });
+
+ fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ int i= fProblemIndicationList.getSelectionIndex();
+ String key= fProblemIndicationColorListModel[i][3];
+ fOverlayStore.setValue(key, fShowInOverviewRulerCheckBox.getSelection());
+ }
+ });
+
+ foregroundColorButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ int i= fProblemIndicationList.getSelectionIndex();
+ String key= fProblemIndicationColorListModel[i][1];
+ PreferenceConverter.setValue(fOverlayStore, key, fProblemIndicationForegroundColorEditor.getColorValue());
+ }
+ });
+
+ return composite;
+ }
+
+// private Control createBehaviourPage(Composite parent) {
+// Composite composite= new Composite(parent, SWT.NULL);
+// GridLayout layout= new GridLayout(); layout.numColumns= 2;
+// composite.setLayout(layout);
+//
+// String label= PHPUIMessages.getString("PHPEditorPreferencePage.wrapStrings"); //$NON-NLS-1$
+// addCheckBox(composite, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
+//
+// label= PHPUIMessages.getString("PHPEditorPreferencePage.smartHomeEnd"); //$NON-NLS-1$
+// addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1);
+//
+// label= PHPUIMessages.getString("PHPEditorPreferencePage.smartPaste"); //$NON-NLS-1$
+// addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_PASTE, 1);
+//
+// label= PHPUIMessages.getString("PHPEditorPreferencePage.insertSpaceForTabs"); //$NON-NLS-1$
+// addCheckBox(composite, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1);
+//
+// label= PHPUIMessages.getString("PHPEditorPreferencePage.closeStrings"); //$NON-NLS-1$
+// addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 1);
+//
+// label= PHPUIMessages.getString("PHPEditorPreferencePage.closeBrackets"); //$NON-NLS-1$
+// addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 1);
+//
+// label= PHPUIMessages.getString("PHPEditorPreferencePage.closeBraces"); //$NON-NLS-1$
+// addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1);
+//
+// label= PHPUIMessages.getString("PHPEditorPreferencePage.closePHPDocs"); //$NON-NLS-1$
+// Button button= addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
+//
+// label= PHPUIMessages.getString("PHPEditorPreferencePage.addPHPDocTags"); //$NON-NLS-1$
+// fAddJavaDocTagsButton= addCheckBox(composite, label, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
+// createDependency(button, fAddJavaDocTagsButton);
+//
+// label= PHPUIMessages.getString("PHPEditorPreferencePage.formatPHPDocs"); //$NON-NLS-1$
+// addCheckBox(composite, label, PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1);
+//
+// return composite;
+// }
+
+ private static void indent(Control control) {
+ GridData gridData= new GridData();
+ gridData.horizontalIndent= 20;
+ control.setLayoutData(gridData);
+ }
+
+ private static void createDependency(final Button master, final Control slave) {
+ indent(slave);
+ master.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ slave.setEnabled(master.getSelection());
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ });
+ }
+
+ private Control createContentAssistPage(Composite parent) {
+
+ Composite contentAssistComposite= new Composite(parent, SWT.NULL);
+ GridLayout layout= new GridLayout(); layout.numColumns= 2;
+ contentAssistComposite.setLayout(layout);
+
+ String label= PHPUIMessages.getString("PHPEditorPreferencePage.insertSingleProposalsAutomatically"); //$NON-NLS-1$
+ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOINSERT, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext"); //$NON-NLS-1$
+ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.presentProposalsInAlphabeticalOrder"); //$NON-NLS-1$
+ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName"); //$NON-NLS-1$
+ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ADDIMPORT, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.insertCompletion"); //$NON-NLS-1$
+ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_INSERT_COMPLETION, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.fillArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
+ Button button= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
+ fGuessMethodArgumentsButton= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0);
+ createDependency(button, fGuessMethodArgumentsButton);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.enableAutoActivation"); //$NON-NLS-1$
+ final Button autoactivation= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationDelay"); //$NON-NLS-1$
+ fAutoInsertDelayText= addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationTriggersForPHP"); //$NON-NLS-1$
+ fAutoInsertJavaTriggerText= addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0, false);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.autoActivationTriggersForPHPDoc"); //$NON-NLS-1$
+ fAutoInsertJavaDocTriggerText= addTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0, false);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForCompletionProposals"); //$NON-NLS-1$
+ addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForCompletionProposals"); //$NON-NLS-1$
+ addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForMethodParameters"); //$NON-NLS-1$
+ addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForMethodParameters"); //$NON-NLS-1$
+ addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.backgroundForCompletionReplacement"); //$NON-NLS-1$
+ addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND, 0);
+
+ label= PHPUIMessages.getString("PHPEditorPreferencePage.foregroundForCompletionReplacement"); //$NON-NLS-1$
+ addColorButton(contentAssistComposite, label, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND, 0);
+
+ autoactivation.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e) {
+ updateAutoactivationControls();
+ }
+ });
+ return contentAssistComposite;
+ }
+
+ /*
+ * @see PreferencePage#createContents(Composite)
+ */
+ protected Control createContents(Composite parent) {
+
+ fOverlayStore.load();
+ fOverlayStore.start();
+
+ TabFolder folder= new TabFolder(parent, SWT.NONE);
+ folder.setLayout(new TabFolderLayout());
+ folder.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ TabItem item= new TabItem(folder, SWT.NONE);
+ item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.general")); //$NON-NLS-1$
+ item.setControl(createAppearancePage(folder));
+
+ item= new TabItem(folder, SWT.NONE);
+ item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.colors")); //$NON-NLS-1$
+ item.setControl(createSyntaxPage(folder));
+
+ item= new TabItem(folder, SWT.NONE);
+ item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.codeAssist")); //$NON-NLS-1$
+ item.setControl(createContentAssistPage(folder));
+
+ item= new TabItem(folder, SWT.NONE);
+ item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.problemIndicationTab.title")); //$NON-NLS-1$
+ item.setControl(createProblemIndicationPage(folder));
+
+// item= new TabItem(folder, SWT.NONE);
+// item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.behaviourTab.title")); //$NON-NLS-1$
+// item.setControl(createBehaviourPage(folder));
+
+// item= new TabItem(folder, SWT.NONE);
+// item.setText(PHPUIMessages.getString("PHPEditorPreferencePage.hoverTab.title")); //$NON-NLS-1$
+// fJavaEditorHoverConfigurationBlock= new JavaEditorHoverConfigurationBlock(fOverlayStore);
+// item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
+
+ initialize();
+
+ return folder;
+ }
+
+ private void initialize() {
+
+ fFontEditor.setPreferenceStore(getPreferenceStore());
+ fFontEditor.setPreferencePage(this);
+ fFontEditor.load();
+
+ initializeFields();
+
+// for (int i= 0; i < fSyntaxColorListModel.length; i++)
+// fSyntaxColorList.add(fSyntaxColorListModel[i][0]);
+
+ fSyntaxColorList.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) {
+ fSyntaxColorList.select(0);
+ handleSyntaxColorListSelection();
+ }
+ }
+ });
+
+ for (int i= 0; i < fAppearanceColorListModel.length; i++)
+ fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
+
+ fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
+ fAppearanceColorList.select(0);
+ handleAppearanceColorListSelection();
+ }
+ }
+ });
+
+ for (int i= 0; i < fProblemIndicationColorListModel.length; i++)
+ fProblemIndicationList.add(fProblemIndicationColorListModel[i][0]);
+
+ fProblemIndicationList.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (fProblemIndicationList != null && !fProblemIndicationList.isDisposed()) {
+ fProblemIndicationList.select(0);
+ handleProblemIndicationColorListSelection();
+ }
+ }
+ });
+ }
+
+ private void initializeFields() {
+
+ Iterator e= fColorButtons.keySet().iterator();
+ while (e.hasNext()) {
+ ColorEditor c= (ColorEditor) e.next();
+ String key= (String) fColorButtons.get(c);
+ RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
+ c.setColorValue(rgb);
+ }
+
+ e= fCheckBoxes.keySet().iterator();
+ while (e.hasNext()) {
+ Button b= (Button) e.next();
+ String key= (String) fCheckBoxes.get(b);
+ b.setSelection(fOverlayStore.getBoolean(key));
+ }
+
+ e= fTextFields.keySet().iterator();
+ while (e.hasNext()) {
+ Text t= (Text) e.next();
+ String key= (String) fTextFields.get(t);
+ t.setText(fOverlayStore.getString(key));
+ }
+
+ RGB rgb= PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR);
+ fBackgroundColorEditor.setColorValue(rgb);
+
+ boolean default_= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR);
+ fBackgroundDefaultRadioButton.setSelection(default_);
+ fBackgroundCustomRadioButton.setSelection(!default_);
+ fBackgroundColorButton.setEnabled(!default_);
+
+ // boolean closeJavaDocs= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
+ // fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
+
+ boolean fillMethodArguments= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
+ fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
+
+ updateAutoactivationControls();
+
+ // fJavaEditorHoverConfigurationBlock.initializeFields();
+ }
+
+ private void updateAutoactivationControls() {
+ boolean autoactivation= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION);
+ fAutoInsertDelayText.setEnabled(autoactivation);
+ fAutoInsertJavaTriggerText.setEnabled(autoactivation);
+ fAutoInsertJavaDocTriggerText.setEnabled(autoactivation);
+ }
+
+ /*
+ * @see PreferencePage#performOk()
+ */
+ public boolean performOk() {
+ fFontEditor.store();
+ // fJavaEditorHoverConfigurationBlock.performOk();
+ fOverlayStore.propagate();
+ PHPeclipsePlugin.getDefault().savePluginPreferences();
+ return true;
+ }
+
+ /*
+ * @see PreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+
+ fFontEditor.loadDefault();
+
+ fOverlayStore.loadDefaults();
+ initializeFields();
+
+ handleSyntaxColorListSelection();
+ handleAppearanceColorListSelection();
+ handleProblemIndicationColorListSelection();
+ super.performDefaults();
+
+ fPreviewViewer.invalidateTextPresentation();
+ }
+
+ /*
+ * @see DialogPage#dispose()
+ */
+ public void dispose() {
+
+ if (fJavaTextTools != null) {
+ fJavaTextTools= null;
+ }
+
+ fFontEditor.setPreferencePage(null);
+ fFontEditor.setPreferenceStore(null);
+
+ if (fOverlayStore != null) {
+ fOverlayStore.stop();
+ fOverlayStore= null;
+ }
+
+ super.dispose();
+ }
+
+ private Control addColorButton(Composite composite, String label, String key, int indentation) {
+
+ Label labelControl= new Label(composite, SWT.NONE);
+ labelControl.setText(label);
+
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent= indentation;
+ labelControl.setLayoutData(gd);
+
+ ColorEditor editor= new ColorEditor(composite);
+ Button button= editor.getButton();
+ button.setData(editor);
+
+ gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ button.setLayoutData(gd);
+ button.addSelectionListener(fColorButtonListener);
+
+ fColorButtons.put(editor, key);
+
+ return composite;
+ }
+
+ private Button addCheckBox(Composite parent, String label, String key, int indentation) {
+ Button checkBox= new Button(parent, SWT.CHECK);
+ checkBox.setText(label);
+
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent= indentation;
+ gd.horizontalSpan= 2;
+ checkBox.setLayoutData(gd);
+ checkBox.addSelectionListener(fCheckBoxListener);
+
+ fCheckBoxes.put(checkBox, key);
+
+ return checkBox;
+ }
+
+ private Control addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
+
+ Label labelControl= new Label(composite, SWT.NONE);
+ labelControl.setText(label);
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalIndent= indentation;
+ labelControl.setLayoutData(gd);
+
+ Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE);
+ gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.widthHint= convertWidthInCharsToPixels(textLimit + 1);
+ textControl.setLayoutData(gd);
+ textControl.setTextLimit(textLimit);
+ fTextFields.put(textControl, key);
+ if (isNumber) {
+ fNumberFields.add(textControl);
+ textControl.addModifyListener(fNumberFieldListener);
+ } else {
+ textControl.addModifyListener(fTextFieldListener);
+ }
+
+ return textControl;
+ }
+
+ private void addTextFontEditor(Composite parent, String label, String key) {
+
+ Composite editorComposite= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 3;
+ editorComposite.setLayout(layout);
+ fFontEditor= new WorkbenchChainedTextFontFieldEditor(key, label, editorComposite);
+ fFontEditor.setChangeButtonText(PHPUIMessages.getString("PHPEditorPreferencePage.change")); //$NON-NLS-1$
+
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan= 2;
+ editorComposite.setLayoutData(gd);
+ }
+
+ private String loadPreviewContentFromFile(String filename) {
+ String line;
+ String separator= System.getProperty("line.separator"); //$NON-NLS-1$
+ StringBuffer buffer= new StringBuffer(512);
+ BufferedReader reader= null;
+ try {
+ reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
+ while ((line= reader.readLine()) != null) {
+ buffer.append(line);
+ buffer.append(separator);
+ }
+ } catch (IOException io) {
+ PHPeclipsePlugin.log(io);
+ } finally {
+ if (reader != null) {
+ try { reader.close(); } catch (IOException e) {}
+ }
+ }
+ return buffer.toString();
+ }
+
+ private void numberFieldChanged(Text textControl) {
+ String number= textControl.getText();
+ IStatus status= validatePositiveNumber(number);
+ if (!status.matches(IStatus.ERROR))
+ fOverlayStore.setValue((String) fTextFields.get(textControl), number);
+ updateStatus(status);
+ }
+
+ private IStatus validatePositiveNumber(String number) {
+ StatusInfo status= new StatusInfo();
+ if (number.length() == 0) {
+ status.setError(PHPUIMessages.getString("PHPEditorPreferencePage.empty_input")); //$NON-NLS-1$
+ } else {
+ try {
+ int value= Integer.parseInt(number);
+ if (value < 0)
+ status.setError(PHPUIMessages.getFormattedString("PHPEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
+ } catch (NumberFormatException e) {
+ status.setError(PHPUIMessages.getFormattedString("PHPEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
+ }
+ }
+ return status;
+ }
+
+ private void updateStatus(IStatus status) {
+ if (!status.matches(IStatus.ERROR)) {
+ for (int i= 0; i < fNumberFields.size(); i++) {
+ Text text= (Text) fNumberFields.get(i);
+ IStatus s= validatePositiveNumber(text.getText());
+ status= StatusUtil.getMoreSevere(s, status);
+ }
+ }
+ setValid(!status.matches(IStatus.ERROR));
+ StatusUtil.applyToStatusLine(this, status);
+ }
+
+ /**
+ * @deprecated Inline to avoid reference to preference page
+ */
+ public static boolean indicateQuixFixableProblems() {
+ return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
+ }
+
+ /**
+ * @deprecated Inline to avoid reference to preference page
+ */
+ static public boolean synchronizeOutlineOnCursorMove() {
+ return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
+ }
+
+}
\ No newline at end of file
import net.sourceforge.phpdt.internal.ui.text.template.TemplateContentProvider;
import net.sourceforge.phpdt.internal.ui.text.template.TemplateLabelProvider;
import net.sourceforge.phpdt.internal.ui.util.SWTUtil;
+import net.sourceforge.phpdt.ui.text.JavaTextTools;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.phpeditor.PHPEditorEnvironment;
import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-public class TemplatePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+public class TemplatePreferencePage
+ extends PreferencePage
+ implements IWorkbenchPreferencePage {
// preference store keys
private static final String PREF_FORMAT_TEMPLATES = PHPeclipsePlugin.PLUGIN_ID + ".template.format"; //$NON-NLS-1$
gd.horizontalSpan = 2;
innerParent.setLayoutData(gd);
- Table table = new Table(innerParent, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
+ Table table =
+ new Table(
+ innerParent,
+ SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = convertWidthInCharsToPixels(3);
int result = left.getName().compareToIgnoreCase(right.getName());
if (result != 0)
return result;
- return left.getDescription().compareToIgnoreCase(right.getDescription());
+ return left.getDescription().compareToIgnoreCase(
+ right.getDescription());
}
return super.compare(viewer, object1, object2);
}
// fFormatButton.setSelection(prefs.getBoolean(PREF_FORMAT_TEMPLATES));
updateButtons();
- configureTableResizing(innerParent, buttons, table, column1, column2, column3);
+ configureTableResizing(
+ innerParent,
+ buttons,
+ table,
+ column1,
+ column2,
+ column3);
// WorkbenchHelp.setHelp(parent, IJavaHelpContextIds.TEMPLATE_PREFERENCE_PAGE);
data.horizontalSpan = 2;
label.setLayoutData(data);
- SourceViewer viewer = new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- // JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+ SourceViewer viewer =
+ new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ JavaTextTools tools = PHPeclipsePlugin.getDefault().getJavaTextTools();
IDocument document = new Document();
- // IDocumentPartitioner partitioner= new PHPPartitionScanner(); //tools.createDocumentPartitioner();
- // document.setDocumentPartitioner(partitioner);
- // partitioner.connect(document);
+ IDocumentPartitioner partitioner = tools.createDocumentPartitioner();
+ document.setDocumentPartitioner(partitioner);
+ partitioner.connect(document);
- viewer.configure(new PHPSourceViewerConfiguration(null)); // (tools, null));
+ viewer.configure(new PHPSourceViewerConfiguration(tools, null));
+ // (tools, null));
viewer.setEditable(false);
viewer.setDocument(document);
- viewer.getTextWidget().setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+ viewer.getTextWidget().setBackground(
+ getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
Font font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
viewer.getTextWidget().setFont(font);
}
private void selectionChanged1() {
- IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
+ IStructuredSelection selection =
+ (IStructuredSelection) fTableViewer.getSelection();
if (selection.size() == 1) {
Template template = (Template) selection.getFirstElement();
}
private void updateButtons() {
- int selectionCount = ((IStructuredSelection) fTableViewer.getSelection()).size();
+ int selectionCount =
+ ((IStructuredSelection) fTableViewer.getSelection()).size();
int itemCount = fTableViewer.getTable().getItemCount();
fEditButton.setEnabled(selectionCount == 1);
}
template.setContext(contextTypeName); //$NON-NLS-1$
- EditTemplateDialog dialog = new EditTemplateDialog(getShell(), template, false);
+ EditTemplateDialog dialog =
+ new EditTemplateDialog(getShell(), template, false);
if (dialog.open() == EditTemplateDialog.OK) {
fTemplates.add(template);
fTableViewer.refresh();
}
private void edit() {
- IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
+ IStructuredSelection selection =
+ (IStructuredSelection) fTableViewer.getSelection();
Object[] objects = selection.toArray();
if ((objects == null) || (objects.length != 1))
private void edit(Template template) {
Template newTemplate = new Template(template);
- EditTemplateDialog dialog = new EditTemplateDialog(getShell(), newTemplate, true);
+ EditTemplateDialog dialog =
+ new EditTemplateDialog(getShell(), newTemplate, true);
if (dialog.open() == EditTemplateDialog.OK) {
if (!newTemplate.getName().equals(template.getName()) && MessageDialog.openQuestion(getShell(), TemplateMessages.getString("TemplatePreferencePage.question.create.new.title"), //$NON-NLS-1$
}
private void export() {
- IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
+ IStructuredSelection selection =
+ (IStructuredSelection) fTableViewer.getSelection();
Object[] templates = selection.toArray();
TemplateSet templateSet = new TemplateSet();
}
private void remove() {
- IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();
+ IStructuredSelection selection =
+ (IStructuredSelection) fTableViewer.getSelection();
Iterator elements = selection.iterator();
while (elements.hasNext()) {
--- /dev/null
+package net.sourceforge.phpdt.internal.ui.text;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.util.Assert;
+
+
+
+/**
+ * A buffered document scanner. The buffer always contains a section
+ * of a fixed size of the document to be scanned.
+ */
+
+public final class BufferedDocumentScanner implements ICharacterScanner {
+
+ /** The document being scanned. */
+ private IDocument fDocument;
+ /** The offset of the document range to scan. */
+ private int fRangeOffset;
+ /** The length of the document range to scan. */
+ private int fRangeLength;
+ /** The delimiters of the document. */
+ private char[][] fDelimiters;
+
+ /** The buffer. */
+ private final char[] fBuffer;
+ /** The offset of the buffer within the document. */
+ private int fBufferOffset;
+ /** The valid length of the buffer for access. */
+ private int fBufferLength;
+ /** The offset of the scanner within the buffer. */
+ private int fOffset;
+
+
+ /**
+ * Creates a new buffered document scanner.
+ * The buffer size is set to the given number of characters.
+ *
+ * @param size the buffer size
+ */
+ public BufferedDocumentScanner(int size) {
+ Assert.isTrue(size >= 1);
+ fBuffer= new char[size];
+ }
+
+ /**
+ * Fills the buffer with the contens of the document starting at the given offset.
+ *
+ * @param offset the document offset at which the buffer starts
+ */
+ private final void updateBuffer(int offset) {
+
+ fBufferOffset= offset;
+
+ if (fBufferOffset + fBuffer.length > fRangeOffset + fRangeLength)
+ fBufferLength= fRangeLength - (fBufferOffset - fRangeOffset);
+ else
+ fBufferLength= fBuffer.length;
+
+ try {
+ final String content= fDocument.get(fBufferOffset, fBufferLength);
+ content.getChars(0, fBufferLength, fBuffer, 0);
+ } catch (BadLocationException e) {
+ }
+ }
+
+ /**
+ * Configures the scanner by providing access to the document range over which to scan.
+ *
+ * @param document the document to scan
+ * @param offset the offset of the document range to scan
+ * @param length the length of the document range to scan
+ */
+ public final void setRange(IDocument document, int offset, int length) {
+
+ fDocument= document;
+ fRangeOffset= offset;
+ fRangeLength= length;
+
+ String[] delimiters= document.getLegalLineDelimiters();
+ fDelimiters= new char[delimiters.length][];
+ for (int i= 0; i < delimiters.length; i++)
+ fDelimiters[i]= delimiters[i].toCharArray();
+
+ updateBuffer(offset);
+ fOffset= 0;
+ }
+
+ /*
+ * @see ICharacterScanner#read()
+ */
+ public final int read() {
+
+ if (fOffset == fBufferLength) {
+ if (fBufferOffset + fBufferLength == fDocument.getLength())
+ return EOF;
+ else {
+ updateBuffer(fBufferOffset + fBufferLength);
+ fOffset= 0;
+ }
+ }
+
+ return fBuffer[fOffset++];
+ }
+
+ /*
+ * @see ICharacterScanner#unread
+ */
+ public final void unread() {
+
+ if (fOffset == 0) {
+ if (fBufferOffset == fRangeOffset) {
+ // error: BOF
+ } else {
+ updateBuffer(fBufferOffset - fBuffer.length);
+ fOffset= fBuffer.length - 1;
+ }
+ } else {
+ --fOffset;
+ }
+ }
+
+ /*
+ * @see ICharacterScanner#getColumn()
+ */
+ public final int getColumn() {
+
+ try {
+ final int offset= fBufferOffset + fOffset;
+ final int line= fDocument.getLineOfOffset(offset);
+ final int start= fDocument.getLineOffset(line);
+ return offset - start;
+ } catch (BadLocationException e) {
+ }
+
+ return -1;
+ }
+
+ /*
+ * @see ICharacterScanner#getLegalLineDelimiters()
+ */
+ public final char[][] getLegalLineDelimiters() {
+ return fDelimiters;
+ }
+}
\ No newline at end of file
--- /dev/null
+package net.sourceforge.phpdt.internal.ui.text;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IPartitionTokenScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+
+/**
+ * This scanner recognizes the JavaDoc comments, Java multi line comments, Java single line comments,
+ * Java strings and Java characters.
+ */
+public class FastJavaPartitionScanner implements IPartitionTokenScanner {
+
+ private final static String SKIP= "__skip"; //$NON-NLS-1$
+ public final static String JAVA_STRING= "__php_string"; //$NON-NLS-1$
+ public final static String JAVA_SINGLE_LINE_COMMENT= "__php_singleline_comment"; //$NON-NLS-1$
+ public final static String JAVA_MULTI_LINE_COMMENT= "__php_multiline_comment"; //$NON-NLS-1$
+ public final static String JAVA_DOC= "__php_phpdoc"; //$NON-NLS-1$
+
+ // states
+ private static final int JAVA= 0;
+ private static final int SINGLE_LINE_COMMENT= 1;
+ private static final int MULTI_LINE_COMMENT= 2;
+ private static final int JAVADOC= 3;
+ private static final int CHARACTER= 4;
+ private static final int STRING= 5;
+
+ // beginning of prefixes and postfixes
+ private static final int NONE= 0;
+ private static final int BACKSLASH= 1; // postfix for STRING and CHARACTER
+ private static final int SLASH= 2; // prefix for SINGLE_LINE or MULTI_LINE or JAVADOC
+ private static final int SLASH_STAR= 3; // prefix for MULTI_LINE_COMMENT or JAVADOC
+ private static final int SLASH_STAR_STAR= 4; // prefix for MULTI_LINE_COMMENT or JAVADOC
+ private static final int STAR= 5; // postfix for MULTI_LINE_COMMENT or JAVADOC
+ private static final int CARRIAGE_RETURN=6; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+
+ /** The scanner. */
+// private final BufferedRuleBasedScanner fScanner= new BufferedRuleBasedScanner(1000);
+ private final BufferedDocumentScanner fScanner= new BufferedDocumentScanner(1000); // faster implementation
+
+ /** The offset of the last returned token. */
+ private int fTokenOffset;
+ /** The length of the last returned token. */
+ private int fTokenLength;
+
+ /** The state of the scanner. */
+ private int fState;
+ /** The last significant characters read. */
+ private int fLast;
+ /** The amount of characters already read on first call to nextToken(). */
+ private int fPrefixLength;
+
+ // emulate JavaPartitionScanner
+ private static final boolean fgEmulate= false;
+ private int fJavaOffset;
+ private int fJavaLength;
+
+ private final IToken[] fTokens= new IToken[] {
+ new Token(null),
+ new Token(JAVA_SINGLE_LINE_COMMENT),
+ new Token(JAVA_MULTI_LINE_COMMENT),
+ new Token(JAVA_DOC),
+ new Token(SKIP),
+ new Token(JAVA_STRING)
+ };
+
+ /*
+ * @see org.eclipse.jface.text.rules.ITokenScanner#nextToken()
+ */
+ public IToken nextToken() {
+
+ // emulate JavaPartitionScanner
+ if (fgEmulate) {
+ if (fJavaOffset != -1 && fTokenOffset + fTokenLength != fJavaOffset + fJavaLength) {
+ fTokenOffset += fTokenLength;
+ return fTokens[JAVA];
+ } else {
+ fJavaOffset= -1;
+ fJavaLength= 0;
+ }
+ }
+
+ fTokenOffset += fTokenLength;
+ fTokenLength= fPrefixLength;
+
+ while (true) {
+ final int ch= fScanner.read();
+
+ // characters
+ switch (ch) {
+ case ICharacterScanner.EOF:
+ if (fTokenLength > 0) {
+ fLast= NONE; // ignore last
+ return preFix(fState, JAVA, NONE, 0);
+
+ } else {
+ fLast= NONE;
+ fPrefixLength= 0;
+ return Token.EOF;
+ }
+
+ case '\r':
+ // emulate JavaPartitionScanner
+ if (!fgEmulate && fLast != CARRIAGE_RETURN) {
+ fLast= CARRIAGE_RETURN;
+ fTokenLength++;
+ continue;
+
+ } else {
+
+ switch (fState) {
+ case SINGLE_LINE_COMMENT:
+ case CHARACTER:
+ case STRING:
+ if (fTokenLength > 0) {
+ IToken token= fTokens[fState];
+
+ // emulate JavaPartitionScanner
+ if (fgEmulate) {
+ fTokenLength++;
+ fLast= NONE;
+ fPrefixLength= 0;
+ } else {
+ fLast= CARRIAGE_RETURN;
+ fPrefixLength= 1;
+ }
+
+ fState= JAVA;
+ return token;
+
+ } else {
+ consume();
+ continue;
+ }
+
+ default:
+ consume();
+ continue;
+ }
+ }
+
+ case '\n':
+ switch (fState) {
+ case SINGLE_LINE_COMMENT:
+ case CHARACTER:
+ case STRING:
+ // assert(fTokenLength > 0);
+ return postFix(fState);
+
+ default:
+ consume();
+ continue;
+ }
+
+ default:
+ if (!fgEmulate && fLast == CARRIAGE_RETURN) {
+ switch (fState) {
+ case SINGLE_LINE_COMMENT:
+ case CHARACTER:
+ case STRING:
+
+ int last;
+ int newState;
+ switch (ch) {
+ case '/':
+ last= SLASH;
+ newState= JAVA;
+ break;
+
+ case '*':
+ last= STAR;
+ newState= JAVA;
+ break;
+
+ case '\'':
+ last= NONE;
+ newState= CHARACTER;
+ break;
+
+ case '"':
+ last= NONE;
+ newState= STRING;
+ break;
+
+ case '\r':
+ last= CARRIAGE_RETURN;
+ newState= JAVA;
+ break;
+
+ case '\\':
+ last= BACKSLASH;
+ newState= JAVA;
+ break;
+
+ default:
+ last= NONE;
+ newState= JAVA;
+ break;
+ }
+
+ fLast= NONE; // ignore fLast
+ return preFix(fState, newState, last, 1);
+
+ default:
+ break;
+ }
+ }
+ }
+
+ // states
+ switch (fState) {
+ case JAVA:
+ switch (ch) {
+ case '/':
+ if (fLast == SLASH) {
+ if (fTokenLength - getLastLength(fLast) > 0) {
+ return preFix(JAVA, SINGLE_LINE_COMMENT, NONE, 2);
+ } else {
+ preFix(JAVA, SINGLE_LINE_COMMENT, NONE, 2);
+ fTokenOffset += fTokenLength;
+ fTokenLength= fPrefixLength;
+ break;
+ }
+
+ } else {
+ fTokenLength++;
+ fLast= SLASH;
+ break;
+ }
+
+ case '*':
+ if (fLast == SLASH) {
+ if (fTokenLength - getLastLength(fLast) > 0)
+ return preFix(JAVA, MULTI_LINE_COMMENT, SLASH_STAR, 2);
+ else {
+ preFix(JAVA, MULTI_LINE_COMMENT, SLASH_STAR, 2);
+ fTokenOffset += fTokenLength;
+ fTokenLength= fPrefixLength;
+ break;
+ }
+
+ } else {
+ consume();
+ break;
+ }
+
+ case '\'':
+ fLast= NONE; // ignore fLast
+ if (fTokenLength > 0)
+ return preFix(JAVA, CHARACTER, NONE, 1);
+ else {
+ preFix(JAVA, CHARACTER, NONE, 1);
+ fTokenOffset += fTokenLength;
+ fTokenLength= fPrefixLength;
+ break;
+ }
+
+ case '"':
+ fLast= NONE; // ignore fLast
+ if (fTokenLength > 0)
+ return preFix(JAVA, STRING, NONE, 1);
+ else {
+ preFix(JAVA, STRING, NONE, 1);
+ fTokenOffset += fTokenLength;
+ fTokenLength= fPrefixLength;
+ break;
+ }
+
+ default:
+ consume();
+ break;
+ }
+ break;
+
+ case SINGLE_LINE_COMMENT:
+ consume();
+ break;
+
+ case JAVADOC:
+ switch (ch) {
+ case '/':
+ switch (fLast) {
+ case SLASH_STAR_STAR:
+ return postFix(MULTI_LINE_COMMENT);
+
+ case STAR:
+ return postFix(JAVADOC);
+
+ default:
+ consume();
+ break;
+ }
+ break;
+
+ case '*':
+ fTokenLength++;
+ fLast= STAR;
+ break;
+
+ default:
+ consume();
+ break;
+ }
+ break;
+
+ case MULTI_LINE_COMMENT:
+ switch (ch) {
+ case '*':
+ if (fLast == SLASH_STAR) {
+ fLast= SLASH_STAR_STAR;
+ fTokenLength++;
+ fState= JAVADOC;
+ } else {
+ fTokenLength++;
+ fLast= STAR;
+ }
+ break;
+
+ case '/':
+ if (fLast == STAR) {
+ return postFix(MULTI_LINE_COMMENT);
+ } else {
+ consume();
+ break;
+ }
+
+ default:
+ consume();
+ break;
+ }
+ break;
+
+ case STRING:
+ switch (ch) {
+ case '\\':
+ fLast= (fLast == BACKSLASH) ? NONE : BACKSLASH;
+ fTokenLength++;
+ break;
+
+ case '\"':
+ if (fLast != BACKSLASH) {
+ return postFix(STRING);
+
+ } else {
+ consume();
+ break;
+ }
+
+ default:
+ consume();
+ break;
+ }
+ break;
+
+ case CHARACTER:
+ switch (ch) {
+ case '\\':
+ fLast= (fLast == BACKSLASH) ? NONE : BACKSLASH;
+ fTokenLength++;
+ break;
+
+ case '\'':
+ if (fLast != BACKSLASH) {
+ return postFix(CHARACTER);
+
+ } else {
+ consume();
+ break;
+ }
+
+ default:
+ consume();
+ break;
+ }
+ break;
+ }
+ }
+ }
+
+ private static final int getLastLength(int last) {
+ switch (last) {
+ default:
+ return -1;
+
+ case NONE:
+ return 0;
+
+ case CARRIAGE_RETURN:
+ case BACKSLASH:
+ case SLASH:
+ case STAR:
+ return 1;
+
+ case SLASH_STAR:
+ return 2;
+
+ case SLASH_STAR_STAR:
+ return 3;
+ }
+ }
+
+ private final void consume() {
+ fTokenLength++;
+ fLast= NONE;
+ }
+
+ private final IToken postFix(int state) {
+ fTokenLength++;
+ fLast= NONE;
+ fState= JAVA;
+ fPrefixLength= 0;
+ return fTokens[state];
+ }
+
+ private final IToken preFix(int state, int newState, int last, int prefixLength) {
+ // emulate JavaPartitionScanner
+ if (fgEmulate && state == JAVA && (fTokenLength - getLastLength(fLast) > 0)) {
+ fTokenLength -= getLastLength(fLast);
+ fJavaOffset= fTokenOffset;
+ fJavaLength= fTokenLength;
+ fTokenLength= 1;
+ fState= newState;
+ fPrefixLength= prefixLength;
+ fLast= last;
+ return fTokens[state];
+
+ } else {
+ fTokenLength -= getLastLength(fLast);
+ fLast= last;
+ fPrefixLength= prefixLength;
+ IToken token= fTokens[state];
+ fState= newState;
+ return token;
+ }
+ }
+
+ private static int getState(String contentType) {
+
+ if (contentType == null)
+ return JAVA;
+
+ else if (contentType.equals(JAVA_SINGLE_LINE_COMMENT))
+ return SINGLE_LINE_COMMENT;
+
+ else if (contentType.equals(JAVA_MULTI_LINE_COMMENT))
+ return MULTI_LINE_COMMENT;
+
+ else if (contentType.equals(JAVA_DOC))
+ return JAVADOC;
+
+ else if (contentType.equals(JAVA_STRING))
+ return STRING;
+
+ else if (contentType.equals(SKIP))
+ return CHARACTER;
+
+ else
+ return JAVA;
+ }
+
+ /*
+ * @see IPartitionTokenScanner#setPartialRange(IDocument, int, int, String, int)
+ */
+ public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
+
+ fScanner.setRange(document, offset, length);
+ fTokenOffset= partitionOffset;
+ fTokenLength= 0;
+ fPrefixLength= offset - partitionOffset;
+ fLast= NONE;
+
+ if (offset == partitionOffset) {
+ // restart at beginning of partition
+ fState= JAVA;
+ } else {
+ fState= getState(contentType);
+ }
+
+ // emulate JavaPartitionScanner
+ if (fgEmulate) {
+ fJavaOffset= -1;
+ fJavaLength= 0;
+ }
+ }
+
+ /*
+ * @see ITokenScanner#setRange(IDocument, int, int)
+ */
+ public void setRange(IDocument document, int offset, int length) {
+
+ fScanner.setRange(document, offset, length);
+ fTokenOffset= offset;
+ fTokenLength= 0;
+ fPrefixLength= 0;
+ fLast= NONE;
+ fState= JAVA;
+
+ // emulate JavaPartitionScanner
+ if (fgEmulate) {
+ fJavaOffset= -1;
+ fJavaLength= 0;
+ }
+ }
+
+ /*
+ * @see ITokenScanner#getTokenLength()
+ */
+ public int getTokenLength() {
+ return fTokenLength;
+ }
+
+ /*
+ * @see ITokenScanner#getTokenOffset()
+ */
+ public int getTokenOffset() {
+ return fTokenOffset;
+ }
+
+}
--- /dev/null
+package net.sourceforge.phpdt.internal.ui.text;
+
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+
+import java.io.IOException;
+import java.io.PushbackReader;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import net.sourceforge.phpdt.internal.ui.PHPUIMessages;
+
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
+
+
+
+
+/**
+ * Reads the text contents from a reader of HTML contents and translates
+ * the tags or cut them out.
+ */
+public class HTML2TextReader extends SubstitutionTextReader {
+
+
+ private static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String EMPTY_STRING= ""; //$NON-NLS-1$
+ private static final Map fgEntityLookup;
+ private static final Set fgTags;
+
+ static {
+
+ fgTags= new HashSet();
+ fgTags.add("b"); //$NON-NLS-1$
+ fgTags.add("br"); //$NON-NLS-1$
+ fgTags.add("h5"); //$NON-NLS-1$
+ fgTags.add("p"); //$NON-NLS-1$
+ fgTags.add("dl"); //$NON-NLS-1$
+ fgTags.add("dt"); //$NON-NLS-1$
+ fgTags.add("dd"); //$NON-NLS-1$
+ fgTags.add("li"); //$NON-NLS-1$
+ fgTags.add("ul"); //$NON-NLS-1$
+ fgTags.add("pre"); //$NON-NLS-1$
+
+ fgEntityLookup= new HashMap(7);
+ fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
+ fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
+ fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
+ fgEntityLookup.put("amp", "&"); //$NON-NLS-1$ //$NON-NLS-2$
+ fgEntityLookup.put("circ", "^"); //$NON-NLS-1$ //$NON-NLS-2$
+ fgEntityLookup.put("tilde", "~"); //$NON-NLS-2$ //$NON-NLS-1$
+ fgEntityLookup.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ private int fCounter= 0;
+ private TextPresentation fTextPresentation;
+ private int fBold= 0;
+ private int fStartOffset= -1;
+ private boolean fInParagraph= false;
+ private boolean fIsPreformattedText= false;
+
+ /**
+ * Transforms the html text from the reader to formatted text.
+ * @param presentation If not <code>null</code>, formattings will be applied to
+ * the presentation.
+ */
+ public HTML2TextReader(Reader reader, TextPresentation presentation) {
+ super(new PushbackReader(reader));
+ fTextPresentation= presentation;
+ }
+
+ public int read() throws IOException {
+ int c= super.read();
+ if (c != -1)
+ ++ fCounter;
+ return c;
+ }
+
+ protected void startBold() {
+ if (fBold == 0)
+ fStartOffset= fCounter;
+ ++ fBold;
+ }
+
+ protected void startPreformattedText() {
+ fIsPreformattedText= true;
+ setSkipWhitespace(false);
+ }
+
+ protected void stopPreformattedText() {
+ fIsPreformattedText= false;
+ setSkipWhitespace(true);
+ }
+
+ protected void stopBold() {
+ -- fBold;
+ if (fBold == 0) {
+ if (fTextPresentation != null) {
+ fTextPresentation.addStyleRange(new StyleRange(fStartOffset, fCounter - fStartOffset, null, null, SWT.BOLD));
+ }
+ fStartOffset= -1;
+ }
+ }
+
+ /**
+ * @see SubstitutionTextReader#computeSubstitution(char)
+ */
+ protected String computeSubstitution(int c) throws IOException {
+
+ if (c == '<')
+ return processHTMLTag();
+ else if (c == '&')
+ return processEntity();
+ else if (fIsPreformattedText)
+ return processPreformattedText(c);
+
+ return null;
+ }
+
+ private String html2Text(String html) {
+
+ String tag= html;
+ if ('/' == tag.charAt(0))
+ tag= tag.substring(1);
+
+ if (!fgTags.contains(tag))
+ return EMPTY_STRING;
+
+
+ if ("pre".equals(html)) { //$NON-NLS-1$
+ startPreformattedText();
+ return EMPTY_STRING;
+ }
+
+ if ("/pre".equals(html)) { //$NON-NLS-1$
+ stopPreformattedText();
+ return EMPTY_STRING;
+ }
+
+ if (fIsPreformattedText)
+ return EMPTY_STRING;
+
+ if ("b".equals(html)) { //$NON-NLS-1$
+ startBold();
+ return EMPTY_STRING;
+ }
+
+ if ("h5".equals(html) || "dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$
+ startBold();
+ return EMPTY_STRING;
+ }
+
+ if ("dl".equals(html)) //$NON-NLS-1$
+ return LINE_DELIM;
+
+ if ("dd".equals(html)) //$NON-NLS-1$
+ return "\t"; //$NON-NLS-1$
+
+ if ("li".equals(html)) //$NON-NLS-1$
+ return LINE_DELIM + "\t" + PHPUIMessages.getString("HTML2TextReader.dash"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if ("/b".equals(html)) { //$NON-NLS-1$
+ stopBold();
+ return EMPTY_STRING;
+ }
+
+ if ("p".equals(html)) { //$NON-NLS-1$
+ fInParagraph= true;
+ return LINE_DELIM;
+ }
+
+ if ("br".equals(html)) //$NON-NLS-1$
+ return LINE_DELIM;
+
+ if ("/p".equals(html)) { //$NON-NLS-1$
+ boolean inParagraph= fInParagraph;
+ fInParagraph= false;
+ return inParagraph ? EMPTY_STRING : LINE_DELIM;
+ }
+
+ if ("/h5".equals(html) || "/dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$
+ stopBold();
+ return LINE_DELIM;
+ }
+
+ if ("/dd".equals(html)) //$NON-NLS-1$
+ return LINE_DELIM;
+
+ return EMPTY_STRING;
+ }
+
+ /*
+ * A '<' has been read. Process a html tag
+ */
+ private String processHTMLTag() throws IOException {
+
+ StringBuffer buf= new StringBuffer();
+ int ch;
+ do {
+
+ ch= nextChar();
+
+ while (ch != -1 && ch != '>') {
+ buf.append(Character.toLowerCase((char) ch));
+ ch= nextChar();
+ if (ch == '"'){
+ buf.append(Character.toLowerCase((char) ch));
+ ch= nextChar();
+ while (ch != -1 && ch != '"'){
+ buf.append(Character.toLowerCase((char) ch));
+ ch= nextChar();
+ }
+ }
+ if (ch == '<'){
+ unread(ch);
+ return '<' + buf.toString();
+ }
+ }
+
+ if (ch == -1)
+ return null;
+
+ int tagLen= buf.length();
+ // needs special treatment for comments
+ if ((tagLen >= 3 && "!--".equals(buf.substring(0, 3))) //$NON-NLS-1$
+ && !(tagLen >= 5 && "--!".equals(buf.substring(tagLen - 3)))) { //$NON-NLS-1$
+ // unfinished comment
+ buf.append(ch);
+ } else {
+ break;
+ }
+ } while (true);
+
+ return html2Text(buf.toString());
+ }
+
+ private String processPreformattedText(int c) {
+ if (c == '\r' || c == '\n')
+ fCounter++;
+ return null;
+ }
+
+
+ private void unread(int ch) throws IOException {
+ ((PushbackReader) getReader()).unread(ch);
+ }
+
+ protected String entity2Text(String symbol) {
+ if (symbol.length() > 1 && symbol.charAt(0) == '#') {
+ int ch;
+ try {
+ if (symbol.charAt(1) == 'x') {
+ ch= Integer.parseInt(symbol.substring(2), 16);
+ } else {
+ ch= Integer.parseInt(symbol.substring(1), 10);
+ }
+ return EMPTY_STRING + (char)ch;
+ } catch (NumberFormatException e) {
+ }
+ } else {
+ String str= (String) fgEntityLookup.get(symbol);
+ if (str != null) {
+ return str;
+ }
+ }
+ return "&" + symbol; // not found //$NON-NLS-1$
+ }
+
+ /*
+ * A '&' has been read. Process a entity
+ */
+ private String processEntity() throws IOException {
+ StringBuffer buf= new StringBuffer();
+ int ch= nextChar();
+ while (Character.isLetterOrDigit((char)ch) || ch == '#') {
+ buf.append((char) ch);
+ ch= nextChar();
+ }
+
+ if (ch == ';')
+ return entity2Text(buf.toString());
+
+ buf.insert(0, '&');
+ if (ch != -1)
+ buf.append((char) ch);
+ return buf.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+package net.sourceforge.phpdt.internal.ui.text;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Iterator;
+
+import net.sourceforge.phpdt.internal.ui.PHPUIMessages;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Display;
+
+
+
+
+public class HTMLTextPresenter implements DefaultInformationControl.IInformationPresenter {
+
+ private static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ private int fCounter;
+ private boolean fEnforceUpperLineLimit;
+
+ public HTMLTextPresenter(boolean enforceUpperLineLimit) {
+ super();
+ fEnforceUpperLineLimit= enforceUpperLineLimit;
+ }
+
+ public HTMLTextPresenter() {
+ this(true);
+ }
+
+ protected Reader createReader(String hoverInfo, TextPresentation presentation) {
+ return new HTML2TextReader(new StringReader(hoverInfo), presentation);
+ }
+
+ protected void adaptTextPresentation(TextPresentation presentation, int offset, int insertLength) {
+
+ int yoursStart= offset;
+ int yoursEnd= offset + insertLength -1;
+ yoursEnd= Math.max(yoursStart, yoursEnd);
+
+ Iterator e= presentation.getAllStyleRangeIterator();
+ while (e.hasNext()) {
+
+ StyleRange range= (StyleRange) e.next();
+
+ int myStart= range.start;
+ int myEnd= range.start + range.length -1;
+ myEnd= Math.max(myStart, myEnd);
+
+ if (myEnd < yoursStart)
+ continue;
+
+ if (myStart < yoursStart)
+ range.length += insertLength;
+ else
+ range.start += insertLength;
+ }
+ }
+
+ private void append(StringBuffer buffer, String string, TextPresentation presentation) {
+
+ int length= string.length();
+ buffer.append(string);
+
+ if (presentation != null)
+ adaptTextPresentation(presentation, fCounter, length);
+
+ fCounter += length;
+ }
+
+ private String getIndent(String line) {
+ int length= line.length();
+
+ int i= 0;
+ while (i < length && Character.isWhitespace(line.charAt(i))) ++i;
+
+ return (i == length ? line : line.substring(0, i)) + " "; //$NON-NLS-1$
+ }
+
+ /*
+ * @see IHoverInformationPresenter#updatePresentation(Display display, String, TextPresentation, int, int)
+ */
+ public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) {
+
+ if (hoverInfo == null)
+ return null;
+
+ GC gc= new GC(display);
+ try {
+
+ StringBuffer buffer= new StringBuffer();
+ int maxNumberOfLines= Math.round(maxHeight / gc.getFontMetrics().getHeight());
+
+ fCounter= 0;
+ LineBreakingReader reader= new LineBreakingReader(createReader(hoverInfo, presentation), gc, maxWidth);
+
+ boolean lastLineFormatted= false;
+ String lastLineIndent= null;
+
+ String line=reader.readLine();
+ boolean lineFormatted= reader.isFormattedLine();
+ boolean firstLineProcessed= false;
+
+ while (line != null) {
+
+ if (fEnforceUpperLineLimit && maxNumberOfLines <= 0)
+ break;
+
+ if (firstLineProcessed) {
+ if (!lastLineFormatted)
+ append(buffer, LINE_DELIM, null);
+ else {
+ append(buffer, LINE_DELIM, presentation);
+ if (lastLineIndent != null)
+ append(buffer, lastLineIndent, presentation);
+ }
+ }
+
+ append(buffer, line, null);
+ firstLineProcessed= true;
+
+ lastLineFormatted= lineFormatted;
+ if (!lineFormatted)
+ lastLineIndent= null;
+ else if (lastLineIndent == null)
+ lastLineIndent= getIndent(line);
+
+ line= reader.readLine();
+ lineFormatted= reader.isFormattedLine();
+
+ maxNumberOfLines--;
+ }
+
+ if (line != null) {
+ append(buffer, LINE_DELIM, lineFormatted ? presentation : null);
+ append(buffer, PHPUIMessages.getString("HTMLTextPresenter.ellipsis"), presentation); //$NON-NLS-1$
+ }
+
+ return trim(buffer, presentation);
+
+ } catch (IOException e) {
+
+ PHPeclipsePlugin.log(e);
+ return null;
+
+ } finally {
+ gc.dispose();
+ }
+ }
+
+ private String trim(StringBuffer buffer, TextPresentation presentation) {
+
+ int length= buffer.length();
+
+ int end= length -1;
+ while (end >= 0 && Character.isWhitespace(buffer.charAt(end)))
+ -- end;
+
+ if (end == -1)
+ return ""; //$NON-NLS-1$
+
+ if (end < length -1)
+ buffer.delete(end + 1, length);
+ else
+ end= length;
+
+ int start= 0;
+ while (start < end && Character.isWhitespace(buffer.charAt(start)))
+ ++ start;
+
+ buffer.delete(0, start);
+ presentation.setResultWindow(new Region(start, buffer.length()));
+ return buffer.toString();
+ }
+}
+
--- /dev/null
+package net.sourceforge.phpdt.internal.ui.text;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+import net.sourceforge.phpdt.ui.text.IColorManager;
+import net.sourceforge.phpdt.ui.text.IColorManagerExtension;
+
+/**
+ * Java color manager.
+ */
+public class JavaColorManager implements IColorManager, IColorManagerExtension {
+
+ protected Map fKeyTable= new HashMap(10);
+ protected Map fDisplayTable= new HashMap(2);
+
+
+ public JavaColorManager() {
+ }
+
+ private void dispose(Display display) {
+ Map colorTable= (Map) fDisplayTable.get(display);
+ if (colorTable != null) {
+ Iterator e= colorTable.values().iterator();
+ while (e.hasNext())
+ ((Color) e.next()).dispose();
+ }
+ }
+
+ /*
+ * @see IColorManager#getColor(RGB)
+ */
+ public Color getColor(RGB rgb) {
+
+ if (rgb == null)
+ return null;
+
+ final Display display= Display.getCurrent();
+ Map colorTable= (Map) fDisplayTable.get(display);
+ if (colorTable == null) {
+ colorTable= new HashMap(10);
+ fDisplayTable.put(display, colorTable);
+ display.disposeExec(new Runnable() {
+ public void run() {
+ dispose(display);
+ }
+ });
+ }
+
+ Color color= (Color) colorTable.get(rgb);
+ if (color == null) {
+ color= new Color(Display.getCurrent(), rgb);
+ colorTable.put(rgb, color);
+ }
+
+ return color;
+ }
+
+ /*
+ * @see IColorManager#dispose
+ */
+ public void dispose() {
+ // nothing to dispose
+ }
+
+ /*
+ * @see IColorManager#getColor(String)
+ */
+ public Color getColor(String key) {
+
+ if (key == null)
+ return null;
+
+ RGB rgb= (RGB) fKeyTable.get(key);
+ return getColor(rgb);
+ }
+
+ /*
+ * @see IColorManagerExtension#bindColor(String, RGB)
+ */
+ public void bindColor(String key, RGB rgb) {
+ Object value= fKeyTable.get(key);
+ if (value != null)
+ throw new UnsupportedOperationException();
+
+ fKeyTable.put(key, rgb);
+ }
+
+ /*
+ * @see IColorManagerExtension#unbindColor(String)
+ */
+ public void unbindColor(String key) {
+ fKeyTable.remove(key);
+ }
+}
--- /dev/null
+package net.sourceforge.phpdt.internal.ui.text;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+
+import java.text.BreakIterator;
+import org.eclipse.swt.graphics.GC;
+
+/*
+ * Not a real reader. Could change if requested
+ */
+public class LineBreakingReader {
+
+ private BufferedReader fReader;
+ private GC fGC;
+ private int fMaxWidth;
+
+ private String fLine;
+ private int fOffset;
+
+ private BreakIterator fLineBreakIterator;
+
+ /**
+ * Creates a reader that breaks an input text to fit in a given width.
+ * @param reader Reader of the input text
+ * @param gc The graphic context that defines the currently used font sizes
+ * @param maxLineWidth The max width (pixes) where the text has to fit in
+ */
+ public LineBreakingReader(Reader reader, GC gc, int maxLineWidth) {
+ fReader= new BufferedReader(reader);
+ fGC= gc;
+ fMaxWidth= maxLineWidth;
+ fOffset= 0;
+ fLine= null;
+ fLineBreakIterator= BreakIterator.getLineInstance();
+ }
+
+ public boolean isFormattedLine() {
+ return fLine != null;
+ }
+
+ /**
+ * Reads the next line. The lengths of the line will not exceed the gived maximum
+ * width.
+ */
+ public String readLine() throws IOException {
+ if (fLine == null) {
+ String line= fReader.readLine();
+ if (line == null)
+ return null;
+
+ int lineLen= fGC.textExtent(line).x;
+ if (lineLen < fMaxWidth) {
+ return line;
+ }
+ fLine= line;
+ fLineBreakIterator.setText(line);
+ fOffset= 0;
+ }
+ int breakOffset= findNextBreakOffset(fOffset);
+ String res;
+ if (breakOffset != BreakIterator.DONE) {
+ res= fLine.substring(fOffset, breakOffset);
+ fOffset= findWordBegin(breakOffset);
+ if (fOffset == fLine.length()) {
+ fLine= null;
+ }
+ } else {
+ res= fLine.substring(fOffset);
+ fLine= null;
+ }
+ return res;
+ }
+
+ private int findNextBreakOffset(int currOffset) {
+ int currWidth= 0;
+ int nextOffset= fLineBreakIterator.following(currOffset);
+ while (nextOffset != BreakIterator.DONE) {
+ String word= fLine.substring(currOffset, nextOffset);
+ int wordWidth= fGC.textExtent(word).x;
+ int nextWidth= wordWidth + currWidth;
+ if (nextWidth > fMaxWidth) {
+ if (currWidth > 0) {
+ return currOffset;
+ } else {
+ return nextOffset;
+ }
+ }
+ currWidth= nextWidth;
+ currOffset= nextOffset;
+ nextOffset= fLineBreakIterator.next();
+ }
+ return nextOffset;
+ }
+
+ private int findWordBegin(int idx) {
+ while (idx < fLine.length() && Character.isWhitespace(fLine.charAt(idx))) {
+ idx++;
+ }
+ return idx;
+ }
+}
--- /dev/null
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM 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 implementation
+**********************************************************************/
+
+package net.sourceforge.phpdt.internal.ui.text;
+
+
+import java.io.IOException;
+import java.io.Reader;
+
+import net.sourceforge.phpdt.internal.corext.phpdoc.SingleCharReader;
+
+
+/**
+ * Reads the text contents from a reader and computes for each character
+ * a potential substitution. The substitution may eat more characters than
+ * only the one passed into the computation routine.
+ */
+public abstract class SubstitutionTextReader extends SingleCharReader {
+
+ protected static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ private Reader fReader;
+ private boolean fWasWhiteSpace;
+ private int fCharAfterWhiteSpace;
+
+ /**
+ * Tells whether white space characters are skipped.
+ */
+ private boolean fSkipWhiteSpace= true;
+
+ private boolean fReadFromBuffer;
+ private StringBuffer fBuffer;
+ private int fIndex;
+
+
+ protected SubstitutionTextReader(Reader reader) {
+ fReader= reader;
+ fBuffer= new StringBuffer();
+ fIndex= 0;
+ fReadFromBuffer= false;
+ fCharAfterWhiteSpace= -1;
+ fWasWhiteSpace= true;
+ }
+
+ /**
+ * Implement to compute the substitution for the given character and
+ * if necessary subsequent characters. Use <code>nextChar</code>
+ * to read subsequent characters.
+ */
+ protected abstract String computeSubstitution(int c) throws IOException;
+
+ /**
+ * Returns the internal reader.
+ */
+ protected Reader getReader() {
+ return fReader;
+ }
+
+ /**
+ * Returns the next character.
+ */
+ protected int nextChar() throws IOException {
+ fReadFromBuffer= (fBuffer.length() > 0);
+ if (fReadFromBuffer) {
+ char ch= fBuffer.charAt(fIndex++);
+ if (fIndex >= fBuffer.length()) {
+ fBuffer.setLength(0);
+ fIndex= 0;
+ }
+ return ch;
+ } else {
+ int ch= fCharAfterWhiteSpace;
+ if (ch == -1) {
+ ch= fReader.read();
+ }
+ if (fSkipWhiteSpace && Character.isWhitespace((char)ch)) {
+ do {
+ ch= fReader.read();
+ } while (Character.isWhitespace((char)ch));
+ if (ch != -1) {
+ fCharAfterWhiteSpace= ch;
+ return ' ';
+ }
+ } else {
+ fCharAfterWhiteSpace= -1;
+ }
+ return ch;
+ }
+ }
+
+ /**
+ * @see Reader#read()
+ */
+ public int read() throws IOException {
+ int c;
+ do {
+
+ c= nextChar();
+ while (!fReadFromBuffer) {
+ String s= computeSubstitution(c);
+ if (s == null)
+ break;
+ if (s.length() > 0)
+ fBuffer.insert(0, s);
+ c= nextChar();
+ }
+
+ } while (fSkipWhiteSpace && fWasWhiteSpace && (c == ' '));
+ fWasWhiteSpace= (c == ' ' || c == '\r' || c == '\n');
+ return c;
+ }
+
+ /**
+ * @see Reader#ready()
+ */
+ public boolean ready() throws IOException {
+ return fReader.ready();
+ }
+
+ /**
+ * @see Reader#close()
+ */
+ public void close() throws IOException {
+ fReader.close();
+ }
+
+ /**
+ * @see Reader#reset()
+ */
+ public void reset() throws IOException {
+ fReader.reset();
+ fWasWhiteSpace= true;
+ fCharAfterWhiteSpace= -1;
+ fBuffer.setLength(0);
+ fIndex= 0;
+ }
+
+ protected final void setSkipWhitespace(boolean state) {
+ fSkipWhiteSpace= state;
+ }
+
+ protected final boolean isSkippingWhitespace() {
+ return fSkipWhiteSpace;
+ }
+}
\ No newline at end of file
--- /dev/null
+package net.sourceforge.phpdt.internal.ui.text.java;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+
+
+/**
+ * Interface of an object participating in reconciling.
+ */
+public interface IReconcilingParticipant {
+
+ /**
+ * Called after reconciling has been finished.
+ */
+ void reconciled();
+}
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM 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 implementation
+**********************************************************************/
+
package net.sourceforge.phpdt.internal.ui.text.link;
import org.eclipse.jface.text.Position;
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM 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 implementation
+**********************************************************************/
+
package net.sourceforge.phpdt.internal.ui.text.link;
import java.util.Arrays;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IAutoEditStrategy;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.TypedPosition;
import org.eclipse.jface.util.Assert;
-//import org.eclipse.jdt.internal.ui.JavaPlugin;
/**
* This class manages linked positions in a document. Positions are linked
* gain control of the same document.
* </ul>
*/
-public class LinkedPositionManager implements IDocumentListener, IPositionUpdater {
-
- private static class PositionComparator implements Comparator {
- /*
- * @see Comparator#compare(Object, Object)
- */
- public int compare(Object object0, Object object1) {
- Position position0= (Position) object0;
- Position position1= (Position) object1;
-
- return position0.getOffset() - position1.getOffset();
- }
- }
-
+public class LinkedPositionManager implements IDocumentListener, IPositionUpdater, IAutoEditStrategy {
+
+ // This class still exists to properly handle code assist.
+ // This is due to the fact that it cannot be distinguished betweeen document changes which are
+ // issued by code assist and document changes which origin from another text viewer.
+ // There is a conflict in interest since in the latter case the linked mode should be left, but in the former case
+ // the linked mode should remain.
+ // To support content assist, document changes have to be propagated to connected positions
+ // by registering replace commands using IDocumentExtension.
+ // if it wasn't for the support of content assist, the documentChanged() method could be reduced to
+ // a simple call to leave(true)
private class Replace implements IDocumentExtension.IReplace {
private Position fReplacePosition;
document.addDocumentListener(owner);
}
}
+
+ private static class PositionComparator implements Comparator {
+ /*
+ * @see Comparator#compare(Object, Object)
+ */
+ public int compare(Object object0, Object object1) {
+ Position position0= (Position) object0;
+ Position position1= (Position) object1;
+
+ return position0.getOffset() - position1.getOffset();
+ }
+ }
private static final String LINKED_POSITION= "LinkedPositionManager.linked.position"; //$NON-NLS-1$
private static final Comparator fgPositionComparator= new PositionComparator();
try {
fDocument.addPosition(LINKED_POSITION, new TypedPosition(offset, length, type));
} catch (BadPositionCategoryException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
Assert.isTrue(false);
}
}
fDocument.removePositionCategory(LINKED_POSITION);
} catch (BadLocationException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
Assert.isTrue(false);
} catch (BadPositionCategoryException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
Assert.isTrue(false);
} finally {
}
/**
+ * Returns the position at the given offset, <code>null</code> if there is no position.
+ * @since 2.1
+ */
+ public Position getPosition(int offset) {
+ Position[] positions= getPositions(fDocument);
+ if (positions == null)
+ return null;
+
+ for (int i= positions.length - 1; i >= 0; i--) {
+ Position position= positions[i];
+ if (offset >= position.getOffset() && offset <= position.getOffset() + position.getLength())
+ return positions[i];
+ }
+
+ return null;
+ }
+
+ /**
* Returns the first linked position.
*
* @return returns <code>null</code> if no linked position exist.
* @return returns <code>null</code> if no linked position exist.
*/
public Position getPreviousPosition(int offset) {
- Position[] positions= getPositions(fDocument);
+ Position[] positions= getPositions(fDocument);
if (positions == null)
return null;
+ TypedPosition currentPosition= (TypedPosition) findCurrentPosition(positions, offset);
+ String currentType= currentPosition == null ? null : currentPosition.getType();
+
Position lastPosition= null;
Position position= getFirstPosition();
-
- while ((position != null) && (position.getOffset() < offset)) {
+
+ while ((position != null) && (position.getOffset() < offset) && !((TypedPosition) position).getType().equals(currentType)) {
lastPosition= position;
position= findNextPosition(positions, position.getOffset());
- }
+ }
return lastPosition;
}
return positions;
} catch (BadPositionCategoryException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
Assert.isTrue(false);
}
* @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
*/
public void documentAboutToBeChanged(DocumentEvent event) {
+
IDocument document= event.getDocument();
Position[] positions= getPositions(document);
- Position position= findCurrentEditablePosition(positions, event.getOffset());
+ Position position= findCurrentPosition(positions, event.getOffset());
// modification outside editable position
if (position == null) {
- position= findCurrentPosition(positions, event.getOffset());
-
- // modification outside any position
- if (position == null) {
- // check for destruction of constraints (spacing of at least 1)
- if ((event.getText().length() == 0) &&
- (findCurrentPosition(positions, event.getOffset()) != null) &&
- (findCurrentPosition(positions, event.getOffset() + event.getLength()) != null))
- {
- leave(true);
- }
-
- // modification intersects non-editable position
- } else {
+ // check for destruction of constraints (spacing of at least 1)
+ if ((event.getText() == null || event.getText().length() == 0) &&
+ (findCurrentPosition(positions, event.getOffset()) != null) &&
+ (findCurrentPosition(positions, event.getOffset() + event.getLength()) != null))
+ {
leave(true);
- }
+ }
// modification intersects editable position
} else {
/*
* @see IDocumentListener#documentChanged(DocumentEvent)
*/
- public void documentChanged(DocumentEvent event) {
+ public void documentChanged(DocumentEvent event) {
+
+ // have to handle code assist, so can't just leave the linked mode
+ // leave(true);
+
IDocument document= event.getDocument();
Position[] positions= getPositions(document);
- TypedPosition currentPosition= (TypedPosition) findCurrentEditablePosition(positions, event.getOffset());
+ TypedPosition currentPosition= (TypedPosition) findCurrentPosition(positions, event.getOffset());
// ignore document changes (assume it won't invalidate constraints)
if (currentPosition == null)
int deltaOffset= event.getOffset() - currentPosition.getOffset();
- if (fListener != null)
- fListener.setCurrentPosition(currentPosition, deltaOffset + event.getText().length());
-
+ if (fListener != null) {
+ int length= event.getText() == null ? 0 : event.getText().length();
+ fListener.setCurrentPosition(currentPosition, deltaOffset + length);
+ }
+
for (int i= 0; i != positions.length; i++) {
TypedPosition p= (TypedPosition) positions[i];
* @see IPositionUpdater#update(DocumentEvent)
*/
public void update(DocumentEvent event) {
- int deltaLength= event.getText().length() - event.getLength();
+ int deltaLength= (event.getText() == null ? 0 : event.getText().length()) - event.getLength();
Position[] positions= getPositions(event.getDocument());
TypedPosition currentPosition= (TypedPosition) findCurrentPosition(positions, event.getOffset());
return null;
}
- private static Position findCurrentEditablePosition(Position[] positions, int offset) {
- Position position= positions[0];
-
- while ((position != null) && !includes(position, offset, 0))
- position= findNextPosition(positions, position.getOffset());
-
- return position;
- }
-
private boolean containsLineDelimiters(String string) {
+
+ if (string == null)
+ return false;
+
String[] delimiters= fDocument.getLegalLineDelimiters();
for (int i= 0; i != delimiters.length; i++)
public boolean anyPositionIncludes(int offset, int length) {
Position[] positions= getPositions(fDocument);
- Position position= findCurrentEditablePosition(positions, offset);
+ Position position= findCurrentPosition(positions, offset);
if (position == null)
return false;
return includes(position, offset, length);
}
-}
+ /*
+ * @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand)
+ */
+ public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
+
+ // don't interfere with preceding auto edit strategies
+ if (command.getCommandCount() != 1) {
+ leave(true);
+ return;
+ }
+
+ Position[] positions= getPositions(document);
+ TypedPosition currentPosition= (TypedPosition) findCurrentPosition(positions, command.offset);
+
+ // handle edits outside of a position
+ if (currentPosition == null) {
+ leave(true);
+ return;
+ }
+
+ if (! command.doit)
+ return;
+
+ command.doit= false;
+ command.owner= this;
+ command.caretOffset= command.offset + command.length;
+
+ int deltaOffset= command.offset - currentPosition.getOffset();
+
+ if (fListener != null)
+ fListener.setCurrentPosition(currentPosition, deltaOffset + command.text.length());
+
+ for (int i= 0; i != positions.length; i++) {
+ TypedPosition position= (TypedPosition) positions[i];
+
+ try {
+ if (position.getType().equals(currentPosition.getType()) && !position.equals(currentPosition))
+ command.addCommand(position.getOffset() + deltaOffset, command.length, command.text, this);
+ } catch (BadLocationException e) {
+ PHPeclipsePlugin.log(e);
+ }
+ }
+ }
+
+}
\ No newline at end of file
import java.lang.reflect.InvocationTargetException;
+import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
+import net.sourceforge.phpdt.ui.PreferenceConstants;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IPositionUpdater;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextInputListener;
+import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension;
+import org.eclipse.jface.text.ITextViewerExtension2;
+import org.eclipse.jface.text.ITextViewerExtension3;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.events.ShellListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Color;
* A user interface for <code>LinkedPositionManager</code>, using <code>ITextViewer</code>.
*/
public class LinkedPositionUI implements LinkedPositionListener,
- ITextInputListener, ModifyListener, VerifyListener, VerifyKeyListener, PaintListener, IPropertyChangeListener {
+ ITextInputListener, ITextListener, ModifyListener, VerifyListener, VerifyKeyListener, PaintListener, IPropertyChangeListener, ShellListener {
/**
* A listener for notification when the user cancelled the edit operation.
void exit(boolean accept);
}
- /** Preference key for linked position color */
- // public final static String LINKED_POSITION_COLOR= "_linkedPositionColor"; //$NON-NLS-1$
+ public static class ExitFlags {
+ public int flags;
+ public boolean doit;
+ public ExitFlags(int flags, boolean doit) {
+ this.flags= flags;
+ this.doit= doit;
+ }
+ }
+
+ public interface ExitPolicy {
+ ExitFlags doExit(LinkedPositionManager manager, VerifyEvent event, int offset, int length);
+ }
+
// leave flags
private static final int UNINSTALL= 1; // uninstall linked position manager
- private static final int COMMIT= 2; // commit changes
+ public static final int COMMIT= 2; // commit changes
private static final int DOCUMENT_CHANGED= 4; // document has changed
- private static final int UPDATE_CARET= 8; // update caret
+ public static final int UPDATE_CARET= 8; // update caret
private static final String CARET_POSITION= "LinkedPositionUI.caret.position"; //$NON-NLS-1$
private static final IPositionUpdater fgUpdater= new DefaultPositionUpdater(CARET_POSITION);
private int fFinalCaretOffset= -1; // no final caret offset
private Position fFramePosition;
+ private int fInitialOffset= -1;
private int fCaretOffset;
+ private ExitPolicy fExitPolicy;
private ExitListener fExitListener;
+ private boolean fNeedRedraw;
+
+ private String fContentType;
+
/**
* Creates a user interface for <code>LinkedPositionManager</code>.
*
* @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent event) {
- // if (event.getProperty().equals(CompilationUnitEditor.LINKED_POSITION_COLOR)) {
- if (event.getProperty().equals(PHPeclipsePlugin.LINKED_POSITION_COLOR)) {
+ if (event.getProperty().equals(PreferenceConstants.EDITOR_LINKED_POSITION_COLOR)) {
initializeHighlightColor(fViewer);
redrawRegion();
}
StyledText text= viewer.getTextWidget();
if (text != null) {
Display display= text.getDisplay();
- // fFrameColor= createColor(fgStore, CompilationUnitEditor.LINKED_POSITION_COLOR, display);
- fFrameColor= createColor(fgStore, PHPeclipsePlugin.LINKED_POSITION_COLOR, display);
- }
+ fFrameColor= createColor(fgStore, PreferenceConstants.EDITOR_LINKED_POSITION_COLOR, display);
+ }
}
/**
return null;
}
+
+ /**
+ * Sets the initial offset.
+ * @param offset
+ */
+ public void setInitialOffset(int offset) {
+ fInitialOffset= offset;
+ }
/**
* Sets the final position of the caret when the linked mode is exited
fExitListener= listener;
}
+ /**
+ * Sets an <code>ExitPolicy</code> which decides when and how
+ * the linked mode is exited.
+ */
+ public void setExitPolicy(ExitPolicy policy) {
+ fExitPolicy= policy;
+ }
+
/*
* @see LinkedPositionManager.LinkedPositionListener#setCurrentPositions(Position, int)
*/
public void setCurrentPosition(Position position, int caretOffset) {
if (!fFramePosition.equals(position)) {
- redrawRegion();
+ fNeedRedraw= true;
fFramePosition= position;
}
* @see #exit(boolean)
*/
public void enter() {
+
// track final caret
IDocument document= fViewer.getDocument();
document.addPositionCategory(CARET_POSITION);
document.addPositionUpdater(fgUpdater);
+
try {
if (fFinalCaretOffset != -1)
document.addPosition(CARET_POSITION, new Position(fFinalCaretOffset));
handleException(fViewer.getTextWidget().getShell(), e);
} catch (BadPositionCategoryException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
Assert.isTrue(false);
}
fViewer.addTextInputListener(this);
+ fViewer.addTextListener(this);
ITextViewerExtension extension= (ITextViewerExtension) fViewer;
extension.prependVerifyKeyListener(this);
text.addPaintListener(this);
text.showSelection();
- fFramePosition= fManager.getFirstPosition();
- if (fFramePosition == null)
+ Shell shell= text.getShell();
+ shell.addShellListener(this);
+
+ fFramePosition= (fInitialOffset == -1) ? fManager.getFirstPosition() : fManager.getPosition(fInitialOffset);
+ if (fFramePosition == null) {
leave(UNINSTALL | COMMIT | UPDATE_CARET);
+ return;
+ }
fgStore.addPropertyChangeListener(this);
+
+ try {
+ fContentType= document.getContentType(fFramePosition.offset);
+ if (fViewer instanceof ITextViewerExtension2) {
+ ((ITextViewerExtension2) fViewer).prependAutoEditStrategy(fManager, fContentType);
+ } else {
+ Assert.isTrue(false);
+ }
+
+ } catch (BadLocationException e) {
+ handleException(fViewer.getTextWidget().getShell(), e);
+ }
}
/*
}
private void leave(int flags) {
+
+ fInitialOffset= -1;
+
if ((flags & UNINSTALL) != 0)
fManager.uninstall((flags & COMMIT) != 0);
text.removeModifyListener(this);
text.removeVerifyListener(this);
+ Shell shell= text.getShell();
+ shell.removeShellListener(this);
+
ITextViewerExtension extension= (ITextViewerExtension) fViewer;
extension.removeVerifyKeyListener(this);
+ if (fViewer instanceof ITextViewerExtension2 && fContentType != null)
+ ((ITextViewerExtension2) fViewer).removeAutoEditStrategy(fManager, fContentType);
+ fContentType= null;
+
+ fViewer.removeTextListener(this);
fViewer.removeTextInputListener(this);
try {
- IRegion region= fViewer.getVisibleRegion();
IDocument document= fViewer.getDocument();
if (((flags & COMMIT) != 0) &&
((flags & UPDATE_CARET) != 0))
{
Position[] positions= document.getPositions(CARET_POSITION);
-
if ((positions != null) && (positions.length != 0)) {
- int offset= positions[0].getOffset() - region.getOffset();
- if ((offset >= 0) && (offset <= region.getLength()))
- text.setSelection(offset, offset);
+
+ if (fViewer instanceof ITextViewerExtension3) {
+ ITextViewerExtension3 extension3= (ITextViewerExtension3) fViewer;
+ int widgetOffset= extension3.modelOffset2WidgetOffset(positions[0].getOffset());
+ if (widgetOffset >= 0)
+ text.setSelection(widgetOffset, widgetOffset);
+
+ } else {
+ IRegion region= fViewer.getVisibleRegion();
+ int offset= positions[0].getOffset() - region.getOffset();
+ if ((offset >= 0) && (offset <= region.getLength()))
+ text.setSelection(offset, offset);
+ }
}
}
((flags & DOCUMENT_CHANGED) != 0));
} catch (BadPositionCategoryException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
Assert.isTrue(false);
}
fFramePosition= position;
selectRegion();
redrawRegion();
- }
+ }
}
/*
* @see VerifyKeyListener#verifyKey(VerifyEvent)
*/
public void verifyKey(VerifyEvent event) {
+
+ if (!event.doit)
+ return;
+
+ Point selection= fViewer.getSelectedRange();
+ int offset= selection.x;
+ int length= selection.y;
+
+ ExitFlags exitFlags= fExitPolicy == null ? null : fExitPolicy.doExit(fManager, event, offset, length);
+ if (exitFlags != null) {
+ leave(UNINSTALL | exitFlags.flags);
+ event.doit= exitFlags.doit;
+ return;
+ }
+
switch (event.character) {
// [SHIFT-]TAB = hop between edit boxes
case 0x09:
{
- Point selection= fViewer.getTextWidget().getSelection();
- IRegion region= fViewer.getVisibleRegion();
- int offset= selection.x + region.getOffset();
- int length= selection.y - selection.x;
-
// if tab was treated as a document change, would it exceed variable range?
if (!LinkedPositionManager.includes(fFramePosition, offset, length)) {
- leave(UNINSTALL | COMMIT | UPDATE_CARET);
+ leave(UNINSTALL | COMMIT);
return;
}
}
if (!event.doit)
return;
- IRegion region= fViewer.getVisibleRegion();
-
- int offset= event.start + region.getOffset();
- int length= event.end - event.start;
+ int offset= 0;
+ int length= 0;
+
+ if (fViewer instanceof ITextViewerExtension3) {
+ ITextViewerExtension3 extension= (ITextViewerExtension3) fViewer;
+ IRegion modelRange= extension.widgetRange2ModelRange(new Region(event.start, event.end - event.start));
+ if (modelRange == null)
+ return;
+
+ offset= modelRange.getOffset();
+ length= modelRange.getLength();
+
+ } else {
+ IRegion visibleRegion= fViewer.getVisibleRegion();
+ offset= event.start + visibleRegion.getOffset();
+ length= event.end - event.start;
+ }
+
// allow changes only within linked positions when coming through UI
if (!fManager.anyPositionIncludes(offset, length))
leave(UNINSTALL | COMMIT);
public void paintControl(PaintEvent event) {
if (fFramePosition == null)
return;
-
- IRegion region= fViewer.getVisibleRegion();
-
- // #6824
- if (!includes(region, fFramePosition)) {
- leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
- return;
- }
-
- int offset= fFramePosition.getOffset() - region.getOffset();
- int length= fFramePosition.getLength();
+ IRegion widgetRange= asWidgetRange(fFramePosition);
+ if (widgetRange == null) {
+ leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
+ return;
+ }
+
+ int offset= widgetRange.getOffset();
+ int length= widgetRange.getLength();
+
StyledText text= fViewer.getTextWidget();
// support for bidi
gc.setForeground(fFrameColor);
gc.drawLine(x1, y, x2, y);
}
+
+ protected IRegion asWidgetRange(Position position) {
+ if (fViewer instanceof ITextViewerExtension3) {
+
+ ITextViewerExtension3 extension= (ITextViewerExtension3) fViewer;
+ return extension.modelRange2WidgetRange(new Region(position.getOffset(), position.getLength()));
+
+ } else {
+
+ IRegion region= fViewer.getVisibleRegion();
+ if (includes(region, position))
+ return new Region(position.getOffset() - region.getOffset(), position.getLength());
+ }
+
+ return null;
+ }
private static Point getMinimumLocation(StyledText text, int offset, int length) {
Point minLocation= new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
private void redrawRegion() {
- IRegion region= fViewer.getVisibleRegion();
-
- if (!includes(region, fFramePosition)) {
+ IRegion widgetRange= asWidgetRange(fFramePosition);
+ if (widgetRange == null) {
leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
return;
}
-
- int offset= fFramePosition.getOffset() - region.getOffset();
- int length= fFramePosition.getLength();
-
+
StyledText text= fViewer.getTextWidget();
- if (text != null && !text.isDisposed())
- text.redrawRange(offset, length, true);
+ if (text != null && !text.isDisposed())
+ text.redrawRange(widgetRange.getOffset(), widgetRange.getLength(), true);
}
private void selectRegion() {
- IRegion region= fViewer.getVisibleRegion();
-
- if (!includes(region, fFramePosition)) {
+
+ IRegion widgetRange= asWidgetRange(fFramePosition);
+ if (widgetRange == null) {
leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
return;
}
- int start= fFramePosition.getOffset() - region.getOffset();
- int end= fFramePosition.getLength() + start;
-
StyledText text= fViewer.getTextWidget();
- if (text != null && !text.isDisposed())
+ if (text != null && !text.isDisposed()) {
+ int start= widgetRange.getOffset();
+ int end= widgetRange.getLength() + start;
text.setSelection(start, end);
+ }
}
-
+
private void updateCaret() {
- IRegion region= fViewer.getVisibleRegion();
-
- if (!includes(region, fFramePosition)) {
+
+ IRegion widgetRange= asWidgetRange(fFramePosition);
+ if (widgetRange == null) {
leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
return;
}
-
- int offset= fFramePosition.getOffset() + fCaretOffset - region.getOffset();
- if ((offset >= 0) && (offset <= region.getLength())) {
- StyledText text= fViewer.getTextWidget();
- if (text != null && !text.isDisposed())
- text.setCaretOffset(offset);
- }
+ int offset= widgetRange.getOffset() + fCaretOffset;
+ StyledText text= fViewer.getTextWidget();
+ if (text != null && !text.isDisposed())
+ text.setCaretOffset(offset);
}
/*
private static void handleException(Shell shell, Exception e) {
String title= LinkedPositionMessages.getString("LinkedPositionUI.error.title"); //$NON-NLS-1$
if (e instanceof CoreException)
- PHPeclipsePlugin.log(e);
- // ExceptionHandler.handle((CoreException)e, shell, title, null);
+ ExceptionHandler.handle((CoreException)e, shell, title, null);
else if (e instanceof InvocationTargetException)
- PHPeclipsePlugin.log(e);
- // ExceptionHandler.handle((InvocationTargetException)e, shell, title, null);
+ ExceptionHandler.handle((InvocationTargetException)e, shell, title, null);
else {
MessageDialog.openError(shell, title, e.getMessage());
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
}
}
position.getOffset() + position.getLength() <= region.getOffset() + region.getLength();
}
+ /*
+ * @see org.eclipse.jface.text.ITextListener#textChanged(TextEvent)
+ */
+ public void textChanged(TextEvent event) {
+ if (!fNeedRedraw)
+ return;
+
+ redrawRegion();
+ fNeedRedraw= false;
+ }
+
+ /*
+ * @see org.eclipse.swt.events.ShellListener#shellActivated(org.eclipse.swt.events.ShellEvent)
+ */
+ public void shellActivated(ShellEvent event) {
+ }
+
+ /*
+ * @see org.eclipse.swt.events.ShellListener#shellClosed(org.eclipse.swt.events.ShellEvent)
+ */
+ public void shellClosed(ShellEvent event) {
+ leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
+ }
+
+ /*
+ * @see org.eclipse.swt.events.ShellListener#shellDeactivated(org.eclipse.swt.events.ShellEvent)
+ */
+ public void shellDeactivated(ShellEvent event) {
+ leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
+ }
+
+ /*
+ * @see org.eclipse.swt.events.ShellListener#shellDeiconified(org.eclipse.swt.events.ShellEvent)
+ */
+ public void shellDeiconified(ShellEvent event) {
+ }
+
+ /*
+ * @see org.eclipse.swt.events.ShellListener#shellIconified(org.eclipse.swt.events.ShellEvent)
+ */
+ public void shellIconified(ShellEvent event) {
+ leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
+ }
+
}
\ No newline at end of file
import java.util.ArrayList;
import java.util.List;
+import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
import net.sourceforge.phpeclipse.phpeditor.util.PHPWhitespaceDetector;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextAttribute;
// };
- public PHPDocCodeScanner(PHPColorProvider provider) { // , IPreferenceStore store) {
+ public PHPDocCodeScanner(JavaColorManager provider, IPreferenceStore store) {
// super(manager, store);
// initialize();
createRules(provider);
/* create the rules for PHPDoc
*/
- protected List createRules(PHPColorProvider provider) {
+ protected List createRules(JavaColorManager provider) {
List list= new ArrayList();
--- /dev/null
+/*******************************************************************************
+ * 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 v1.0
+ * 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;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
+
+//import org.phpeclipse.phpdt.core.IClasspathEntry;
+//
+//import org.phpeclipse.phpdt.ui.text.IJavaColorConstants;
+//
+//import org.phpeclipse.phpdt.internal.ui.JavaPlugin;
+//import org.phpeclipse.phpdt.internal.ui.preferences.NewJavaProjectPreferencePage;
+
+/**
+ * Preference constants used in the JDT-UI preference store. Clients should only read the
+ * JDT-UI preference store using these values. Clients are not allowed to modify the
+ * preference store programmatically.
+ *
+ * @since 2.0
+ */
+public class PreferenceConstants {
+
+ private PreferenceConstants() {
+ }
+
+ /**
+ * A named preference that controls return type rendering of methods in the UI.
+ * <p>
+ * Value is of type <code>Boolean</code>: if <code>true</code> return types
+ * are rendered
+ * </p>
+ */
+ public static final String APPEARANCE_METHOD_RETURNTYPE= "net.sourceforge.phpdt.ui.methodreturntype";//$NON-NLS-1$
+
+ /**
+ * A named preference that controls if override indicators are rendered in the UI.
+ * <p>
+ * Value is of type <code>Boolean</code>: if <code>true</code> override
+ * indicators are rendered
+ * </p>
+ */
+ public static final String APPEARANCE_OVERRIDE_INDICATOR= "net.sourceforge.phpdt.ui.overrideindicator";//$NON-NLS-1$
+
+ /**
+ * A named preference that defines the pattern used for package name compression.
+ * <p>
+ * Value is of type <code>String</code>. For example foe the given package name 'org.eclipse.jdt' pattern
+ * '.' will compress it to '..jdt', '1~' to 'o~.e~.jdt'.
+ * </p>
+ */
+ public static final String APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW= "PackagesView.pkgNamePatternForPackagesView";//$NON-NLS-1$
+
+ /**
+ * A named preference that controls if package name compression is turned on or off.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @see #APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW
+ */
+ public static final String APPEARANCE_COMPRESS_PACKAGE_NAMES= "net.sourceforge.phpdt.ui.compresspackagenames";//$NON-NLS-1$
+
+ /**
+ * A named preference that controls if empty inner packages are folded in
+ * the hierarchical mode of the package explorer.
+ * <p>
+ * Value is of type <code>Boolean</code>: if <code>true</code> empty
+ * inner packages are folded.
+ * </p>
+ * @since 2.1
+ */
+ public static final String APPEARANCE_FOLD_PACKAGES_IN_PACKAGE_EXPLORER= "net.sourceforge.phpdt.ui.flatPackagesInPackageExplorer";//$NON-NLS-1$
+
+ /**
+ * A named preference that defines how member elements are ordered by the
+ * Java views using the <code>JavaElementSorter</code>.
+ * <p>
+ * Value is of type <code>String</code>: A comma separated list of the
+ * following entries. Each entry must be in the list, no duplication. List
+ * order defines the sort order.
+ * <ul>
+ * <li><b>T</b>: Types</li>
+ * <li><b>C</b>: Constructors</li>
+ * <li><b>I</b>: Initializers</li>
+ * <li><b>M</b>: Methods</li>
+ * <li><b>F</b>: Fields</li>
+ * <li><b>SI</b>: Static Initializers</li>
+ * <li><b>SM</b>: Static Methods</li>
+ * <li><b>SF</b>: Static Fields</li>
+ * </ul>
+ * </p>
+ * @since 2.1
+ */
+ public static final String APPEARANCE_MEMBER_SORT_ORDER= "outlinesortoption"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if prefix removal during setter/getter generation is turned on or off.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String CODEGEN_USE_GETTERSETTER_PREFIX= "net.sourceforge.phpdt.ui.gettersetter.prefix.enable";//$NON-NLS-1$
+
+ /**
+ * A named preference that holds a list of prefixes to be removed from a local variable to compute setter
+ * and gettter names.
+ * <p>
+ * Value is of type <code>String</code>: comma separated list of prefixed
+ * </p>
+ *
+ * @see #CODEGEN_USE_GETTERSETTER_PREFIX
+ */
+ public static final String CODEGEN_GETTERSETTER_PREFIX= "net.sourceforge.phpdt.ui.gettersetter.prefix.list";//$NON-NLS-1$
+
+ /**
+ * A named preference that controls if suffix removal during setter/getter generation is turned on or off.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String CODEGEN_USE_GETTERSETTER_SUFFIX= "net.sourceforge.phpdt.ui.gettersetter.suffix.enable";//$NON-NLS-1$
+
+ /**
+ * A named preference that holds a list of suffixes to be removed from a local variable to compute setter
+ * and getter names.
+ * <p>
+ * Value is of type <code>String</code>: comma separated list of suffixes
+ * </p>
+ *
+ * @see #CODEGEN_USE_GETTERSETTER_SUFFIX
+ */
+ public static final String CODEGEN_GETTERSETTER_SUFFIX= "net.sourceforge.phpdt.ui.gettersetter.suffix.list"; //$NON-NLS-1$
+
+ /**
+ * A name preference that controls if a JavaDoc stub gets added to newly created types and methods.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String CODEGEN__JAVADOC_STUBS= "net.sourceforge.phpdt.ui.phpdoc"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if a non-phpdoc comment gets added to methods generated via the
+ * "Override Methods" operation.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String CODEGEN__NON_JAVADOC_COMMENTS= "net.sourceforge.phpdt.ui.seecomments"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if a file comment gets added to newly created files.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String CODEGEN__FILE_COMMENTS= "net.sourceforge.phpdt.ui.filecomments"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds a list of comma separated package names. The list specifies the import order used by
+ * the "Organize Imports" opeation.
+ * <p>
+ * Value is of type <code>String</code>: semicolon separated list of package
+ * names
+ * </p>
+ */
+ public static final String ORGIMPORTS_IMPORTORDER= "net.sourceforge.phpdt.ui.importorder"; //$NON-NLS-1$
+
+ /**
+ * A named preference that specifies the number of imports added before a star-import declaration is used.
+ * <p>
+ * Value is of type <code>Int</code>: positive value specifing the number of non star-import is used
+ * </p>
+ */
+ public static final String ORGIMPORTS_ONDEMANDTHRESHOLD= "net.sourceforge.phpdt.ui.ondemandthreshold"; //$NON-NLS-1$
+
+ /**
+ * A named preferences that controls if types that start with a lower case letters get added by the
+ * "Organize Import" operation.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String ORGIMPORTS_IGNORELOWERCASE= "net.sourceforge.phpdt.ui.ignorelowercasenames"; //$NON-NLS-1$
+
+ /**
+ * A named preference that speficies whether children of a compilation unit are shown in the package explorer.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String SHOW_CU_CHILDREN= "net.sourceforge.phpdt.ui.packages.cuchildren"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the package explorer's selection is linked to the active editor.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String LINK_PACKAGES_TO_EDITOR= "net.sourceforge.phpdt.ui.packages.linktoeditor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the hierarchy view's selection is linked to the active editor.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String LINK_TYPEHIERARCHY_TO_EDITOR= "net.sourceforge.phpdt.ui.packages.linktypehierarchytoeditor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the browsing view's selection is
+ * linked to the active editor.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public static final String LINK_BROWSING_VIEW_TO_EDITOR= "net.sourceforge.phpdt.ui.browsing.linktoeditor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether new projects are generated using source and output folder.
+ * <p>
+ * Value is of type <code>Boolean</code>. if <code>true</code> new projects are created with a source and
+ * output folder. If <code>false</code> source and output folder equals to the project.
+ * </p>
+ */
+ public static final String SRCBIN_FOLDERS_IN_NEWPROJ= "net.sourceforge.phpdt.ui.wizards.srcBinFoldersInNewProjects"; //$NON-NLS-1$
+
+ /**
+ * A named preference that specifies the source folder name used when creating a new Java project. Value is inactive
+ * if <code>SRCBIN_FOLDERS_IN_NEWPROJ</code> is set to <code>false</code>.
+ * <p>
+ * Value is of type <code>String</code>.
+ * </p>
+ *
+ * @see #SRCBIN_FOLDERS_IN_NEWPROJ
+ */
+ public static final String SRCBIN_SRCNAME= "net.sourceforge.phpdt.ui.wizards.srcBinFoldersSrcName"; //$NON-NLS-1$
+
+ /**
+ * A named preference that specifies the output folder name used when creating a new Java project. Value is inactive
+ * if <code>SRCBIN_FOLDERS_IN_NEWPROJ</code> is set to <code>false</code>.
+ * <p>
+ * Value is of type <code>String</code>.
+ * </p>
+ *
+ * @see #SRCBIN_FOLDERS_IN_NEWPROJ
+ */
+ public static final String SRCBIN_BINNAME= "net.sourceforge.phpdt.ui.wizards.srcBinFoldersBinName"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds a list of possible JRE libraries used by the New Java Project wizard. An library
+ * consists of a description and an arbitrary number of <code>IClasspathEntry</code>s, that will represent the
+ * JRE on the new project's classpath.
+ * <p>
+ * Value is of type <code>String</code>: a semicolon separated list of encoded JRE libraries.
+ * <code>NEWPROJECT_JRELIBRARY_INDEX</code> defines the currently used library. Clients
+ * should use the method <code>encodeJRELibrary</code> to encode a JRE library into a string
+ * and the methods <code>decodeJRELibraryDescription(String)</code> and <code>
+ * decodeJRELibraryClasspathEntries(String)</code> to decode the description and the array
+ * of classpath entries from an encoded string.
+ * </p>
+ *
+ * @see #NEWPROJECT_JRELIBRARY_INDEX
+ * @see #encodeJRELibrary(String, IClasspathEntry[])
+ * @see #decodeJRELibraryDescription(String)
+ * @see #decodeJRELibraryClasspathEntries(String)
+ */
+ public static final String NEWPROJECT_JRELIBRARY_LIST= "net.sourceforge.phpdt.ui.wizards.jre.list"; //$NON-NLS-1$
+
+ /**
+ * A named preferences that specifies the current active JRE library.
+ * <p>
+ * Value is of type <code>Int</code>: an index into the list of possible JRE libraries.
+ * </p>
+ *
+ * @see #NEWPROJECT_JRELIBRARY_LIST
+ */
+ public static final String NEWPROJECT_JRELIBRARY_INDEX= "net.sourceforge.phpdt.ui.wizards.jre.index"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if a new type hierarchy gets opened in a
+ * new type hierarchy perspective or inside the type hierarchy view part.
+ * <p>
+ * Value is of type <code>String</code>: possible values are <code>
+ * OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE</code> or <code>
+ * OPEN_TYPE_HIERARCHY_IN_VIEW_PART</code>.
+ * </p>
+ *
+ * @see #OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE
+ * @see #OPEN_TYPE_HIERARCHY_IN_VIEW_PART
+ */
+ public static final String OPEN_TYPE_HIERARCHY= "net.sourceforge.phpdt.ui.openTypeHierarchy"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preference <code>OPEN_TYPE_HIERARCHY</code>.
+ *
+ * @see #OPEN_TYPE_HIERARCHY
+ */
+ public static final String OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE= "perspective"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preference <code>OPEN_TYPE_HIERARCHY</code>.
+ *
+ * @see #OPEN_TYPE_HIERARCHY
+ */
+ public static final String OPEN_TYPE_HIERARCHY_IN_VIEW_PART= "viewPart"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls the behaviour when double clicking on a container in the packages view.
+ * <p>
+ * Value is of type <code>String</code>: possible values are <code>
+ * DOUBLE_CLICK_GOES_INTO</code> or <code>
+ * DOUBLE_CLICK_EXPANDS</code>.
+ * </p>
+ *
+ * @see #DOUBLE_CLICK_EXPANDS
+ * @see #DOUBLE_CLICK_GOES_INTO
+ */
+ public static final String DOUBLE_CLICK= "packageview.doubleclick"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preference <code>DOUBLE_CLICK</code>.
+ *
+ * @see #DOUBLE_CLICK
+ */
+ public static final String DOUBLE_CLICK_GOES_INTO= "packageview.gointo"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preference <code>DOUBLE_CLICK</code>.
+ *
+ * @see #DOUBLE_CLICK
+ */
+ public static final String DOUBLE_CLICK_EXPANDS= "packageview.doubleclick.expands"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether Java views update their presentation while editing or when saving the
+ * content of an editor.
+ * <p>
+ * Value is of type <code>String</code>: possible values are <code>
+ * UPDATE_ON_SAVE</code> or <code>
+ * UPDATE_WHILE_EDITING</code>.
+ * </p>
+ *
+ * @see #UPDATE_ON_SAVE
+ * @see #UPDATE_WHILE_EDITING
+ */
+ public static final String UPDATE_JAVA_VIEWS= "JavaUI.update"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preference <code>UPDATE_JAVA_VIEWS</code>
+ *
+ * @see #UPDATE_JAVA_VIEWS
+ */
+ public static final String UPDATE_ON_SAVE= "JavaUI.update.onSave"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preference <code>UPDATE_JAVA_VIEWS</code>
+ *
+ * @see #UPDATE_JAVA_VIEWS
+ */
+ public static final String UPDATE_WHILE_EDITING= "JavaUI.update.whileEditing"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the path of the Javadoc command used by the Javadoc creation wizard.
+ * <p>
+ * Value is of type <code>String</code>.
+ * </p>
+ */
+ public static final String JAVADOC_COMMAND= "command"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether bracket matching highlighting is turned on or off.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_MATCHING_BRACKETS= "matchingBrackets"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to highlight matching brackets.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_MATCHING_BRACKETS_COLOR= "matchingBracketsColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the current line highlighting is turned on or off.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_CURRENT_LINE= "currentLine"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to highlight the current line.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_CURRENT_LINE_COLOR= "currentLineColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the print margin is turned on or off.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_PRINT_MARGIN= "printMargin"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render the print margin.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_PRINT_MARGIN_COLOR= "printMarginColor"; //$NON-NLS-1$
+
+ /**
+ * Print margin column. Int value.
+ */
+ public final static String EDITOR_PRINT_MARGIN_COLUMN= "printMarginColumn"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used for the find/replace scope.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_FIND_SCOPE_COLOR= AbstractTextEditor.PREFERENCE_COLOR_FIND_SCOPE;
+
+ /**
+ * A named preference that specifies if the editor uses spaces for tabs.
+ * <p>
+ * Value is of type <code>Boolean</code>. If <code>true</code>spaces instead of tabs are used
+ * in the editor. If <code>false</code> the editor inserts a tab character when pressing the tab
+ * key.
+ * </p>
+ */
+ public final static String EDITOR_SPACES_FOR_TABS= "spacesForTabs"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the number of spaces used per tab in the editor.
+ * <p>
+ * Value is of type <code>Int</code>: positive int value specifying the number of
+ * spaces per tab.
+ * </p>
+ */
+ public final static String EDITOR_TAB_WIDTH= "net.sourceforge.phpdt.ui.editor.tab.width"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the outline view selection
+ * should stay in sync with with the element at the current cursor position.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE= "JavaEditor.SyncOutlineOnCursorMove"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if correction indicators are shown in the UI.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_CORRECTION_INDICATION= "JavaEditor.ShowTemporaryProblem"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the editor shows problem indicators in text (squiggly lines).
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_PROBLEM_INDICATION= "problemIndication"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render problem indicators.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see #EDITOR_PROBLEM_INDICATION
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_PROBLEM_INDICATION_COLOR= "problemIndicationColor"; //$NON-NLS-1$
+
+ /**PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR;
+ * A named preference that controls whether the editor shows warning indicators in text (squiggly lines).
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_WARNING_INDICATION= "warningIndication"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render warning indicators.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see #EDITOR_WARNING_INDICATION
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_WARNING_INDICATION_COLOR= "warningIndicationColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the editor shows task indicators in text (squiggly lines).
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_TASK_INDICATION= "taskIndication"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render task indicators.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see #EDITOR_TASK_INDICATION
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_TASK_INDICATION_COLOR= "taskIndicationColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the editor shows bookmark
+ * indicators in text (squiggly lines).
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_BOOKMARK_INDICATION= "bookmarkIndication"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render bookmark indicators.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see #EDITOR_BOOKMARK_INDICATION
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ * @since 2.1
+ */
+ public final static String EDITOR_BOOKMARK_INDICATION_COLOR= "bookmarkIndicationColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the editor shows search
+ * indicators in text (squiggly lines).
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_SEARCH_RESULT_INDICATION= "searchResultIndication"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render search indicators.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see #EDITOR_SEARCH_RESULT_INDICATION
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ * @since 2.1
+ */
+ public final static String EDITOR_SEARCH_RESULT_INDICATION_COLOR= "searchResultIndicationColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the editor shows unknown
+ * indicators in text (squiggly lines).
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_UNKNOWN_INDICATION= "othersIndication"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render unknown
+ * indicators.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see #EDITOR_UNKNOWN_INDICATION
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ * @since 2.1
+ */
+ public final static String EDITOR_UNKNOWN_INDICATION_COLOR= "othersIndicationColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the overview ruler shows error
+ * indicators.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER= "errorIndicationInOverviewRuler"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the overview ruler shows warning
+ * indicators.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER= "warningIndicationInOverviewRuler"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the overview ruler shows task
+ * indicators.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER= "taskIndicationInOverviewRuler"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the overview ruler shows
+ * bookmark indicators.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER= "bookmarkIndicationInOverviewRuler"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the overview ruler shows
+ * search result indicators.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER= "searchResultIndicationInOverviewRuler"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the overview ruler shows
+ * unknown indicators.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER= "othersIndicationInOverviewRuler"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the 'close strings' feature
+ * is enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_CLOSE_STRINGS= "closeStrings"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the 'wrap strings' feature is
+ * enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_WRAP_STRINGS= "wrapStrings"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the 'close brackets' feature is
+ * enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_CLOSE_BRACKETS= "closeBrackets"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the 'close braces' feature is
+ * enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_CLOSE_BRACES= "closeBraces"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the 'close php docs' feature is
+ * enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_CLOSE_JAVADOCS= "closeJavaDocs"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the 'add JavaDoc tags' feature
+ * is enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_ADD_JAVADOC_TAGS= "addJavaDocTags"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the 'format Javadoc tags'
+ * feature is enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_FORMAT_JAVADOCS= "formatJavaDocs"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the 'smart paste' feature is
+ * enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_SMART_PASTE= "smartPaste"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the 'smart home-end' feature is
+ * enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_SMART_HOME_END= AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END;
+
+ /**
+ * A named preference that controls if temporary problems are evaluated and shown in the UI.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_EVALUTE_TEMPORARY_PROBLEMS= "handleTemporaryProblems"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if the overview ruler is shown in the UI.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_OVERVIEW_RULER= "overviewRuler"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if the line number ruler is shown in the UI.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_LINE_NUMBER_RULER= "lineNumberRuler"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render line numbers inside the line number ruler.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ * @see #EDITOR_LINE_NUMBER_RULER
+ */
+ public final static String EDITOR_LINE_NUMBER_RULER_COLOR= "lineNumberColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render linked positions inside code templates.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_LINKED_POSITION_COLOR= "linkedPositionColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used as the text foreground.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_FOREGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND;
+
+ /**
+ * A named preference that describes if the system default foreground color
+ * is used as the text foreground.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_FOREGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT;
+
+ /**
+ * A named preference that holds the color used as the text background.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_BACKGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND;
+
+ /**
+ * A named preference that describes if the system default background color
+ * is used as the text foreground.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_BACKGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT;
+
+ /**
+ * Preference key suffix for bold text style preference keys.
+ */
+ public static final String EDITOR_BOLD_SUFFIX= "_bold"; //$NON-NLS-1$
+
+// /**
+// * A named preference that holds the color used to render multi line comments.
+// * <p>
+// * Value is of type <code>String</code>. A RGB color value encoded as a string
+// * using class <code>PreferenceConverter</code>
+// * </p>
+// *
+// * @see org.eclipse.jface.resource.StringConverter
+// * @see org.eclipse.jface.preference.PreferenceConverter
+// */
+// public final static String EDITOR_MULTI_LINE_COMMENT_COLOR= IJavaColorConstants.JAVA_MULTI_LINE_COMMENT;
+//
+// /**
+// * A named preference that controls whether multi line comments are rendered in bold.
+// * <p>
+// * Value is of type <code>Boolean</code>. If <code>true</code> multi line comments are rendered
+// * in bold. If <code>false</code> the are rendered using no font style attribute.
+// * </p>
+// */
+// public final static String EDITOR_MULTI_LINE_COMMENT_BOLD= IJavaColorConstants.JAVA_MULTI_LINE_COMMENT + EDITOR_BOLD_SUFFIX;
+//
+// /**
+// * A named preference that holds the color used to render single line comments.
+// * <p>
+// * Value is of type <code>String</code>. A RGB color value encoded as a string
+// * using class <code>PreferenceConverter</code>
+// * </p>
+// *
+// * @see org.eclipse.jface.resource.StringConverter
+// * @see org.eclipse.jface.preference.PreferenceConverter
+// */
+// public final static String EDITOR_SINGLE_LINE_COMMENT_COLOR= IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT;
+//
+// /**
+// * A named preference that controls whether sinle line comments are rendered in bold.
+// * <p>
+// * Value is of type <code>Boolean</code>. If <code>true</code> single line comments are rendered
+// * in bold. If <code>false</code> the are rendered using no font style attribute.
+// * </p>
+// */
+// public final static String EDITOR_SINGLE_LINE_COMMENT_BOLD= IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT + EDITOR_BOLD_SUFFIX;
+//
+// /**
+// * A named preference that holds the color used to render php keywords.
+// * <p>
+// * Value is of type <code>String</code>. A RGB color value encoded as a string
+// * using class <code>PreferenceConverter</code>
+// * </p>
+// *
+// * @see org.eclipse.jface.resource.StringConverter
+// * @see org.eclipse.jface.preference.PreferenceConverter
+// */
+// public final static String EDITOR_JAVA_KEYWORD_COLOR= IJavaColorConstants.JAVA_KEYWORD;
+//
+// /**
+// * A named preference that controls whether keywords are rendered in bold.
+// * <p>
+// * Value is of type <code>Boolean</code>.
+// * </p>
+// */
+// public final static String EDITOR_JAVA_KEYWORD_BOLD= IJavaColorConstants.JAVA_KEYWORD + EDITOR_BOLD_SUFFIX;
+//
+// /**
+// * A named preference that holds the color used to render string constants.
+// * <p>
+// * Value is of type <code>String</code>. A RGB color value encoded as a string
+// * using class <code>PreferenceConverter</code>
+// * </p>
+// *
+// * @see org.eclipse.jface.resource.StringConverter
+// * @see org.eclipse.jface.preference.PreferenceConverter
+// */
+// public final static String EDITOR_STRING_COLOR= IJavaColorConstants.JAVA_STRING;
+//
+// /**
+// * A named preference that controls whether string constants are rendered in bold.
+// * <p>
+// * Value is of type <code>Boolean</code>.
+// * </p>
+// */
+// public final static String EDITOR_STRING_BOLD= IJavaColorConstants.JAVA_STRING + EDITOR_BOLD_SUFFIX;
+//
+// /**
+// * A named preference that holds the color used to render php default text.
+// * <p>
+// * Value is of type <code>String</code>. A RGB color value encoded as a string
+// * using class <code>PreferenceConverter</code>
+// * </p>
+// *
+// * @see org.eclipse.jface.resource.StringConverter
+// * @see org.eclipse.jface.preference.PreferenceConverter
+// */
+// public final static String EDITOR_JAVA_DEFAULT_COLOR= IJavaColorConstants.JAVA_DEFAULT;
+//
+// /**
+// * A named preference that controls whether Java default text is rendered in bold.
+// * <p>
+// * Value is of type <code>Boolean</code>.
+// * </p>
+// */
+// public final static String EDITOR_JAVA_DEFAULT_BOLD= IJavaColorConstants.JAVA_DEFAULT + EDITOR_BOLD_SUFFIX;
+//
+// /**
+// * A named preference that holds the color used to render phpdoc keywords.
+// * <p>
+// * Value is of type <code>String</code>. A RGB color value encoded as a string
+// * using class <code>PreferenceConverter</code>
+// * </p>
+// *
+// * @see org.eclipse.jface.resource.StringConverter
+// * @see org.eclipse.jface.preference.PreferenceConverter
+// */
+// public final static String EDITOR_JAVADOC_KEYWORD_COLOR= IJavaColorConstants.JAVADOC_KEYWORD;
+//
+// /**
+// * A named preference that controls whether phpdoc keywords are rendered in bold.
+// * <p>
+// * Value is of type <code>Boolean</code>.
+// * </p>
+// */
+// public final static String EDITOR_JAVADOC_KEYWORD_BOLD= IJavaColorConstants.JAVADOC_KEYWORD + EDITOR_BOLD_SUFFIX;
+//
+// /**
+// * A named preference that holds the color used to render phpdoc tags.
+// * <p>
+// * Value is of type <code>String</code>. A RGB color value encoded as a string
+// * using class <code>PreferenceConverter</code>
+// * </p>
+// *
+// * @see org.eclipse.jface.resource.StringConverter
+// * @see org.eclipse.jface.preference.PreferenceConverter
+// */
+// public final static String EDITOR_JAVADOC_TAG_COLOR= IJavaColorConstants.JAVADOC_TAG;
+//
+// /**
+// * A named preference that controls whether phpdoc tags are rendered in bold.
+// * <p>
+// * Value is of type <code>Boolean</code>.
+// * </p>
+// */
+// public final static String EDITOR_JAVADOC_TAG_BOLD= IJavaColorConstants.JAVADOC_TAG + EDITOR_BOLD_SUFFIX;
+//
+// /**
+// * A named preference that holds the color used to render phpdoc links.
+// * <p>
+// * Value is of type <code>String</code>. A RGB color value encoded as a string
+// * using class <code>PreferenceConverter</code>
+// * </p>
+// *
+// * @see org.eclipse.jface.resource.StringConverter
+// * @see org.eclipse.jface.preference.PreferenceConverter
+// */
+// public final static String EDITOR_JAVADOC_LINKS_COLOR= IJavaColorConstants.JAVADOC_LINK;
+//
+// /**
+// * A named preference that controls whether phpdoc links are rendered in bold.
+// * <p>
+// * Value is of type <code>Boolean</code>.
+// * </p>
+// */
+// public final static String EDITOR_JAVADOC_LINKS_BOLD= IJavaColorConstants.JAVADOC_LINK + EDITOR_BOLD_SUFFIX;
+//
+// /**
+// * A named preference that holds the color used to render phpdoc default text.
+// * <p>
+// * Value is of type <code>String</code>. A RGB color value encoded as a string
+// * using class <code>PreferenceConverter</code>
+// * </p>
+// *
+// * @see org.eclipse.jface.resource.StringConverter
+// * @see org.eclipse.jface.preference.PreferenceConverter
+// */
+// public final static String EDITOR_JAVADOC_DEFAULT_COLOR= IJavaColorConstants.JAVADOC_DEFAULT;
+//
+// /**
+// * A named preference that controls whether phpdoc default text is rendered in bold.
+// * <p>
+// * Value is of type <code>Boolean</code>.
+// * </p>
+// */
+// public final static String EDITOR_JAVADOC_DEFAULT_BOLD= IJavaColorConstants.JAVADOC_DEFAULT + EDITOR_BOLD_SUFFIX;
+
+ /**
+ * A named preference that holds the color used for 'linked-mode' underline.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ * @since 2.1
+ */
+ public final static String EDITOR_LINK_COLOR= "linkColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether hover tooltips in the editor are turned on or off.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String EDITOR_SHOW_HOVER= "net.sourceforge.phpdt.ui.editor.showHover"; //$NON-NLS-1$
+
+ /**
+ * A named preference that defines the hover shown when no control key is
+ * pressed.
+ * <p>Value is of type <code>String</code>: possible values are <code>
+ * EDITOR_NO_HOVER_CONFIGURED_ID</code> or
+ * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a hover
+ * contributed as <code>phpEditorTextHovers</code>.
+ * </p>
+ * @see #EDITOR_NO_HOVER_CONFIGURED_ID
+ * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID
+ * @see JavaUI
+ * @since 2.1
+ */
+ public static final String EDITOR_NONE_HOVER= "noneHover"; //$NON-NLS-1$
+
+ /**
+ * A named preference that defines the hover shown when the
+ * <code>CTRL</code> modifier key is pressed.
+ * <p>Value is of type <code>String</code>: possible values are <code>
+ * EDITOR_NO_HOVER_CONFIGURED_ID</code> or
+ * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a
+ * hover contributed as <code>phpEditorTextHovers</code>.
+ * </p>
+ * @see #EDITOR_NO_HOVER_CONFIGURED_ID
+ * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID
+ * @see JavaUI
+ * @since 2.1
+ */
+ public static final String EDITOR_CTRL_HOVER= "ctrlHover"; //$NON-NLS-1$
+
+ /**
+ * A named preference that defines the hover shown when the
+ * <code>SHIFT</code> modifier key is pressed.
+ * <p>Value is of type <code>String</code>: possible values are <code>
+ * EDITOR_NO_HOVER_CONFIGURED_ID</code> or
+ * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a
+ * hover contributed as <code>phpEditorTextHovers</code>.
+ * </p>
+ * @see #EDITOR_NO_HOVER_CONFIGURED_ID
+ * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID
+ * @see JavaUI ID_*_HOVER
+ * @since 2.1
+ */
+ public static final String EDITOR_SHIFT_HOVER= "shiftHover"; //$NON-NLS-1$
+
+ /**
+ * A named preference that defines the hover shown when the
+ * <code>CTRL + ALT</code> modifier keys is pressed.
+ * <p>Value is of type <code>String</code>: possible values are <code>
+ * EDITOR_NO_HOVER_CONFIGURED_ID</code> or
+ * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a
+ * hover contributed as <code>phpEditorTextHovers</code>.
+ * </p>
+ * @see #EDITOR_NO_HOVER_CONFIGURED_ID
+ * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID
+ * @see JavaUI ID_*_HOVER
+ * @since 2.1
+ */
+ public static final String EDITOR_CTRL_ALT_HOVER= "ctrlAltHover"; //$NON-NLS-1$
+
+ /**
+ * A named preference that defines the hover shown when the
+ * <code>CTRL + ALT + SHIFT</code> modifier keys is pressed.
+ * <p>Value is of type <code>String</code>: possible values are <code>
+ * EDITOR_NO_HOVER_CONFIGURED_ID</code> or
+ * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a
+ * hover contributed as <code>phpEditorTextHovers</code>.
+ * </p>
+ * @see #EDITOR_NO_HOVER_CONFIGURED_ID
+ * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID
+ * @see JavaUI ID_*_HOVER
+ * @since 2.1
+ */
+ public static final String EDITOR_CTRL_ALT_SHIFT_HOVER= "ctrlAltShiftHover"; //$NON-NLS-1$
+
+ /**
+ * A named preference that defines the hover shown when the
+ * <code>CTRL + SHIFT</code> modifier keys is pressed.
+ * <p>Value is of type <code>String</code>: possible values are <code>
+ * EDITOR_NO_HOVER_CONFIGURED_ID</code> or
+ * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a
+ * hover contributed as <code>phpEditorTextHovers</code>.
+ * </p>
+ * @see #EDITOR_NO_HOVER_CONFIGURED_ID
+ * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID
+ * @see JavaUI ID_*_HOVER
+ * @since 2.1
+ */
+ public static final String EDITOR_CTRL_SHIFT_HOVER= "ctrlShiftHover"; //$NON-NLS-1$
+
+ /**
+ * A named preference that defines the hover shown when the
+ * <code>ALT</code> modifier key is pressed.
+ * <p>Value is of type <code>String</code>: possible values are <code>
+ * EDITOR_NO_HOVER_CONFIGURED_ID</code>,
+ * <code>EDITOR_DEFAULT_HOVER_CONFIGURED_ID</code> or the hover id of a
+ * hover contributed as <code>phpEditorTextHovers</code>.
+ * </p>
+ * @see #EDITOR_NO_HOVER_CONFIGURED_ID
+ * @see #EDITOR_DEFAULT_HOVER_CONFIGURED_ID
+ * @see JavaUI ID_*_HOVER
+ * @since 2.1
+ */
+ public static final String EDITOR_ALT_SHIFT_HOVER= "altShiftHover"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preferences for hover configuration to
+ * descibe that no hover should be shown for the given key modifiers.
+ * @since 2.1
+ */
+ public static final String EDITOR_NO_HOVER_CONFIGURED_ID= "noHoverConfiguredId"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preferences for hover configuration to
+ * descibe that the default hover should be shown for the given key
+ * modifiers. The default hover is described by the
+ * <code>EDITOR_DEFAULT_HOVER</code> property.
+ * @since 2.1
+ */
+ public static final String EDITOR_DEFAULT_HOVER_CONFIGURED_ID= "defaultHoverConfiguredId"; //$NON-NLS-1$
+
+ /**
+ * A named preference that defines the hover named the 'default hover'.
+ * Value is of type <code>String</code>: possible values are <code>
+ * EDITOR_NO_HOVER_CONFIGURED_ID</code> or <code> the hover id of a hover
+ * contributed as <code>phpEditorTextHovers</code>.
+ * </p>
+ *@since 2.1
+ */
+ public static final String EDITOR_DEFAULT_HOVER= "defaultHover"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if segmented view (show selected element only) is turned on or off.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String EDITOR_SHOW_SEGMENTS= "net.sourceforge.phpdt.ui.editor.showSegments"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if the Java code assist gets auto activated.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String CODEASSIST_AUTOACTIVATION= "content_assist_autoactivation"; //$NON-NLS-1$
+
+ /**
+ * A name preference that holds the auto activation delay time in milli seconds.
+ * <p>
+ * Value is of type <code>Int</code>.
+ * </p>
+ */
+ public final static String CODEASSIST_AUTOACTIVATION_DELAY= "content_assist_autoactivation_delay"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if code assist contains only visible proposals.
+ * <p>
+ * Value is of type <code>Boolean</code>. if <code>true<code> code assist only contains visible members. If
+ * <code>false</code> all members are included.
+ * </p>
+ */
+ public final static String CODEASSIST_SHOW_VISIBLE_PROPOSALS= "content_assist_show_visible_proposals"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if the Java code assist inserts a
+ * proposal automatically if only one proposal is available.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String CODEASSIST_AUTOINSERT= "content_assist_autoinsert"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if the Java code assist adds import
+ * statements.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String CODEASSIST_ADDIMPORT= "content_assist_add_import"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if the Java code assist only inserts
+ * completions. If set to false the proposals can also _replace_ code.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String CODEASSIST_INSERT_COMPLETION= "content_assist_insert_completion"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether code assist proposals filtering is case sensitive or not.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String CODEASSIST_CASE_SENSITIVITY= "content_assist_case_sensitivity"; //$NON-NLS-1$
+
+ /**
+ * A named preference that defines if code assist proposals are sorted in alphabetical order.
+ * <p>
+ * Value is of type <code>Boolean</code>. If <code>true</code> that are sorted in alphabetical
+ * order. If <code>false</code> that are unsorted.
+ * </p>
+ */
+ public final static String CODEASSIST_ORDER_PROPOSALS= "content_assist_order_proposals"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if argument names are filled in when a method is selected from as list
+ * of code assist proposal.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String CODEASSIST_FILL_ARGUMENT_NAMES= "content_assist_fill_method_arguments"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if method arguments are guessed when a
+ * method is selected from as list of code assist proposal.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String CODEASSIST_GUESS_METHOD_ARGUMENTS= "content_assist_guess_method_arguments"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the characters that auto activate code assist in Java code.
+ * <p>
+ * Value is of type <code>Sring</code>. All characters that trigger auto code assist in Java code.
+ * </p>
+ */
+ public final static String CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA= "content_assist_autoactivation_triggers_php"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the characters that auto activate code assist in Javadoc.
+ * <p>
+ * Value is of type <code>Sring</code>. All characters that trigger auto code assist in Javadoc.
+ * </p>
+ */
+ public final static String CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC= "content_assist_autoactivation_triggers_phpdoc"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the background color used in the code assist selection dialog.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String CODEASSIST_PROPOSALS_BACKGROUND= "content_assist_proposals_background"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the foreground color used in the code assist selection dialog.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String CODEASSIST_PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the background color used for parameter hints.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String CODEASSIST_PARAMETERS_BACKGROUND= "content_assist_parameters_background"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the foreground color used in the code assist selection dialog
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String CODEASSIST_PARAMETERS_FOREGROUND= "content_assist_parameters_foreground"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the background color used in the code
+ * assist selection dialog to mark replaced code.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ * @since 2.1
+ */
+ public final static String CODEASSIST_REPLACEMENT_BACKGROUND= "content_assist_completion_replacement_background"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the foreground color used in the code
+ * assist selection dialog to mark replaced code.
+ * <p>
+ * Value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>
+ * </p>
+ *
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ * @since 2.1
+ */
+ public final static String CODEASSIST_REPLACEMENT_FOREGROUND= "content_assist_completion_replacement_foreground"; //$NON-NLS-1$
+
+
+ /**
+ * A named preference that controls the behaviour of the refactoring wizard for showing the error page.
+ * <p>
+ * Value is of type <code>String</code>. Valid values are:
+ * <code>REFACTOR_FATAL_SEVERITY</code>,
+ * <code>REFACTOR_ERROR_SEVERITY</code>,
+ * <code>REFACTOR_WARNING_SEVERITY</code>
+ * <code>REFACTOR_INFO_SEVERITY</code>,
+ * <code>REFACTOR_OK_SEVERITY</code>.
+ * </p>
+ *
+ * @see #REFACTOR_FATAL_SEVERITY
+ * @see #REFACTOR_ERROR_SEVERITY
+ * @see #REFACTOR_WARNING_SEVERITY
+ * @see #REFACTOR_INFO_SEVERITY
+ * @see #REFACTOR_OK_SEVERITY
+ */
+ public static final String REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD= "Refactoring.ErrorPage.severityThreshold"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>.
+ *
+ * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD
+ */
+ public static final String REFACTOR_FATAL_SEVERITY= "4"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>.
+ *
+ * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD
+ */
+ public static final String REFACTOR_ERROR_SEVERITY= "3"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>.
+ *
+ * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD
+ */
+ public static final String REFACTOR_WARNING_SEVERITY= "2"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>.
+ *
+ * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD
+ */
+ public static final String REFACTOR_INFO_SEVERITY= "1"; //$NON-NLS-1$
+
+ /**
+ * A string value used by the named preference <code>REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD</code>.
+ *
+ * @see #REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD
+ */
+ public static final String REFACTOR_OK_SEVERITY= "0"; //$NON-NLS-1$
+
+ /**
+ * A named preference thet controls whether all dirty editors are automatically saved before a refactoring is
+ * executed.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String REFACTOR_SAVE_ALL_EDITORS= "Refactoring.savealleditors"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if the Java Browsing views are linked to the active editor.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @see #LINK_PACKAGES_TO_EDITOR
+ */
+ public static final String BROWSING_LINK_VIEW_TO_EDITOR= "net.sourceforge.phpdt.ui.browsing.linktoeditor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls the layout of the Java Browsing views vertically. Boolean value.
+ * <p>
+ * Value is of type <code>Boolean</code>. If <code>true<code> the views are stacked vertical.
+ * If <code>false</code> they are stacked horizontal.
+ * </p>
+ */
+ public static final String BROWSING_STACK_VERTICALLY= "net.sourceforge.phpdt.ui.browsing.stackVertically"; //$NON-NLS-1$
+
+
+ /**
+ * A named preference that controls if templates are formatted when applied.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ *
+ * @since 2.1
+ */
+ public static final String TEMPLATES_USE_CODEFORMATTER= "net.sourceforge.phpdt.ui.template.format"; //$NON-NLS-1$
+
+
+
+ public static void initializeDefaultValues(IPreferenceStore store) {
+ store.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false);
+
+ // JavaBasePreferencePage
+ store.setDefault(PreferenceConstants.LINK_PACKAGES_TO_EDITOR, true);
+ store.setDefault(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR, false);
+ store.setDefault(PreferenceConstants.LINK_BROWSING_VIEW_TO_EDITOR, true);
+ store.setDefault(PreferenceConstants.OPEN_TYPE_HIERARCHY, PreferenceConstants.OPEN_TYPE_HIERARCHY_IN_VIEW_PART);
+ store.setDefault(PreferenceConstants.DOUBLE_CLICK, PreferenceConstants.DOUBLE_CLICK_EXPANDS);
+ store.setDefault(PreferenceConstants.UPDATE_JAVA_VIEWS, PreferenceConstants.UPDATE_WHILE_EDITING);
+
+ // AppearancePreferencePage
+ store.setDefault(PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES, false);
+ store.setDefault(PreferenceConstants.APPEARANCE_METHOD_RETURNTYPE, false);
+ store.setDefault(PreferenceConstants.SHOW_CU_CHILDREN, true);
+ store.setDefault(PreferenceConstants.APPEARANCE_OVERRIDE_INDICATOR, true);
+ store.setDefault(PreferenceConstants.BROWSING_STACK_VERTICALLY, false);
+ store.setDefault(PreferenceConstants.APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW, ""); //$NON-NLS-1$
+ store.setDefault(PreferenceConstants.APPEARANCE_FOLD_PACKAGES_IN_PACKAGE_EXPLORER, true);
+
+ // ImportOrganizePreferencePage
+ store.setDefault(PreferenceConstants.ORGIMPORTS_IMPORTORDER, "php;phpx;org;com"); //$NON-NLS-1$
+ store.setDefault(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD, 99);
+ store.setDefault(PreferenceConstants.ORGIMPORTS_IGNORELOWERCASE, true);
+
+ // ClasspathVariablesPreferencePage
+ // CodeFormatterPreferencePage
+ // CompilerPreferencePage
+ // no initialization needed
+
+ // RefactoringPreferencePage
+ store.setDefault(PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD, PreferenceConstants.REFACTOR_ERROR_SEVERITY);
+ store.setDefault(PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS, false);
+ store.setDefault("RefactoringUI", "dialog");
+
+ // TemplatePreferencePage
+ store.setDefault(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER, true);
+
+ // CodeGenerationPreferencePage
+ store.setDefault(PreferenceConstants.CODEGEN_USE_GETTERSETTER_PREFIX, false);
+ store.setDefault(PreferenceConstants.CODEGEN_USE_GETTERSETTER_SUFFIX, false);
+ store.setDefault(PreferenceConstants.CODEGEN_GETTERSETTER_PREFIX, "fg, f, _$, _, m_"); //$NON-NLS-1$
+ store.setDefault(PreferenceConstants.CODEGEN_GETTERSETTER_SUFFIX, "_"); //$NON-NLS-1$
+ store.setDefault(PreferenceConstants.CODEGEN__JAVADOC_STUBS, true);
+ store.setDefault(PreferenceConstants.CODEGEN__NON_JAVADOC_COMMENTS, false);
+ store.setDefault(PreferenceConstants.CODEGEN__FILE_COMMENTS, false);
+
+ // MembersOrderPreferencePage
+ store.setDefault(PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER, "T,SI,SF,SM,I,F,C,M"); //$NON-NLS-1$
+ // must add here to guarantee that it is the first in the listener list
+ // store.addPropertyChangeListener(PHPeclipsePlugin.getDefault().getMemberOrderPreferenceCache());
+
+
+ // PHPEditorPreferencePage
+ /*
+ * Ensure that the display is accessed only in the UI thread.
+ * Ensure that there are no side effects of switching the thread.
+ */
+ final RGB[] rgbs= new RGB[3];
+ final Display display= Display.getDefault();
+ display.syncExec(new Runnable() {
+ public void run() {
+ Color c= display.getSystemColor(SWT.COLOR_GRAY);
+ rgbs[0]= c.getRGB();
+ c= display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
+ rgbs[1]= c.getRGB();
+ c= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
+ rgbs[2]= c.getRGB();
+ }
+ });
+
+ store.setDefault(PreferenceConstants.EDITOR_MATCHING_BRACKETS, true);
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR, rgbs[0]);
+
+ store.setDefault(PreferenceConstants.EDITOR_CURRENT_LINE, true);
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_CURRENT_LINE_COLOR, new RGB(225, 235, 224));
+
+ store.setDefault(PreferenceConstants.EDITOR_PRINT_MARGIN, false);
+ store.setDefault(PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 80);
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, new RGB(176, 180 , 185));
+
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_FIND_SCOPE_COLOR, new RGB(185, 176 , 180));
+
+ store.setDefault(PreferenceConstants.EDITOR_PROBLEM_INDICATION, true);
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR, new RGB(255, 0 , 128));
+ store.setDefault(PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER, true);
+
+ store.setDefault(PreferenceConstants.EDITOR_WARNING_INDICATION, true);
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR, new RGB(244, 200 , 45));
+ store.setDefault(PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER, true);
+
+ store.setDefault(PreferenceConstants.EDITOR_TASK_INDICATION, false);
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_TASK_INDICATION_COLOR, new RGB(0, 128, 255));
+ store.setDefault(PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER, false);
+
+ store.setDefault(PreferenceConstants.EDITOR_BOOKMARK_INDICATION, false);
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR, new RGB(34, 164, 99));
+ store.setDefault(PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER, false);
+
+ store.setDefault(PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION, false);
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR, new RGB(192, 192, 192));
+ store.setDefault(PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER, false);
+
+ store.setDefault(PreferenceConstants.EDITOR_UNKNOWN_INDICATION, false);
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR, new RGB(0, 0, 0));
+ store.setDefault(PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER, false);
+
+ store.setDefault(PreferenceConstants.EDITOR_CORRECTION_INDICATION, true);
+ store.setDefault(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, false);
+
+ store.setDefault(PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, true);
+
+ store.setDefault(PreferenceConstants.EDITOR_OVERVIEW_RULER, true);
+
+ store.setDefault(PreferenceConstants.EDITOR_LINE_NUMBER_RULER, false);
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, new RGB(0, 0, 0));
+
+ WorkbenchChainedTextFontFieldEditor.startPropagate(store, JFaceResources.TEXT_FONT);
+
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_LINKED_POSITION_COLOR, new RGB(0, 200 , 100));
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_LINK_COLOR, new RGB(0, 0, 255));
+
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgbs[1]);
+ store.setDefault(PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR, true);
+
+ PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgbs[2]);
+ store.setDefault(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, true);
+
+ store.setDefault(PreferenceConstants.EDITOR_TAB_WIDTH, 4);
+ store.setDefault(PreferenceConstants.EDITOR_SPACES_FOR_TABS, false);
+
+// PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR, new RGB(63, 127, 95));
+// store.setDefault(PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD, false);
+//
+// PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR, new RGB(63, 127, 95));
+// store.setDefault(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD, false);
+//
+// PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR, new RGB(127, 0, 85));
+// store.setDefault(PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD, true);
+//
+// PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_STRING_COLOR, new RGB(42, 0, 255));
+// store.setDefault(PreferenceConstants.EDITOR_STRING_BOLD, false);
+//
+// PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR, new RGB(0, 0, 0));
+// store.setDefault(PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD, false);
+//
+// PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR, new RGB(127, 159, 191));
+// store.setDefault(PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD, true);
+//
+// PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR, new RGB(127, 127, 159));
+// store.setDefault(PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD, false);
+//
+// PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR, new RGB(63, 63, 191));
+// store.setDefault(PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD, false);
+//
+// PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR, new RGB(63, 95, 191));
+// store.setDefault(PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD, false);
+
+ store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION, true);
+ store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 500);
+
+ store.setDefault(PreferenceConstants.CODEASSIST_AUTOINSERT, true);
+ PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, new RGB(254, 241, 233));
+ PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, new RGB(0, 0, 0));
+ PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, new RGB(254, 241, 233));
+ PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, new RGB(0, 0, 0));
+ PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND, new RGB(255, 255, 0));
+ PreferenceConverter.setDefault(store, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND, new RGB(255, 0, 0));
+ store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, "."); //$NON-NLS-1$
+ store.setDefault(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, "@"); //$NON-NLS-1$
+ store.setDefault(PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, true);
+ store.setDefault(PreferenceConstants.CODEASSIST_CASE_SENSITIVITY, false);
+ store.setDefault(PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, false);
+ store.setDefault(PreferenceConstants.CODEASSIST_ADDIMPORT, true);
+ store.setDefault(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, true);
+ store.setDefault(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, false);
+ store.setDefault(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, true);
+
+ store.setDefault(PreferenceConstants.EDITOR_SMART_HOME_END, true);
+ store.setDefault(PreferenceConstants.EDITOR_SMART_PASTE, true);
+ store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, true);
+ store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true);
+ store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACES, true);
+ store.setDefault(PreferenceConstants.EDITOR_CLOSE_JAVADOCS, true);
+ store.setDefault(PreferenceConstants.EDITOR_WRAP_STRINGS, true);
+ store.setDefault(PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, true);
+ store.setDefault(PreferenceConstants.EDITOR_FORMAT_JAVADOCS, true);
+
+ // store.setDefault(PreferenceConstants.EDITOR_DEFAULT_HOVER, JavaPlugin.ID_BESTMATCH_HOVER);
+ store.setDefault(PreferenceConstants.EDITOR_NONE_HOVER, PreferenceConstants.EDITOR_DEFAULT_HOVER_CONFIGURED_ID);
+// store.setDefault(PreferenceConstants.EDITOR_CTRL_HOVER, JavaPlugin.ID_SOURCE_HOVER);
+ store.setDefault(PreferenceConstants.EDITOR_SHIFT_HOVER, PreferenceConstants.EDITOR_DEFAULT_HOVER_CONFIGURED_ID);
+ store.setDefault(PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER, PreferenceConstants.EDITOR_DEFAULT_HOVER_CONFIGURED_ID);
+ store.setDefault(PreferenceConstants.EDITOR_CTRL_ALT_HOVER, PreferenceConstants.EDITOR_DEFAULT_HOVER_CONFIGURED_ID);
+ store.setDefault(PreferenceConstants.EDITOR_ALT_SHIFT_HOVER, PreferenceConstants.EDITOR_DEFAULT_HOVER_CONFIGURED_ID);
+ store.setDefault(PreferenceConstants.EDITOR_CTRL_ALT_SHIFT_HOVER, PreferenceConstants.EDITOR_DEFAULT_HOVER_CONFIGURED_ID);
+
+ // do more complicated stuff
+ // NewJavaProjectPreferencePage.initDefaults(store);
+ }
+
+ /**
+ * Returns the JDT-UI preference store.
+ *
+ * @return the JDT-UI preference store
+ */
+ public static IPreferenceStore getPreferenceStore() {
+ return PHPeclipsePlugin.getDefault().getPreferenceStore();
+ }
+
+// /**
+// * Encodes a JRE library to be used in the named preference <code>NEWPROJECT_JRELIBRARY_LIST</code>.
+// *
+// * @param description a string value describing the JRE library. The description is used
+// * to indentify the JDR library in the UI
+// * @param entries an array of classpath entries to be encoded
+// *
+// * @return the encoded string.
+// */
+// public static String encodeJRELibrary(String description, IClasspathEntry[] entries) {
+// return NewJavaProjectPreferencePage.encodeJRELibrary(description, entries);
+// }
+//
+// /**
+// * Decodes an encoded JRE library and returns its description string.
+// *
+// * @return the description of an encoded JRE library
+// *
+// * @see #encodeJRELibrary(String, IClasspathEntry[])
+// */
+// public static String decodeJRELibraryDescription(String encodedLibrary) {
+// return NewJavaProjectPreferencePage.decodeJRELibraryDescription(encodedLibrary);
+// }
+//
+// /**
+// * Decodes an encoded JRE library and returns its classpath entries.
+// *
+// * @return the array of classpath entries of an encoded JRE library.
+// *
+// * @see #encodeJRELibrary(String, IClasspathEntry[])
+// */
+// public static IClasspathEntry[] decodeJRELibraryClasspathEntries(String encodedLibrary) {
+// return NewJavaProjectPreferencePage.decodeJRELibraryClasspathEntries(encodedLibrary);
+// }
+//
+// /**
+// * Returns the current configuration for the JRE to be used as default in new Java projects.
+// * This is a convenience method to access the named preference <code>NEWPROJECT_JRELIBRARY_LIST
+// * </code> with the index defined by <code> NEWPROJECT_JRELIBRARY_INDEX</code>.
+// *
+// * @return the current default set of classpath entries
+// *
+// * @see #NEWPROJECT_JRELIBRARY_LIST
+// * @see #NEWPROJECT_JRELIBRARY_INDEX
+// */
+// public static IClasspathEntry[] getDefaultJRELibrary() {
+// return NewJavaProjectPreferencePage.getDefaultJRELibrary();
+// }
+}
--- /dev/null
+package net.sourceforge.phpdt.ui.text;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.RGB;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.StringConverter;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import net.sourceforge.phpdt.ui.text.IColorManager;
+import net.sourceforge.phpdt.ui.text.IColorManagerExtension;
+
+
+/**
+ * Initialized with a color manager and a preference store, its subclasses are
+ * only responsible for providing a list of preference keys based on which tokens
+ * are generated and to use this tokens to define the rules controlling this scanner.
+ */
+public abstract class AbstractJavaScanner extends BufferedRuleBasedScanner {
+
+
+ private IColorManager fColorManager;
+ private IPreferenceStore fPreferenceStore;
+
+ private Map fTokenMap= new HashMap();
+ private String[] fPropertyNamesColor;
+ private String[] fPropertyNamesStyle;
+
+
+ /**
+ * Returns the list of preference keys which define the tokens
+ * used in the rules of this scanner.
+ */
+ abstract protected String[] getTokenProperties();
+
+ /**
+ * Creates the list of rules controlling this scanner.
+ */
+ abstract protected List createRules();
+
+
+ /**
+ * Creates an abstract Java scanner.
+ */
+ public AbstractJavaScanner(IColorManager manager, IPreferenceStore store) {
+ super();
+ fColorManager= manager;
+ fPreferenceStore= store;
+ }
+
+ /**
+ * Must be called after the constructor has been called.
+ */
+ public final void initialize() {
+
+ fPropertyNamesColor= getTokenProperties();
+ int length= fPropertyNamesColor.length;
+ fPropertyNamesStyle= new String[length];
+ for (int i= 0; i < length; i++) {
+ fPropertyNamesStyle[i]= fPropertyNamesColor[i] + "_bold"; //$NON-NLS-1$
+ addToken(fPropertyNamesColor[i], fPropertyNamesStyle[i]);
+ }
+
+ initializeRules();
+ }
+
+ private void addToken(String colorKey, String styleKey) {
+ RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey);
+ if (fColorManager instanceof IColorManagerExtension) {
+ IColorManagerExtension ext= (IColorManagerExtension) fColorManager;
+ ext.unbindColor(colorKey);
+ ext.bindColor(colorKey, rgb);
+ }
+
+ boolean bold= fPreferenceStore.getBoolean(styleKey);
+ fTokenMap.put(colorKey, new Token(new TextAttribute(fColorManager.getColor(colorKey), null, bold ? SWT.BOLD : SWT.NORMAL)));
+ }
+
+ protected Token getToken(String key) {
+ return (Token) fTokenMap.get(key);
+ }
+
+ private void initializeRules() {
+ List rules= createRules();
+ if (rules != null) {
+ IRule[] result= new IRule[rules.size()];
+ rules.toArray(result);
+ setRules(result);
+ }
+ }
+
+ private int indexOf(String property) {
+ if (property != null) {
+ int length= fPropertyNamesColor.length;
+ for (int i= 0; i < length; i++) {
+ if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesStyle[i]))
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public boolean affectsBehavior(PropertyChangeEvent event) {
+ return indexOf(event.getProperty()) >= 0;
+ }
+
+ public void adaptToPreferenceChange(PropertyChangeEvent event) {
+ String p= event.getProperty();
+ int index= indexOf(p);
+ Token token= getToken(fPropertyNamesColor[index]);
+ if (fPropertyNamesColor[index].equals(p))
+ adaptToColorChange(token, event);
+ else
+ adaptToStyleChange(token, event);
+ }
+
+ private void adaptToColorChange(Token token, PropertyChangeEvent event) {
+ RGB rgb= null;
+
+ Object value= event.getNewValue();
+ if (value instanceof RGB)
+ rgb= (RGB) value;
+ else if (value instanceof String)
+ rgb= StringConverter.asRGB((String) value);
+
+ if (rgb != null) {
+
+ String property= event.getProperty();
+
+ if (fColorManager instanceof IColorManagerExtension) {
+ IColorManagerExtension ext= (IColorManagerExtension) fColorManager;
+ ext.unbindColor(property);
+ ext.bindColor(property, rgb);
+ }
+
+ Object data= token.getData();
+ if (data instanceof TextAttribute) {
+ TextAttribute oldAttr= (TextAttribute) data;
+ token.setData(new TextAttribute(fColorManager.getColor(property), oldAttr.getBackground(), oldAttr.getStyle()));
+ }
+ }
+ }
+
+ private void adaptToStyleChange(Token token, PropertyChangeEvent event) {
+ boolean bold= false;
+ Object value= event.getNewValue();
+ if (value instanceof Boolean)
+ bold= ((Boolean) value).booleanValue();
+ else if (value instanceof String) {
+ String s= (String) value;
+ if (IPreferenceStore.TRUE.equals(s))
+ bold= true;
+ else if (IPreferenceStore.FALSE.equals(s))
+ bold= false;
+ }
+
+ Object data= token.getData();
+ if (data instanceof TextAttribute) {
+ TextAttribute oldAttr= (TextAttribute) data;
+ boolean isBold= (oldAttr.getStyle() == SWT.BOLD);
+ if (isBold != bold)
+ token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), bold ? SWT.BOLD : SWT.NORMAL));
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2001 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.text;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+
+
+/**
+ * Manages SWT color objects for given color keys and
+ * given <code>RGB</code> objects. Until the <code>dispose</code>
+ * method is called, the same color object is returned for
+ * equal keys and equal <code>RGB</code> values.
+ * <p>
+ * This interface may be implemented by clients.
+ * </p>
+ *
+ * @see IJavaColorConstants
+ */
+public interface IColorManager {
+
+ /**
+ * Returns a color object for the given key. The color objects
+ * are remembered internally; the same color object is returned
+ * for equal keys.
+ *
+ * @param key the color key
+ * @return the color object for the given key
+ */
+ Color getColor(String key);
+
+ /**
+ * Returns the color object for the value represented by the given
+ * <code>RGB</code> object.
+ *
+ * @param rgb the rgb color specification
+ * @return the color object for the given rgb value
+ */
+ Color getColor(RGB rgb);
+
+ /**
+ * Disposes all color objects remembered by this color manager.
+ */
+ void dispose();
+}
--- /dev/null
+/*******************************************************************************
+ * 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 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.text;
+
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * A color manager extension for extending <code>IColorManager</code>
+ * instances with new functionality.
+ *
+ * @since 2.0
+ */
+public interface IColorManagerExtension {
+
+ /**
+ * Remembers the given color specification under the given key.
+ *
+ * @param key the color key
+ * @param rgb the color specification
+ * @exception UnsupportedOperationException if there is already a
+ * color specification remembered under the given key
+ */
+ void bindColor(String key, RGB rgb);
+
+
+ /**
+ * Forgets the color specification remembered under the given key.
+ * @param key the color key
+ */
+ void unbindColor(String key);
+}
--- /dev/null
+/*******************************************************************************
+ * 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.text;
+
+/**
+ * Color keys used for syntax highlighting Java
+ * code and JavaDoc compliant comments.
+ * A <code>IColorManager</code> is responsible for mapping
+ * concrete colors to these keys.
+ * <p>
+ * This interface declares static final fields only; it is not intended to be
+ * implemented.
+ * </p>
+ *
+ * @see IColorManager
+ */
+public interface IJavaColorConstants {
+
+ /**
+ * Note: This constant is for internal use only. Clients should not use this constant.
+ * The prefix all color constants start with.
+ */
+ String PREFIX= "php_"; //$NON-NLS-1$
+
+ /** The color key for multi-line comments in Java code. */
+ String JAVA_MULTI_LINE_COMMENT= "php_multi_line_comment"; //$NON-NLS-1$
+ /** The color key for single-line comments in Java code. */
+ String JAVA_SINGLE_LINE_COMMENT= "php_single_line_comment"; //$NON-NLS-1$
+ /** The color key for Java keywords in Java code. */
+ String JAVA_KEYWORD= "php_keyword"; //$NON-NLS-1$
+ /** The color key for string and character literals in Java code. */
+ String JAVA_STRING= "php_string"; //$NON-NLS-1$
+ /** The color key for everthing in Java code for which no other color is specified. */
+ String JAVA_DEFAULT= "php_default"; //$NON-NLS-1$
+ /**
+ * The color key for the Java built-in types such as int and char in Java code.
+ * @deprecated no longer used, use <code>JAVA_KEYWORD</code> instead
+ */
+ String JAVA_TYPE= "php_type"; //$NON-NLS-1$
+
+
+ /** The color key for JavaDoc keywords (<code>@foo</code>) in JavaDoc comments. */
+ String JAVADOC_KEYWORD= "php_doc_keyword"; //$NON-NLS-1$
+ /** The color key for HTML tags (<code><foo></code>) in JavaDoc comments. */
+ String JAVADOC_TAG= "php_doc_tag"; //$NON-NLS-1$
+ /** The color key for JavaDoc links (<code>{foo}</code>) in JavaDoc comments. */
+ String JAVADOC_LINK= "php_doc_link"; //$NON-NLS-1$
+ /** The color key for everthing in JavaDoc comments for which no other color is specified. */
+ String JAVADOC_DEFAULT= "php_doc_default"; //$NON-NLS-1$
+}
\ No newline at end of file
--- /dev/null
+package net.sourceforge.phpdt.ui.text;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import net.sourceforge.phpdt.internal.ui.text.FastJavaPartitionScanner;
+import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
+import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCodeScanner;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.DefaultPartitioner;
+import org.eclipse.jface.text.rules.IPartitionTokenScanner;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+//
+//import org.phpeclipse.phpdt.internal.ui.text.FastJavaPartitionScanner;
+//import org.phpeclipse.phpdt.internal.ui.text.JavaColorManager;
+//import org.phpeclipse.phpdt.internal.ui.text.JavaPartitionScanner;
+//import org.phpeclipse.phpdt.internal.ui.text.SingleTokenJavaScanner;
+//import org.phpeclipse.phpdt.internal.ui.text.php.JavaCodeScanner;
+//import org.phpeclipse.phpdt.internal.ui.text.phpdoc.JavaDocScanner;
+
+
+/**
+ * Tools required to configure a Java text viewer.
+ * The color manager and all scanner exist only one time, i.e.
+ * the same instances are returned to all clients. Thus, clients
+ * share those tools.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ */
+public class JavaTextTools {
+
+ private class PreferenceListener implements IPropertyChangeListener {
+ public void propertyChange(PropertyChangeEvent event) {
+ adaptToPreferenceChange(event);
+ }
+ };
+
+ /** The color manager */
+ private JavaColorManager fColorManager;
+ /** The Java source code scanner */
+ private PHPCodeScanner fCodeScanner;
+ /** The Java multiline comment scanner */
+ private SingleTokenPHPScanner fMultilineCommentScanner;
+ /** The Java singleline comment scanner */
+ private SingleTokenPHPScanner fSinglelineCommentScanner;
+ /** The Java string scanner */
+ private SingleTokenPHPScanner fStringScanner;
+ /** The JavaDoc scanner */
+ private PHPDocCodeScanner fJavaDocScanner;
+ /** The Java partitions scanner */
+ private FastJavaPartitionScanner fPartitionScanner;
+
+ /** The preference store */
+ private IPreferenceStore fPreferenceStore;
+ /** The preference change listener */
+ private PreferenceListener fPreferenceListener= new PreferenceListener();
+
+
+ /**
+ * Creates a new Java text tools collection.
+ *
+ * @param store the preference store to initialize the text tools. The text tool
+ * instance installs a listener on the passed preference store to adapt itself to
+ * changes in the preference store. In general <code>PreferenceConstants.
+ * getPreferenceStore()</code> shoould be used to initialize the text tools.
+ *
+ * @see org.phpeclipse.phpdt.ui.PreferenceConstants#getPreferenceStore()
+ * @since 2.0
+ */
+ public JavaTextTools(IPreferenceStore store) {
+ fPreferenceStore= store;
+ fPreferenceStore.addPropertyChangeListener(fPreferenceListener);
+
+ fColorManager= new JavaColorManager();
+ fCodeScanner= new PHPCodeScanner(fColorManager, store);
+ fMultilineCommentScanner= new SingleTokenPHPScanner(fColorManager, store, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT);
+ fSinglelineCommentScanner= new SingleTokenPHPScanner(fColorManager, store, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT);
+ fStringScanner= new SingleTokenPHPScanner(fColorManager, store, IJavaColorConstants.JAVA_STRING);
+ fJavaDocScanner= new PHPDocCodeScanner(fColorManager, store);
+ fPartitionScanner= new FastJavaPartitionScanner();
+ }
+
+ /**
+ * Disposes all the individual tools of this tools collection.
+ */
+ public void dispose() {
+
+ fCodeScanner= null;
+ fMultilineCommentScanner= null;
+ fSinglelineCommentScanner= null;
+ fStringScanner= null;
+ fJavaDocScanner= null;
+ fPartitionScanner= null;
+
+ if (fColorManager != null) {
+ fColorManager.dispose();
+ fColorManager= null;
+ }
+
+ if (fPreferenceStore != null) {
+ fPreferenceStore.removePropertyChangeListener(fPreferenceListener);
+ fPreferenceStore= null;
+ fPreferenceListener= null;
+ }
+ }
+
+ /**
+ * Returns the color manager which is used to manage
+ * any Java-specific colors needed for such things like syntax highlighting.
+ *
+ * @return the color manager to be used for Java text viewers
+ */
+ public JavaColorManager getColorManager() {
+ return fColorManager;
+ }
+
+ /**
+ * Returns a scanner which is configured to scan Java source code.
+ *
+ * @return a Java source code scanner
+ */
+ public RuleBasedScanner getCodeScanner() {
+ return fCodeScanner;
+ }
+
+ /**
+ * Returns a scanner which is configured to scan Java multiline comments.
+ *
+ * @return a Java multiline comment scanner
+ *
+ * @since 2.0
+ */
+ public RuleBasedScanner getMultilineCommentScanner() {
+ return fMultilineCommentScanner;
+ }
+
+ /**
+ * Returns a scanner which is configured to scan Java singleline comments.
+ *
+ * @return a Java singleline comment scanner
+ *
+ * @since 2.0
+ */
+ public RuleBasedScanner getSinglelineCommentScanner() {
+ return fSinglelineCommentScanner;
+ }
+
+ /**
+ * Returns a scanner which is configured to scan Java strings.
+ *
+ * @return a Java string scanner
+ *
+ * @since 2.0
+ */
+ public RuleBasedScanner getStringScanner() {
+ return fStringScanner;
+ }
+
+ /**
+ * Returns a scanner which is configured to scan JavaDoc compliant comments.
+ * Notes that the start sequence "/**" and the corresponding end sequence
+ * are part of the JavaDoc comment.
+ *
+ * @return a JavaDoc scanner
+ */
+ public RuleBasedScanner getJavaDocScanner() {
+ return fJavaDocScanner;
+ }
+
+ /**
+ * Returns a scanner which is configured to scan
+ * Java-specific partitions, which are multi-line comments,
+ * JavaDoc comments, and regular Java source code.
+ *
+ * @return a Java partition scanner
+ */
+ public IPartitionTokenScanner getPartitionScanner() {
+ return fPartitionScanner;
+ }
+
+ /**
+ * Factory method for creating a Java-specific document partitioner
+ * using this object's partitions scanner. This method is a
+ * convenience method.
+ *
+ * @return a newly created Java document partitioner
+ */
+ public IDocumentPartitioner createDocumentPartitioner() {
+
+ String[] types= new String[] {
+ FastJavaPartitionScanner.JAVA_DOC,
+ FastJavaPartitionScanner.JAVA_MULTI_LINE_COMMENT,
+ FastJavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT,
+ FastJavaPartitionScanner.JAVA_STRING
+ };
+
+ return new DefaultPartitioner(getPartitionScanner(), types);
+ }
+
+ /**
+ * Returns the names of the document position categories used by the document
+ * partitioners created by this object to manage their partition information.
+ * If the partitioners don't use document position categories, the returned
+ * result is <code>null</code>.
+ *
+ * @return the partition managing position categories or <code>null</code>
+ * if there is none
+ */
+ public String[] getPartitionManagingPositionCategories() {
+ return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
+ }
+
+ /**
+ * Determines whether the preference change encoded by the given event
+ * changes the behavior of one its contained components.
+ *
+ * @param event the event to be investigated
+ * @return <code>true</code> if event causes a behavioral change
+ *
+ * @since 2.0
+ */
+ public boolean affectsBehavior(PropertyChangeEvent event) {
+ return // fCodeScanner.affectsBehavior(event) ||
+ fMultilineCommentScanner.affectsBehavior(event) ||
+ fSinglelineCommentScanner.affectsBehavior(event) ||
+ fStringScanner.affectsBehavior(event); // ||
+// fJavaDocScanner.affectsBehavior(event);
+ }
+
+ /**
+ * Adapts the behavior of the contained components to the change
+ * encoded in the given event.
+ *
+ * @param event the event to which to adapt
+ * @since 2.0
+ */
+ protected void adaptToPreferenceChange(PropertyChangeEvent event) {
+// if (fCodeScanner.affectsBehavior(event))
+// fCodeScanner.adaptToPreferenceChange(event);
+ if (fMultilineCommentScanner.affectsBehavior(event))
+ fMultilineCommentScanner.adaptToPreferenceChange(event);
+ if (fSinglelineCommentScanner.affectsBehavior(event))
+ fSinglelineCommentScanner.adaptToPreferenceChange(event);
+ if (fStringScanner.affectsBehavior(event))
+ fStringScanner.adaptToPreferenceChange(event);
+// if (fJavaDocScanner.affectsBehavior(event))
+// fJavaDocScanner.adaptToPreferenceChange(event);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+package net.sourceforge.phpdt.ui.text;
+
+
+import java.util.List;
+import org.eclipse.jface.preference.IPreferenceStore;
+import net.sourceforge.phpdt.ui.text.IColorManager;
+
+
+/**
+ *
+ */
+public final class SingleTokenPHPScanner extends AbstractJavaScanner{
+
+
+ private String[] fProperty;
+
+ public SingleTokenPHPScanner(IColorManager manager, IPreferenceStore store, String property) {
+ super(manager, store);
+ fProperty= new String[] { property };
+ initialize();
+ }
+
+ /*
+ * @see AbstractJavaScanner#getTokenProperties()
+ */
+ protected String[] getTokenProperties() {
+ return fProperty;
+ }
+
+ /*
+ * @see AbstractJavaScanner#createRules()
+ */
+ protected List createRules() {
+ setDefaultReturnToken(getToken(fProperty[0]));
+ return null;
+ }
+}
+
import net.sourceforge.phpdt.internal.ui.preferences.TemplatePreferencePage;
import net.sourceforge.phpdt.internal.ui.viewsupport.ImageDescriptorRegistry;
+import net.sourceforge.phpdt.ui.PreferenceConstants;
+import net.sourceforge.phpdt.ui.text.JavaTextTools;
import net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider;
import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr;
import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
private ImageDescriptorRegistry fImageDescriptorRegistry;
private PHPDocumentProvider fCompilationUnitDocumentProvider;
+
+ private JavaTextTools fJavaTextTools;
+
/**
* The Java virtual machine that we are running on.
*/
static IPath getInstallLocation() {
return new Path(getDefault().getDescriptor().getInstallURL().getFile());
}
-
+
+ public synchronized JavaTextTools getJavaTextTools() {
+ if (fJavaTextTools == null)
+ fJavaTextTools= new JavaTextTools(getPreferenceStore());
+ return fJavaTextTools;
+ }
+
/**
* Returns the string from the plugin's resource bundle,
* or 'key' if not found.
new PHPSyntaxRdr();
PHPCore.initializeDefaultPluginPreferences();
+ PreferenceConstants.initializeDefaultValues(store);
}
public void startup() throws CoreException {
--- /dev/null
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM 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 implementation
+**********************************************************************/
+package net.sourceforge.phpeclipse.phpeditor;
+
+public final class AnnotationType {
+
+ public final static AnnotationType ALL= new AnnotationType();
+ public final static AnnotationType UNKNOWN= new AnnotationType();
+ public final static AnnotationType BOOKMARK= new AnnotationType();
+ public final static AnnotationType TASK= new AnnotationType();
+ public final static AnnotationType ERROR= new AnnotationType();
+ public final static AnnotationType WARNING= new AnnotationType();
+ public final static AnnotationType SEARCH_RESULT= new AnnotationType();
+
+ private AnnotationType() {
+ }
+}
--- /dev/null
+package net.sourceforge.phpeclipse.phpeditor;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewerExtension3;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+
+
+public final class BracketPainter implements IPainter, PaintListener {
+
+ private PHPPairMatcher fMatcher= new PHPPairMatcher(new char[] { '{', '}', '(', ')', '[', ']' });
+ private Position fBracketPosition= new Position(0, 0);
+ private int fAnchor;
+
+ private boolean fIsActive= false;
+ private ISourceViewer fSourceViewer;
+ private StyledText fTextWidget;
+ private Color fColor;
+
+ private IPositionManager fPositionManager;
+
+
+ public BracketPainter(ISourceViewer sourceViewer) {
+ fSourceViewer= sourceViewer;
+ fTextWidget= sourceViewer.getTextWidget();
+ }
+
+ public void setHighlightColor(Color color) {
+ fColor= color;
+ }
+
+ public void dispose() {
+ if (fMatcher != null) {
+ fMatcher.dispose();
+ fMatcher= null;
+ }
+
+ fColor= null;
+ fTextWidget= null;
+ }
+
+ public void deactivate(boolean redraw) {
+ if (fIsActive) {
+ fIsActive= false;
+ fTextWidget.removePaintListener(this);
+ if (fPositionManager != null)
+ fPositionManager.removeManagedPosition(fBracketPosition);
+ if (redraw)
+ handleDrawRequest(null);
+ }
+ }
+
+ public void paintControl(PaintEvent event) {
+ if (fTextWidget != null)
+ handleDrawRequest(event.gc);
+ }
+
+ private void handleDrawRequest(GC gc) {
+
+ if (fBracketPosition.isDeleted)
+ return;
+
+ int offset= fBracketPosition.getOffset();
+ int length= fBracketPosition.getLength();
+ if (length < 1)
+ return;
+
+ if (fSourceViewer instanceof ITextViewerExtension3) {
+ ITextViewerExtension3 extension= (ITextViewerExtension3) fSourceViewer;
+ IRegion widgetRange= extension.modelRange2WidgetRange(new Region(offset, length));
+ if (widgetRange == null)
+ return;
+
+ offset= widgetRange.getOffset();
+ length= widgetRange.getLength();
+
+ } else {
+ IRegion region= fSourceViewer.getVisibleRegion();
+ if (region.getOffset() > offset || region.getOffset() + region.getLength() < offset + length)
+ return;
+ offset -= region.getOffset();
+ }
+
+ if (PHPPairMatcher.RIGHT == fAnchor)
+ draw(gc, offset, 1);
+ else
+ draw(gc, offset + length -1, 1);
+ }
+
+ private void draw(GC gc, int offset, int length) {
+ if (gc != null) {
+ Point left= fTextWidget.getLocationAtOffset(offset);
+ Point right= fTextWidget.getLocationAtOffset(offset + length);
+
+ gc.setForeground(fColor);
+ gc.drawRectangle(left.x, left.y, right.x - left.x - 1, gc.getFontMetrics().getHeight() - 1);
+
+ } else {
+ fTextWidget.redrawRange(offset, length, true);
+ }
+ }
+
+ /*
+ * @see IPainter#paint(int)
+ */
+ public void paint(int reason) {
+ Point selection= fSourceViewer.getSelectedRange();
+ if (selection.y > 0) {
+ deactivate(true);
+ return;
+ }
+
+ IRegion pair= fMatcher.match(fSourceViewer.getDocument(), selection.x);
+ if (pair == null) {
+ deactivate(true);
+ return;
+ }
+
+ if (fIsActive) {
+ // only if different
+ if (pair.getOffset() != fBracketPosition.getOffset() ||
+ pair.getLength() != fBracketPosition.getLength() ||
+ fMatcher.getAnchor() != fAnchor) {
+
+ // remove old highlighting
+ handleDrawRequest(null);
+ // update position
+ fBracketPosition.isDeleted= false;
+ fBracketPosition.offset= pair.getOffset();
+ fBracketPosition.length= pair.getLength();
+ fAnchor= fMatcher.getAnchor();
+ // apply new highlighting
+ handleDrawRequest(null);
+
+ }
+ } else {
+
+ fIsActive= true;
+
+ fBracketPosition.isDeleted= false;
+ fBracketPosition.offset= pair.getOffset();
+ fBracketPosition.length= pair.getLength();
+ fAnchor= fMatcher.getAnchor();
+
+ fTextWidget.addPaintListener(this);
+ fPositionManager.addManagedPosition(fBracketPosition);
+ handleDrawRequest(null);
+ }
+ }
+
+ /*
+ * @see IPainter#setPositionManager(IPositionManager)
+ */
+ public void setPositionManager(IPositionManager manager) {
+ fPositionManager= manager;
+ }
+}
--- /dev/null
+package net.sourceforge.phpeclipse.phpeditor;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+
+public interface IPainter {
+
+ /** Paint reasons */
+ int SELECTION= 0;
+ int TEXT_CHANGE= 1;
+ int KEY_STROKE= 2;
+ int MOUSE_BUTTON= 4;
+ int INTERNAL= 8;
+ int CONFIGURATION= 16;
+
+
+ /**
+ * Disposes this painter.
+ * <p>
+ * XXX: The relationship with deactivate is not yet defined.
+ * </p>
+ * */
+ void dispose();
+
+ void paint(int reason);
+
+ /**
+ * Deactivates the painter.
+ * <p>
+ * XXX: The relationship with dispose is not yet defined.
+ * </p>
+ */
+ void deactivate(boolean redraw);
+
+ void setPositionManager(IPositionManager manager);
+}
--- /dev/null
+package net.sourceforge.phpeclipse.phpeditor;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.jface.text.Position;
+
+
+public interface IPositionManager {
+
+ void addManagedPosition(Position position);
+
+ void removeManagedPosition(Position position);
+}
--- /dev/null
+package net.sourceforge.phpeclipse.phpeditor;
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+
+import java.util.Iterator;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * Interface of annotations representing problems.
+ */
+public interface IProblemAnnotation {
+
+ AnnotationType getAnnotationType();
+
+ boolean isTemporary();
+
+ String getMessage();
+
+ String[] getArguments();
+
+ int getId();
+
+
+ Image getImage(Display display);
+
+ boolean isRelevant();
+
+ boolean hasOverlay();
+
+ Iterator getOverlaidIterator();
+
+ void addOverlaid(IProblemAnnotation annotation);
+
+ void removeOverlaid(IProblemAnnotation annotation);
+
+
+ /**
+ * @deprecated
+ */
+ boolean isProblem();
+
+ /**
+ * @deprecated
+ */
+ boolean isTask();
+
+ /**
+ * @deprecated
+ */
+ boolean isWarning();
+
+ /**
+ * @deprecated
+ */
+ boolean isError();
+}
--- /dev/null
+package net.sourceforge.phpeclipse.phpeditor;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.swt.custom.LineBackgroundEvent;
+import org.eclipse.swt.custom.LineBackgroundListener;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+
+public class LinePainter implements IPainter, LineBackgroundListener {
+
+ private final ISourceViewer fViewer;
+ private Color fHighlightColor;
+ private IPositionManager fPositionManager;
+
+ // positions to keep track of beginning and end of line to be painted or cleared
+ private Position fCurrentLine= new Position(0, 0);
+ private Position fLastLine= new Position(0, 0);
+ // used to keep track of the last line painted
+ private int fLastLineNumber= -1;
+ private boolean fIsActive;
+
+ public LinePainter(ISourceViewer sourceViewer) {
+ fViewer= sourceViewer;
+ }
+
+ public void setHighlightColor(Color highlightColor) {
+ fHighlightColor= highlightColor;
+ }
+
+ /*
+ * @see LineBackgroundListener#lineGetBackground(LineBackgroundEvent)
+ */
+ public void lineGetBackground(LineBackgroundEvent event) {
+ // don't use cached line information because of asynch painting
+
+ StyledText textWidget= fViewer.getTextWidget();
+ if (textWidget != null) {
+
+ int caret= textWidget.getCaretOffset();
+ int length= event.lineText.length();
+
+ if (event.lineOffset <= caret && caret <= event.lineOffset + length)
+ event.lineBackground= fHighlightColor;
+ else
+ event.lineBackground= textWidget.getBackground();
+ }
+ }
+
+ private boolean updateHighlightLine() {
+ try {
+
+ IDocument document= fViewer.getDocument();
+
+ int offset= fViewer.getTextWidget().getCaretOffset() + fViewer.getVisibleRegion().getOffset();
+ int lineNumber= document.getLineOfOffset(offset);
+
+ // redraw if the current line number is different from the last line number we painted
+ // initially fLastLineNumber is -1
+ if (lineNumber != fLastLineNumber) {
+
+ fLastLine.offset= fCurrentLine.offset;
+ fLastLine.length= fCurrentLine.length;
+ fLastLine.isDeleted= fCurrentLine.isDeleted;
+
+ fCurrentLine.isDeleted= false;
+ fCurrentLine.offset= document.getLineOffset(lineNumber);
+ if (lineNumber == document.getNumberOfLines() - 1)
+ fCurrentLine.length= document.getLength() - fCurrentLine.offset;
+ else
+ fCurrentLine.length= document.getLineOffset(lineNumber + 1) - fCurrentLine.offset;
+
+ fLastLineNumber= lineNumber;
+ return true;
+
+ }
+
+ } catch (BadLocationException e) {
+ }
+
+ return false;
+ }
+
+ private void drawHighlightLine(Position position, int visibleOffset) {
+ StyledText textWidget= fViewer.getTextWidget();
+
+ // if the position that is about to be drawn was deleted then we can't
+ if (position.isDeleted())
+ return;
+
+ int delta= position.offset - visibleOffset;
+ if (0 <= delta && delta <= fViewer.getVisibleRegion().getLength()) {
+ Point upperLeft= textWidget.getLocationAtOffset(delta);
+ int width= textWidget.getClientArea().width + textWidget.getHorizontalPixel();
+ int height= textWidget.getLineHeight();
+ textWidget.redraw(upperLeft.x, upperLeft.y, width, height, false);
+ }
+ }
+
+ /*
+ * @see IPainter#deactivate(boolean)
+ */
+ public void deactivate(boolean redraw) {
+ if (fIsActive) {
+ fIsActive= false;
+
+ /* on turning off the feature one has to paint the currently
+ * highlighted line with the standard background color
+ */
+ if (redraw)
+ drawHighlightLine(fCurrentLine, fViewer.getVisibleRegion().getOffset());
+
+ fViewer.getTextWidget().removeLineBackgroundListener(this);
+
+ if (fPositionManager != null)
+ fPositionManager.removeManagedPosition(fCurrentLine);
+
+ fLastLineNumber= -1;
+ }
+ }
+
+ /*
+ * @see IPainter#dispose()
+ */
+ public void dispose() {
+ }
+
+ /*
+ * @see IPainter#paint(int)
+ */
+ public void paint(int reason) {
+
+ // check selection
+ Point selection= fViewer.getTextWidget().getSelectionRange();
+ if (selection.y > 0) {
+ deactivate(true);
+ return;
+ }
+
+ // initialization
+ if (!fIsActive) {
+ fViewer.getTextWidget().addLineBackgroundListener(this);
+ fPositionManager.addManagedPosition(fCurrentLine);
+ fIsActive= true;
+ }
+
+ //redraw line highlight only if it hasn't been drawn yet on the respective line
+ if (updateHighlightLine()) {
+ // used to handle segmented view of source files
+ int visibleRegionOffset= fViewer.getVisibleRegion().getOffset();
+ // clear last line
+ drawHighlightLine(fLastLine, visibleRegionOffset);
+ // draw new line
+ drawHighlightLine(fCurrentLine, visibleRegionOffset);
+ }
+ }
+
+ /*
+ * @see IPainter#setPositionManager(IPositionManager)
+ */
+ public void setPositionManager(IPositionManager manager) {
+ fPositionManager = manager;
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM 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 implementation
+**********************************************************************/
+
+package net.sourceforge.phpeclipse.phpeditor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension3;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModelListener;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ *
+ */
+public class OverviewRuler implements IVerticalRulerInfo {
+
+ /**
+ * Internal listener class.
+ */
+ class InternalListener implements ITextListener, IAnnotationModelListener {
+
+ /*
+ * @see ITextListener#textChanged
+ */
+ public void textChanged(TextEvent e) {
+ if (fTextViewer != null
+ && e.getDocumentEvent() == null
+ && e.getViewerRedrawState()) {
+ // handle only changes of visible document
+ redraw();
+ }
+ }
+
+ /*
+ * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
+ */
+ public void modelChanged(IAnnotationModel model) {
+ update();
+ }
+ }
+
+ /**
+ * Filters problems based on their types.
+ */
+ class FilterIterator implements Iterator {
+
+ private final static int IGNORE = 0;
+ private final static int TEMPORARY = 1;
+ private final static int PERSISTENT = 2;
+
+ private Iterator fIterator;
+ private AnnotationType fType;
+ private IProblemAnnotation fNext;
+ private int fTemporary;
+
+ public FilterIterator(AnnotationType type) {
+ this(type, IGNORE);
+ }
+
+ public FilterIterator(AnnotationType type, boolean temporary) {
+ this(type, temporary ? TEMPORARY : PERSISTENT);
+ }
+
+ private FilterIterator(AnnotationType type, int temporary) {
+ fType = type;
+ fTemporary = temporary;
+ if (fModel != null) {
+ fIterator = fModel.getAnnotationIterator();
+ skip();
+ }
+ }
+
+ private void skip() {
+ while (fIterator.hasNext()) {
+ Object next = fIterator.next();
+ if (next instanceof IProblemAnnotation) {
+ fNext = (IProblemAnnotation) next;
+ AnnotationType type = fNext.getAnnotationType();
+ if (fType == AnnotationType.ALL || fType == type) {
+ if (fTemporary == IGNORE)
+ return;
+ if (fTemporary == TEMPORARY && fNext.isTemporary())
+ return;
+ if (fTemporary == PERSISTENT && !fNext.isTemporary())
+ return;
+ }
+ }
+ }
+ fNext = null;
+ }
+
+ /*
+ * @see Iterator#hasNext()
+ */
+ public boolean hasNext() {
+ return fNext != null;
+ }
+ /*
+ * @see Iterator#next()
+ */
+ public Object next() {
+ try {
+ return fNext;
+ } finally {
+ if (fModel != null)
+ skip();
+ }
+ }
+ /*
+ * @see Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ private static final int INSET = 2;
+ private static final int PROBLEM_HEIGHT_MIN = 4;
+ private static boolean PROBLEM_HEIGHT_SCALABLE = false;
+
+ /** The model of the overview ruler */
+ private IAnnotationModel fModel;
+ /** The view to which this ruler is connected */
+ private ITextViewer fTextViewer;
+ /** The ruler's canvas */
+ private Canvas fCanvas;
+ /** The drawable for double buffering */
+ private Image fBuffer;
+ /** The internal listener */
+ private InternalListener fInternalListener = new InternalListener();
+ /** The width of this vertical ruler */
+ private int fWidth;
+ /** The hit detection cursor */
+ private Cursor fHitDetectionCursor;
+ /** The last cursor */
+ private Cursor fLastCursor;
+ /** Cache for the actual scroll position in pixels */
+ private int fScrollPos;
+ /** The line of the last mouse button activity */
+ private int fLastMouseButtonActivityLine = -1;
+ /** The actual problem height */
+ private int fProblemHeight = -1;
+
+ private Set fAnnotationSet = new HashSet();
+ private Map fLayers = new HashMap();
+ private Map fColorTable = new HashMap();
+
+ /**
+ * Constructs a vertical ruler with the given width.
+ *
+ * @param width the width of the vertical ruler
+ */
+ public OverviewRuler(int width) {
+ fWidth = width;
+ }
+
+ public Control getControl() {
+ return fCanvas;
+ }
+
+ public int getWidth() {
+ return fWidth;
+ }
+
+ public void setModel(IAnnotationModel model) {
+ if (model != fModel || model != null) {
+
+ if (fModel != null)
+ fModel.removeAnnotationModelListener(fInternalListener);
+
+ fModel = model;
+
+ if (fModel != null)
+ fModel.addAnnotationModelListener(fInternalListener);
+
+ update();
+ }
+ }
+
+ public Control createControl(Composite parent, ITextViewer textViewer) {
+
+ fTextViewer = textViewer;
+
+ fHitDetectionCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
+ fCanvas = new Canvas(parent, SWT.NO_BACKGROUND);
+
+ fCanvas.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent event) {
+ if (fTextViewer != null)
+ doubleBufferPaint(event.gc);
+ }
+ });
+
+ fCanvas.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent event) {
+ handleDispose();
+ fTextViewer = null;
+ }
+ });
+
+ fCanvas.addMouseListener(new MouseAdapter() {
+ public void mouseDown(MouseEvent event) {
+ handleMouseDown(event);
+ }
+ });
+
+ fCanvas.addMouseMoveListener(new MouseMoveListener() {
+ public void mouseMove(MouseEvent event) {
+ handleMouseMove(event);
+ }
+ });
+
+ if (fTextViewer != null)
+ fTextViewer.addTextListener(fInternalListener);
+
+ return fCanvas;
+ }
+
+ /**
+ * Disposes the ruler's resources.
+ */
+ private void handleDispose() {
+
+ if (fTextViewer != null) {
+ fTextViewer.removeTextListener(fInternalListener);
+ fTextViewer = null;
+ }
+
+ if (fModel != null)
+ fModel.removeAnnotationModelListener(fInternalListener);
+
+ if (fBuffer != null) {
+ fBuffer.dispose();
+ fBuffer = null;
+ }
+
+ if (fHitDetectionCursor != null) {
+ fHitDetectionCursor.dispose();
+ fHitDetectionCursor = null;
+ }
+
+ fAnnotationSet.clear();
+ fLayers.clear();
+ fColorTable.clear();
+ }
+
+ /**
+ * Double buffer drawing.
+ */
+ private void doubleBufferPaint(GC dest) {
+
+ Point size = fCanvas.getSize();
+
+ if (size.x <= 0 || size.y <= 0)
+ return;
+
+ if (fBuffer != null) {
+ Rectangle r = fBuffer.getBounds();
+ if (r.width != size.x || r.height != size.y) {
+ fBuffer.dispose();
+ fBuffer = null;
+ }
+ }
+ if (fBuffer == null)
+ fBuffer = new Image(fCanvas.getDisplay(), size.x, size.y);
+
+ GC gc = new GC(fBuffer);
+ try {
+ gc.setBackground(fCanvas.getBackground());
+ gc.fillRectangle(0, 0, size.x, size.y);
+
+ if (fTextViewer instanceof ITextViewerExtension3)
+ doPaint1(gc);
+ else
+ doPaint(gc);
+
+ } finally {
+ gc.dispose();
+ }
+
+ dest.drawImage(fBuffer, 0, 0);
+ }
+
+ private void doPaint(GC gc) {
+
+ if (fTextViewer == null)
+ return;
+
+ Rectangle r = new Rectangle(0, 0, 0, 0);
+ int yy, hh = PROBLEM_HEIGHT_MIN;
+
+ IDocument document = fTextViewer.getDocument();
+ IRegion visible = fTextViewer.getVisibleRegion();
+
+ StyledText textWidget = fTextViewer.getTextWidget();
+ int maxLines = textWidget.getLineCount();
+ fScrollPos = textWidget.getTopPixel();
+
+ Point size = fCanvas.getSize();
+ int writable = maxLines * textWidget.getLineHeight();
+ if (size.y > writable)
+ size.y = writable;
+
+ List indices = new ArrayList(fLayers.keySet());
+ Collections.sort(indices);
+
+ for (Iterator iterator = indices.iterator(); iterator.hasNext();) {
+ Object layer = iterator.next();
+ AnnotationType annotationType = (AnnotationType) fLayers.get(layer);
+
+ if (skip(annotationType))
+ continue;
+
+ boolean[] temporary = new boolean[] { false, true };
+ for (int t = 0; t < temporary.length; t++) {
+
+ Iterator e = new FilterIterator(annotationType, temporary[t]);
+ Color fill = getFillColor(annotationType, temporary[t]);
+ Color stroke = getStrokeColor(annotationType, temporary[t]);
+
+ for (int i = 0; e.hasNext(); i++) {
+
+ Annotation a = (Annotation) e.next();
+ Position p = fModel.getPosition(a);
+
+ if (p == null
+ || !p.overlapsWith(visible.getOffset(), visible.getLength()))
+ continue;
+
+ int problemOffset = Math.max(p.getOffset(), visible.getOffset());
+ int problemEnd =
+ Math.min(
+ p.getOffset() + p.getLength(),
+ visible.getOffset() + visible.getLength());
+ int problemLength = problemEnd - problemOffset;
+
+ try {
+ if (PROBLEM_HEIGHT_SCALABLE) {
+ int numbersOfLines =
+ document.getNumberOfLines(problemOffset, problemLength);
+ hh = (numbersOfLines * size.y) / maxLines;
+ if (hh < PROBLEM_HEIGHT_MIN)
+ hh = PROBLEM_HEIGHT_MIN;
+ }
+ fProblemHeight = hh;
+
+ int startLine =
+ textWidget.getLineAtOffset(problemOffset - visible.getOffset());
+ yy = Math.min((startLine * size.y) / maxLines, size.y - hh);
+
+ if (fill != null) {
+ gc.setBackground(fill);
+ gc.fillRectangle(INSET, yy, size.x - (2 * INSET), hh);
+ }
+
+ if (stroke != null) {
+ gc.setForeground(stroke);
+ r.x = INSET;
+ r.y = yy;
+ r.width = size.x - (2 * INSET) - 1;
+ r.height = hh;
+ gc.setLineWidth(1);
+ gc.drawRectangle(r);
+ }
+ } catch (BadLocationException x) {
+ }
+ }
+ }
+ }
+ }
+
+ private void doPaint1(GC gc) {
+
+ if (fTextViewer == null)
+ return;
+
+ Rectangle r = new Rectangle(0, 0, 0, 0);
+ int yy, hh = PROBLEM_HEIGHT_MIN;
+
+ ITextViewerExtension3 extension = (ITextViewerExtension3) fTextViewer;
+ IDocument document = fTextViewer.getDocument();
+ StyledText textWidget = fTextViewer.getTextWidget();
+ fScrollPos = textWidget.getTopPixel();
+
+ int maxLines = textWidget.getLineCount();
+ Point size = fCanvas.getSize();
+ int writable = maxLines * textWidget.getLineHeight();
+ if (size.y > writable)
+ size.y = writable;
+
+ List indices = new ArrayList(fLayers.keySet());
+ Collections.sort(indices);
+
+ for (Iterator iterator = indices.iterator(); iterator.hasNext();) {
+ Object layer = iterator.next();
+ AnnotationType annotationType = (AnnotationType) fLayers.get(layer);
+
+ if (skip(annotationType))
+ continue;
+
+ boolean[] temporary = new boolean[] { false, true };
+ for (int t = 0; t < temporary.length; t++) {
+
+ Iterator e = new FilterIterator(annotationType, temporary[t]);
+ Color fill = getFillColor(annotationType, temporary[t]);
+ Color stroke = getStrokeColor(annotationType, temporary[t]);
+
+ for (int i = 0; e.hasNext(); i++) {
+
+ Annotation a = (Annotation) e.next();
+ Position p = fModel.getPosition(a);
+
+ if (p == null)
+ continue;
+
+ IRegion widgetRegion =
+ extension.modelRange2WidgetRange(
+ new Region(p.getOffset(), p.getLength()));
+ if (widgetRegion == null)
+ continue;
+
+ try {
+ if (PROBLEM_HEIGHT_SCALABLE) {
+ int numbersOfLines =
+ document.getNumberOfLines(p.getOffset(), p.getLength());
+ hh = (numbersOfLines * size.y) / maxLines;
+ if (hh < PROBLEM_HEIGHT_MIN)
+ hh = PROBLEM_HEIGHT_MIN;
+ }
+ fProblemHeight = hh;
+
+ int startLine =
+ textWidget.getLineAtOffset(widgetRegion.getOffset());
+ yy = Math.min((startLine * size.y) / maxLines, size.y - hh);
+
+ if (fill != null) {
+ gc.setBackground(fill);
+ gc.fillRectangle(INSET, yy, size.x - (2 * INSET), hh);
+ }
+
+ if (stroke != null) {
+ gc.setForeground(stroke);
+ r.x = INSET;
+ r.y = yy;
+ r.width = size.x - (2 * INSET) - 1;
+ r.height = hh;
+ gc.setLineWidth(1);
+ gc.drawRectangle(r);
+ }
+ } catch (BadLocationException x) {
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Thread-safe implementation.
+ * Can be called from any thread.
+ */
+ public void update() {
+ if (fCanvas != null && !fCanvas.isDisposed()) {
+ Display d = fCanvas.getDisplay();
+ if (d != null) {
+ d.asyncExec(new Runnable() {
+ public void run() {
+ redraw();
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Redraws the overview ruler.
+ */
+ private void redraw() {
+ if (fCanvas != null && !fCanvas.isDisposed()) {
+ GC gc = new GC(fCanvas);
+ doubleBufferPaint(gc);
+ gc.dispose();
+ }
+ }
+
+ private int[] toLineNumbers(int y_coordinate) {
+
+ StyledText textWidget = fTextViewer.getTextWidget();
+ int maxLines = textWidget.getContent().getLineCount();
+
+ int rulerLength = fCanvas.getSize().y;
+ int writable = maxLines * textWidget.getLineHeight();
+
+ if (rulerLength > writable)
+ rulerLength = writable;
+
+ if (y_coordinate >= writable)
+ return new int[] { -1, -1 };
+
+ int[] lines = new int[2];
+
+ int pixel = Math.max(y_coordinate - 1, 0);
+ lines[0] = (pixel * maxLines) / rulerLength;
+
+ pixel = Math.min(rulerLength, y_coordinate + 1);
+ lines[1] = (pixel * maxLines) / rulerLength;
+
+ if (fTextViewer instanceof ITextViewerExtension3) {
+ ITextViewerExtension3 extension = (ITextViewerExtension3) fTextViewer;
+ lines[0] = extension.widgetlLine2ModelLine(lines[0]);
+ lines[1] = extension.widgetlLine2ModelLine(lines[1]);
+ } else {
+ try {
+ IRegion visible = fTextViewer.getVisibleRegion();
+ int lineNumber =
+ fTextViewer.getDocument().getLineOfOffset(visible.getOffset());
+ lines[0] += lineNumber;
+ lines[1] += lineNumber;
+ } catch (BadLocationException x) {
+ }
+ }
+
+ return lines;
+ }
+
+ boolean hasAnnotationAt(int y_coordinate) {
+ return findBestMatchingLineNumber(toLineNumbers(y_coordinate)) != -1;
+ }
+
+ private Position getProblemPositionAt(int[] lineNumbers) {
+ if (lineNumbers[0] == -1)
+ return null;
+
+ Position found = null;
+
+ try {
+ IDocument d = fTextViewer.getDocument();
+ IRegion line = d.getLineInformation(lineNumbers[0]);
+
+ int start = line.getOffset();
+
+ line = d.getLineInformation(lineNumbers[lineNumbers.length - 1]);
+ int end = line.getOffset() + line.getLength();
+
+ Iterator e = new FilterIterator(AnnotationType.ALL);
+ while (e.hasNext()) {
+ Annotation a = (Annotation) e.next();
+ Position p = fModel.getPosition(a);
+ if (start <= p.getOffset() && p.getOffset() < end) {
+ if (found == null || p.getOffset() < found.getOffset())
+ found = p;
+ }
+ }
+
+ } catch (BadLocationException x) {
+ }
+
+ return found;
+ }
+
+ /**
+ * Returns the line which best corresponds to one of
+ * the underlying problem annotations at the given
+ * y ruler coordinate.
+ *
+ * @return the best matching line or <code>-1</code> if no such line can be found
+ * @since 2.1
+ */
+ private int findBestMatchingLineNumber(int[] lineNumbers) {
+ if (lineNumbers == null || lineNumbers.length < 1)
+ return -1;
+
+ try {
+ Position pos = getProblemPositionAt(lineNumbers);
+ if (pos == null)
+ return -1;
+ return fTextViewer.getDocument().getLineOfOffset(pos.getOffset());
+ } catch (BadLocationException ex) {
+ return -1;
+ }
+ }
+
+ private void handleMouseDown(MouseEvent event) {
+ if (fTextViewer != null) {
+ int[] lines = toLineNumbers(event.y);
+ Position p = getProblemPositionAt(lines);
+ if (p != null) {
+ fTextViewer.revealRange(p.getOffset(), p.getLength());
+ fTextViewer.setSelectedRange(p.getOffset(), p.getLength());
+ }
+ fTextViewer.getTextWidget().setFocus();
+ }
+ fLastMouseButtonActivityLine = toDocumentLineNumber(event.y);
+ }
+
+ private void handleMouseMove(MouseEvent event) {
+ if (fTextViewer != null) {
+ int[] lines = toLineNumbers(event.y);
+ Position p = getProblemPositionAt(lines);
+ Cursor cursor = (p != null ? fHitDetectionCursor : null);
+ if (cursor != fLastCursor) {
+ fCanvas.setCursor(cursor);
+ fLastCursor = cursor;
+ }
+ }
+ }
+
+ private void handleMouseDoubleClick(MouseEvent event) {
+ fLastMouseButtonActivityLine = toDocumentLineNumber(event.y);
+ }
+
+ public void showAnnotation(AnnotationType annotationType, boolean show) {
+ if (show)
+ fAnnotationSet.add(annotationType);
+ else
+ fAnnotationSet.remove(annotationType);
+ }
+
+ public void setLayer(AnnotationType annotationType, int layer) {
+ if (layer >= 0)
+ fLayers.put(new Integer(layer), annotationType);
+ else {
+ Iterator e = fLayers.keySet().iterator();
+ while (e.hasNext()) {
+ Object key = e.next();
+ if (annotationType.equals(fLayers.get(key))) {
+ fLayers.remove(key);
+ return;
+ }
+ }
+ }
+ }
+
+ public void setColor(AnnotationType annotationType, Color color) {
+ if (color != null)
+ fColorTable.put(annotationType, color);
+ else
+ fColorTable.remove(annotationType);
+ }
+
+ private boolean skip(AnnotationType annotationType) {
+ return !fAnnotationSet.contains(annotationType);
+ }
+
+ private static RGB interpolate(RGB fg, RGB bg, double scale) {
+ return new RGB(
+ (int) ((1.0 - scale) * fg.red + scale * bg.red),
+ (int) ((1.0 - scale) * fg.green + scale * bg.green),
+ (int) ((1.0 - scale) * fg.blue + scale * bg.blue));
+ }
+
+ private static double greyLevel(RGB rgb) {
+ if (rgb.red == rgb.green && rgb.green == rgb.blue)
+ return rgb.red;
+ return (0.299 * rgb.red + 0.587 * rgb.green + 0.114 * rgb.blue + 0.5);
+ }
+
+ private static boolean isDark(RGB rgb) {
+ return greyLevel(rgb) > 128;
+ }
+
+ private static Color getColor(RGB rgb) {
+ // PHPTextTools textTools= PHPeclipsePlugin.getDefault().getPHPTextTools();
+ // return textTools.getColorManager().getColor(rgb);
+ return PHPEditorEnvironment.getPHPColorProvider().getColor(rgb);
+ }
+
+ private Color getColor(AnnotationType annotationType, double scale) {
+ Color base = (Color) fColorTable.get(annotationType);
+ if (base == null)
+ return null;
+
+ RGB baseRGB = base.getRGB();
+ RGB background = fCanvas.getBackground().getRGB();
+
+ boolean darkBase = isDark(baseRGB);
+ boolean darkBackground = isDark(background);
+ if (darkBase && darkBackground)
+ background = new RGB(255, 255, 255);
+ else if (!darkBase && !darkBackground)
+ background = new RGB(0, 0, 0);
+
+ return getColor(interpolate(baseRGB, background, scale));
+ }
+
+ private Color getStrokeColor(
+ AnnotationType annotationType,
+ boolean temporary) {
+ return getColor(annotationType, temporary ? 0.5 : 0.2);
+ }
+
+ private Color getFillColor(
+ AnnotationType annotationType,
+ boolean temporary) {
+ return getColor(annotationType, temporary ? 0.9 : 0.6);
+ }
+
+ /**
+ * @see IVerticalRulerInfo#getLineOfLastMouseButtonActivity()
+ * @since 2.1
+ */
+ public int getLineOfLastMouseButtonActivity() {
+ return fLastMouseButtonActivityLine;
+ }
+
+ /**
+ * @see IVerticalRulerInfo#toDocumentLineNumber(int)
+ * @since 2.1
+ */
+ public int toDocumentLineNumber(int y_coordinate) {
+
+ if (fTextViewer == null || y_coordinate == -1)
+ return -1;
+
+ int[] lineNumbers = toLineNumbers(y_coordinate);
+ int bestLine = findBestMatchingLineNumber(lineNumbers);
+ if (bestLine == -1 && lineNumbers.length > 0)
+ return lineNumbers[0];
+ return bestLine;
+ }
+
+ /**
+ * Returns the height of the problem rectangle.
+ *
+ * @return the height of the problem rectangle
+ * @since 2.1
+ */
+ int getAnnotationHeight() {
+ return fProblemHeight;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2000, 2002 IBM 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.phpeclipse.phpeditor;
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.source.AnnotationBarHoverManager;
+import org.eclipse.jface.text.source.IAnnotationHover;
+import org.eclipse.jface.text.source.ISourceViewer;
+
+/**
+ * This manager controls the layout, content, and visibility of an information
+ * control in reaction to mouse hover events issued by the overview ruler of a
+ * source viewer.
+ *
+ * @since 2.1
+ */
+class OverviewRulerHoverManager extends AnnotationBarHoverManager {
+
+ /**
+ * Creates an overview hover manager with the given parameters. In addition,
+ * the hovers anchor is RIGHT and the margin is 5 points to the right.
+ *
+ * @param ruler the overview ruler this manager connects to
+ * @param sourceViewer the source viewer this manager connects to
+ * @param annotationHover the annotation hover providing the information to be displayed
+ * @param creator the information control creator
+ */
+ public OverviewRulerHoverManager(OverviewRuler ruler, ISourceViewer sourceViewer, IAnnotationHover annotationHover, IInformationControlCreator creator) {
+ super(ruler, sourceViewer, annotationHover, creator);
+ }
+
+ /*
+ * @see AbstractHoverInformationControlManager#computeInformation()
+ */
+ protected void computeInformation() {
+ Point location= getHoverEventLocation();
+ int line= getVerticalRulerInfo().toDocumentLineNumber(location.y);
+ setInformation(getAnnotationHover().getHoverInfo(getSourceViewer(), line), computeArea(location.y));
+ }
+
+ /**
+ * Determines graphical area covered for which the hover is valid.
+ *
+ * @param y-coordinate in the vertical ruler
+ * @return the graphical extend where the hover is valid
+ */
+ private Rectangle computeArea(int y) {
+ // This is ok (see constructor)
+ OverviewRuler overviewRuler= (OverviewRuler)getVerticalRulerInfo();
+
+ int hover_height= overviewRuler.getAnnotationHeight();
+ int hover_width= getVerticalRulerInfo().getControl().getSize().x;
+
+ // Calculate y-coordinate for hover
+ int hover_y= y;
+ boolean hasAnnotation= true;
+ while (hasAnnotation && hover_y > y - hover_height) {
+ hover_y--;
+ hasAnnotation= overviewRuler.hasAnnotationAt(hover_y);
+ }
+ hover_y++;
+
+ return new Rectangle(0, hover_y, hover_width, hover_height);
+ }
+}
import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.DefaultLineTracker;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.ILineTracker;
import org.eclipse.jface.text.rules.DefaultPartitioner;
import org.eclipse.ui.editors.text.FileDocumentProvider;
fgScanner = new PHPPartitionScanner();
return fgScanner;
}
+
+ /**
+ * Creates a line tracker working with the same line delimiters as the document
+ * of the given element. Assumes the element to be managed by this document provider.
+ *
+ * @param element the element serving as blue print
+ * @return a line tracker based on the same line delimiters as the element's document
+ */
+ public ILineTracker createLineTracker(Object element) {
+ return new DefaultLineTracker();
+ }
}
IBM Corporation - Initial implementation
Klaus Hartlage - www.eclipseproject.de
**********************************************************************/
+import java.util.ArrayList;
+import java.util.List;
+
import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
+import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
+import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
+import net.sourceforge.phpdt.internal.ui.viewsupport.IViewPartInputProvider;
import net.sourceforge.phpdt.ui.actions.GenerateActionGroup;
import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction;
+import net.sourceforge.phpdt.ui.text.JavaTextTools;
import net.sourceforge.phpeclipse.IPreferenceConstants;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
-import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension3;
+import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.information.InformationPresenter;
import org.eclipse.jface.text.source.AnnotationRulerColumn;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.LineNumberRulerColumn;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BidiSegmentEvent;
+import org.eclipse.swt.custom.BidiSegmentListener;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
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.ContentAssistAction;
import org.eclipse.ui.texteditor.DefaultRangeIndicator;
+import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.IEditorStatusLine;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.texteditor.StatusTextEditor;
import org.eclipse.ui.texteditor.TextOperationAction;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
/**
* PHP specific text editor.
*/
-public class PHPEditor extends TextEditor {
-// extends StatusTextEditor implements IViewPartInputProvider { // extends TextEditor {
+public class PHPEditor
+ extends StatusTextEditor
+ implements IViewPartInputProvider { // extends TextEditor {
// protected PHPActionGroup fActionGroups;
/** The outline page */
private PHPContentOutlinePage fOutlinePage;
- private IPreferenceStore phpPrefStore;
+
+ // protected PHPSyntaxParserThread fValidationThread = null;
+
+ // private IPreferenceStore fPHPPrefStore;
/** The editor's bracket matcher */
private PHPPairMatcher fBracketMatcher;
/** The standard action groups added to the menu */
private GenerateActionGroup fGenerateActionGroup;
private CompositeActionGroup fContextMenuGroup;
+
+ /** The information presenter. */
+ private InformationPresenter fInformationPresenter;
+
/**
* Default constructor.
*/
public PHPEditor() {
super();
- setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
- setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
+ JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
+ setSourceViewerConfiguration(
+ new PHPSourceViewerConfiguration(textTools, this));
+ setRangeIndicator(new DefaultRangeIndicator());
+ setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
+
+ // if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
+ // fUpdater= new OutlinePageSelectionUpdater();
+
+ initializeEditor();
}
//
// /**
// return doc.get().toCharArray();
// }
+ /*
+ * @see net.sourceforge.phpdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
+ */
+ public Object getViewPartInput() {
+ return getEditorInput().getAdapter(IResource.class);
+ }
+
+ /*
+ * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.
+ * widgets.Composite)
+ */
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+
+ IInformationControlCreator informationControlCreator =
+ new IInformationControlCreator() {
+ public IInformationControl createInformationControl(Shell parent) {
+ boolean cutDown = false;
+ int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL);
+ return new DefaultInformationControl(
+ parent,
+ SWT.RESIZE,
+ style,
+ new HTMLTextPresenter(cutDown));
+ }
+ };
+
+ fInformationPresenter = new InformationPresenter(informationControlCreator);
+ fInformationPresenter.setSizeConstraints(60, 10, true, true);
+ fInformationPresenter.install(getSourceViewer());
+ }
+
/**
* Returns this document's complete text.
*
new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup });
// rg,
// new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT)});
+
+ // if (fValidationThread == null) {
+ // fValidationThread =
+ // new PHPSyntaxParserThread(this, getSourceViewer());
+ // //Thread defaults
+ //
+ // fValidationThread.start();
+ // }
+ //
+ // fValidationThread.setText(getSourceViewer().getTextWidget().getText());
}
/** The <code>PHPEditor</code> implementation of this
public void doSave(IProgressMonitor monitor) {
super.doSave(monitor);
// compile or not, according to the user preferences
- IPreferenceStore store = phpPrefStore;
+ IPreferenceStore store = getPreferenceStore(); // fPHPPrefStore;
if (store.getBoolean(PHPeclipsePlugin.PHP_PARSE_ON_SAVE)) {
IAction a = PHPParserAction.getInstance();
if (a != null)
* <code>AbstractTextEditor</code> method performs sets the
* input of the outline page after AbstractTextEditor has set input.
*/
- public void doSetInput(IEditorInput input) throws CoreException {
+ protected void doSetInput(IEditorInput input) throws CoreException {
super.doSetInput(input);
if (fOutlinePage != null)
fOutlinePage.setInput(input);
/*
* @see org.phpeclipse.phpdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
*/
-// public Object getViewPartInput() {
-// return getEditorInput().getAdapter(IFile.class);
-// }
-
+ // public Object getViewPartInput() {
+ // return getEditorInput().getAdapter(IFile.class);
+ // }
+
/** The <code>PHPEditor</code> implementation of this
* <code>AbstractTextEditor</code> method adds any
* PHPEditor specific entries.
*/
private boolean isLineNumberRulerVisible() {
// IPreferenceStore store= getPreferenceStore();
- return phpPrefStore.getBoolean(IPreferenceConstants.LINE_NUMBER_RULER);
+ return getPreferenceStore().getBoolean(
+ IPreferenceConstants.LINE_NUMBER_RULER);
}
/**
* Hides the line number ruler column.
* @param rulerColumn the ruler column to be initialized
*/
protected void initializeLineNumberRulerColumn(LineNumberRulerColumn rulerColumn) {
- // JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools();
- PHPColorProvider manager = PHPEditorEnvironment.getPHPColorProvider();
+ JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
+ // PHPColorProvider manager = PHPEditorEnvironment.getPHPColorProvider();
+ JavaColorManager manager = textTools.getColorManager();
- if (phpPrefStore != null) {
+ IPreferenceStore store = getPreferenceStore();
+ if (store != null) {
RGB rgb = null;
// foreground color
- if (phpPrefStore.contains(IPreferenceConstants.LINE_NUMBER_COLOR)) {
- if (phpPrefStore.isDefault(IPreferenceConstants.LINE_NUMBER_COLOR))
+ if (store.contains(IPreferenceConstants.LINE_NUMBER_COLOR)) {
+ if (store.isDefault(IPreferenceConstants.LINE_NUMBER_COLOR))
rgb =
PreferenceConverter.getDefaultColor(
- phpPrefStore,
+ store,
IPreferenceConstants.LINE_NUMBER_COLOR);
else
rgb =
PreferenceConverter.getColor(
- phpPrefStore,
+ store,
IPreferenceConstants.LINE_NUMBER_COLOR);
}
rulerColumn.setForeground(manager.getColor(rgb));
rgb = null;
// background color
- if (!phpPrefStore
+ if (!store
.getBoolean(
IPreferenceConstants.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
- if (phpPrefStore
- .contains(IPreferenceConstants.PREFERENCE_COLOR_BACKGROUND)) {
- if (phpPrefStore
+ if (store.contains(IPreferenceConstants.PREFERENCE_COLOR_BACKGROUND)) {
+ if (store
.isDefault(IPreferenceConstants.PREFERENCE_COLOR_BACKGROUND))
rgb =
PreferenceConverter.getDefaultColor(
- phpPrefStore,
+ store,
IPreferenceConstants.PREFERENCE_COLOR_BACKGROUND);
else
rgb =
PreferenceConverter.getColor(
- phpPrefStore,
+ store,
IPreferenceConstants.PREFERENCE_COLOR_BACKGROUND);
}
rulerColumn.setBackground(manager.getColor(rgb));
* Method declared on TextEditor
*/
protected void initializeEditor() {
+ IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
PHPEditorEnvironment.connect(this);
- setSourceViewerConfiguration(new PHPSourceViewerConfiguration(this));
- setRangeIndicator(new DefaultRangeIndicator());
setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
// setDocumentProvider(PHPeclipsePlugin.getCompilationUnitDocumentProvider());
- phpPrefStore = PHPeclipsePlugin.getDefault().getPreferenceStore();
- phpPrefStore.addPropertyChangeListener(new IPropertyChangeListener() {
+ store.addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
PHPCodeScanner scanner = PHPEditorEnvironment.getPHPCodeScanner();
if (scanner != null) {
}
});
}
-
+
private static IRegion getSignedSelection(ITextViewer viewer) {
StyledText text = viewer.getTextWidget();
if (statusLine != null)
statusLine.setMessage(true, msg, null);
}
+
+ /**
+ * Returns a segmentation of the line of the given document appropriate for bidi rendering.
+ * The default implementation returns only the string literals of a php code line as segments.
+ *
+ * @param document the document
+ * @param lineOffset the offset of the line
+ * @return the line's bidi segmentation
+ * @throws BadLocationException in case lineOffset is not valid in document
+ */
+ public static int[] getBidiLineSegments(IDocument document, int lineOffset) throws BadLocationException {
+
+ IRegion line= document.getLineInformationOfOffset(lineOffset);
+ ITypedRegion[] linePartitioning= document.computePartitioning(lineOffset, line.getLength());
+
+ List segmentation= new ArrayList();
+ for (int i= 0; i < linePartitioning.length; i++) {
+ if (IPHPPartitionScannerConstants.PHP_STRING.equals(linePartitioning[i].getType()))
+ segmentation.add(linePartitioning[i]);
+ }
+
+
+ if (segmentation.size() == 0)
+ return null;
+
+ int size= segmentation.size();
+ int[] segments= new int[size * 2 + 1];
+
+ int j= 0;
+ for (int i= 0; i < size; i++) {
+ ITypedRegion segment= (ITypedRegion) segmentation.get(i);
+
+ if (i == 0)
+ segments[j++]= 0;
+
+ int offset= segment.getOffset() - lineOffset;
+ if (offset > segments[j - 1])
+ segments[j++]= offset;
+
+ if (offset + segment.getLength() >= line.getLength())
+ break;
+
+ segments[j++]= offset + segment.getLength();
+ }
+
+ if (j < segments.length) {
+ int[] result= new int[j];
+ System.arraycopy(segments, 0, result, 0, j);
+ segments= result;
+ }
+
+ return segments;
+ }
+ /**
+ * Returns a segmentation of the given line appropriate for bidi rendering. The default
+ * implementation returns only the string literals of a php code line as segments.
+ *
+ * @param lineOffset the offset of the line
+ * @param line the content of the line
+ * @return the line's bidi segmentation
+ */
+ protected int[] getBidiLineSegments(int lineOffset, String line) {
+ IDocumentProvider provider = getDocumentProvider();
+ if (provider != null && line != null && line.length() > 0) {
+ IDocument document = provider.getDocument(getEditorInput());
+ if (document != null)
+ try {
+ return getBidiLineSegments(document, lineOffset);
+ } catch (BadLocationException x) {
+ // ignore
+ }
+ }
+ return null;
+ }
+
+ /*
+ * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
+ */
+ protected final ISourceViewer createSourceViewer(
+ Composite parent,
+ IVerticalRuler ruler,
+ int styles) {
+ ISourceViewer viewer = createJavaSourceViewer(parent, ruler, styles);
+ StyledText text = viewer.getTextWidget();
+ text.addBidiSegmentListener(new BidiSegmentListener() {
+ public void lineGetSegments(BidiSegmentEvent event) {
+ event.segments = getBidiLineSegments(event.lineOffset, event.lineText);
+ }
+ });
+ // JavaUIHelp.setHelp(this, text, IJavaHelpContextIds.JAVA_EDITOR);
+ return viewer;
+ }
+
+ /*
+ * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
+ */
+ protected ISourceViewer createJavaSourceViewer(
+ Composite parent,
+ IVerticalRuler ruler,
+ int styles) {
+ return super.createSourceViewer(parent, ruler, styles);
+ }
}
Klaus Hartlage - www.eclipseproject.de
**********************************************************************/
+import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCodeScanner;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner;
import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
/** The PHPEditorEnvironment maintains singletons used by the php editor
*/
public class PHPEditorEnvironment {
-
- private static PHPColorProvider fgColorProvider;
+ // PHPColorProvider
+ private static JavaColorManager fgColorProvider;
private static PHPCodeScanner fgPHPCodeScanner;
private static HTMLCodeScanner fgHTMLCodeScanner;
private static PHPDocCodeScanner fgDocScanner;
*/
public static void connect(Object client) {
if (++fgRefCount == 1) {
- fgColorProvider = new PHPColorProvider();
- fgPHPCodeScanner = new PHPCodeScanner(fgColorProvider);
- fgHTMLCodeScanner = new HTMLCodeScanner(fgColorProvider);
- fgDocScanner = new PHPDocCodeScanner(fgColorProvider);
+ fgColorProvider = new JavaColorManager(); // new PHPColorProvider();
+ fgPHPCodeScanner = new PHPCodeScanner(fgColorProvider, PHPeclipsePlugin.getDefault().getPreferenceStore() );
+ fgHTMLCodeScanner = new HTMLCodeScanner(fgColorProvider, PHPeclipsePlugin.getDefault().getPreferenceStore());
+ fgDocScanner = new PHPDocCodeScanner(fgColorProvider, PHPeclipsePlugin.getDefault().getPreferenceStore() );
}
}
/**
* Returns the singleton color provider.
*/
- public static PHPColorProvider getPHPColorProvider() {
+ public static JavaColorManager getPHPColorProvider() {
return fgColorProvider;
}
import java.util.Vector;
+import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
+import net.sourceforge.phpdt.ui.text.JavaTextTools;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
*/
public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
- public static final String HTML_DEFAULT = IPHPPartitionScannerConstants.HTML; //IDocument.DEFAULT_CONTENT_TYPE;
-
+ public static final String HTML_DEFAULT = IPHPPartitionScannerConstants.HTML;
+ //IDocument.DEFAULT_CONTENT_TYPE;
+
+ private JavaTextTools fJavaTextTools;
private PHPEditor fEditor;
-
+
private ContentFormatter fFormatter;
private HTMLFormattingStrategy fFormattingStrategy;
/**
/**
* Default constructor.
*/
- public PHPSourceViewerConfiguration(PHPEditor editor) {
+ public PHPSourceViewerConfiguration(JavaTextTools textTools, PHPEditor editor) {
+ fJavaTextTools = textTools;
fEditor = editor;
}
* @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
*/
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
-// if (fFormatter == null) {
-// fFormatter = new ContentFormatter();
-// fFormattingStrategy = new HTMLFormattingStrategy(this, sourceViewer);
-// fFormatter.setFormattingStrategy(fFormattingStrategy, HTML_DEFAULT);
-// fFormatter.enablePartitionAwareFormatting(false);
-// fFormatter.setPartitionManagingPositionCategories(getConfiguredContentTypes(null));
-// }
-// return fFormatter;
-
+ // if (fFormatter == null) {
+ // fFormatter = new ContentFormatter();
+ // fFormattingStrategy = new HTMLFormattingStrategy(this, sourceViewer);
+ // fFormatter.setFormattingStrategy(fFormattingStrategy, HTML_DEFAULT);
+ // fFormatter.enablePartitionAwareFormatting(false);
+ // fFormatter.setPartitionManagingPositionCategories(getConfiguredContentTypes(null));
+ // }
+ // return fFormatter;
+
if (fFormatter == null) {
- //ContentFormatter
- fFormatter= new ContentFormatter();
- IFormattingStrategy strategy= new JavaFormattingStrategy(sourceViewer);
-
- fFormatter.setFormattingStrategy(strategy, IDocument.DEFAULT_CONTENT_TYPE);
- fFormatter.enablePartitionAwareFormatting(false);
- fFormatter.setPartitionManagingPositionCategories(getPartitionManagingPositionCategories());
+ //ContentFormatter
+ fFormatter = new ContentFormatter();
+ IFormattingStrategy strategy = new JavaFormattingStrategy(sourceViewer);
+
+ fFormatter.setFormattingStrategy(
+ strategy,
+ IDocument.DEFAULT_CONTENT_TYPE);
+ fFormatter.enablePartitionAwareFormatting(false);
+ fFormatter.setPartitionManagingPositionCategories(
+ getPartitionManagingPositionCategories());
}
return fFormatter;
}
-
+
/**
* Returns the names of the document position categories used by the document
* partitioners created by this object to manage their partition information.
public String[] getPartitionManagingPositionCategories() {
return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
}
-// /**
-// * Returns the names of the document position categories used by the document
-// * partitioners created by this object to manage their partition information.
-// * If the partitioners don't use document position categories, the returned
-// * result is <code>null</code>.
-// *
-// * @return the partition managing position categories or <code>null</code>
-// * if there is none
-// */
-// private String[] getPartitionManagingPositionCategories() {
-// return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
-// }
-
+ // /**
+ // * Returns the names of the document position categories used by the document
+ // * partitioners created by this object to manage their partition information.
+ // * If the partitioners don't use document position categories, the returned
+ // * result is <code>null</code>.
+ // *
+ // * @return the partition managing position categories or <code>null</code>
+ // * if there is none
+ // */
+ // private String[] getPartitionManagingPositionCategories() {
+ // return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
+ // }
+
public PHPEditor getEditor() {
return fEditor;
}
-
+
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
- public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
- return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? new PHPAutoIndentStrategy() : new DefaultAutoIndentStrategy());
+ public IAutoIndentStrategy getAutoIndentStrategy(
+ ISourceViewer sourceViewer,
+ String contentType) {
+ return (
+ IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)
+ ? new PHPAutoIndentStrategy()
+ : new DefaultAutoIndentStrategy());
}
-/* (non-Javadoc)
- * Method declared on SourceViewerConfiguration
- */
-public String[] getConfiguredContentTypes(ISourceViewer sourceViewer)
-{
+ /* (non-Javadoc)
+ * Method declared on SourceViewerConfiguration
+ */
+ public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return new String[] {
- IDocument.DEFAULT_CONTENT_TYPE,
- IPHPPartitionScannerConstants.PHP,
- IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT,
- IPHPPartitionScannerConstants.HTML,
- IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT,
- IPHPPartitionScannerConstants.CSS,
- IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT,
- IPHPPartitionScannerConstants.JAVASCRIPT,
- IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT
- };
+ IDocument.DEFAULT_CONTENT_TYPE,
+ IPHPPartitionScannerConstants.PHP,
+ IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT,
+ IPHPPartitionScannerConstants.HTML,
+ IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT,
+ IPHPPartitionScannerConstants.CSS,
+ IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT,
+ IPHPPartitionScannerConstants.JAVASCRIPT,
+ IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT };
}
/* (non-Javadoc)
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant = new ContentAssistant();
- assistant.setContentAssistProcessor(new HTMLCompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
- assistant.setContentAssistProcessor(new PHPCompletionProcessor(), IPHPPartitionScannerConstants.PHP);
- assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(), IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
-
+ assistant.setContentAssistProcessor(
+ new HTMLCompletionProcessor(),
+ IDocument.DEFAULT_CONTENT_TYPE);
+ assistant.setContentAssistProcessor(
+ new PHPCompletionProcessor(),
+ IPHPPartitionScannerConstants.PHP);
+ assistant.setContentAssistProcessor(
+ new PHPDocCompletionProcessor(),
+ IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+
assistant.enableAutoActivation(true);
assistant.setAutoActivationDelay(500);
assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
- assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
- assistant.setContextInformationPopupBackground(PHPEditorEnvironment.getPHPColorProvider().getColor(new RGB(150, 150, 0)));
+ assistant.setContextInformationPopupOrientation(
+ ContentAssistant.CONTEXT_INFO_ABOVE);
+ assistant.setContextInformationPopupBackground(
+ PHPEditorEnvironment.getPHPColorProvider().getColor(
+ new RGB(150, 150, 0)));
return assistant;
}
/* (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) {
+ public String[] getDefaultPrefixes(
+ ISourceViewer sourceViewer,
+ String contentType) {
return new String[] { "//", "" }; //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
- public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
+ public ITextDoubleClickStrategy getDoubleClickStrategy(
+ ISourceViewer sourceViewer,
+ String contentType) {
return new PHPDoubleClickSelector();
}
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
-// public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
-// return new String[] { "\t", " " }; //$NON-NLS-1$ //$NON-NLS-2$
-// }
+ // 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) {
+ public String[] getIndentPrefixes(
+ ISourceViewer sourceViewer,
+ String contentType) {
- Vector vector= new Vector();
+ 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();
+ 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(' ');
-
+ 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(' ');
-
+ prefix.append('\t');
+ } else {
+ for (int j = 0; j < i; j++)
+ prefix.append(' ');
+
if (i != tabWidth)
- prefix.append('\t');
+ prefix.append('\t');
}
-
+
vector.add(prefix.toString());
}
vector.add(""); //$NON-NLS-1$
-
+
return (String[]) vector.toArray(new String[vector.size()]);
}
/* (non-Javadoc)
*/
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
- PHPColorProvider provider = PHPEditorEnvironment.getPHPColorProvider();
+ // PHPColorProvider provider = PHPEditorEnvironment.getPHPColorProvider();
+ JavaColorManager provider = PHPEditorEnvironment.getPHPColorProvider();
PresentationReconciler reconciler = new PresentationReconciler();
-
- DefaultDamagerRepairer dr= new DefaultDamagerRepairer(PHPEditorEnvironment.getHTMLCodeScanner());
+
+ DefaultDamagerRepairer dr =
+ new DefaultDamagerRepairer(PHPEditorEnvironment.getHTMLCodeScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
-
-// dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(provider.HTML_DEFAULT))));
-// reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
-// reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
- dr = new DefaultDamagerRepairer(PHPEditorEnvironment.getPHPCodeScanner());
+ // dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(provider.HTML_DEFAULT))));
+ // reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ // reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+ dr = new DefaultDamagerRepairer(PHPEditorEnvironment.getPHPCodeScanner());
reconciler.setDamager(dr, IPHPPartitionScannerConstants.PHP);
reconciler.setRepairer(dr, IPHPPartitionScannerConstants.PHP);
- dr = new DefaultDamagerRepairer(PHPEditorEnvironment.getPHPDocCodeScanner());
- reconciler.setDamager(dr, IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
- reconciler.setRepairer(dr, IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
-
+ dr =
+ new DefaultDamagerRepairer(PHPEditorEnvironment.getPHPDocCodeScanner());
+ reconciler.setDamager(
+ dr,
+ IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+ reconciler.setRepairer(
+ dr,
+ IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
+
dr = new DefaultDamagerRepairer(PHPEditorEnvironment.getHTMLCodeScanner());
reconciler.setDamager(dr, IPHPPartitionScannerConstants.HTML);
reconciler.setRepairer(dr, IPHPPartitionScannerConstants.HTML);
- dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(PHPColorProvider.MULTI_LINE_COMMENT))));
- reconciler.setDamager(dr, IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
- reconciler.setRepairer(dr, IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
+ dr =
+ new DefaultDamagerRepairer(
+ new SingleTokenScanner(
+ new TextAttribute(
+ provider.getColor(PHPColorProvider.MULTI_LINE_COMMENT))));
+ reconciler.setDamager(
+ dr,
+ IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
+ reconciler.setRepairer(
+ dr,
+ IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
return reconciler;
}
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
- public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
+ public ITextHover getTextHover(
+ ISourceViewer sourceViewer,
+ String contentType) {
return new PHPTextHover();
}
}
--- /dev/null
+package net.sourceforge.phpeclipse.phpeditor;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.editors.text.TextEditor;
+
+import test.PHPParserManager;
+import test.PHPParserSuperclass;
+
+
+public class PHPSyntaxParserThread extends Thread {
+ private static String[] EXTENSIONS = { ".php", ".php3", ".php4", ".inc", ".phtml" };
+
+ private String text = "";
+ private String previousText = "";
+
+ private boolean stopValidation = false;
+ private boolean validationTerminated = false;
+ private boolean isActive = false;
+
+ private TextEditor fTextEditor;
+ private ISourceViewer fSourceViewer;
+
+ private int previousHashCode = 0;
+ // Defaults
+ private int validationInterval = 2000; //millis
+ private int waitForTermination = 400; // millis
+ private int maxErrorsShown = 10;
+
+ public PHPSyntaxParserThread(
+ TextEditor textEditor,
+ ISourceViewer viewer) {
+ super();
+ fTextEditor = textEditor;
+ fSourceViewer = viewer;
+ }
+
+ public void setText(String text) {
+ if (!isActive)
+ this.text = text;
+ }
+
+ public void setText(String text, boolean forceUpdate) {
+ if (!isActive) {
+ this.text = text;
+ }
+
+ if (forceUpdate) {
+ this.previousText = "";
+ this.previousHashCode = 0;
+ }
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setInterval(int millis) {
+ this.validationInterval = millis;
+ }
+
+ public int getInterval() {
+ return validationInterval;
+ }
+
+ public void setErrorsShown(int number) {
+ this.maxErrorsShown = number;
+ }
+
+ public int getErrorsShown() {
+ return maxErrorsShown;
+ }
+
+ public void dispose() {
+ this.stopValidation = true;
+
+ if (validationTerminated == false) {
+
+ try {
+ Thread.sleep(waitForTermination);
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ public void run() {
+ while (stopValidation == false) {
+ try {
+
+ this.isActive = true;
+ boolean ret = this.validateSyntax();
+
+ this.previousText = this.text;
+ this.isActive = false;
+
+ Thread.sleep(validationInterval);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ this.validationTerminated = true;
+ }
+
+ public boolean validateSyntax() {
+
+ boolean phpFlag = false;
+ try {
+ IFile fileToParse = getPHPFile(fTextEditor.getEditorInput());
+ if (fileToParse == null) {
+ // should never happen
+ System.err.println("Error : no file in the editor");
+ // should throw an exception
+ return false;
+ }
+ String name = fileToParse.getName();
+ for (int i = 0; i<EXTENSIONS.length; i++) {
+ if (name.endsWith(EXTENSIONS[i])) {
+ phpFlag = true; // php file extension
+ break;
+ }
+ }
+ if (phpFlag) {
+ IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+ if (store.getString(PHPeclipsePlugin.PHP_PARSER_DEFAULT).equals(PHPeclipsePlugin.PHP_INTERNAL_PARSER)) {
+ // first delete all the previous markers
+ fileToParse.deleteMarkers(IMarker.PROBLEM, false, 0);
+
+ try {
+ InputStream iStream = fileToParse.getContents();
+ // int c = iStream.read();
+ parse(fileToParse, iStream);
+ iStream.close();
+ } catch (IOException e) {
+ }
+ } else {
+ PHPParserSuperclass.phpExternalParse(fileToParse);
+ }
+ }
+ } catch (CoreException e) {
+ }
+
+
+//
+// Process proc = null;
+//
+// if (this.previousText.equals(this.text)) {
+// return true;
+// }
+//
+// try {
+// IEditorInput input = fTextEditor.getEditorInput();
+// IResource resource =
+// (IResource) ((IAdaptable) input).getAdapter(IResource.class);
+//
+// // Write output file
+// FileOutputStream fos = new FileOutputStream(new File(tmpFileName));
+// fos.write(text.getBytes());
+// fos.flush();
+// fos.close();
+//
+// proc =
+// Runtime.getRuntime().exec(
+// PerlEditorPlugin
+// .getDefault()
+// .getExecutablePreference()
+// .trim()
+// + " "
+// + "-I"
+// + ((IFileEditorInput) this.fTextEditor.getEditorInput())
+// .getFile()
+// .getLocation()
+// .makeAbsolute()
+// .removeLastSegments(1)
+// + " "
+// + PERL_CMD_EXT
+// + " "
+// + tmpFileName);
+//
+// InputStream in = proc.getErrorStream();
+//
+// StringBuffer content = new StringBuffer();
+//
+// byte[] buffer = new byte[1];
+//
+// int read;
+// while ((read = in.read(buffer)) > 0) {
+// content.append(new String(buffer));
+// }
+// in.close();
+//
+// //jjjjjjj
+// // DEBUG start
+// System.out.println("-----------------------------------------");
+// System.out.println(" OUTPUT");
+// System.out.println("-----------------------------------------");
+// System.out.println(content);
+// System.out.println("-----------------------------------------");
+// // DEBUG END
+//
+// String line = null;
+// List lines = new ArrayList();
+// int index;
+//
+// // Compare checksums
+// int hashCode = content.toString().hashCode();
+//
+// if (previousHashCode == hashCode) {
+//
+// return true;
+// }
+//
+// previousHashCode = hashCode;
+//
+// StringTokenizer st = new StringTokenizer(content.toString(), "\n");
+//
+// int lineCount = 0;
+//
+// while (st.hasMoreTokens()) {
+// line = st.nextToken();
+// if (line.indexOf("\r") != -1) {
+// line = line.substring(0, line.indexOf("\r"));
+// }
+//
+// lines.add(line);
+// if (++lineCount >= maxErrorsShown) {
+// break;
+// }
+//
+// }
+//
+// //Delete markers
+// resource.deleteMarkers(IMarker.PROBLEM, true, 1);
+//
+// // Markers have to be added in reverse order
+// // Otherwise lower line number will appear at the end of the list
+// for (int i = lines.size() - 1; i >= 0; i--) {
+// line = (String) lines.get(i);
+//
+// // If error message is not from temporary file, skip
+// if (line.indexOf(tmpFileName) == -1) {
+// continue;
+// }
+//
+// // Delete filename from error message
+// StringBuffer lineSb = new StringBuffer(line);
+// replace(lineSb, tmpFileName + " ", "", true);
+// line = lineSb.toString();
+//
+// if ((index = line.indexOf(PERL_ERROR_INDICATOR)) != -1) {
+//
+// // truncatedLIne is the stripped error-line up to the next " " after the line number if present
+// // To avoid cluttering with other "." and "," which might occur in the error message
+// String truncatedLine = line;
+// if (truncatedLine
+// .indexOf(" ", index + PERL_ERROR_INDICATOR.length() + 1)
+// != -1) {
+// truncatedLine =
+// truncatedLine.substring(
+// 0,
+// truncatedLine.indexOf(
+// " ",
+// index + PERL_ERROR_INDICATOR.length() + 1));
+// }
+//
+// int endIndex;
+// if ((endIndex = truncatedLine.indexOf(".", index)) == -1) {
+// endIndex = truncatedLine.indexOf(",", index);
+// }
+//
+// if (endIndex == -1) {
+// continue;
+// }
+//
+// String lineNr =
+// truncatedLine.substring(
+// index + PERL_ERROR_INDICATOR.length(),
+// endIndex);
+//
+// // If there is an addition to the error message
+// if (i + 1 < lines.size()) {
+// if (((String) lines.get(i + 1)).startsWith(" ")) {
+// line += " " + (String) lines.get(i + 1);
+// }
+// }
+//
+// IMarker marker = resource.createMarker(IMarker.PROBLEM);
+//
+// // Check if it's a warning
+// boolean isWarning = false;
+//
+// for (int x = 0; x < WARNING_STRINGS.length; x++) {
+// if (truncatedLine.indexOf(WARNING_STRINGS[x]) != -1) {
+// isWarning = true;
+// }
+// }
+//
+// if (isWarning) {
+// marker.setAttribute(
+// IMarker.SEVERITY,
+// IMarker.SEVERITY_WARNING);
+// } else {
+// marker.setAttribute(
+// IMarker.SEVERITY,
+// IMarker.SEVERITY_ERROR);
+// }
+//
+// marker.setAttribute(IMarker.MESSAGE, line);
+//
+// marker.setAttribute(
+// IMarker.LINE_NUMBER,
+// Integer.parseInt(lineNr));
+//
+// Position pos =
+// new Position(
+// fSourceViewer.getDocument().getLineOffset(
+// Integer.parseInt(lineNr) - 1));
+// fSourceViewer.getAnnotationModel().addAnnotation(
+// new MarkerAnnotation(marker),
+// pos);
+//
+// }
+// }
+//
+// } catch (Exception e) {
+// e.printStackTrace();
+// if (proc != null) {
+// killProcess(proc);
+// }
+// return false;
+// } finally {
+// try {
+// // Delete tmp file
+// new File(tmpFileName).delete();
+// } catch (Exception ex) {
+// ex.printStackTrace();
+// }
+// }
+
+ return true;
+
+ }
+
+ /**
+ * Finds the file that's currently opened in the PHP Text Editor
+ */
+ protected IFile getPHPFile(IEditorInput editorInput) {
+ if (editorInput instanceof IFileEditorInput)
+ return ((IFileEditorInput) editorInput).getFile();
+
+ return null;
+ }
+
+ protected void parse(IFile fileToParse, InputStream iStream) {
+
+ StringBuffer buf = new StringBuffer();
+ int c0;
+ try {
+ while ((c0 = iStream.read()) != (-1)) {
+ buf.append((char) c0);
+ }
+ } catch (IOException e) {
+ return;
+ }
+ String input = buf.toString();
+
+ PHPParserSuperclass parser = PHPParserManager.getParser(fileToParse);
+ try {
+ parser.parse(input);
+ } catch (CoreException e) {
+ }
+ }
+
+ private void killProcess(Process proc) {
+ while (true) {
+ try {
+ proc.destroy();
+ proc.exitValue();
+ } catch (Exception ex) {
+
+ continue;
+ }
+ break;
+ }
+ }
+
+ // Replaces all instances of the String o with the String n in the
+ // StringBuffer orig if all is true, or only the first instance if all is false.
+ private static void replace(
+ StringBuffer orig,
+ String o,
+ String n,
+ boolean all) {
+ if (orig == null || o == null || o.length() == 0 || n == null)
+ throw new IllegalArgumentException("Null or zero-length String");
+
+ int i = 0;
+
+ while (i + o.length() <= orig.length()) {
+ if (orig.substring(i, i + o.length()).equals(o)) {
+ orig.replace(i, i + o.length(), n);
+ if (!all)
+ break;
+ else
+ i += n.length();
+ } else
+ i++;
+ }
+ }
+}
--- /dev/null
+package net.sourceforge.phpeclipse.phpeditor;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
+import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
+import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
+import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI.ExitFlags;
+import net.sourceforge.phpdt.ui.PreferenceConstants;
+import net.sourceforge.phpeclipse.PHPCore;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.AbstractHoverInformationControlManager;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ILineTracker;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewerExtension;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.IWidgetTokenKeeper;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.custom.VerifyKeyListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM 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 implementation
+ Klaus Hartlage - www.eclipseproject.de
+**********************************************************************/
+/**
+ * PHP specific text editor.
+ */
+public class PHPUnitEditor extends PHPEditor {
+ interface ITextConverter {
+ void customizeDocumentCommand(IDocument document, DocumentCommand command);
+ };
+
+ class AdaptedRulerLayout extends Layout {
+
+ protected int fGap;
+ protected AdaptedSourceViewer fAdaptedSourceViewer;
+
+ protected AdaptedRulerLayout(int gap, AdaptedSourceViewer asv) {
+ fGap = gap;
+ fAdaptedSourceViewer = asv;
+ }
+
+ protected Point computeSize(
+ Composite composite,
+ int wHint,
+ int hHint,
+ boolean flushCache) {
+ Control[] children = composite.getChildren();
+ Point s =
+ children[children.length
+ - 1].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
+ if (fAdaptedSourceViewer.isVerticalRulerVisible())
+ s.x += fAdaptedSourceViewer.getVerticalRuler().getWidth() + fGap;
+ return s;
+ }
+
+ protected void layout(Composite composite, boolean flushCache) {
+ Rectangle clArea = composite.getClientArea();
+ if (fAdaptedSourceViewer.isVerticalRulerVisible()) {
+
+ StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
+ Rectangle trim = textWidget.computeTrim(0, 0, 0, 0);
+ int scrollbarHeight = trim.height;
+
+ IVerticalRuler vr = fAdaptedSourceViewer.getVerticalRuler();
+ int vrWidth = vr.getWidth();
+
+ int orWidth = 0;
+ if (fAdaptedSourceViewer.isOverviewRulerVisible()) {
+ OverviewRuler or = fAdaptedSourceViewer.getOverviewRuler();
+ orWidth = or.getWidth();
+ or.getControl().setBounds(
+ clArea.width - orWidth,
+ scrollbarHeight,
+ orWidth,
+ clArea.height - 3 * scrollbarHeight);
+ }
+
+ textWidget.setBounds(
+ vrWidth + fGap,
+ 0,
+ clArea.width - vrWidth - orWidth - 2 * fGap,
+ clArea.height);
+ vr.getControl().setBounds(
+ 0,
+ 0,
+ vrWidth,
+ clArea.height - scrollbarHeight);
+
+ } else {
+ StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
+ textWidget.setBounds(0, 0, clArea.width, clArea.height);
+ }
+ }
+ };
+
+ class AdaptedSourceViewer
+ extends SourceViewer { // extends JavaCorrectionSourceViewer {
+
+ private List fTextConverters;
+
+ private OverviewRuler fOverviewRuler;
+ private boolean fIsOverviewRulerVisible;
+ /** The viewer's overview ruler hovering controller */
+ private AbstractHoverInformationControlManager fOverviewRulerHoveringController;
+
+ private boolean fIgnoreTextConverters = false;
+
+ private IVerticalRuler fCachedVerticalRuler;
+ private boolean fCachedIsVerticalRulerVisible;
+
+ public AdaptedSourceViewer(
+ Composite parent,
+ IVerticalRuler ruler,
+ int styles) {
+ super(parent, ruler, styles); //, CompilationUnitEditor.this);
+
+ fCachedVerticalRuler = ruler;
+ fCachedIsVerticalRulerVisible = (ruler != null);
+ fOverviewRuler = new OverviewRuler(VERTICAL_RULER_WIDTH);
+
+ delayedCreateControl(parent, styles);
+ }
+
+ /*
+ * @see ISourceViewer#showAnnotations(boolean)
+ */
+ public void showAnnotations(boolean show) {
+ fCachedIsVerticalRulerVisible = (show && fCachedVerticalRuler != null);
+ // super.showAnnotations(show);
+ }
+
+ public IContentAssistant getContentAssistant() {
+ return fContentAssistant;
+ }
+
+ /*
+ * @see ITextOperationTarget#doOperation(int)
+ */
+ public void doOperation(int operation) {
+
+ if (getTextWidget() == null)
+ return;
+
+ switch (operation) {
+ case CONTENTASSIST_PROPOSALS :
+ String msg = fContentAssistant.showPossibleCompletions();
+ setStatusLineErrorMessage(msg);
+ return;
+ case UNDO :
+ fIgnoreTextConverters = true;
+ break;
+ case REDO :
+ fIgnoreTextConverters = true;
+ break;
+ }
+
+ super.doOperation(operation);
+ }
+
+ public void insertTextConverter(ITextConverter textConverter, int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addTextConverter(ITextConverter textConverter) {
+ if (fTextConverters == null) {
+ fTextConverters = new ArrayList(1);
+ fTextConverters.add(textConverter);
+ } else if (!fTextConverters.contains(textConverter))
+ fTextConverters.add(textConverter);
+ }
+
+ public void removeTextConverter(ITextConverter textConverter) {
+ if (fTextConverters != null) {
+ fTextConverters.remove(textConverter);
+ if (fTextConverters.size() == 0)
+ fTextConverters = null;
+ }
+ }
+
+ /*
+ * @see TextViewer#customizeDocumentCommand(DocumentCommand)
+ */
+ protected void customizeDocumentCommand(DocumentCommand command) {
+ super.customizeDocumentCommand(command);
+ if (!fIgnoreTextConverters && fTextConverters != null) {
+ for (Iterator e = fTextConverters.iterator(); e.hasNext();)
+ ((ITextConverter) e.next()).customizeDocumentCommand(
+ getDocument(),
+ command);
+ }
+ fIgnoreTextConverters = false;
+ }
+
+ public IVerticalRuler getVerticalRuler() {
+ return fCachedVerticalRuler;
+ }
+
+ public boolean isVerticalRulerVisible() {
+ return fCachedIsVerticalRulerVisible;
+ }
+
+ public OverviewRuler getOverviewRuler() {
+ return fOverviewRuler;
+ }
+
+ /*
+ * @see TextViewer#createControl(Composite, int)
+ */
+ protected void createControl(Composite parent, int styles) {
+ // do nothing here
+ }
+
+ protected void delayedCreateControl(Composite parent, int styles) {
+ //create the viewer
+ super.createControl(parent, styles);
+
+ Control control = getControl();
+ if (control instanceof Composite) {
+ Composite composite = (Composite) control;
+ composite.setLayout(new AdaptedRulerLayout(GAP_SIZE, this));
+ fOverviewRuler.createControl(composite, this);
+ }
+ }
+
+ private void ensureOverviewHoverManagerInstalled() {
+ if (fOverviewRulerHoveringController == null
+ && fAnnotationHover != null
+ && fHoverControlCreator != null) {
+ fOverviewRulerHoveringController =
+ new OverviewRulerHoverManager(
+ fOverviewRuler,
+ this,
+ fAnnotationHover,
+ fHoverControlCreator);
+ fOverviewRulerHoveringController.install(fOverviewRuler.getControl());
+ }
+ }
+
+ public void hideOverviewRuler() {
+ fIsOverviewRulerVisible = false;
+ Control control = getControl();
+ if (control instanceof Composite) {
+ Composite composite = (Composite) control;
+ composite.layout();
+ }
+ if (fOverviewRulerHoveringController != null) {
+ fOverviewRulerHoveringController.dispose();
+ fOverviewRulerHoveringController = null;
+ }
+ }
+
+ public void showOverviewRuler() {
+ fIsOverviewRulerVisible = true;
+ Control control = getControl();
+ if (control instanceof Composite) {
+ Composite composite = (Composite) control;
+ composite.layout();
+ }
+ ensureOverviewHoverManagerInstalled();
+ }
+
+ public boolean isOverviewRulerVisible() {
+ return fIsOverviewRulerVisible;
+ }
+
+ /*
+ * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
+ */
+ public void setDocument(
+ IDocument document,
+ IAnnotationModel annotationModel,
+ int visibleRegionOffset,
+ int visibleRegionLength) {
+ super.setDocument(
+ document,
+ annotationModel,
+ visibleRegionOffset,
+ visibleRegionLength);
+ fOverviewRuler.setModel(annotationModel);
+ }
+
+ // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
+ public void updateIndentationPrefixes() {
+ SourceViewerConfiguration configuration = getSourceViewerConfiguration();
+ String[] types = configuration.getConfiguredContentTypes(this);
+ for (int i = 0; i < types.length; i++) {
+ String[] prefixes = configuration.getIndentPrefixes(this, types[i]);
+ if (prefixes != null && prefixes.length > 0)
+ setIndentPrefixes(prefixes, types[i]);
+ }
+ }
+
+ /*
+ * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
+ */
+ public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
+ if (WorkbenchHelp.isContextHelpDisplayed())
+ return false;
+ return super.requestWidgetToken(requester);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
+ */
+ public void configure(SourceViewerConfiguration configuration) {
+ super.configure(configuration);
+ // prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this), IDocument.DEFAULT_CONTENT_TYPE);
+ }
+
+ protected void handleDispose() {
+ fOverviewRuler = null;
+
+ if (fOverviewRulerHoveringController != null) {
+ fOverviewRulerHoveringController.dispose();
+ fOverviewRulerHoveringController = null;
+ }
+
+ super.handleDispose();
+ }
+
+ };
+
+ static class TabConverter implements ITextConverter {
+
+ private int fTabRatio;
+ private ILineTracker fLineTracker;
+
+ public TabConverter() {
+ }
+
+ public void setNumberOfSpacesPerTab(int ratio) {
+ fTabRatio = ratio;
+ }
+
+ public void setLineTracker(ILineTracker lineTracker) {
+ fLineTracker = lineTracker;
+ }
+
+ private int insertTabString(StringBuffer buffer, int offsetInLine) {
+
+ if (fTabRatio == 0)
+ return 0;
+
+ int remainder = offsetInLine % fTabRatio;
+ remainder = fTabRatio - remainder;
+ for (int i = 0; i < remainder; i++)
+ buffer.append(' ');
+ return remainder;
+ }
+
+ public void customizeDocumentCommand(
+ IDocument document,
+ DocumentCommand command) {
+ String text = command.text;
+ if (text == null)
+ return;
+
+ int index = text.indexOf('\t');
+ if (index > -1) {
+
+ StringBuffer buffer = new StringBuffer();
+
+ fLineTracker.set(command.text);
+ int lines = fLineTracker.getNumberOfLines();
+
+ try {
+
+ for (int i = 0; i < lines; i++) {
+
+ int offset = fLineTracker.getLineOffset(i);
+ int endOffset = offset + fLineTracker.getLineLength(i);
+ String line = text.substring(offset, endOffset);
+
+ int position = 0;
+ if (i == 0) {
+ IRegion firstLine =
+ document.getLineInformationOfOffset(command.offset);
+ position = command.offset - firstLine.getOffset();
+ }
+
+ int length = line.length();
+ for (int j = 0; j < length; j++) {
+ char c = line.charAt(j);
+ if (c == '\t') {
+ position += insertTabString(buffer, position);
+ } else {
+ buffer.append(c);
+ ++position;
+ }
+ }
+
+ }
+
+ command.text = buffer.toString();
+
+ } catch (BadLocationException x) {
+ }
+ }
+ }
+ };
+
+ private static class ExitPolicy implements LinkedPositionUI.ExitPolicy {
+
+ final char fExitCharacter;
+
+ public ExitPolicy(char exitCharacter) {
+ fExitCharacter= exitCharacter;
+ }
+
+ /*
+ * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionManager, org.eclipse.swt.events.VerifyEvent, int, int)
+ */
+ public ExitFlags doExit(LinkedPositionManager manager, VerifyEvent event, int offset, int length) {
+
+ if (event.character == fExitCharacter) {
+ if (manager.anyPositionIncludes(offset, length))
+ return new ExitFlags(LinkedPositionUI.COMMIT| LinkedPositionUI.UPDATE_CARET, false);
+ else
+ return new ExitFlags(LinkedPositionUI.COMMIT, true);
+ }
+
+ switch (event.character) {
+ case '\b':
+ if (manager.getFirstPosition().length == 0)
+ return new ExitFlags(0, false);
+ else
+ return null;
+
+ case '\n':
+ case '\r':
+ return new ExitFlags(LinkedPositionUI.COMMIT, true);
+
+ default:
+ return null;
+ }
+ }
+
+ }
+ private class BracketInserter implements VerifyKeyListener, LinkedPositionUI.ExitListener {
+
+ private boolean fCloseBrackets= true;
+ private boolean fCloseStrings= true;
+
+ private int fOffset;
+ private int fLength;
+
+ public void setCloseBracketsEnabled(boolean enabled) {
+ fCloseBrackets= enabled;
+ }
+
+ public void setCloseStringsEnabled(boolean enabled) {
+ fCloseStrings= enabled;
+ }
+
+ private boolean hasIdentifierToTheRight(IDocument document, int offset) {
+ try {
+ int end= offset;
+ IRegion endLine= document.getLineInformationOfOffset(end);
+ int maxEnd= endLine.getOffset() + endLine.getLength();
+ while (end != maxEnd && Character.isWhitespace(document.getChar(end)))
+ ++end;
+
+ return end != maxEnd && Character.isJavaIdentifierPart(document.getChar(end));
+
+ } catch (BadLocationException e) {
+ // be conservative
+ return true;
+ }
+ }
+
+ private boolean hasIdentifierToTheLeft(IDocument document, int offset) {
+ try {
+ int start= offset;
+ IRegion startLine= document.getLineInformationOfOffset(start);
+ int minStart= startLine.getOffset();
+ while (start != minStart && Character.isWhitespace(document.getChar(start - 1)))
+ --start;
+
+ return start != minStart && Character.isJavaIdentifierPart(document.getChar(start - 1));
+
+ } catch (BadLocationException e) {
+ return true;
+ }
+ }
+
+ private boolean hasCharacterToTheRight(IDocument document, int offset, char character) {
+ try {
+ int end= offset;
+ IRegion endLine= document.getLineInformationOfOffset(end);
+ int maxEnd= endLine.getOffset() + endLine.getLength();
+ while (end != maxEnd && Character.isWhitespace(document.getChar(end)))
+ ++end;
+
+ return end != maxEnd && document.getChar(end) == character;
+
+
+ } catch (BadLocationException e) {
+ // be conservative
+ return true;
+ }
+ }
+
+ /*
+ * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
+ */
+ public void verifyKey(VerifyEvent event) {
+
+ if (!event.doit)
+ return;
+
+ final ISourceViewer sourceViewer= getSourceViewer();
+ IDocument document= sourceViewer.getDocument();
+
+ final Point selection= sourceViewer.getSelectedRange();
+ final int offset= selection.x;
+ final int length= selection.y;
+
+ switch (event.character) {
+ case '(':
+ if (hasCharacterToTheRight(document, offset + length, '('))
+ return;
+
+ // fall through
+
+ case '[':
+ if (!fCloseBrackets)
+ return;
+ if (hasIdentifierToTheRight(document, offset + length))
+ return;
+
+ // fall through
+
+ case '"':
+ if (event.character == '"') {
+ if (!fCloseStrings)
+ return;
+ if (hasIdentifierToTheLeft(document, offset) || hasIdentifierToTheRight(document, offset + length))
+ return;
+ }
+
+ try {
+ ITypedRegion partition= document.getPartition(offset);
+ if (! IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) && partition.getOffset() != offset)
+ return;
+
+ final char character= event.character;
+ final char closingCharacter= getPeerCharacter(character);
+ final StringBuffer buffer= new StringBuffer();
+ buffer.append(character);
+ buffer.append(closingCharacter);
+
+ document.replace(offset, length, buffer.toString());
+
+ LinkedPositionManager manager= new LinkedPositionManager(document);
+ manager.addPosition(offset + 1, 0);
+
+ fOffset= offset;
+ fLength= 2;
+
+ LinkedPositionUI editor= new LinkedPositionUI(sourceViewer, manager);
+ editor.setCancelListener(this);
+ editor.setExitPolicy(new ExitPolicy(closingCharacter));
+ editor.setFinalCaretOffset(offset + 2);
+ editor.enter();
+
+ IRegion newSelection= editor.getSelectedRegion();
+ sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength());
+
+ event.doit= false;
+
+ } catch (BadLocationException e) {
+ }
+ break;
+ }
+ }
+
+ /*
+ * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitListener#exit(boolean)
+ */
+ public void exit(boolean accept) {
+ if (accept)
+ return;
+
+ // remove brackets
+ try {
+ final ISourceViewer sourceViewer= getSourceViewer();
+ IDocument document= sourceViewer.getDocument();
+ document.replace(fOffset, fLength, null);
+ } catch (BadLocationException e) {
+ }
+ }
+
+ }
+ /** The editor's paint manager */
+ private PaintManager fPaintManager;
+ /** The editor's bracket painter */
+ private BracketPainter fBracketPainter;
+ /** The editor's bracket matcher */
+ private PHPPairMatcher fBracketMatcher;
+ /** The editor's line painter */
+ private LinePainter fLinePainter;
+ /** The editor's print margin ruler painter */
+ private PrintMarginPainter fPrintMarginPainter;
+ /** The editor's problem painter */
+ private ProblemPainter fProblemPainter;
+ /** The editor's tab converter */
+ private TabConverter fTabConverter;
+ /** History for structure select action */
+ //private SelectionHistory fSelectionHistory;
+
+ /** The preference property change listener for php core. */
+ private IPropertyChangeListener fPropertyChangeListener= new PropertyChangeListener();
+ /** The remembered selection */
+ private ITextSelection fRememberedSelection;
+ /** The remembered php element offset */
+ private int fRememberedElementOffset;
+ /** The bracket inserter. */
+ private BracketInserter fBracketInserter= new BracketInserter();
+
+ private class PropertyChangeListener implements IPropertyChangeListener {
+ /*
+ * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ public void propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
+ handlePreferencePropertyChanged(event);
+ }
+ }
+ /* Preference key for code formatter tab size */
+ private final static String CODE_FORMATTER_TAB_SIZE =
+ PHPCore.FORMATTER_TAB_SIZE;
+ /** Preference key for matching brackets */
+ private final static String MATCHING_BRACKETS =
+ PreferenceConstants.EDITOR_MATCHING_BRACKETS;
+ /** Preference key for matching brackets color */
+ private final static String MATCHING_BRACKETS_COLOR =
+ PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
+ /** Preference key for highlighting current line */
+ private final static String CURRENT_LINE =
+ PreferenceConstants.EDITOR_CURRENT_LINE;
+ /** Preference key for highlight color of current line */
+ private final static String CURRENT_LINE_COLOR =
+ PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
+ /** Preference key for showing print marging ruler */
+ private final static String PRINT_MARGIN =
+ PreferenceConstants.EDITOR_PRINT_MARGIN;
+ /** Preference key for print margin ruler color */
+ private final static String PRINT_MARGIN_COLOR =
+ PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
+ /** Preference key for print margin ruler column */
+ private final static String PRINT_MARGIN_COLUMN =
+ PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
+ /** Preference key for inserting spaces rather than tabs */
+ private final static String SPACES_FOR_TABS =
+ PreferenceConstants.EDITOR_SPACES_FOR_TABS;
+ /** Preference key for error indication */
+ private final static String ERROR_INDICATION =
+ PreferenceConstants.EDITOR_PROBLEM_INDICATION;
+ /** Preference key for error color */
+ private final static String ERROR_INDICATION_COLOR =
+ PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR;
+ /** Preference key for warning indication */
+ private final static String WARNING_INDICATION =
+ PreferenceConstants.EDITOR_WARNING_INDICATION;
+ /** Preference key for warning color */
+ private final static String WARNING_INDICATION_COLOR =
+ PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR;
+ /** Preference key for task indication */
+ private final static String TASK_INDICATION =
+ PreferenceConstants.EDITOR_TASK_INDICATION;
+ /** Preference key for task color */
+ private final static String TASK_INDICATION_COLOR =
+ PreferenceConstants.EDITOR_TASK_INDICATION_COLOR;
+ /** Preference key for bookmark indication */
+ private final static String BOOKMARK_INDICATION =
+ PreferenceConstants.EDITOR_BOOKMARK_INDICATION;
+ /** Preference key for bookmark color */
+ private final static String BOOKMARK_INDICATION_COLOR =
+ PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR;
+ /** Preference key for search result indication */
+ private final static String SEARCH_RESULT_INDICATION =
+ PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION;
+ /** Preference key for search result color */
+ private final static String SEARCH_RESULT_INDICATION_COLOR =
+ PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR;
+ /** Preference key for unknown annotation indication */
+ private final static String UNKNOWN_INDICATION =
+ PreferenceConstants.EDITOR_UNKNOWN_INDICATION;
+ /** Preference key for unknown annotation color */
+ private final static String UNKNOWN_INDICATION_COLOR =
+ PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR;
+ /** Preference key for linked position color */
+ private final static String LINKED_POSITION_COLOR =
+ PreferenceConstants.EDITOR_LINKED_POSITION_COLOR;
+ /** Preference key for shwoing the overview ruler */
+ private final static String OVERVIEW_RULER =
+ PreferenceConstants.EDITOR_OVERVIEW_RULER;
+
+ /** Preference key for error indication in overview ruler */
+ private final static String ERROR_INDICATION_IN_OVERVIEW_RULER =
+ PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER;
+ /** Preference key for warning indication in overview ruler */
+ private final static String WARNING_INDICATION_IN_OVERVIEW_RULER =
+ PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER;
+ /** Preference key for task indication in overview ruler */
+ private final static String TASK_INDICATION_IN_OVERVIEW_RULER =
+ PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER;
+ /** Preference key for bookmark indication in overview ruler */
+ private final static String BOOKMARK_INDICATION_IN_OVERVIEW_RULER =
+ PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
+ /** Preference key for search result indication in overview ruler */
+ private final static String SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER =
+ PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
+ /** Preference key for unknown annotation indication in overview ruler */
+ private final static String UNKNOWN_INDICATION_IN_OVERVIEW_RULER =
+ PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
+ /** Preference key for automatically closing strings */
+ private final static String CLOSE_STRINGS= PreferenceConstants.EDITOR_CLOSE_STRINGS;
+ /** Preference key for automatically wrapping Java strings */
+ private final static String WRAP_STRINGS= PreferenceConstants.EDITOR_WRAP_STRINGS;
+ /** Preference key for automatically closing brackets and parenthesis */
+ private final static String CLOSE_BRACKETS= PreferenceConstants.EDITOR_CLOSE_BRACKETS;
+ /** Preference key for automatically closing phpdocs and comments */
+ private final static String CLOSE_JAVADOCS= PreferenceConstants.EDITOR_CLOSE_JAVADOCS;
+ /** Preference key for automatically adding phpdoc tags */
+ private final static String ADD_JAVADOC_TAGS= PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS;
+ /** Preference key for automatically formatting phpdocs */
+ private final static String FORMAT_JAVADOCS= PreferenceConstants.EDITOR_FORMAT_JAVADOCS;
+ /** Preference key for smart paste */
+ private final static String SMART_PASTE= PreferenceConstants.EDITOR_SMART_PASTE;
+ private final static class AnnotationInfo {
+ public String fColorPreference;
+ public String fOverviewRulerPreference;
+ public String fEditorPreference;
+ };
+
+ private final static Map ANNOTATION_MAP;
+ static {
+
+ AnnotationInfo info;
+ ANNOTATION_MAP = new HashMap();
+
+ info = new AnnotationInfo();
+ info.fColorPreference = TASK_INDICATION_COLOR;
+ info.fOverviewRulerPreference = TASK_INDICATION_IN_OVERVIEW_RULER;
+ info.fEditorPreference = TASK_INDICATION;
+ ANNOTATION_MAP.put(AnnotationType.TASK, info);
+
+ info = new AnnotationInfo();
+ info.fColorPreference = ERROR_INDICATION_COLOR;
+ info.fOverviewRulerPreference = ERROR_INDICATION_IN_OVERVIEW_RULER;
+ info.fEditorPreference = ERROR_INDICATION;
+ ANNOTATION_MAP.put(AnnotationType.ERROR, info);
+
+ info = new AnnotationInfo();
+ info.fColorPreference = WARNING_INDICATION_COLOR;
+ info.fOverviewRulerPreference = WARNING_INDICATION_IN_OVERVIEW_RULER;
+ info.fEditorPreference = WARNING_INDICATION;
+ ANNOTATION_MAP.put(AnnotationType.WARNING, info);
+
+ info = new AnnotationInfo();
+ info.fColorPreference = BOOKMARK_INDICATION_COLOR;
+ info.fOverviewRulerPreference = BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
+ info.fEditorPreference = BOOKMARK_INDICATION;
+ ANNOTATION_MAP.put(AnnotationType.BOOKMARK, info);
+
+ info = new AnnotationInfo();
+ info.fColorPreference = SEARCH_RESULT_INDICATION_COLOR;
+ info.fOverviewRulerPreference = SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
+ info.fEditorPreference = SEARCH_RESULT_INDICATION;
+ ANNOTATION_MAP.put(AnnotationType.SEARCH_RESULT, info);
+
+ info = new AnnotationInfo();
+ info.fColorPreference = UNKNOWN_INDICATION_COLOR;
+ info.fOverviewRulerPreference = UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
+ info.fEditorPreference = UNKNOWN_INDICATION;
+ ANNOTATION_MAP.put(AnnotationType.UNKNOWN, info);
+ };
+
+ private final static AnnotationType[] ANNOTATION_LAYERS =
+ new AnnotationType[] {
+ AnnotationType.UNKNOWN,
+ AnnotationType.BOOKMARK,
+ AnnotationType.TASK,
+ AnnotationType.SEARCH_RESULT,
+ AnnotationType.WARNING,
+ AnnotationType.ERROR };
+
+ /**
+ * Creates a new php unit editor.
+ */
+ public PHPUnitEditor() {
+ super();
+ }
+
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+
+ fPaintManager = new PaintManager(getSourceViewer());
+
+ LinePainter linePainter;
+ linePainter = new LinePainter(getSourceViewer());
+
+ linePainter.setHighlightColor(
+ new Color(Display.getCurrent(), 225, 235, 224));
+
+ fPaintManager.addPainter(linePainter);
+
+
+ if (isBracketHighlightingEnabled())
+ startBracketHighlighting();
+ if (isLineHighlightingEnabled())
+ startLineHighlighting();
+ if (isPrintMarginVisible())
+ showPrintMargin();
+
+
+ Iterator e= ANNOTATION_MAP.keySet().iterator();
+ while (e.hasNext()) {
+ AnnotationType type= (AnnotationType) e.next();
+ if (isAnnotationIndicationEnabled(type))
+ startAnnotationIndication(type);
+ }
+
+ if (isTabConversionEnabled())
+ startTabConversion();
+
+ if (isOverviewRulerVisible())
+ showOverviewRuler();
+
+
+ Preferences preferences= PHPeclipsePlugin.getDefault().getPluginPreferences();
+ preferences.addPropertyChangeListener(fPropertyChangeListener);
+
+ IPreferenceStore preferenceStore= getPreferenceStore();
+ boolean closeBrackets= preferenceStore.getBoolean(CLOSE_BRACKETS);
+ boolean closeStrings= preferenceStore.getBoolean(CLOSE_STRINGS);
+
+ fBracketInserter.setCloseBracketsEnabled(closeBrackets);
+ fBracketInserter.setCloseStringsEnabled(closeStrings);
+
+ ISourceViewer sourceViewer= getSourceViewer();
+ if (sourceViewer instanceof ITextViewerExtension)
+ ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
+
+ }
+
+ private static char getPeerCharacter(char character) {
+ switch (character) {
+ case '(':
+ return ')';
+
+ case ')':
+ return '(';
+
+ case '[':
+ return ']';
+
+ case ']':
+ return '[';
+
+ case '"':
+ return character;
+
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /*
+ * @see AbstractTextEditor#doSetInput(IEditorInput)
+ */
+ protected void doSetInput(IEditorInput input) throws CoreException {
+ super.doSetInput(input);
+ configureTabConverter();
+ }
+
+ private void startBracketHighlighting() {
+ if (fBracketPainter == null) {
+ ISourceViewer sourceViewer = getSourceViewer();
+ fBracketPainter = new BracketPainter(sourceViewer);
+ fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
+ fPaintManager.addPainter(fBracketPainter);
+ }
+ }
+
+ private void stopBracketHighlighting() {
+ if (fBracketPainter != null) {
+ fPaintManager.removePainter(fBracketPainter);
+ fBracketPainter.deactivate(true);
+ fBracketPainter.dispose();
+ fBracketPainter = null;
+ }
+ }
+
+ private boolean isBracketHighlightingEnabled() {
+ IPreferenceStore store = getPreferenceStore();
+ return store.getBoolean(MATCHING_BRACKETS);
+ }
+
+ private void startLineHighlighting() {
+ if (fLinePainter == null) {
+ ISourceViewer sourceViewer = getSourceViewer();
+ fLinePainter = new LinePainter(sourceViewer);
+ fLinePainter.setHighlightColor(getColor(CURRENT_LINE_COLOR));
+ fPaintManager.addPainter(fLinePainter);
+ }
+ }
+
+ private void stopLineHighlighting() {
+ if (fLinePainter != null) {
+ fPaintManager.removePainter(fLinePainter);
+ fLinePainter.deactivate(true);
+ fLinePainter.dispose();
+ fLinePainter = null;
+ }
+ }
+
+ private boolean isLineHighlightingEnabled() {
+ IPreferenceStore store = getPreferenceStore();
+ return store.getBoolean(CURRENT_LINE);
+ }
+
+ private void showPrintMargin() {
+ if (fPrintMarginPainter == null) {
+ fPrintMarginPainter = new PrintMarginPainter(getSourceViewer());
+ fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
+ fPrintMarginPainter.setMarginRulerColumn(
+ getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
+ fPaintManager.addPainter(fPrintMarginPainter);
+ }
+ }
+
+ private void hidePrintMargin() {
+ if (fPrintMarginPainter != null) {
+ fPaintManager.removePainter(fPrintMarginPainter);
+ fPrintMarginPainter.deactivate(true);
+ fPrintMarginPainter.dispose();
+ fPrintMarginPainter = null;
+ }
+ }
+
+ private boolean isPrintMarginVisible() {
+ IPreferenceStore store = getPreferenceStore();
+ return store.getBoolean(PRINT_MARGIN);
+ }
+
+ private void startAnnotationIndication(AnnotationType annotationType) {
+ if (fProblemPainter == null) {
+ fProblemPainter = new ProblemPainter(this, getSourceViewer());
+ fPaintManager.addPainter(fProblemPainter);
+ }
+ fProblemPainter.setColor(annotationType, getColor(annotationType));
+ fProblemPainter.paintAnnotations(annotationType, true);
+ fProblemPainter.paint(IPainter.CONFIGURATION);
+ }
+
+ private void shutdownAnnotationIndication() {
+ if (fProblemPainter != null) {
+
+ if (!fProblemPainter.isPaintingAnnotations()) {
+ fPaintManager.removePainter(fProblemPainter);
+ fProblemPainter.deactivate(true);
+ fProblemPainter.dispose();
+ fProblemPainter = null;
+ } else {
+ fProblemPainter.paint(IPainter.CONFIGURATION);
+ }
+ }
+ }
+
+ private void stopAnnotationIndication(AnnotationType annotationType) {
+ if (fProblemPainter != null) {
+ fProblemPainter.paintAnnotations(annotationType, false);
+ shutdownAnnotationIndication();
+ }
+ }
+
+ private boolean isAnnotationIndicationEnabled(AnnotationType annotationType) {
+ IPreferenceStore store = getPreferenceStore();
+ AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(annotationType);
+ if (info != null)
+ return store.getBoolean(info.fEditorPreference);
+ return false;
+ }
+
+ private boolean isAnnotationIndicationInOverviewRulerEnabled(AnnotationType annotationType) {
+ IPreferenceStore store = getPreferenceStore();
+ AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(annotationType);
+ if (info != null)
+ return store.getBoolean(info.fOverviewRulerPreference);
+ return false;
+ }
+
+ private void showAnnotationIndicationInOverviewRuler(
+ AnnotationType annotationType,
+ boolean show) {
+ AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+ OverviewRuler ruler = asv.getOverviewRuler();
+ if (ruler != null) {
+ ruler.setColor(annotationType, getColor(annotationType));
+ ruler.showAnnotation(annotationType, show);
+ ruler.update();
+ }
+ }
+
+ private void setColorInOverviewRuler(
+ AnnotationType annotationType,
+ Color color) {
+ AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+ OverviewRuler ruler = asv.getOverviewRuler();
+ if (ruler != null) {
+ ruler.setColor(annotationType, color);
+ ruler.update();
+ }
+ }
+
+ private void configureTabConverter() {
+ if (fTabConverter != null) {
+ IDocumentProvider provider = getDocumentProvider();
+ if (provider instanceof PHPDocumentProvider) {
+ PHPDocumentProvider cup = (PHPDocumentProvider) provider;
+ fTabConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
+ }
+ }
+ }
+
+ private int getTabSize() {
+ Preferences preferences =
+ PHPeclipsePlugin.getDefault().getPluginPreferences();
+ return preferences.getInt(CODE_FORMATTER_TAB_SIZE);
+ }
+
+ private void startTabConversion() {
+ if (fTabConverter == null) {
+ fTabConverter = new TabConverter();
+ configureTabConverter();
+ fTabConverter.setNumberOfSpacesPerTab(getTabSize());
+ AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+ asv.addTextConverter(fTabConverter);
+ // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
+ asv.updateIndentationPrefixes();
+ }
+ }
+
+ private void stopTabConversion() {
+ if (fTabConverter != null) {
+ AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+ asv.removeTextConverter(fTabConverter);
+ // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
+ asv.updateIndentationPrefixes();
+ fTabConverter = null;
+ }
+ }
+
+ private boolean isTabConversionEnabled() {
+ IPreferenceStore store = getPreferenceStore();
+ return store.getBoolean(SPACES_FOR_TABS);
+ }
+
+ private void showOverviewRuler() {
+ AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+ asv.showOverviewRuler();
+
+ OverviewRuler overviewRuler = asv.getOverviewRuler();
+ if (overviewRuler != null) {
+ for (int i = 0; i < ANNOTATION_LAYERS.length; i++) {
+ AnnotationType type = ANNOTATION_LAYERS[i];
+ overviewRuler.setLayer(type, i);
+ if (isAnnotationIndicationInOverviewRulerEnabled(type))
+ showAnnotationIndicationInOverviewRuler(type, true);
+ }
+ }
+ }
+
+ private void hideOverviewRuler() {
+ AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+ asv.hideOverviewRuler();
+ }
+
+ private boolean isOverviewRulerVisible() {
+ IPreferenceStore store = getPreferenceStore();
+ return store.getBoolean(OVERVIEW_RULER);
+ }
+
+ private Color getColor(String key) {
+ RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key);
+ return getColor(rgb);
+ }
+
+ private Color getColor(RGB rgb) {
+ // JavaTextTools textTools = JavaPlugin.getDefault().getJavaTextTools();
+ // return textTools.getColorManager().getColor(rgb);
+ return PHPEditorEnvironment.getPHPColorProvider().getColor(rgb);
+ }
+
+ private Color getColor(AnnotationType annotationType) {
+ AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(annotationType);
+ if (info != null)
+ return getColor(info.fColorPreference);
+ return null;
+ }
+
+ public void dispose() {
+ ISourceViewer sourceViewer= getSourceViewer();
+ if (sourceViewer instanceof ITextViewerExtension)
+ ((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);
+
+ if (fPropertyChangeListener != null) {
+ Preferences preferences= PHPeclipsePlugin.getDefault().getPluginPreferences();
+ preferences.removePropertyChangeListener(fPropertyChangeListener);
+ fPropertyChangeListener= null;
+ }
+
+
+// if (fJavaEditorErrorTickUpdater != null) {
+// fJavaEditorErrorTickUpdater.dispose();
+// fJavaEditorErrorTickUpdater= null;
+// }
+//
+// if (fSelectionHistory != null)
+// fSelectionHistory.dispose();
+
+ if (fPaintManager != null) {
+ fPaintManager.dispose();
+ fPaintManager = null;
+ }
+
+ if (fActionGroups != null)
+ fActionGroups.dispose();
+
+ super.dispose();
+ }
+
+ protected AnnotationType getAnnotationType(String preferenceKey) {
+ Iterator e= ANNOTATION_MAP.keySet().iterator();
+ while (e.hasNext()) {
+ AnnotationType type= (AnnotationType) e.next();
+ AnnotationInfo info= (AnnotationInfo) ANNOTATION_MAP.get(type);
+ if (info != null) {
+ if (preferenceKey.equals(info.fColorPreference) || preferenceKey.equals(info.fEditorPreference) || preferenceKey.equals(info.fOverviewRulerPreference))
+ return type;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
+ */
+ protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
+
+ try {
+
+ AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer();
+ if (asv != null) {
+
+ String p= event.getProperty();
+
+ if (CLOSE_BRACKETS.equals(p)) {
+ fBracketInserter.setCloseBracketsEnabled(getPreferenceStore().getBoolean(p));
+ return;
+ }
+
+ if (CLOSE_STRINGS.equals(p)) {
+ fBracketInserter.setCloseStringsEnabled(getPreferenceStore().getBoolean(p));
+ return;
+ }
+
+ if (SPACES_FOR_TABS.equals(p)) {
+ if (isTabConversionEnabled())
+ startTabConversion();
+ else
+ stopTabConversion();
+ return;
+ }
+
+ if (MATCHING_BRACKETS.equals(p)) {
+ if (isBracketHighlightingEnabled())
+ startBracketHighlighting();
+ else
+ stopBracketHighlighting();
+ return;
+ }
+
+ if (MATCHING_BRACKETS_COLOR.equals(p)) {
+ if (fBracketPainter != null)
+ fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
+ return;
+ }
+
+ if (CURRENT_LINE.equals(p)) {
+ if (isLineHighlightingEnabled())
+ startLineHighlighting();
+ else
+ stopLineHighlighting();
+ return;
+ }
+
+ if (CURRENT_LINE_COLOR.equals(p)) {
+ if (fLinePainter != null) {
+ stopLineHighlighting();
+ startLineHighlighting();
+ }
+ return;
+ }
+
+ if (PRINT_MARGIN.equals(p)) {
+ if (isPrintMarginVisible())
+ showPrintMargin();
+ else
+ hidePrintMargin();
+ return;
+ }
+
+ if (PRINT_MARGIN_COLOR.equals(p)) {
+ if (fPrintMarginPainter != null)
+ fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
+ return;
+ }
+
+ if (PRINT_MARGIN_COLUMN.equals(p)) {
+ if (fPrintMarginPainter != null)
+ fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
+ return;
+ }
+
+ if (OVERVIEW_RULER.equals(p)) {
+ if (isOverviewRulerVisible())
+ showOverviewRuler();
+ else
+ hideOverviewRuler();
+ return;
+ }
+
+ AnnotationType type= getAnnotationType(p);
+ if (type != null) {
+
+ AnnotationInfo info= (AnnotationInfo) ANNOTATION_MAP.get(type);
+ if (info.fColorPreference.equals(p)) {
+ Color color= getColor(type);
+ if (fProblemPainter != null) {
+ fProblemPainter.setColor(type, color);
+ fProblemPainter.paint(IPainter.CONFIGURATION);
+ }
+ setColorInOverviewRuler(type, color);
+ return;
+ }
+
+ if (info.fEditorPreference.equals(p)) {
+ if (isAnnotationIndicationEnabled(type))
+ startAnnotationIndication(type);
+ else
+ stopAnnotationIndication(type);
+ return;
+ }
+
+ if (info.fOverviewRulerPreference.equals(p)) {
+ if (isAnnotationIndicationInOverviewRulerEnabled(type))
+ showAnnotationIndicationInOverviewRuler(type, true);
+ else
+ showAnnotationIndicationInOverviewRuler(type, false);
+ return;
+ }
+ }
+
+// IContentAssistant c= asv.getContentAssistant();
+// if (c instanceof ContentAssistant)
+// ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
+ }
+
+ } finally {
+ super.handlePreferenceStoreChanged(event);
+ }
+ }
+
+ /**
+ * Handles a property change event describing a change
+ * of the php core's preferences and updates the preference
+ * related editor properties.
+ *
+ * @param event the property change event
+ */
+ protected void handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
+ AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer();
+ if (asv != null) {
+ String p= event.getProperty();
+ if (CODE_FORMATTER_TAB_SIZE.equals(p)) {
+ asv.updateIndentationPrefixes();
+ if (fTabConverter != null)
+ fTabConverter.setNumberOfSpacesPerTab(getTabSize());
+ }
+ }
+ }
+
+ /*
+ * @see PHPEditor#createJavaSourceViewer(Composite, IVerticalRuler, int)
+ */
+ protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+ return new AdaptedSourceViewer(parent, ruler, styles);
+ }
+
+ private boolean isValidSelection(int offset, int length) {
+ IDocumentProvider provider= getDocumentProvider();
+ if (provider != null) {
+ IDocument document= provider.getDocument(getEditorInput());
+ if (document != null) {
+ int end= offset + length;
+ int documentLength= document.getLength();
+ return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength;
+ }
+ }
+ return false;
+ }
+
+ /*
+ * @see AbstractTextEditor#canHandleMove(IEditorInput, IEditorInput)
+ */
+ protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
+
+ String oldExtension= ""; //$NON-NLS-1$
+ if (originalElement instanceof IFileEditorInput) {
+ IFile file= ((IFileEditorInput) originalElement).getFile();
+ if (file != null) {
+ String ext= file.getFileExtension();
+ if (ext != null)
+ oldExtension= ext;
+ }
+ }
+
+ String newExtension= ""; //$NON-NLS-1$
+ if (movedElement instanceof IFileEditorInput) {
+ IFile file= ((IFileEditorInput) movedElement).getFile();
+ if (file != null)
+ newExtension= file.getFileExtension();
+ }
+
+ return oldExtension.equals(newExtension);
+ }
+}
--- /dev/null
+package net.sourceforge.phpeclipse.phpeditor;
+
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DefaultPositionUpdater;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IPositionUpdater;
+import org.eclipse.jface.text.ITextInputListener;
+import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+
+
+public final class PaintManager implements KeyListener, MouseListener, ISelectionChangedListener, ITextListener, ITextInputListener {
+
+
+ static class PaintPositionUpdater extends DefaultPositionUpdater {
+
+ /**
+ * Creates the position updater.
+ */
+ protected PaintPositionUpdater(String category) {
+ super(category);
+ }
+
+ /**
+ * If an insertion happens at a position's offset, the
+ * position is extended rather than shifted. Also, if something is added
+ * right behind the end of the position, the position is extended rather
+ * than kept stable.
+ */
+ protected void adaptToInsert() {
+
+ int myStart= fPosition.offset;
+ int myEnd= fPosition.offset + fPosition.length;
+ myEnd= Math.max(myStart, myEnd);
+
+ int yoursStart= fOffset;
+ int yoursEnd= fOffset + fReplaceLength;// - 1;
+ yoursEnd= Math.max(yoursStart, yoursEnd);
+
+ if (myEnd < yoursStart)
+ return;
+
+ if (myStart <= yoursStart)
+ fPosition.length += fReplaceLength;
+ else
+ fPosition.offset += fReplaceLength;
+ }
+ };
+
+ static class PositionManager implements IPositionManager {
+
+ private IDocument fDocument;
+ private IPositionUpdater fPositionUpdater;
+ private String fCategory;
+
+ public PositionManager() {
+ fCategory= getClass().getName() + hashCode();
+ fPositionUpdater= new PaintPositionUpdater(fCategory);
+ }
+
+ public void install(IDocument document) {
+ fDocument= document;
+ fDocument.addPositionCategory(fCategory);
+ fDocument.addPositionUpdater(fPositionUpdater);
+ }
+
+ public void dispose() {
+ uninstall(fDocument);
+ }
+
+ public void uninstall(IDocument document) {
+ if (document == fDocument && document != null) {
+ try {
+ fDocument.removePositionUpdater(fPositionUpdater);
+ fDocument.removePositionCategory(fCategory);
+ } catch (BadPositionCategoryException x) {
+ // should not happen
+ }
+ fDocument= null;
+ }
+ }
+
+ /*
+ * @see IPositionManager#addManagedPosition(Position)
+ */
+ public void addManagedPosition(Position position) {
+ try {
+ fDocument.addPosition(fCategory, position);
+ } catch (BadPositionCategoryException x) {
+ // should not happen
+ } catch (BadLocationException x) {
+ // should not happen
+ }
+ }
+
+ /*
+ * @see IPositionManager#removeManagedPosition(Position)
+ */
+ public void removeManagedPosition(Position position) {
+ try {
+ fDocument.removePosition(fCategory, position);
+ } catch (BadPositionCategoryException x) {
+ // should not happen
+ }
+ }
+ };
+
+
+ private List fPainters= new ArrayList(2);
+ private PositionManager fManager;
+ private ISourceViewer fSourceViewer;
+ private boolean fTextChanged= false;
+ private boolean fAutoRepeat= false;
+
+
+ public PaintManager(ISourceViewer sourceViewer) {
+ fSourceViewer= sourceViewer;
+ }
+
+ public void addPainter(IPainter painter) {
+ if (!fPainters.contains(painter)) {
+ fPainters.add(painter);
+ if (fPainters.size() == 1)
+ install();
+ painter.setPositionManager(fManager);
+ painter.paint(IPainter.INTERNAL);
+ }
+ }
+
+ public void removePainter(IPainter painter) {
+ if (fPainters.remove(painter))
+ painter.setPositionManager(null);
+ if (fPainters.size() == 0)
+ dispose();
+ }
+
+ private void install() {
+
+ fManager= new PositionManager();
+ fManager.install(fSourceViewer.getDocument());
+
+ fSourceViewer.addTextInputListener(this);
+
+ ISelectionProvider provider= fSourceViewer.getSelectionProvider();
+ provider.addSelectionChangedListener(this);
+
+ fSourceViewer.addTextListener(this);
+
+ StyledText text= fSourceViewer.getTextWidget();
+ text.addKeyListener(this);
+ text.addMouseListener(this);
+ }
+
+ public void dispose() {
+
+ if (fManager != null) {
+ fManager.dispose();
+ fManager= null;
+ }
+
+ for (Iterator e = fPainters.iterator(); e.hasNext();)
+ ((IPainter) e.next()).dispose();
+ fPainters.clear();
+
+ fSourceViewer.removeTextInputListener(this);
+
+ ISelectionProvider provider= fSourceViewer.getSelectionProvider();
+ if (provider != null)
+ provider.removeSelectionChangedListener(this);
+
+ fSourceViewer.removeTextListener(this);
+
+ StyledText text= fSourceViewer.getTextWidget();
+ if (text != null && !text.isDisposed()) {
+ text.removeKeyListener(this);
+ text.removeMouseListener(this);
+ }
+ }
+
+ private void paint(int reason) {
+ for (Iterator e = fPainters.iterator(); e.hasNext();)
+ ((IPainter) e.next()).paint(reason);
+ }
+
+ /*
+ * @see KeyListener#keyPressed(KeyEvent)
+ */
+ public void keyPressed(KeyEvent e) {
+ paint(IPainter.KEY_STROKE);
+ }
+
+ /*
+ * @see KeyListener#keyReleased(KeyEvent)
+ */
+ public void keyReleased(KeyEvent e) {
+ }
+
+ /*
+ * @see MouseListener#mouseDoubleClick(MouseEvent)
+ */
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ /*
+ * @see MouseListener#mouseDown(MouseEvent)
+ */
+ public void mouseDown(MouseEvent e) {
+ paint(IPainter.MOUSE_BUTTON);
+ }
+
+ /*
+ * @see MouseListener#mouseUp(MouseEvent)
+ */
+ public void mouseUp(MouseEvent e) {
+ }
+
+ /*
+ * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ paint(IPainter.SELECTION);
+ }
+
+ /*
+ * @see ITextListener#textChanged(TextEvent)
+ */
+ public void textChanged(TextEvent event) {
+
+ if (!event.getViewerRedrawState())
+ return;
+
+ fTextChanged= true;
+ Control control= fSourceViewer.getTextWidget();
+ if (control != null) {
+ control.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (fTextChanged && fSourceViewer != null)
+ paint(IPainter.TEXT_CHANGE);
+ }
+ });
+ }
+ }
+
+ /*
+ * @see ITextInputListener#inputDocumentAboutToBeChanged(IDocument, IDocument)
+ */
+ public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
+ if (oldInput != null) {
+ for (Iterator e = fPainters.iterator(); e.hasNext();)
+ ((IPainter) e.next()).deactivate(false);
+ fManager.uninstall(oldInput);
+ }
+ }
+
+ /*
+ * @see ITextInputListener#inputDocumentChanged(IDocument, IDocument)
+ */
+ public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
+ if (newInput != null) {
+ fManager.install(newInput);
+ paint(IPainter.TEXT_CHANGE);
+ }
+ }
+}
+
--- /dev/null
+package net.sourceforge.phpeclipse.phpeditor;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+
+import org.eclipse.jface.text.source.ISourceViewer;
+
+
+
+public class PrintMarginPainter implements IPainter, PaintListener {
+
+
+ private StyledText fTextWidget;
+
+ private int fMarginWidth= 80;
+ private Color fColor;
+ private int fLineStyle= SWT.LINE_SOLID;
+ private int fLineWidth= 1;
+
+ private int fCachedWidgetX= -1;
+ private boolean fIsActive= false;
+
+ public PrintMarginPainter(ISourceViewer sourceViewer) {
+ fTextWidget= sourceViewer.getTextWidget();
+ }
+
+ public void setMarginRulerColumn(int width) {
+ fMarginWidth= width;
+ intialize();
+ }
+
+ public void setMarginRulerStyle(int lineStyle) {
+ fLineStyle= lineStyle;
+ }
+
+ public void setMarginRulerWidth(int lineWidth) {
+ fLineWidth= lineWidth;
+ }
+
+ /**
+ * Must be called before <code>paint</code> is called the first time.
+ */
+ public void setMarginRulerColor(Color color) {
+ fColor= color;
+ }
+
+ /**
+ * Must be called explicitly when font of text widget changes.
+ */
+ public void intialize() {
+ computeWidgetX();
+ fTextWidget.redraw();
+ }
+
+ private void computeWidgetX() {
+ GC gc= new GC(fTextWidget);
+ int pixels= gc.getFontMetrics().getAverageCharWidth();
+ gc.dispose();
+
+ fCachedWidgetX= pixels * fMarginWidth;
+ }
+
+ /*
+ * @see IPainter#deactivate(boolean)
+ */
+ public void deactivate(boolean redraw) {
+ if (fIsActive) {
+ fIsActive= false;
+ fTextWidget.removePaintListener(this);
+ if (redraw)
+ fTextWidget.redraw();
+ }
+ }
+
+ /*
+ * @see IPainter#dispose()
+ */
+ public void dispose() {
+ fTextWidget= null;
+ }
+
+ /*
+ * @see IPainter#paint(int)
+ */
+ public void paint(int reason) {
+ if (!fIsActive) {
+ fIsActive= true;
+ fTextWidget.addPaintListener(this);
+ if (fCachedWidgetX == -1)
+ computeWidgetX();
+ fTextWidget.redraw();
+ }
+ }
+
+ /*
+ * @see IPainter#setPositionManager(IPositionManager)
+ */
+ public void setPositionManager(IPositionManager manager) {
+ }
+
+ /*
+ * @see PaintListener#paintControl(PaintEvent)
+ */
+ public void paintControl(PaintEvent e) {
+ if (fTextWidget != null) {
+ int x= fCachedWidgetX - fTextWidget.getHorizontalPixel();
+ if (x >= 0) {
+ Rectangle area= fTextWidget.getClientArea();
+ e.gc.setForeground(fColor);
+ e.gc.setLineStyle(fLineStyle);
+ e.gc.setLineWidth(fLineWidth);
+ e.gc.drawLine(x, 0, x, area.height);
+ }
+ }
+ }
+}
--- /dev/null
+package net.sourceforge.phpeclipse.phpeditor;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+
+import java.util.Iterator;
+import org.eclipse.jface.text.source.IAnnotationModel;
+
+
+/**
+ * Filters problems based on their types.
+ */
+public class ProblemAnnotationIterator implements Iterator {
+
+ private Iterator fIterator;
+ private IProblemAnnotation fNext;
+ private boolean fSkipIrrelevants;
+
+ public ProblemAnnotationIterator(IAnnotationModel model, boolean skipIrrelevants) {
+ fIterator= model.getAnnotationIterator();
+ fSkipIrrelevants= skipIrrelevants;
+ skip();
+ }
+
+ private void skip() {
+ while (fIterator.hasNext()) {
+ Object next= fIterator.next();
+ if (next instanceof IProblemAnnotation) {
+ IProblemAnnotation a= (IProblemAnnotation) next;
+ if (fSkipIrrelevants) {
+ if (a.isRelevant()) {
+ fNext= a;
+ return;
+ }
+ } else {
+ fNext= a;
+ return;
+ }
+ }
+ }
+ fNext= null;
+ }
+
+ /*
+ * @see Iterator#hasNext()
+ */
+ public boolean hasNext() {
+ return fNext != null;
+ }
+
+ /*
+ * @see Iterator#next()
+ */
+ public Object next() {
+ try {
+ return fNext;
+ } finally {
+ skip();
+ }
+ }
+
+ /*
+ * @see Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
--- /dev/null
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM 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 implementation
+**********************************************************************/
+
+package net.sourceforge.phpeclipse.phpeditor;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewerExtension3;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModelListener;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * Highlights the temporary problems.
+ */
+public class ProblemPainter implements IPainter, PaintListener, IAnnotationModelListener {
+
+ private static class ProblemPosition {
+ Position fPosition;
+ Color fColor;
+ boolean fMultiLine;
+ };
+
+ private boolean fIsActive= false;
+ private boolean fIsPainting= false;
+ private boolean fIsSettingModel= false;
+
+ private ITextEditor fTextEditor;
+ private ISourceViewer fSourceViewer;
+ private StyledText fTextWidget;
+ private IAnnotationModel fModel;
+ private List fProblemPositions= new ArrayList();
+
+ private Map fColorTable= new HashMap();
+ private Set fAnnotationSet= new HashSet();
+
+
+
+ public ProblemPainter(ITextEditor textEditor, ISourceViewer sourceViewer) {
+ fTextEditor= textEditor;
+ fSourceViewer= sourceViewer;
+ fTextWidget= sourceViewer.getTextWidget();
+ }
+
+ private boolean hasProblems() {
+ return !fProblemPositions.isEmpty();
+ }
+
+ private void enablePainting() {
+ if (!fIsPainting && hasProblems()) {
+ fIsPainting= true;
+ fTextWidget.addPaintListener(this);
+ handleDrawRequest(null);
+ }
+ }
+
+ private void disablePainting(boolean redraw) {
+ if (fIsPainting) {
+ fIsPainting= false;
+ fTextWidget.removePaintListener(this);
+ if (redraw && hasProblems())
+ handleDrawRequest(null);
+ }
+ }
+
+ private void setModel(IAnnotationModel model) {
+ if (fModel != model) {
+ if (fModel != null)
+ fModel.removeAnnotationModelListener(this);
+ fModel= model;
+ if (fModel != null) {
+ try {
+ fIsSettingModel= true;
+ fModel.addAnnotationModelListener(this);
+ } finally {
+ fIsSettingModel= false;
+ }
+ }
+ }
+ }
+
+ private void catchupWithModel() {
+ if (fProblemPositions != null) {
+ fProblemPositions.clear();
+ if (fModel != null) {
+
+ Iterator e= new ProblemAnnotationIterator(fModel, true);
+ while (e.hasNext()) {
+ IProblemAnnotation pa= (IProblemAnnotation) e.next();
+ Annotation a= (Annotation) pa;
+
+ Color color= null;
+ AnnotationType type= pa.getAnnotationType();
+ if (fAnnotationSet.contains(type))
+ color= (Color) fColorTable.get(type);
+
+ if (color != null) {
+ ProblemPosition pp= new ProblemPosition();
+ pp.fPosition= fModel.getPosition(a);
+ pp.fColor= color;
+ pp.fMultiLine= true;
+ fProblemPositions.add(pp);
+ }
+ }
+ }
+ }
+ }
+
+ private void updatePainting() {
+ disablePainting(true);
+ catchupWithModel();
+ enablePainting();
+ }
+
+ /*
+ * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
+ */
+ public void modelChanged(final IAnnotationModel model) {
+ if (fTextWidget != null && !fTextWidget.isDisposed()) {
+ if (fIsSettingModel) {
+ // inside the ui thread -> no need for posting
+ updatePainting();
+ } else {
+ Display d= fTextWidget.getDisplay();
+ if (d != null) {
+ d.asyncExec(new Runnable() {
+ public void run() {
+ if (fTextWidget != null && !fTextWidget.isDisposed())
+ updatePainting();
+ }
+ });
+ }
+ }
+ }
+ }
+
+ public void setColor(AnnotationType annotationType, Color color) {
+ if (color != null)
+ fColorTable.put(annotationType, color);
+ else
+ fColorTable.remove(annotationType);
+ }
+
+ public void paintAnnotations(AnnotationType annotationType, boolean paint) {
+ if (paint)
+ fAnnotationSet.add(annotationType);
+ else
+ fAnnotationSet.remove(annotationType);
+ }
+
+ public boolean isPaintingAnnotations() {
+ return !fAnnotationSet.isEmpty();
+ }
+
+ /*
+ * @see IPainter#dispose()
+ */
+ public void dispose() {
+
+ if (fColorTable != null)
+ fColorTable.clear();
+ fColorTable= null;
+
+ if (fAnnotationSet != null)
+ fAnnotationSet.clear();
+ fAnnotationSet= null;
+
+ fTextWidget= null;
+ fModel= null;
+ fProblemPositions= null;
+ }
+
+ /*
+ * Returns the document offset of the upper left corner of the widgets viewport,
+ * possibly including partially visible lines.
+ */
+ private int getInclusiveTopIndexStartOffset() {
+
+ if (fTextWidget != null && !fTextWidget.isDisposed()) {
+ int top= fSourceViewer.getTopIndex();
+ if ((fTextWidget.getTopPixel() % fTextWidget.getLineHeight()) != 0)
+ top--;
+ try {
+ IDocument document= fSourceViewer.getDocument();
+ return document.getLineOffset(top);
+ } catch (BadLocationException ex) {
+ }
+ }
+
+ return -1;
+ }
+
+ /*
+ * @see PaintListener#paintControl(PaintEvent)
+ */
+ public void paintControl(PaintEvent event) {
+ if (fTextWidget != null)
+ handleDrawRequest(event.gc);
+ }
+
+ private void handleDrawRequest(GC gc) {
+
+ int vOffset= getInclusiveTopIndexStartOffset();
+ // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17147
+ int vLength= fSourceViewer.getBottomIndexEndOffset() + 1;
+
+ for (Iterator e = fProblemPositions.iterator(); e.hasNext();) {
+ ProblemPosition pp = (ProblemPosition) e.next();
+ Position p= pp.fPosition;
+ if (p.overlapsWith(vOffset, vLength)) {
+
+ if (!pp.fMultiLine) {
+
+ IRegion widgetRange= getWidgetRange(p);
+ if (widgetRange != null)
+ draw(gc, widgetRange.getOffset(), widgetRange.getLength(), pp.fColor);
+
+ } else {
+
+ IDocument document= fSourceViewer.getDocument();
+ try {
+
+ int startLine= document.getLineOfOffset(p.getOffset());
+ int lastInclusive= Math.max(p.getOffset(), p.getOffset() + p.getLength() - 1);
+ int endLine= document.getLineOfOffset(lastInclusive);
+
+ for (int i= startLine; i <= endLine; i++) {
+ IRegion line= document.getLineInformation(i);
+ int paintStart= Math.max(line.getOffset(), p.getOffset());
+ int paintEnd= Math.min(line.getOffset() + line.getLength(), p.getOffset() + p.getLength());
+ if (paintEnd > paintStart) {
+ // otherwise inside a line delimiter
+ IRegion widgetRange= getWidgetRange(new Position(paintStart, paintEnd - paintStart));
+ if (widgetRange != null)
+ draw(gc, widgetRange.getOffset(), widgetRange.getLength(), pp.fColor);
+ }
+ }
+
+ } catch (BadLocationException x) {
+ }
+ }
+ }
+ }
+ }
+
+ private IRegion getWidgetRange(Position p) {
+ if (fSourceViewer instanceof ITextViewerExtension3) {
+
+ ITextViewerExtension3 extension= (ITextViewerExtension3) fSourceViewer;
+ return extension.modelRange2WidgetRange(new Region(p.getOffset(), p.getLength()));
+
+ } else {
+
+ IRegion region= fSourceViewer.getVisibleRegion();
+ int offset= region.getOffset();
+ int length= region.getLength();
+
+ if (p.overlapsWith(offset , length)) {
+ int p1= Math.max(offset, p.getOffset());
+ int p2= Math.min(offset + length, p.getOffset() + p.getLength());
+ return new Region(p1 - offset, p2 - p1);
+ }
+ }
+
+ return null;
+ }
+
+ private int[] computePolyline(Point left, Point right, int height) {
+
+ final int WIDTH= 4; // must be even
+ final int HEIGHT= 2; // can be any number
+// final int MINPEEKS= 2; // minimal number of peeks
+
+ int peeks= (right.x - left.x) / WIDTH;
+// if (peeks < MINPEEKS) {
+// int missing= (MINPEEKS - peeks) * WIDTH;
+// left.x= Math.max(0, left.x - missing/2);
+// peeks= MINPEEKS;
+// }
+
+ int leftX= left.x;
+
+ // compute (number of point) * 2
+ int length= ((2 * peeks) + 1) * 2;
+ if (length < 0)
+ return new int[0];
+
+ int[] coordinates= new int[length];
+
+ // cache peeks' y-coordinates
+ int bottom= left.y + height - 1;
+ int top= bottom - HEIGHT;
+
+ // populate array with peek coordinates
+ for (int i= 0; i < peeks; i++) {
+ int index= 4 * i;
+ coordinates[index]= leftX + (WIDTH * i);
+ coordinates[index+1]= bottom;
+ coordinates[index+2]= coordinates[index] + WIDTH/2;
+ coordinates[index+3]= top;
+ }
+
+ // the last down flank is missing
+ coordinates[length-2]= left.x + (WIDTH * peeks);
+ coordinates[length-1]= bottom;
+
+ return coordinates;
+ }
+
+ private void draw(GC gc, int offset, int length, Color color) {
+ if (gc != null) {
+
+ Point left= fTextWidget.getLocationAtOffset(offset);
+ Point right= fTextWidget.getLocationAtOffset(offset + length);
+
+ gc.setForeground(color);
+ int[] polyline= computePolyline(left, right, gc.getFontMetrics().getHeight());
+ gc.drawPolyline(polyline);
+
+ } else {
+ fTextWidget.redrawRange(offset, length, true);
+ }
+ }
+
+ /*
+ * @see IPainter#deactivate(boolean)
+ */
+ public void deactivate(boolean redraw) {
+ if (fIsActive) {
+ fIsActive= false;
+ disablePainting(redraw);
+ setModel(null);
+ catchupWithModel();
+ }
+ }
+
+ /*
+ * @see IPainter#paint(int)
+ */
+ public void paint(int reason) {
+ if (!fIsActive) {
+ fIsActive= true;
+ IDocumentProvider provider= PHPeclipsePlugin.getDefault().getCompilationUnitDocumentProvider();
+ setModel(provider.getAnnotationModel(fTextEditor.getEditorInput()));
+ } else if (CONFIGURATION == reason || INTERNAL == reason)
+ updatePainting();
+ }
+
+ /*
+ * @see IPainter#setPositionManager(IPositionManager)
+ */
+ public void setPositionManager(IPositionManager manager) {
+ }
+}
package net.sourceforge.phpeclipse.phpeditor.html;
+import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.formatter.IFormattingStrategy;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.ui.editors.text.TextEditor;
/**
* @author chrisl
private PHPSourceViewerConfiguration fConfig;
private ISourceViewer fViewer;
//
- private TextEditor fEditor;
+ private PHPEditor fEditor;
private int fTabWidth;
////////////////////////////////////////////////////////////////////////
import java.util.ArrayList;
import java.util.List;
+import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
import net.sourceforge.phpeclipse.phpeditor.util.HTMLWordDetector;
import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
import net.sourceforge.phpeclipse.phpeditor.util.PHPWhitespaceDetector;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IRule;
/**
* Creates a Java code scanner
*/
- public HTMLCodeScanner(PHPColorProvider provider) {
+ public HTMLCodeScanner(JavaColorManager provider, IPreferenceStore store) {
keyword = new Token(new TextAttribute(provider.getColor(PHPColorProvider.KEYWORD)));
IToken type = new Token(new TextAttribute(provider.getColor(PHPColorProvider.FUNCTION_NAME)));
public interface IPHPPartitionScannerConstants
{
public final static String PHP = "__php"; //$NON-NLS-1$
- public final static String PHP_MULTILINE_COMMENT = "__php_multiline_comment";
- public final static String JAVASCRIPT = "__javascript";
- public final static String JS_MULTILINE_COMMENT = "__js_multiline_comment";
- public final static String CSS = "__css";
- public final static String CSS_MULTILINE_COMMENT = "__css_multiline_comment";
- public final static String HTML = "__html";
+ public final static String PHP_MULTILINE_COMMENT = "__php_multiline_comment"; //$NON-NLS-1$
+ public final static String PHP_STRING = "__php_string"; //$NON-NLS-1$
+ public final static String JAVASCRIPT = "__javascript"; //$NON-NLS-1$
+ public final static String JS_MULTILINE_COMMENT = "__js_multiline_comment"; //$NON-NLS-1$
+ public final static String CSS = "__css"; //$NON-NLS-1$
+ public final static String CSS_MULTILINE_COMMENT = "__css_multiline_comment"; //$NON-NLS-1$
+ public final static String HTML = "__html"; //$NON-NLS-1$
public final static String HTML_MULTILINE_COMMENT = "__html_multiline_comment"; //$NON-NLS-1$
}
import java.util.List;
import java.util.Vector;
+import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
import net.sourceforge.phpeclipse.IPreferenceConstants;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr;
/**
* Creates a PHP code scanner
*/
- public PHPCodeScanner(PHPColorProvider provider) {
- final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+ public PHPCodeScanner(JavaColorManager provider, IPreferenceStore store) {
+ // final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
Color BackgroundColor = provider.getColor(PreferenceConverter.getColor(store, PHP_EDITOR_BACKGROUND));
variable =
new Token(
updateWordRules();
}
- public void updateToken(PHPColorProvider provider) {
+ public void updateToken(JavaColorManager provider) {
final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
Color BackgroundColor = provider.getColor(PreferenceConverter.getColor(store, PHP_EDITOR_BACKGROUND));