fixed size of xampp icons
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / DocumentAdapter.java
index 85dacc1..006503e 100644 (file)
@@ -1,10 +1,10 @@
 /*******************************************************************************
  * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
+ * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/cpl-v10.html
- * 
+ *
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
@@ -47,12 +47,12 @@ import org.eclipse.swt.widgets.Display;
 
 /**
  * Adapts <code>IDocument</code> to <code>IBuffer</code>. Uses the
- * same algorithm as the text widget to determine the buffer's line delimiter. 
+ * same algorithm as the text widget to determine the buffer's line delimiter.
  * All text inserted into the buffer is converted to this line delimiter.
  * This class is <code>public</code> for test purposes only.
  */
 public class DocumentAdapter implements IBuffer, IDocumentListener {
-       
+
                /**
                 * Internal implementation of a NULL instanceof IBuffer.
                 */
@@ -78,38 +78,38 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                        public void setContents(char[] contents) {}
                        public void setContents(String contents) {}
                }
-       
-       
+
+
                /** NULL implementing <code>IBuffer</code> */
                public final static IBuffer NULL= new NullBuffer();
-                       
-               
+
+
                /**
                 *  Executes a document set content call in the ui thread.
                 */
                protected class DocumentSetCommand implements Runnable {
-                       
+
                        private String fContents;
-                       
+
                        public void run() {
                                fDocument.set(fContents);
                        }
-               
+
                        public void set(String contents) {
                                fContents= contents;
                                Display.getDefault().syncExec(this);
                        }
                }
-               
+
                /**
                 * Executes a document replace call in the ui thread.
                 */
                protected class DocumentReplaceCommand implements Runnable {
-                       
+
                        private int fOffset;
                        private int fLength;
                        private String fText;
-                       
+
                        public void run() {
                                try {
                                        fDocument.replace(fOffset, fLength, fText);
@@ -117,7 +117,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                                        // ignore
                                }
                        }
-                       
+
                        public void replace(int offset, int length, String text) {
                                fOffset= offset;
                                fLength= length;
@@ -125,34 +125,34 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                                Display.getDefault().syncExec(this);
                        }
                }
-       
+
        private static final boolean DEBUG_LINE_DELIMITERS= true;
-       
+
        private IOpenable fOwner;
        private IFile fFile;
        private ITextFileBuffer fTextFileBuffer;
        private IDocument fDocument;
-       
+
        private DocumentSetCommand fSetCmd= new DocumentSetCommand();
        private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
-       
+
        private Set fLegalLineDelimiters;
-       
+
        private List fBufferListeners= new ArrayList(3);
        private IStatus fStatus;
-       
-       
+
+
        /**
         * This method is <code>public</code> for test purposes only.
         */
        public DocumentAdapter(IOpenable owner, IFile file) {
-               
+
                fOwner= owner;
                fFile= file;
-               
+
                initialize();
        }
-       
+
        private void initialize() {
                ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
                IPath location= fFile.getFullPath();
@@ -166,7 +166,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                }
                fDocument.addPrenotifiedDocumentListener(this);
        }
-       
+
        /**
         * Returns the status of this document adapter.
         */
@@ -177,16 +177,16 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                        return fTextFileBuffer.getStatus();
                return null;
        }
-       
+
        /**
         * Returns the adapted document.
-        * 
+        *
         * @return the adapted document
         */
        public IDocument getDocument() {
                return fDocument;
        }
-               
+
        /*
         * @see IBuffer#addBufferChangedListener(IBufferChangedListener)
         */
@@ -195,7 +195,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                if (!fBufferListeners.contains(listener))
                        fBufferListeners.add(listener);
        }
-       
+
        /*
         * @see IBuffer#removeBufferChangedListener(IBufferChangedListener)
         */
@@ -203,16 +203,16 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                Assert.isNotNull(listener);
                fBufferListeners.remove(listener);
        }
-       
+
        /*
         * @see IBuffer#append(char[])
         */
        public void append(char[] text) {
                append(new String(text));
        }
-       
+
        /*
-        * @see IBuffer#append(String) 
+        * @see IBuffer#append(String)
         */
        public void append(String text) {
                if (DEBUG_LINE_DELIMITERS) {
@@ -220,19 +220,19 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                }
                fReplaceCmd.replace(fDocument.getLength(), 0, text);
        }
