directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r880901 - in /directory/studio/trunk/ldifeditor: pom.xml src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java
Date Mon, 16 Nov 2009 18:40:36 GMT
Author: pamarcelot
Date: Mon Nov 16 18:40:36 2009
New Revision: 880901

URL: http://svn.apache.org/viewvc?rev=880901&view=rev
Log:
Fix for DIRSTUDIO-577 (LDIF editor doesn't notify Eclipse that the LDIF file has changed when
saving).

Modified:
    directory/studio/trunk/ldifeditor/pom.xml
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java

Modified: directory/studio/trunk/ldifeditor/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/pom.xml?rev=880901&r1=880900&r2=880901&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/pom.xml (original)
+++ directory/studio/trunk/ldifeditor/pom.xml Mon Nov 16 18:40:36 2009
@@ -124,6 +124,8 @@
  org.eclipse.ui.views,
  org.eclipse.ui.forms,
  org.eclipse.jface.text,
+ org.eclipse.ui.ide,
+ org.eclipse.core.resources,
  org.apache.directory.studio.jars,
  org.apache.directory.studio.ldifparser,
  org.apache.directory.studio.connection.core,
@@ -191,6 +193,16 @@
     
 	<!-- Eclipse plugins dependencies -->
     <dependency>
+      <groupId>org.eclipse.ui</groupId>
+      <artifactId>ide</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.core</groupId>
+      <artifactId>resources</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
       <groupId>org.eclipse.swt.gtk.linux</groupId>
       <artifactId>x86</artifactId>
       <scope>provided</scope>

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java?rev=880901&r1=880900&r2=880901&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java
(original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifDocumentProvider.java
Mon Nov 16 18:40:36 2009
@@ -23,6 +23,7 @@
 
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
@@ -40,6 +41,7 @@
 import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
 import org.apache.directory.studio.ldifparser.model.container.LdifRecord;
 import org.apache.directory.studio.ldifparser.parser.LdifParser;
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -55,6 +57,7 @@
 import org.eclipse.jface.text.source.IAnnotationModel;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
 import org.eclipse.ui.texteditor.AbstractDocumentProvider;
 
 
@@ -376,7 +379,14 @@
     {
         File file = null;
         String elementClassName = element.getClass().getName();
-        if ( element instanceof IPathEditorInput )
+        if ( element instanceof FileEditorInput )
+        // FileEditorInput class is used when the file is opened
+        // from a project in the workspace.
+        {
+            writeDocumentContent( document, ( ( FileEditorInput ) element ).getFile(), monitor
);
+            return;
+        }
+        else if ( element instanceof IPathEditorInput )
         {
             IPathEditorInput pei = ( IPathEditorInput ) element;
             IPath path = pei.getPath();
@@ -431,6 +441,24 @@
      * Saves the document contents to a stream.
      * 
      * @param document the document to save
+     * @param file the file to save it to
+     * @param monitor a progress monitor to report progress
+     * @throws CoreException 
+     * @throws IOException if writing fails
+     */
+    private void writeDocumentContent( IDocument document, IFile file, IProgressMonitor monitor
) throws CoreException
+    {
+        if ( file != null )
+        {
+            file.setContents( new ByteArrayInputStream( document.get().getBytes() ), true,
true, monitor );
+        }
+    }
+
+
+    /**
+     * Saves the document contents to a stream.
+     * 
+     * @param document the document to save
      * @param writer the stream to save it to
      * @param monitor a progress monitor to report progress
      * @throws IOException if writing fails



Mime
View raw message