directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r638956 - /directory/studio/branches/1.1.0/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java
Date Wed, 19 Mar 2008 17:58:20 GMT
Author: pamarcelot
Date: Wed Mar 19 10:58:18 2008
New Revision: 638956

URL: http://svn.apache.org/viewvc?rev=638956&view=rev
Log:
Fix for DIRSTUDIO-302 (LDIF Editor does not work when loading LDIF file outside of workspace
with Eclipse 3.3.x).

Modified:
    directory/studio/branches/1.1.0/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java

Modified: directory/studio/branches/1.1.0/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/1.1.0/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java?rev=638956&r1=638955&r2=638956&view=diff
==============================================================================
--- directory/studio/branches/1.1.0/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java
(original)
+++ directory/studio/branches/1.1.0/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java
Wed Mar 19 10:58:18 2008
@@ -248,10 +248,20 @@
         Reader reader;
         try
         {
+            String inputClassName = input.getClass().getName();
             if ( input instanceof IPathEditorInput )
             {
                 reader = new FileReader( ( ( IPathEditorInput ) input ).getPath().toFile()
);
             }
+            else if ( inputClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput"
)
+                || inputClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) )
+            // The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput'
+            // is used when opening a file from the menu File > Open... in Eclipse 3.2.x
+            // The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when
+            // opening a file from the menu File > Open... in Eclipse 3.3.x
+            {
+                reader = new FileReader( new File( input.getToolTipText() ) );
+            }
             else
             {
                 return false;
@@ -364,13 +374,26 @@
     protected void doSaveDocument( IProgressMonitor monitor, Object element, IDocument document,
boolean overwrite )
         throws CoreException
     {
-
+        File file = null;
+        String elementClassName = element.getClass().getName();
         if ( element instanceof IPathEditorInput )
         {
             IPathEditorInput pei = ( IPathEditorInput ) element;
             IPath path = pei.getPath();
-            File file = path.toFile();
+            file = path.toFile();
+        }
+        else if ( elementClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput"
)
+            || elementClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) )
+        // The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput'
+        // is used when opening a file from the menu File > Open... in Eclipse 3.2.x
+        // The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when
+        // opening a file from the menu File > Open... in Eclipse 3.3.x
+        {
+            file = new File( ( ( IEditorInput ) element ).getToolTipText() );
+        }
 
+        if ( file != null )
+        {
             try
             {
                 file.createNewFile();
@@ -440,12 +463,24 @@
      */
     public boolean isModifiable( Object element )
     {
+        String elementClassName = element.getClass().getName();
         if ( element instanceof IPathEditorInput )
         {
             IPathEditorInput pei = ( IPathEditorInput ) element;
             File file = pei.getPath().toFile();
             return file.canWrite() || !file.exists(); // Allow to edit new files
         }
+        else if ( elementClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput"
)
+            || elementClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) )
+        // The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput'
+        // is used when opening a file from the menu File > Open... in Eclipse 3.2.x
+        // The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when
+        // opening a file from the menu File > Open... in Eclipse 3.3.x
+        {
+            File file = new File( ( ( IEditorInput ) element ).getToolTipText() );
+            return file.canWrite() || !file.exists(); // Allow to edit new files
+        }
+        
         return false;
     }
 



Mime
View raw message