Thread: [Pydev-cvs] org.python.pydev/src/org/python/pydev/editor PyAutoIndentStrategy.java,1.2,1.3 Hyperlink
Brought to you by:
fabioz
From: Aleksandar T. <at...@us...> - 2004-04-22 10:35:33
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14105/src/org/python/pydev/editor Modified Files: PyAutoIndentStrategy.java Hyperlink.java PyDoubleClickStrategy.java PyEditConfiguration.java PyEdit.java Log Message: Lots of minor changes: double-clicking, more hyperlink navigation, making editor more useable. Moved some files here from debug, and pruned some obsolete ones. Index: PyAutoIndentStrategy.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyAutoIndentStrategy.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyAutoIndentStrategy.java 8 Jan 2004 22:41:38 -0000 1.2 --- PyAutoIndentStrategy.java 22 Apr 2004 10:35:23 -0000 1.3 *************** *** 32,35 **** --- 32,43 ---- this.forceTabs = forceTabs; } + + private String createSpaceString(int width) { + StringBuffer b = new StringBuffer(width); + while (tabWidth-- > 0) + b.append(" "); + return b.toString(); + } + /** returns correct single-step indentation */ private String getIndentationString() { *************** *** 40,49 **** tabWidth = PydevPrefs.getPreferences().getInt(PydevPrefs.TAB_WIDTH); useSpaces = PydevPrefs.getPreferences().getBoolean(PydevPrefs.SUBSTITUTE_TABS); ! if (useSpaces && !forceTabs) { ! StringBuffer b = new StringBuffer(tabWidth); ! while (tabWidth-- > 0) ! b.append(" "); ! identString = b.toString(); ! } else identString = "\t"; } --- 48,54 ---- tabWidth = PydevPrefs.getPreferences().getInt(PydevPrefs.TAB_WIDTH); useSpaces = PydevPrefs.getPreferences().getBoolean(PydevPrefs.SUBSTITUTE_TABS); ! if (useSpaces && !forceTabs) ! identString = createSpaceString(tabWidth); ! else identString = "\t"; } *************** *** 63,73 **** * tab location * - * @param document - * @param length - * @param text - * @param offset - * @param indentString - * @return String - * @throws BadLocationException */ protected String convertTabs( --- 68,71 ---- *************** *** 104,107 **** --- 102,117 ---- return text; } + + /** + * Converts spaces to strings. Useful when pasting + */ + protected String convertSpaces( + IDocument document, int length, String text, int offset, + String indentString) throws BadLocationException + { + if (text.length() > 2) + return text; + return text.replaceAll(createSpaceString(tabWidth), "\t"); + } /** *************** *** 173,176 **** --- 183,189 ---- document, command.length, command.text, command.offset, getIndentationString()); + else command.text = convertSpaces( + document, command.length, command.text, command.offset, + getIndentationString()); } catch (BadLocationException e) { e.printStackTrace(); Index: PyEditConfiguration.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditConfiguration.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyEditConfiguration.java 15 Apr 2004 23:19:21 -0000 1.8 --- PyEditConfiguration.java 22 Apr 2004 10:35:23 -0000 1.9 *************** *** 86,90 **** if (autoIndentStrategy == null) autoIndentStrategy = new PyAutoIndentStrategy(); ! return autoIndentStrategy; } --- 86,93 ---- if (autoIndentStrategy == null) autoIndentStrategy = new PyAutoIndentStrategy(); ! if (contentType == null || contentType.equals(IDocument.DEFAULT_CONTENT_TYPE)) ! return autoIndentStrategy; ! else ! return super.getAutoIndentStrategy(sourceViewer, contentType); } *************** *** 186,190 **** "if","import","in","is","lambda","not", "or","pass","print","raise","return", ! "try","while","yield","None" }; public GreatKeywordDetector() { --- 189,193 ---- "if","import","in","is","lambda","not", "or","pass","print","raise","return", ! "try","while","yield","False", "None", "True" }; public GreatKeywordDetector() { *************** *** 280,290 **** // next create a content assistant processor to populate the completions window IContentAssistProcessor processor = new PythonCompletionProcessor(); ! assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_SINGLELINE_STRING ); ! assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_MULTILINE_STRING ); assistant.setContentAssistProcessor(processor,IDocument.DEFAULT_CONTENT_TYPE ); assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); // Allow automatic activation after 500 msec ! assistant.enableAutoActivation(true); ! assistant.setAutoActivationDelay(500); Color bgColor = colorCache.getColor(new RGB(230,255,230)); assistant.setProposalSelectorBackground(bgColor); --- 283,294 ---- // next create a content assistant processor to populate the completions window IContentAssistProcessor processor = new PythonCompletionProcessor(); ! // No code completion in strings ! // assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_SINGLELINE_STRING ); ! // assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_MULTILINE_STRING ); assistant.setContentAssistProcessor(processor,IDocument.DEFAULT_CONTENT_TYPE ); assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); // Allow automatic activation after 500 msec ! // assistant.enableAutoActivation(true); ! // assistant.setAutoActivationDelay(500); Color bgColor = colorCache.getColor(new RGB(230,255,230)); assistant.setProposalSelectorBackground(bgColor); Index: PyEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEdit.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyEdit.java 15 Apr 2004 23:19:21 -0000 1.12 --- PyEdit.java 22 Apr 2004 10:35:23 -0000 1.13 *************** *** 12,16 **** --- 12,18 ---- import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; + import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; + import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Preferences; *************** *** 25,28 **** --- 27,31 ---- import org.eclipse.ui.IEditorSite; import org.eclipse.ui.IFileEditorInput; + import org.eclipse.ui.IStorageEditorInput; import org.eclipse.ui.PartInitException; import org.eclipse.ui.editors.text.TextEditor; *************** *** 94,98 **** editConfiguration = new PyEditConfiguration(colorCache); setSourceViewerConfiguration(editConfiguration); ! indentStrategy = (PyAutoIndentStrategy)editConfiguration.getAutoIndentStrategy(null, null); setRangeIndicator(new DefaultRangeIndicator()); // enables standard vertical ruler --- 97,101 ---- editConfiguration = new PyEditConfiguration(colorCache); setSourceViewerConfiguration(editConfiguration); ! indentStrategy = (PyAutoIndentStrategy)editConfiguration.getAutoIndentStrategy(null, IDocument.DEFAULT_CONTENT_TYPE); setRangeIndicator(new DefaultRangeIndicator()); // enables standard vertical ruler *************** *** 250,255 **** return; // nothing to see here boolean wholeLine = false; - // if (node instanceof ImportNode) - // wholeLine = true; Location start = node.getStart(); Location end = node.getEnd(); --- 253,256 ---- *************** *** 282,299 **** // Remove all the error markers IEditorInput input = getEditorInput(); ! IFile original= (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; try { ! if (original != null) ! original.deleteMarkers(IMarker.PROBLEM, false, 1); } catch (CoreException e) { // What bad can come from removing markers? Ignore this exception PydevPlugin.log(IStatus.WARNING, "Unexpected error removing markers", e); } ! IDocument document = getDocumentProvider().getDocument(getEditorInput()); int lastLine = document.getNumberOfLines(); IRegion r; try { r = document.getLineInformation(lastLine-1); ! pythonModel = ModelMaker.createModel(root, document, original); fireModelChanged(pythonModel); } catch (BadLocationException e1) { --- 283,310 ---- // Remove all the error markers IEditorInput input = getEditorInput(); ! IPath filePath = null; ! if (input instanceof IStorageEditorInput) ! try { ! filePath = ((IStorageEditorInput)input).getStorage().getFullPath(); ! } catch (CoreException e2) { ! PydevPlugin.log(IStatus.ERROR, "unexpected error getting path", e2); ! } ! else ! PydevPlugin.log(IStatus.ERROR, "unexpected type of editor input " + input.getClass().toString(), null); ! try { ! IResource res = (IResource) input.getAdapter(IResource.class); ! if (res != null) ! res.deleteMarkers(IMarker.PROBLEM, false, 1); } catch (CoreException e) { // What bad can come from removing markers? Ignore this exception PydevPlugin.log(IStatus.WARNING, "Unexpected error removing markers", e); } ! IDocument document = getDocumentProvider().getDocument(input); int lastLine = document.getNumberOfLines(); IRegion r; try { r = document.getLineInformation(lastLine-1); ! pythonModel = ModelMaker.createModel(root, document, filePath); fireModelChanged(pythonModel); } catch (BadLocationException e1) { *************** *** 374,378 **** private void enableBrowserLikeLinks() { if (fMouseListener == null) { ! fMouseListener= new Hyperlink(getSourceViewer(), this); fMouseListener.install(); } --- 385,389 ---- private void enableBrowserLikeLinks() { if (fMouseListener == null) { ! fMouseListener= new Hyperlink(getSourceViewer(), this, colorCache); fMouseListener.install(); } Index: PyDoubleClickStrategy.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyDoubleClickStrategy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyDoubleClickStrategy.java 15 Apr 2004 23:19:21 -0000 1.1 --- PyDoubleClickStrategy.java 22 Apr 2004 10:35:23 -0000 1.2 *************** *** 6,16 **** package org.python.pydev.editor; ! import org.eclipse.jdt.internal.ui.text.JavaPairMatcher; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextDoubleClickStrategy; import org.eclipse.jface.text.ITextViewer; /** --- 6,20 ---- package org.python.pydev.editor; ! import java.io.IOException; ! import java.io.Reader; ! import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; + import org.eclipse.jface.text.Region; import org.eclipse.jface.text.ITextDoubleClickStrategy; import org.eclipse.jface.text.ITextViewer; + import org.eclipse.jface.text.source.ICharacterPairMatcher; /** *************** *** 22,26 **** --- 26,454 ---- protected static final char[] BRACKETS = { '{', '}', '(', ')', '[', ']' }; + + + public class JavaCodeReader extends Reader { + + /** The EOF character */ + public static final int EOF= -1; + + private boolean fSkipComments= false; + private boolean fSkipStrings= false; + private boolean fForward= false; + + private IDocument fDocument; + private int fOffset; + + private int fEnd= -1; + private int fCachedLineNumber= -1; + private int fCachedLineOffset= -1; + + + public int read(char cbuf[], int off, int len) throws IOException { + int end= off + len; + for (int i= off; i < end; i++) { + int ch= read(); + if (ch == -1) { + if (i == off) { + return -1; + } else { + return i - off; + } + } + cbuf[i]= (char)ch; + } + return len; + } + + /** + * @see Reader#ready() + */ + public boolean ready() throws IOException { + return true; + } + + /** + * Gets the content as a String + */ + public String getString() throws IOException { + StringBuffer buf= new StringBuffer(); + int ch; + while ((ch= read()) != -1) { + buf.append((char)ch); + } + return buf.toString(); + } + public JavaCodeReader() { + } + + /** + * Returns the offset of the last read character. Should only be called after read has been called. + */ + public int getOffset() { + return fForward ? fOffset -1 : fOffset; + } + + public void configureForwardReader(IDocument document, int offset, int length, boolean skipComments, boolean skipStrings) throws IOException { + fDocument= document; + fOffset= offset; + fSkipComments= skipComments; + fSkipStrings= skipStrings; + + fForward= true; + fEnd= Math.min(fDocument.getLength(), fOffset + length); + } + + public void configureBackwardReader(IDocument document, int offset, boolean skipComments, boolean skipStrings) throws IOException { + fDocument= document; + fOffset= offset; + fSkipComments= skipComments; + fSkipStrings= skipStrings; + + fForward= false; + try { + fCachedLineNumber= fDocument.getLineOfOffset(fOffset); + } catch (BadLocationException x) { + throw new IOException(x.getMessage()); + } + } + + /* + * @see Reader#close() + */ + public void close() throws IOException { + fDocument= null; + } + + /* + * @see SingleCharReader#read() + */ + public int read() throws IOException { + try { + return fForward ? readForwards() : readBackwards(); + } catch (BadLocationException x) { + throw new IOException(x.getMessage()); + } + } + + private void gotoCommentEnd() throws BadLocationException { + while (fOffset < fEnd) { + char current= fDocument.getChar(fOffset++); + if (current == '*') { + if (fOffset < fEnd && fDocument.getChar(fOffset) == '/') { + ++ fOffset; + return; + } + } + } + } + + private void gotoStringEnd(char delimiter) throws BadLocationException { + while (fOffset < fEnd) { + char current= fDocument.getChar(fOffset++); + if (current == '\\') { + // ignore escaped characters + ++ fOffset; + } else if (current == delimiter) { + return; + } + } + } + + private void gotoLineEnd() throws BadLocationException { + int line= fDocument.getLineOfOffset(fOffset); + fOffset= fDocument.getLineOffset(line + 1); + } + + private int readForwards() throws BadLocationException { + while (fOffset < fEnd) { + char current= fDocument.getChar(fOffset++); + + switch (current) { + case '/': + + if (fSkipComments && fOffset < fEnd) { + char next= fDocument.getChar(fOffset); + if (next == '*') { + // a comment starts, advance to the comment end + ++ fOffset; + gotoCommentEnd(); + continue; + } else if (next == '/') { + // '//'-comment starts, advance to the line end + gotoLineEnd(); + continue; + } + } + + return current; + + case '"': + case '\'': + + if (fSkipStrings) { + gotoStringEnd(current); + continue; + } + + return current; + } + + return current; + } + + return EOF; + } + + private void handleSingleLineComment() throws BadLocationException { + int line= fDocument.getLineOfOffset(fOffset); + if (line < fCachedLineNumber) { + fCachedLineNumber= line; + fCachedLineOffset= fDocument.getLineOffset(line); + int offset= fOffset; + while (fCachedLineOffset < offset) { + char current= fDocument.getChar(offset--); + if (current == '/' && fCachedLineOffset <= offset && fDocument.getChar(offset) == '/') { + fOffset= offset; + return; + } + } + } + } + + private void gotoCommentStart() throws BadLocationException { + while (0 < fOffset) { + char current= fDocument.getChar(fOffset--); + if (current == '*' && 0 <= fOffset && fDocument.getChar(fOffset) == '/') + return; + } + } + + private void gotoStringStart(char delimiter) throws BadLocationException { + while (0 < fOffset) { + char current= fDocument.getChar(fOffset); + if (current == delimiter) { + if ( !(0 <= fOffset && fDocument.getChar(fOffset -1) == '\\')) + return; + } + -- fOffset; + } + } + + private int readBackwards() throws BadLocationException { + + while (0 < fOffset) { + -- fOffset; + + handleSingleLineComment(); + + char current= fDocument.getChar(fOffset); + switch (current) { + case '/': + + if (fSkipComments && fOffset > 1) { + char next= fDocument.getChar(fOffset - 1); + if (next == '*') { + // a comment ends, advance to the comment start + fOffset -= 2; + gotoCommentStart(); + continue; + } + } + + return current; + + case '"': + case '\'': + + if (fSkipStrings) { + -- fOffset; + gotoStringStart(current); + continue; + } + + return current; + } + + return current; + } + + return EOF; + } + }; + + + /** + * swiped an internal class straight out of Java code + * it was originaly org.eclipse.jdt.internal.ui.text.JavaPairMatcher + */ + public class JavaPairMatcher implements ICharacterPairMatcher { + + protected char[] fPairs; + protected IDocument fDocument; + protected int fOffset; + + protected int fStartPos; + protected int fEndPos; + protected int fAnchor; + + protected JavaCodeReader fReader= new JavaCodeReader(); + + + public JavaPairMatcher(char[] pairs) { + fPairs= pairs; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.source.ICharacterPairMatcher#match(org.eclipse.jface.text.IDocument, int) + */ + public IRegion match(IDocument document, int offset) { + fOffset= offset; + + if (fOffset < 0) + return null; + + fDocument= document; + + if (fDocument != null && matchPairsAt() && fStartPos != fEndPos) + return new Region(fStartPos, fEndPos - fStartPos + 1); + + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.source.ICharacterPairMatcher#getAnchor() + */ + public int getAnchor() { + return fAnchor; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.source.ICharacterPairMatcher#dispose() + */ + public void dispose() { + clear(); + fDocument= null; + fReader= null; + } + + /* + * @see org.eclipse.jface.text.source.ICharacterPairMatcher#clear() + */ + public void clear() { + if (fReader != null) { + try { + fReader.close(); + } catch (IOException x) { + // ignore + } + } + } + + protected boolean matchPairsAt() { + + int i; + int pairIndex1= fPairs.length; + int pairIndex2= fPairs.length; + + fStartPos= -1; + fEndPos= -1; + + // get the chars preceding and following the start position + try { + + char prevChar= fDocument.getChar(Math.max(fOffset - 1, 0)); + // modified behavior for http://dev.eclipse.org/bugs/show_bug.cgi?id=16879 + // char nextChar= fDocument.getChar(fOffset); + + // search for opening peer character next to the activation point + for (i= 0; i < fPairs.length; i= i + 2) { + // if (nextChar == fPairs[i]) { + // fStartPos= fOffset; + // pairIndex1= i; + // } else + if (prevChar == fPairs[i]) { + fStartPos= fOffset - 1; + pairIndex1= i; + } + } + + // search for closing peer character next to the activation point + for (i= 1; i < fPairs.length; i= i + 2) { + if (prevChar == fPairs[i]) { + fEndPos= fOffset - 1; + pairIndex2= i; + } + // else if (nextChar == fPairs[i]) { + // fEndPos= fOffset; + // pairIndex2= i; + // } + } + + if (fEndPos > -1) { + fAnchor= RIGHT; + fStartPos= searchForOpeningPeer(fEndPos, fPairs[pairIndex2 - 1], fPairs[pairIndex2], fDocument); + if (fStartPos > -1) + return true; + else + fEndPos= -1; + } else if (fStartPos > -1) { + fAnchor= LEFT; + fEndPos= searchForClosingPeer(fStartPos, fPairs[pairIndex1], fPairs[pairIndex1 + 1], fDocument); + if (fEndPos > -1) + return true; + else + fStartPos= -1; + } + + } catch (BadLocationException x) { + } catch (IOException x) { + } + + return false; + } + + protected int searchForClosingPeer(int offset, int openingPeer, int closingPeer, IDocument document) throws IOException { + + fReader.configureForwardReader(document, offset + 1, document.getLength(), true, true); + + int stack= 1; + int c= fReader.read(); + while (c != JavaCodeReader.EOF) { + if (c == openingPeer && c != closingPeer) + stack++; + else if (c == closingPeer) + stack--; + + if (stack == 0) + return fReader.getOffset(); + + c= fReader.read(); + } + + return -1; + } + + protected int searchForOpeningPeer(int offset, int openingPeer, int closingPeer, IDocument document) throws IOException { + + fReader.configureBackwardReader(document, offset, true, true); + + int stack= 1; + int c= fReader.read(); + while (c != JavaCodeReader.EOF) { + if (c == closingPeer && c != openingPeer) + stack++; + else if (c == openingPeer) + stack--; + + if (stack == 0) + return fReader.getOffset(); + + c= fReader.read(); + } + + return -1; + } + } protected JavaPairMatcher fPairMatcher = new JavaPairMatcher(BRACKETS); Index: Hyperlink.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/Hyperlink.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Hyperlink.java 15 Apr 2004 23:19:21 -0000 1.2 --- Hyperlink.java 22 Apr 2004 10:35:23 -0000 1.3 *************** *** 10,15 **** import org.eclipse.core.runtime.IStatus; - import org.eclipse.jdt.internal.ui.JavaPlugin; - import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jface.action.Action; import org.eclipse.jface.preference.IPreferenceStore; --- 10,13 ---- *************** *** 27,32 **** import org.eclipse.jface.text.Region; import org.eclipse.jface.text.source.ISourceViewer; - import org.eclipse.jface.util.IPropertyChangeListener; - import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; --- 25,28 ---- *************** *** 54,57 **** --- 50,55 ---- import org.python.pydev.editor.model.ModelUtils; import org.python.pydev.plugin.PydevPlugin; + import org.python.pydev.plugin.PydevPrefs; + import org.python.pydev.ui.ColorCache; /** *************** *** 61,65 **** */ public class Hyperlink implements KeyListener, MouseListener, MouseMoveListener, ! FocusListener, PaintListener, IPropertyChangeListener, IDocumentListener, ITextInputListener { /** The session is active. */ --- 59,63 ---- */ public class Hyperlink implements KeyListener, MouseListener, MouseMoveListener, ! FocusListener, PaintListener, IDocumentListener, ITextInputListener { /** The session is active. */ *************** *** 78,81 **** --- 76,81 ---- private int fKeyModifierMask; + private ColorCache fColorCache; + /************ * ALEKS ADDITIONS *************** *** 85,104 **** private AbstractNode fClickedNode; ! public Hyperlink(ISourceViewer sourceViewer, PyEdit editor) { fSourceViewer = sourceViewer; fEditor = editor; } private ISourceViewer getSourceViewer() { return fSourceViewer; ! } ! ! IPreferenceStore fPrefStore = null; ! ! public IPreferenceStore getPreferenceStore() { ! if (fPrefStore == null) ! fPrefStore = JavaPlugin.getDefault().getPreferenceStore(); ! return fPrefStore; ! } public void deactivate() { --- 85,98 ---- private AbstractNode fClickedNode; ! public Hyperlink(ISourceViewer sourceViewer, PyEdit editor, ColorCache colorCache) { fSourceViewer = sourceViewer; fEditor = editor; + fKeyModifierMask = SWT.CTRL; + fColorCache = colorCache; } private ISourceViewer getSourceViewer() { return fSourceViewer; ! } public void deactivate() { *************** *** 137,154 **** text.addFocusListener(this); text.addPaintListener(this); - - updateKeyModifierMask(); - - IPreferenceStore preferenceStore= getPreferenceStore(); - preferenceStore.addPropertyChangeListener(this); - } - - private void updateKeyModifierMask() { - String modifiers= getPreferenceStore().getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK); - fKeyModifierMask= computeStateMask(modifiers); - if (fKeyModifierMask == -1) { - // Fallback to stored state mask - fKeyModifierMask= getPreferenceStore().getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK); - }; } --- 131,134 ---- *************** *** 192,199 **** if (document != null) document.removeDocumentListener(this); - - IPreferenceStore preferenceStore= getPreferenceStore(); - if (preferenceStore != null) - preferenceStore.removePropertyChangeListener(this); StyledText text= sourceViewer.getTextWidget(); --- 172,175 ---- *************** *** 207,227 **** text.removePaintListener(this); } - - /* - * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(PreferenceConstants.EDITOR_LINK_COLOR)) { - ISourceViewer viewer= getSourceViewer(); - if (viewer != null) - updateColor(viewer); - } else if (event.getProperty().equals(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)) { - updateKeyModifierMask(); - } - } private void updateColor(ISourceViewer viewer) { - if (fColor != null) - fColor.dispose(); StyledText text= viewer.getTextWidget(); --- 183,188 ---- *************** *** 229,234 **** return; ! Display display= text.getDisplay(); ! fColor= createColor(getPreferenceStore(), PreferenceConstants.EDITOR_LINK_COLOR, display); } --- 190,194 ---- return; ! fColor = fColorCache.getNamedColor(PydevPrefs.HYPERLINK_COLOR); } |