-       
+
        /*
         * @see IBuffer#close()
         */
        public void close() {
-               
+
                if (isClosed())
                        return;
-                       
+
                IDocument d= fDocument;
                fDocument= null;
                d.removePrenotifiedDocumentListener(this);
-               
+
                if (fTextFileBuffer != null) {
                        ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
                        try {
@@ -242,11 +242,11 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                        }
                        fTextFileBuffer= null;
                }
-               
+
                fireBufferChanged(new BufferChangedEvent(this, 0, 0, null));
                fBufferListeners.clear();
        }
-       
+
        /*
         * @see IBuffer#getChar(int)
         */
@@ -257,7 +257,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                        throw new ArrayIndexOutOfBoundsException();
                }
        }
-       
+
        /*
         *  @see IBuffer#getCharacters()
         */
@@ -265,28 +265,28 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                String content= getContents();
                return content == null ? null : content.toCharArray();
        }
-       
+
        /*
         * @see IBuffer#getContents()
         */
        public String getContents() {
                return fDocument.get();
        }
-       
+
        /*
         * @see IBuffer#getLength()
         */
        public int getLength() {
                return fDocument.getLength();
        }
-       
+
        /*
         * @see IBuffer#getOwner()
         */
        public IOpenable getOwner() {
                return fOwner;
        }
-       
+
        /*
         * @see IBuffer#getText(int, int)
         */
@@ -297,43 +297,43 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                        throw new ArrayIndexOutOfBoundsException();
                }
        }
-       
+
        /*
         * @see IBuffer#getUnderlyingResource()
         */
        public IResource getUnderlyingResource() {
                return fFile;
        }
-       
+
        /*
         * @see IBuffer#hasUnsavedChanges()
         */
        public boolean hasUnsavedChanges() {
                return fTextFileBuffer != null ? fTextFileBuffer.isDirty() : false;
        }
-       
+
        /*
         * @see IBuffer#isClosed()
         */
        public boolean isClosed() {
                return fDocument == null;
        }
-       
+
        /*
         * @see IBuffer#isReadOnly()
         */
        public boolean isReadOnly() {
                IResource resource= getUnderlyingResource();
-               return resource == null ? true : resource.isReadOnly();
+               return resource == null ? true : resource.getResourceAttributes().isReadOnly();
        }
-       
+
        /*
         * @see IBuffer#replace(int, int, char[])
         */
        public void replace(int position, int length, char[] text) {
                replace(position, length, new String(text));
        }
-       
+
        /*
         * @see IBuffer#replace(int, int, String)
         */
@@ -343,7 +343,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                }
                fReplaceCmd.replace(position, length, text);
        }
-       
+
        /*
         * @see IBuffer#save(IProgressMonitor, boolean)
         */
@@ -355,38 +355,38 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                        throw new JavaModelException(e);
                }
        }
-       
+
        /*
         * @see IBuffer#setContents(char[])
         */
        public void setContents(char[] contents) {
                setContents(new String(contents));
        }
-       
+
        /*
         * @see IBuffer#setContents(String)
         */
        public void setContents(String contents) {
                int oldLength= fDocument.getLength();
-               
+
                if (contents == null) {
-                       
+
                        if (oldLength != 0)
                                fSetCmd.set(""); //$NON-NLS-1$
-               
+
                } else {
-                       
+
                        // set only if different
                        if (DEBUG_LINE_DELIMITERS) {
                                validateLineDelimiters(contents);
                        }
-                       
+
                        if (!contents.equals(fDocument.get()))
                                fSetCmd.set(contents);
                }
        }
-       
-       
+
+
        private void validateLineDelimiters(String contents) {
 
                if (fLegalLineDelimiters == null) {
@@ -407,16 +407,16 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
                                return; // first insertion of a line delimiter: no test
                        }
                        fLegalLineDelimiters= existingDelimiters;
-                       
+
                }
-               
+
                DefaultLineTracker tracker= new DefaultLineTracker();
                tracker.set(contents);
-               
+
                int lines= tracker.getNumberOfLines();
                if (lines <= 1)
                        return;
-               
+
                for (int i= 0; i < lines; i++) {
                        try {
                                String curr= tracker.getLineDelimiter(i);
@@ -446,7 +446,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
        public void documentChanged(DocumentEvent event) {
                fireBufferChanged(new BufferChangedEvent(this, event.getOffset(), event.getLength(), event.getText()));
        }
-       
+
        private void fireBufferChanged(BufferChangedEvent event) {
                if (fBufferListeners != null && fBufferListeners.size() > 0) {
                        Iterator e= new ArrayList(fBufferListeners).iterator();