You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2010/08/20 19:07:23 UTC
svn commit: r987577 [9/10] - in
/directory/studio/branches/studio-rap/plugins:
common.ui/src/main/java/org/apache/directory/studio/common/ui/
connection.ui/src/main/java/org/apache/directory/studio/connection/ui/
connection.ui/src/main/java/org/apache/...
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/reconciler/LdifFoldingRegionUpdater.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/reconciler/LdifFoldingRegionUpdater.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/reconciler/LdifFoldingRegionUpdater.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/reconciler/LdifFoldingRegionUpdater.java Fri Aug 20 17:07:19 2010
@@ -21,29 +21,9 @@
package org.apache.directory.studio.ldifeditor.editor.reconciler;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
import org.apache.directory.studio.ldifeditor.LdifEditorActivator;
import org.apache.directory.studio.ldifeditor.LdifEditorConstants;
import org.apache.directory.studio.ldifeditor.editor.ILdifEditor;
-import org.apache.directory.studio.ldifparser.model.LdifFile;
-import org.apache.directory.studio.ldifparser.model.LdifPart;
-import org.apache.directory.studio.ldifparser.model.container.LdifCommentContainer;
-import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
-import org.apache.directory.studio.ldifparser.model.lines.LdifNonEmptyLineBase;
-import org.apache.directory.studio.ldifparser.model.lines.LdifSepLine;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.projection.ProjectionAnnotation;
-import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
@@ -83,142 +63,142 @@ public class LdifFoldingRegionUpdater im
public void updateFoldingRegions()
{
- ISourceViewer viewer = ( ISourceViewer ) editor.getAdapter( ISourceViewer.class );
- if ( viewer == null )
- return;
-
- IDocument document = viewer.getDocument();
-
- try
- {
- ProjectionAnnotationModel projectionAnnotationModel = ( ProjectionAnnotationModel ) editor
- .getAdapter( ProjectionAnnotationModel.class );
- if ( projectionAnnotationModel == null )
- return;
-
- // create folding regions of current LDIF model; mark comments
- // and
- // folded lines as collapsed
- Map positionToAnnotationMap = createFoldingRegions( editor.getLdifModel(), document );
-
- // compare with current annotation model (--> toAdd, toDelete)
- List annotationsToDeleteList = new ArrayList();
- Map annotationsToAddMap = new HashMap();
- this.computeDifferences( projectionAnnotationModel, positionToAnnotationMap, annotationsToDeleteList,
- annotationsToAddMap );
- Annotation[] annotationsToDelete = ( Annotation[] ) annotationsToDeleteList
- .toArray( new Annotation[annotationsToDeleteList.size()] );
-
- // update annotation model
- if ( !annotationsToDeleteList.isEmpty() || !annotationsToAddMap.isEmpty() )
- {
- projectionAnnotationModel.modifyAnnotations( annotationsToDelete, annotationsToAddMap,
- new Annotation[0] );
- }
-
- }
- catch ( BadLocationException e )
- {
- e.printStackTrace();
- }
- }
-
-
- private void computeDifferences( ProjectionAnnotationModel model, Map positionToAnnotationMap,
- List annotationsToDeleteList, Map annotationsToAddMap )
- {
-
- for ( Iterator iter = model.getAnnotationIterator(); iter.hasNext(); )
- {
- Object annotation = iter.next();
- if ( annotation instanceof ProjectionAnnotation )
- {
- Position position = model.getPosition( ( Annotation ) annotation );
- if ( positionToAnnotationMap.containsKey( position ) )
- positionToAnnotationMap.remove( position );
- else
- annotationsToDeleteList.add( annotation );
- }
- }
-
- for ( Iterator iter = positionToAnnotationMap.keySet().iterator(); iter.hasNext(); )
- {
- Position position = ( Position ) iter.next();
- ProjectionAnnotation annotation = ( ProjectionAnnotation ) positionToAnnotationMap.get( position );
- annotationsToAddMap.put( annotation, position );
- }
- }
-
-
- /**
- * Creates all folding region of the given LDIF model.
- * LdifCommentContainers and wrapped lines are marked as collapsed.
- *
- * @param model
- * @param document
- * @return a map with positions as keys to annotations as values
- * @throws BadLocationException
- */
- private Map createFoldingRegions( LdifFile model, IDocument document ) throws BadLocationException
- {
- Map positionToAnnotationMap = new HashMap();
- LdifContainer[] containers = model.getContainers();
-
- boolean ENABLE_FOLDING = LdifEditorActivator.getDefault().getPreferenceStore().getBoolean(
- LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_ENABLE );
- boolean FOLD_COMMENTS = LdifEditorActivator.getDefault().getPreferenceStore().getBoolean(
- LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDCOMMENTS );
- boolean FOLD_RECORDS = LdifEditorActivator.getDefault().getPreferenceStore().getBoolean(
- LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDRECORDS );
- boolean FOLD_WRAPPEDLINES = LdifEditorActivator.getDefault().getPreferenceStore().getBoolean(
- LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDWRAPPEDLINES );
-
- if ( ENABLE_FOLDING )
- {
- for ( int i = 0; i < containers.length; i++ )
- {
- LdifContainer container = containers[i];
- int containerStartLine = document.getLineOfOffset( container.getOffset() );
- int containerEndLine = -1;
- LdifPart[] parts = container.getParts();
- for ( int j = parts.length - 1; j >= 0; j-- )
- {
- if ( containerEndLine == -1
- && ( !( parts[j] instanceof LdifSepLine ) || ( container instanceof LdifCommentContainer && j < parts.length - 1 ) ) )
- {
- containerEndLine = document.getLineOfOffset( parts[j].getOffset() + parts[j].getLength() - 1 );
- // break;
- }
- if ( parts[j] instanceof LdifNonEmptyLineBase )
- {
- LdifNonEmptyLineBase line = ( LdifNonEmptyLineBase ) parts[j];
- if ( line.isFolded() )
- {
- Position position = new Position( line.getOffset(), line.getLength() );
- // ProjectionAnnotation annotation = new
- // ProjectionAnnotation(true);
- ProjectionAnnotation annotation = new ProjectionAnnotation( FOLD_WRAPPEDLINES );
- positionToAnnotationMap.put( position, annotation );
- }
- }
- }
-
- if ( containerStartLine < containerEndLine )
- {
- int start = document.getLineOffset( containerStartLine );
- int end = document.getLineOffset( containerEndLine ) + document.getLineLength( containerEndLine );
- Position position = new Position( start, end - start );
- // ProjectionAnnotation annotation = new
- // ProjectionAnnotation(container instanceof
- // LdifCommentContainer);
- ProjectionAnnotation annotation = new ProjectionAnnotation( FOLD_RECORDS
- || ( FOLD_COMMENTS && container instanceof LdifCommentContainer ) );
- positionToAnnotationMap.put( position, annotation );
- }
- }
- }
-
- return positionToAnnotationMap;
- }
+// ISourceViewer viewer = ( ISourceViewer ) editor.getAdapter( ISourceViewer.class );
+// if ( viewer == null )
+// return;
+//
+// IDocument document = viewer.getDocument();
+//
+// try
+// {
+// ProjectionAnnotationModel projectionAnnotationModel = ( ProjectionAnnotationModel ) editor
+// .getAdapter( ProjectionAnnotationModel.class );
+// if ( projectionAnnotationModel == null )
+// return;
+//
+// // create folding regions of current LDIF model; mark comments
+// // and
+// // folded lines as collapsed
+// Map positionToAnnotationMap = createFoldingRegions( editor.getLdifModel(), document );
+//
+// // compare with current annotation model (--> toAdd, toDelete)
+// List annotationsToDeleteList = new ArrayList();
+// Map annotationsToAddMap = new HashMap();
+// this.computeDifferences( projectionAnnotationModel, positionToAnnotationMap, annotationsToDeleteList,
+// annotationsToAddMap );
+// Annotation[] annotationsToDelete = ( Annotation[] ) annotationsToDeleteList
+// .toArray( new Annotation[annotationsToDeleteList.size()] );
+//
+// // update annotation model
+// if ( !annotationsToDeleteList.isEmpty() || !annotationsToAddMap.isEmpty() )
+// {
+// projectionAnnotationModel.modifyAnnotations( annotationsToDelete, annotationsToAddMap,
+// new Annotation[0] );
+// }
+//
+// }
+// catch ( BadLocationException e )
+// {
+// e.printStackTrace();
+// }
+ }
+
+
+// private void computeDifferences( ProjectionAnnotationModel model, Map positionToAnnotationMap,
+// List annotationsToDeleteList, Map annotationsToAddMap )
+// {
+//
+// for ( Iterator iter = model.getAnnotationIterator(); iter.hasNext(); )
+// {
+// Object annotation = iter.next();
+// if ( annotation instanceof ProjectionAnnotation )
+// {
+// Position position = model.getPosition( ( Annotation ) annotation );
+// if ( positionToAnnotationMap.containsKey( position ) )
+// positionToAnnotationMap.remove( position );
+// else
+// annotationsToDeleteList.add( annotation );
+// }
+// }
+//
+// for ( Iterator iter = positionToAnnotationMap.keySet().iterator(); iter.hasNext(); )
+// {
+// Position position = ( Position ) iter.next();
+// ProjectionAnnotation annotation = ( ProjectionAnnotation ) positionToAnnotationMap.get( position );
+// annotationsToAddMap.put( annotation, position );
+// }
+// }
+//
+//
+// /**
+// * Creates all folding region of the given LDIF model.
+// * LdifCommentContainers and wrapped lines are marked as collapsed.
+// *
+// * @param model
+// * @param document
+// * @return a map with positions as keys to annotations as values
+// * @throws BadLocationException
+// */
+// private Map createFoldingRegions( LdifFile model, IDocument document ) throws BadLocationException
+// {
+// Map positionToAnnotationMap = new HashMap();
+// LdifContainer[] containers = model.getContainers();
+//
+// boolean ENABLE_FOLDING = LdifEditorActivator.getDefault().getPreferenceStore().getBoolean(
+// LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_ENABLE );
+// boolean FOLD_COMMENTS = LdifEditorActivator.getDefault().getPreferenceStore().getBoolean(
+// LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDCOMMENTS );
+// boolean FOLD_RECORDS = LdifEditorActivator.getDefault().getPreferenceStore().getBoolean(
+// LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDRECORDS );
+// boolean FOLD_WRAPPEDLINES = LdifEditorActivator.getDefault().getPreferenceStore().getBoolean(
+// LdifEditorConstants.PREFERENCE_LDIFEDITOR_FOLDING_INITIALLYFOLDWRAPPEDLINES );
+//
+// if ( ENABLE_FOLDING )
+// {
+// for ( int i = 0; i < containers.length; i++ )
+// {
+// LdifContainer container = containers[i];
+// int containerStartLine = document.getLineOfOffset( container.getOffset() );
+// int containerEndLine = -1;
+// LdifPart[] parts = container.getParts();
+// for ( int j = parts.length - 1; j >= 0; j-- )
+// {
+// if ( containerEndLine == -1
+// && ( !( parts[j] instanceof LdifSepLine ) || ( container instanceof LdifCommentContainer && j < parts.length - 1 ) ) )
+// {
+// containerEndLine = document.getLineOfOffset( parts[j].getOffset() + parts[j].getLength() - 1 );
+// // break;
+// }
+// if ( parts[j] instanceof LdifNonEmptyLineBase )
+// {
+// LdifNonEmptyLineBase line = ( LdifNonEmptyLineBase ) parts[j];
+// if ( line.isFolded() )
+// {
+// Position position = new Position( line.getOffset(), line.getLength() );
+// // ProjectionAnnotation annotation = new
+// // ProjectionAnnotation(true);
+// ProjectionAnnotation annotation = new ProjectionAnnotation( FOLD_WRAPPEDLINES );
+// positionToAnnotationMap.put( position, annotation );
+// }
+// }
+// }
+//
+// if ( containerStartLine < containerEndLine )
+// {
+// int start = document.getLineOffset( containerStartLine );
+// int end = document.getLineOffset( containerEndLine ) + document.getLineLength( containerEndLine );
+// Position position = new Position( start, end - start );
+// // ProjectionAnnotation annotation = new
+// // ProjectionAnnotation(container instanceof
+// // LdifCommentContainer);
+// ProjectionAnnotation annotation = new ProjectionAnnotation( FOLD_RECORDS
+// || ( FOLD_COMMENTS && container instanceof LdifCommentContainer ) );
+// positionToAnnotationMap.put( position, annotation );
+// }
+// }
+// }
+//
+// return positionToAnnotationMap;
+// }
}
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/reconciler/LdifReconcilingStrategy.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/reconciler/LdifReconcilingStrategy.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/reconciler/LdifReconcilingStrategy.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/reconciler/LdifReconcilingStrategy.java Fri Aug 20 17:07:19 2010
@@ -21,107 +21,6 @@
package org.apache.directory.studio.ldifeditor.editor.reconciler;
-import org.apache.directory.studio.ldifeditor.editor.ILdifEditor;
-import org.apache.directory.studio.ldifeditor.editor.LdifOutlinePage;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-public class LdifReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension
-{
-
- private ILdifEditor editor;
-
- // private IDocument document;
- // private IProgressMonitor progressMonitor;
-
- private LdifFoldingRegionUpdater foldingUpdater;
-
- private LdifAnnotationUpdater annotationUpdater;
-
-
- public LdifReconcilingStrategy( ILdifEditor editor )
- {
- this.editor = editor;
-
- this.annotationUpdater = new LdifAnnotationUpdater( this.editor );
- this.foldingUpdater = new LdifFoldingRegionUpdater( this.editor );
-
- }
-
-
- public void dispose()
- {
- this.annotationUpdater.dispose();
- this.foldingUpdater.dispose();
- }
-
-
- public void setDocument( IDocument document )
- {
- // this.document = document;
- }
-
-
- public void setProgressMonitor( IProgressMonitor monitor )
- {
- // this.progressMonitor = monitor;
- }
-
-
- public void reconcile( DirtyRegion dirtyRegion, IRegion subRegion )
- {
- reconcile();
- }
-
-
- public void reconcile( IRegion partition )
- {
- reconcile();
- }
-
-
- public void initialReconcile()
- {
- reconcile();
- }
-
-
- private void reconcile()
- {
- notifyEnvironment();
- }
-
-
- private void notifyEnvironment()
- {
-
- Display.getDefault().asyncExec( new Runnable()
- {
- public void run()
- {
-
- // notify outline
- IContentOutlinePage outline = ( IContentOutlinePage ) editor.getAdapter( IContentOutlinePage.class );
- if ( outline != null && outline instanceof LdifOutlinePage )
- {
- ( ( LdifOutlinePage ) outline ).refresh();
- }
-
- // notify annotation updater
- annotationUpdater.updateAnnotations();
-
- // notify folding updater
- foldingUpdater.updateFoldingRegions();
-
- }
- } );
- }
-
-}
+public class LdifReconcilingStrategy {}
\ No newline at end of file
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifAnnotationHover.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifAnnotationHover.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifAnnotationHover.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifAnnotationHover.java Fri Aug 20 17:07:19 2010
@@ -21,55 +21,6 @@
package org.apache.directory.studio.ldifeditor.editor.text;
-import org.apache.directory.studio.ldifeditor.editor.ILdifEditor;
-import org.apache.directory.studio.ldifparser.model.LdifFile;
-import org.apache.directory.studio.ldifparser.model.LdifPart;
-import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-public class LdifAnnotationHover implements IAnnotationHover
-{
-
- private ILdifEditor editor;
-
-
- public LdifAnnotationHover( ILdifEditor editor )
- {
- this.editor = editor;
- }
-
-
- public String getHoverInfo( ISourceViewer sourceViewer, int lineNumber )
- {
-
- try
- {
- if ( this.editor != null )
- {
-
- int offset = sourceViewer.getDocument().getLineOffset( lineNumber );
- LdifContainer container = LdifFile.getContainer( this.editor.getLdifModel(), offset );
- if ( container != null )
- {
- LdifPart part = LdifFile.getContainerContent( container, offset );
- if ( part != null )
- {
- // return container.getClass().getName() + " - " +
- // part.getClass().getName();
- return container.getInvalidString() + " - " + part.getInvalidString(); //$NON-NLS-1$
- }
- }
- }
- }
- catch ( BadLocationException e )
- {
- }
-
- return null;
- }
-
-}
+public class LdifAnnotationHover{}
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifAutoEditStrategy.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifAutoEditStrategy.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifAutoEditStrategy.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifAutoEditStrategy.java Fri Aug 20 17:07:19 2010
@@ -21,68 +21,8 @@
package org.apache.directory.studio.ldifeditor.editor.text;
-import org.apache.directory.studio.ldifeditor.LdifEditorActivator;
-import org.apache.directory.studio.ldifeditor.LdifEditorConstants;
-import org.apache.directory.studio.ldifeditor.editor.ILdifEditor;
-import org.apache.directory.studio.ldifparser.model.LdifFile;
-import org.apache.directory.studio.ldifparser.model.LdifPart;
-import org.apache.directory.studio.ldifparser.model.container.LdifChangeModifyRecord;
-import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
-import org.apache.directory.studio.ldifparser.model.container.LdifModSpec;
-import org.apache.directory.studio.ldifparser.model.lines.LdifAttrValLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifModSpecTypeLine;
-import org.eclipse.jface.text.DocumentCommand;
-import org.eclipse.jface.text.IAutoEditStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.TextUtilities;
-
-public class LdifAutoEditStrategy implements IAutoEditStrategy
-{
-
- private ILdifEditor editor;
-
-
- public LdifAutoEditStrategy( ILdifEditor editor )
- {
- this.editor = editor;
- }
-
-
- public void customizeDocumentCommand( IDocument d, DocumentCommand c )
- {
-
- LdifFile model = editor.getLdifModel();
- LdifContainer container = LdifFile.getContainer( model, c.offset );
- LdifContainer innerContainer = container != null ? LdifFile.getInnerContainer( container, c.offset ) : null;
- LdifPart part = container != null ? LdifFile.getContainerContent( container, c.offset ) : null;
-
- boolean smartInsertAttributeInModSpec = LdifEditorActivator.getDefault().getPreferenceStore().getBoolean(
- LdifEditorConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_SMARTINSERTATTRIBUTEINMODSPEC );
- if ( smartInsertAttributeInModSpec )
- {
- if ( c.length == 0 && c.text != null && TextUtilities.endsWith( d.getLegalLineDelimiters(), c.text ) != -1 )
- {
-
- if ( container instanceof LdifChangeModifyRecord && innerContainer instanceof LdifModSpec
- && ( part instanceof LdifAttrValLine || part instanceof LdifModSpecTypeLine ) )
- {
- LdifModSpec modSpec = ( LdifModSpec ) innerContainer;
- String att = modSpec.getModSpecType().getUnfoldedAttributeDescription();
- c.text += att + ": "; //$NON-NLS-1$
- }
- }
- }
-
- boolean autoWrap = LdifEditorActivator.getDefault().getPreferenceStore().getBoolean(
- LdifEditorConstants.PREFERENCE_LDIFEDITOR_FORMATTER_AUTOWRAP );
-
- if ( autoWrap )
- {
-
- }
-
- }
+public class LdifAutoEditStrategy {
}
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifCompletionProcessor.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifCompletionProcessor.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifCompletionProcessor.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifCompletionProcessor.java Fri Aug 20 17:07:19 2010
@@ -21,440 +21,7 @@
package org.apache.directory.studio.ldifeditor.editor.text;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
-import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
-import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
-import org.apache.directory.studio.ldifeditor.LdifEditorActivator;
-import org.apache.directory.studio.ldifeditor.LdifEditorConstants;
-import org.apache.directory.studio.ldifeditor.editor.ILdifEditor;
-import org.apache.directory.studio.ldifparser.model.LdifFile;
-import org.apache.directory.studio.ldifparser.model.LdifInvalidPart;
-import org.apache.directory.studio.ldifparser.model.LdifPart;
-import org.apache.directory.studio.ldifparser.model.container.LdifChangeAddRecord;
-import org.apache.directory.studio.ldifparser.model.container.LdifChangeModDnRecord;
-import org.apache.directory.studio.ldifparser.model.container.LdifChangeModifyRecord;
-import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
-import org.apache.directory.studio.ldifparser.model.container.LdifContentRecord;
-import org.apache.directory.studio.ldifparser.model.container.LdifInvalidContainer;
-import org.apache.directory.studio.ldifparser.model.container.LdifModSpec;
-import org.apache.directory.studio.ldifparser.model.container.LdifRecord;
-import org.apache.directory.studio.ldifparser.model.container.LdifSepContainer;
-import org.apache.directory.studio.ldifparser.model.lines.LdifAttrValLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifChangeTypeLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifSepLine;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.CompletionProposal;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateCompletionProcessor;
-import org.eclipse.jface.text.templates.TemplateContextType;
-import org.eclipse.swt.graphics.Image;
-
-
-public class LdifCompletionProcessor extends TemplateCompletionProcessor
-{
-
- // private final static String DN = "dn: ";
- private final static String CT_ADD = "changetype: add" + BrowserCoreConstants.LINE_SEPARATOR; //$NON-NLS-1$
-
- private final static String CT_MODIFY = "changetype: modify" + BrowserCoreConstants.LINE_SEPARATOR; //$NON-NLS-1$
-
- private final static String CT_DELETE = "changetype: delete" + BrowserCoreConstants.LINE_SEPARATOR; //$NON-NLS-1$
-
- private final static String CT_MODDN = "changetype: moddn" + BrowserCoreConstants.LINE_SEPARATOR; //$NON-NLS-1$
-
- private final static String MD_NEWRDN = "newrdn: "; //$NON-NLS-1$
-
- private final static String MD_DELETEOLDRDN_TRUE = "deleteoldrdn: 1"; //$NON-NLS-1$
-
- // private final static String MD_DELETEOLDRDN_FALSE = "deleteoldrdn:
- // 0";
- private final static String MD_NEWSUPERIOR = "newsuperior: "; //$NON-NLS-1$
-
- private final ILdifEditor editor;
-
- private final ContentAssistant contentAssistant;
-
-
- public LdifCompletionProcessor( ILdifEditor editor, ContentAssistant contentAssistant )
- {
- this.editor = editor;
- this.contentAssistant = contentAssistant;
- }
-
-
- public ICompletionProposal[] computeCompletionProposals( ITextViewer viewer, int offset )
- {
-
- IPreferenceStore store = LdifEditorActivator.getDefault().getPreferenceStore();
- contentAssistant.enableAutoInsert( store
- .getBoolean( LdifEditorConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_INSERTSINGLEPROPOSALAUTO ) );
- contentAssistant.enableAutoActivation( store
- .getBoolean( LdifEditorConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_ENABLEAUTOACTIVATION ) );
- contentAssistant.setAutoActivationDelay( store
- .getInt( LdifEditorConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_AUTOACTIVATIONDELAY ) );
-
- List<ICompletionProposal> proposalList = new ArrayList<ICompletionProposal>();
-
- LdifFile model = editor.getLdifModel();
- LdifContainer container = LdifFile.getContainer( model, offset );
- LdifContainer innerContainer = container != null ? LdifFile.getInnerContainer( container, offset ) : null;
- LdifPart part = container != null ? LdifFile.getContainerContent( container, offset ) : null;
- int documentLine = -1;
- int documentLineOffset = -1;
- String prefix = ""; //$NON-NLS-1$
- try
- {
- documentLine = viewer.getDocument().getLineOfOffset( offset );
- documentLineOffset = viewer.getDocument().getLineOffset( documentLine );
- prefix = viewer.getDocument().get( documentLineOffset, offset - documentLineOffset );
- }
- catch ( BadLocationException e )
- {
- }
- // TemplateContextType contextType = getContextType(viewer, new
- // Region(offset, 0));
-
- // Add context dependend template proposals
- ICompletionProposal[] templateProposals = super.computeCompletionProposals( viewer, offset );
- if ( templateProposals != null )
- {
- proposalList.addAll( Arrays.asList( templateProposals ) );
- }
-
- // changetype: xxx
- if ( container instanceof LdifRecord )
- {
- LdifRecord record = ( LdifRecord ) container;
- LdifPart[] parts = record.getParts();
- if ( parts.length > 1 && ( !( parts[1] instanceof LdifChangeTypeLine ) || !parts[1].isValid() ) )
- {
- if ( CT_ADD.startsWith( prefix ) )
- proposalList.add( new CompletionProposal( CT_ADD, offset - prefix.length(), prefix.length(), CT_ADD
- .length(), LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_ADD ),
- CT_ADD.substring( 0, CT_ADD.length() - BrowserCoreConstants.LINE_SEPARATOR.length() ), null,
- null ) );
- if ( CT_MODIFY.startsWith( prefix ) )
- proposalList.add( new CompletionProposal( CT_MODIFY, offset - prefix.length(), prefix.length(),
- CT_MODIFY.length(), LdifEditorActivator.getDefault().getImage(
- LdifEditorConstants.IMG_LDIF_MODIFY ), CT_MODIFY.substring( 0, CT_MODIFY.length()
- - BrowserCoreConstants.LINE_SEPARATOR.length() ), null, null ) );
- if ( CT_DELETE.startsWith( prefix ) )
- proposalList.add( new CompletionProposal( CT_DELETE, offset - prefix.length(), prefix.length(),
- CT_DELETE.length(), LdifEditorActivator.getDefault().getImage(
- LdifEditorConstants.IMG_LDIF_DELETE ), CT_DELETE.substring( 0, CT_DELETE.length()
- - BrowserCoreConstants.LINE_SEPARATOR.length() ), null, null ) );
- if ( CT_MODDN.startsWith( prefix ) )
- proposalList.add( new CompletionProposal( CT_MODDN, offset - prefix.length(), prefix.length(),
- CT_MODDN.length(), LdifEditorActivator.getDefault().getImage(
- LdifEditorConstants.IMG_LDIF_RENAME ), CT_MODDN.substring( 0, CT_MODDN.length()
- - BrowserCoreConstants.LINE_SEPARATOR.length() ), null, null ) );
- }
-
- }
-
- // changetype: modify
- if ( container instanceof LdifChangeModDnRecord )
- {
- LdifChangeModDnRecord record = ( LdifChangeModDnRecord ) container;
- if ( ( record.getNewrdnLine() == null || !record.getNewrdnLine().isValid() )
- && MD_NEWRDN.startsWith( prefix ) )
- {
- proposalList.add( new CompletionProposal( MD_NEWRDN, offset - prefix.length(), prefix.length(),
- MD_NEWRDN.length(), null, null, null, null ) );
- }
- if ( ( record.getDeloldrdnLine() == null || !record.getDeloldrdnLine().isValid() )
- && MD_DELETEOLDRDN_TRUE.startsWith( prefix ) )
- {
- proposalList.add( new CompletionProposal( MD_DELETEOLDRDN_TRUE, offset - prefix.length(), prefix
- .length(), MD_DELETEOLDRDN_TRUE.length(), null, null, null, null ) );
- }
- if ( ( record.getNewsuperiorLine() == null || !record.getNewsuperiorLine().isValid() )
- && MD_NEWSUPERIOR.startsWith( prefix ) )
- {
- proposalList.add( new CompletionProposal( MD_NEWSUPERIOR, offset - prefix.length(), prefix.length(),
- MD_NEWSUPERIOR.length(), null, null, null, null ) );
- }
- }
-
- // modspecs
- if ( innerContainer instanceof LdifModSpec )
- {
- LdifModSpec modSpec = ( LdifModSpec ) innerContainer;
- String att = modSpec.getModSpecType().getRawAttributeDescription();
- if ( att != null && att.startsWith( prefix ) )
- {
- proposalList.add( new CompletionProposal( att, offset - prefix.length(), prefix.length(), att.length(),
- null, null, null, null ) );
- }
- }
-
- // attribute descriptions
- if ( container instanceof LdifContentRecord || container instanceof LdifChangeAddRecord )
- {
-
- if ( part instanceof LdifInvalidPart
- || part instanceof LdifAttrValLine
- || ( part instanceof LdifSepLine && ( container instanceof LdifContentRecord || container instanceof LdifChangeAddRecord ) ) )
- {
-
- String rawAttributeDescription = prefix;
- String rawValueType = ""; //$NON-NLS-1$
-
- if ( part instanceof LdifAttrValLine )
- {
- LdifAttrValLine line = ( LdifAttrValLine ) part;
- rawAttributeDescription = line.getRawAttributeDescription();
- rawValueType = line.getRawValueType();
- }
-
- if ( offset <= part.getOffset() + rawAttributeDescription.length() )
- {
- Schema schema = editor.getConnection() != null ? editor.getConnection().getSchema()
- : Schema.DEFAULT_SCHEMA;
- String[] attributeNames = SchemaUtils.getNamesAsArray( schema.getAttributeTypeDescriptions() );
- Arrays.sort( attributeNames );
- for ( String attributeName : attributeNames )
- {
- if ( rawAttributeDescription.length() == 0
- || attributeName.toLowerCase().startsWith( rawAttributeDescription.toLowerCase() ) )
- {
-
- String proposal = attributeName;
-
- if ( rawValueType.length() == 0 )
- {
- if ( SchemaUtils.isBinary( schema.getAttributeTypeDescription( proposal ), schema ) )
- {
- proposal += ":: "; //$NON-NLS-1$
- }
- else
- {
- proposal += ": "; //$NON-NLS-1$
- }
- }
-
- proposalList
- .add( new CompletionProposal( proposal, offset - rawAttributeDescription.length(),
- rawAttributeDescription.length(), proposal.length() ) );
- }
- }
- }
- }
- }
-
- // comment
- boolean commentOnly = false;
- if ( documentLineOffset == offset )
- {
- commentOnly = proposalList.isEmpty();
- proposalList.add( new CompletionProposal( "# ", offset, 0, 2, LdifEditorActivator.getDefault().getImage( //$NON-NLS-1$
- LdifEditorConstants.IMG_LDIF_COMMENT ), "# - Comment", null, null ) ); //$NON-NLS-1$
- }
-
- // adjust auto-insert
- this.contentAssistant.enableAutoInsert( !commentOnly );
-
- ICompletionProposal[] proposals = ( ICompletionProposal[] ) proposalList.toArray( new ICompletionProposal[0] );
- return proposals;
-
- }
-
-
- protected String extractPrefix( ITextViewer viewer, int offset )
- {
-
- IDocument document = viewer.getDocument();
- if ( offset > document.getLength() )
- return ""; //$NON-NLS-1$
-
- try
- {
- int documentLine = viewer.getDocument().getLineOfOffset( offset );
- int documentLineOffset = viewer.getDocument().getLineOffset( documentLine );
- String prefix = viewer.getDocument().get( documentLineOffset, offset - documentLineOffset );
- return prefix;
- }
- catch ( BadLocationException e )
- {
- return ""; //$NON-NLS-1$
- }
- }
-
-
- public IContextInformation[] computeContextInformation( ITextViewer viewer, int offset )
- {
- return null;
- }
-
-
- public char[] getCompletionProposalAutoActivationCharacters()
- {
-
- char[] chars = new char[53];
- for ( int i = 0; i < 26; i++ )
- chars[i] = ( char ) ( 'a' + i );
- for ( int i = 0; i < 26; i++ )
- chars[i + 26] = ( char ) ( 'A' + i );
- chars[52] = ':';
-
- return chars;
- }
-
-
- public char[] getContextInformationAutoActivationCharacters()
- {
- return null;
- }
-
-
- public String getErrorMessage()
- {
- return null;
- }
-
-
- public IContextInformationValidator getContextInformationValidator()
- {
- return null;
- }
-
-
- protected Template[] getTemplates( String contextTypeId )
- {
- Template[] templates = LdifEditorActivator.getDefault().getLdifTemplateStore().getTemplates( contextTypeId );
- return templates;
- }
-
-
- protected TemplateContextType getContextType( ITextViewer viewer, IRegion region )
- {
-
- int offset = region.getOffset();
-
- LdifFile model = editor.getLdifModel();
- LdifContainer container = LdifFile.getContainer( model, offset );
- LdifContainer innerContainer = container != null ? LdifFile.getInnerContainer( container, offset ) : null;
- LdifPart part = container != null ? LdifFile.getContainerContent( container, offset ) : null;
- int documentLine = -1;
- int documentLineOffset = -1;
- String prefix = ""; //$NON-NLS-1$
- try
- {
- documentLine = viewer.getDocument().getLineOfOffset( offset );
- documentLineOffset = viewer.getDocument().getLineOffset( documentLine );
- prefix = viewer.getDocument().get( documentLineOffset, offset - documentLineOffset );
- }
- catch ( BadLocationException e )
- {
- }
-
- // FILE
- if ( container == null && innerContainer == null && part == null )
- {
- return LdifEditorActivator.getDefault().getLdifTemplateContextTypeRegistry().getContextType(
- LdifEditorConstants.LDIF_FILE_TEMPLATE_ID );
- }
- if ( container instanceof LdifSepContainer && innerContainer == null && part instanceof LdifSepLine )
- {
- return LdifEditorActivator.getDefault().getLdifTemplateContextTypeRegistry().getContextType(
- LdifEditorConstants.LDIF_FILE_TEMPLATE_ID );
- }
- if ( ( container instanceof LdifInvalidContainer && part instanceof LdifInvalidPart && "d".equals( prefix ) ) //$NON-NLS-1$
- || ( container instanceof LdifContentRecord && part instanceof LdifInvalidPart && "dn".equals( prefix ) ) //$NON-NLS-1$
- || ( container instanceof LdifContentRecord && part instanceof LdifInvalidPart && "dn:".equals( prefix ) ) ) //$NON-NLS-1$
- {
- return LdifEditorActivator.getDefault().getLdifTemplateContextTypeRegistry().getContextType(
- LdifEditorConstants.LDIF_FILE_TEMPLATE_ID );
- }
-
- // MODIFICATION RECORD
- if ( container instanceof LdifChangeModifyRecord && innerContainer == null
- && ( part instanceof LdifSepLine || part instanceof LdifInvalidPart ) )
- {
- return LdifEditorActivator.getDefault().getLdifTemplateContextTypeRegistry().getContextType(
- LdifEditorConstants.LDIF_MODIFICATION_RECORD_TEMPLATE_ID );
- }
-
- // MODIFICATION ITEM
- if ( container instanceof LdifChangeModifyRecord && innerContainer instanceof LdifModSpec )
- {
- return LdifEditorActivator.getDefault().getLdifTemplateContextTypeRegistry().getContextType(
- LdifEditorConstants.LDIF_MODIFICATION_ITEM_TEMPLATE_ID );
- }
-
- // MODDN RECORD
- if ( container instanceof LdifChangeModDnRecord && innerContainer == null
- && ( part instanceof LdifSepLine || part instanceof LdifInvalidPart ) )
- {
- return LdifEditorActivator.getDefault().getLdifTemplateContextTypeRegistry().getContextType(
- LdifEditorConstants.LDIF_MODDN_RECORD_TEMPLATE_ID );
- }
-
- // TemplateContextType contextType =
- // Activator.getDefault().getContextTypeRegistry().getContextType(LdifEditorConstants.LDIF_FILE_TEMPLATE_ID);
- // TemplateContextType contextType =
- // Activator.getDefault().getContextTypeRegistry().getContextType(LdifEditorConstants.LDIF_MODIFICATION_RECORD_TEMPLATE_ID);
-
- return null;
-
- }
-
-
- protected Image getImage( Template template )
- {
-
- if ( template.getPattern().indexOf( "add: " ) > -1 ) //$NON-NLS-1$
- {
- return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_MOD_ADD );
- }
- else if ( template.getPattern().indexOf( "replace: " ) > -1 ) //$NON-NLS-1$
- {
- return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_MOD_REPLACE );
- }
- else if ( template.getPattern().indexOf( "delete: " ) > -1 ) //$NON-NLS-1$
- {
- return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_MOD_DELETE );
- }
-
- else if ( template.getPattern().indexOf( "changetype: add" ) > -1 ) //$NON-NLS-1$
- {
- return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_ADD );
- }
- else if ( template.getPattern().indexOf( "changetype: modify" ) > -1 ) //$NON-NLS-1$
- {
- return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_MODIFY );
- }
- else if ( template.getPattern().indexOf( "changetype: delete" ) > -1 ) //$NON-NLS-1$
- {
- return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_DELETE );
- }
- else if ( template.getPattern().indexOf( "changetype: moddn" ) > -1 ) //$NON-NLS-1$
- {
- return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_RENAME );
- }
- else if ( template.getPattern().indexOf( "dn: " ) > -1 ) //$NON-NLS-1$
- {
- return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_ENTRY );
- }
-
- else
- {
- return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_TEMPLATE );
- }
-
- }
+public class LdifCompletionProcessor {
}
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifDamagerRepairer.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifDamagerRepairer.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifDamagerRepairer.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifDamagerRepairer.java Fri Aug 20 17:07:19 2010
@@ -21,400 +21,8 @@
package org.apache.directory.studio.ldifeditor.editor.text;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.directory.studio.ldifeditor.LdifEditorActivator;
-import org.apache.directory.studio.ldifeditor.LdifEditorConstants;
-import org.apache.directory.studio.ldifeditor.editor.ILdifEditor;
-import org.apache.directory.studio.ldifparser.model.LdifEOFPart;
-import org.apache.directory.studio.ldifparser.model.LdifFile;
-import org.apache.directory.studio.ldifparser.model.LdifInvalidPart;
-import org.apache.directory.studio.ldifparser.model.LdifPart;
-import org.apache.directory.studio.ldifparser.model.container.LdifChangeAddRecord;
-import org.apache.directory.studio.ldifparser.model.container.LdifChangeDeleteRecord;
-import org.apache.directory.studio.ldifparser.model.container.LdifChangeModDnRecord;
-import org.apache.directory.studio.ldifparser.model.container.LdifChangeModifyRecord;
-import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
-import org.apache.directory.studio.ldifparser.model.container.LdifModSpec;
-import org.apache.directory.studio.ldifparser.model.lines.LdifAttrValLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifChangeTypeLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifCommentLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifControlLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifDeloldrdnLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifDnLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifLineBase;
-import org.apache.directory.studio.ldifparser.model.lines.LdifModSpecSepLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifModSpecTypeLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifNewrdnLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifNewsuperiorLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifVersionLine;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.presentation.IPresentationDamager;
-import org.eclipse.jface.text.presentation.IPresentationRepairer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-
-
-public class LdifDamagerRepairer implements IPresentationDamager, IPresentationRepairer
-{
-
- private ILdifEditor editor;
-
-
- // private IDocument document;
-
- public LdifDamagerRepairer( ILdifEditor editor )
- {
- super();
- this.editor = editor;
- // this.document = null;
- }
-
-
- public void setDocument( IDocument document )
- {
- // this.document = document;
- }
-
-
- public IRegion getDamageRegion( ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged )
- {
- return partition;
- }
-
-
- public void createPresentation( TextPresentation presentation, ITypedRegion damage )
- {
-
- LdifFile ldifModel = this.editor.getLdifModel();
- LdifContainer[] allContainers = ldifModel.getContainers();
- List containerList = new ArrayList();
- for ( int i = 0; i < allContainers.length; i++ )
- {
- LdifContainer container = allContainers[i];
- Region containerRegion = new Region( container.getOffset(), container.getLength() );
- if ( TextUtilities.overlaps( containerRegion, damage ) )
- {
- containerList.add( container );
- }
- }
- LdifContainer[] containers = ( LdifContainer[] ) containerList
- .toArray( new LdifContainer[containerList.size()] );
- this.highlight( containers, presentation, damage );
-
- // LdifFile ldifModel = this.editor.getLdifModel();
- // System.out.println(ldifModel.toRawString());
- // LdifContainer[] allContainers = ldifModel.getContainers();
- // this.highlight(allContainers, presentation, null);
-
- }
-
- private Map textAttributeKeyToValueMap;
-
-
- private TextAttribute geTextAttribute( String key )
- {
- IPreferenceStore store = LdifEditorActivator.getDefault().getPreferenceStore();
-
- RGB rgb = PreferenceConverter.getColor( store, key
- + LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_RGB_SUFFIX );
- int style = store.getInt( key + LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_STYLE_SUFFIX );
-
- if ( textAttributeKeyToValueMap != null )
- {
- if ( textAttributeKeyToValueMap.containsKey( key
- + LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_RGB_SUFFIX ) )
- {
- rgb = ( RGB ) textAttributeKeyToValueMap.get( key
- + LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_RGB_SUFFIX );
- }
- if ( textAttributeKeyToValueMap.containsKey( key
- + LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_STYLE_SUFFIX ) )
- {
- style = ( ( Integer ) textAttributeKeyToValueMap.get( key
- + LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_STYLE_SUFFIX ) ).intValue();
- }
- }
-
- Color color = LdifEditorActivator.getDefault().getColor( rgb );
- TextAttribute textAttribute = new TextAttribute( color, null, style );
- return textAttribute;
- }
-
-
- /**
- * Overwrites the style set in preference store
- *
- * @param key
- * the key
- * LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_xxx +
- * LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_RGB_SUFFIX
- * ore
- * LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_STYLE_SUFFIX
- * @param newValue
- * RGB object or Integer object
- */
- public void setTextAttribute( String key, RGB rgb, int style )
- {
- if ( textAttributeKeyToValueMap == null )
- {
- textAttributeKeyToValueMap = new HashMap();
- }
- textAttributeKeyToValueMap.put( key + LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_RGB_SUFFIX, rgb );
- textAttributeKeyToValueMap.put( key + LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_STYLE_SUFFIX,
- new Integer( style ) );
- }
-
-
- private void highlight( LdifContainer[] containers, TextPresentation presentation, ITypedRegion damage )
- {
-
- // TextAttribute DEFAULT_TEXT_ATTRIBUTE = new
- // TextAttribute(Activator.getDefault().getColor(new RGB(0, 0,
- // 0)));
-
- TextAttribute COMMENT_TEXT_ATTRIBUTE = geTextAttribute( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_COMMENT );
- TextAttribute KEYWORD_TEXT_ATTRIBUTE = geTextAttribute( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_KEYWORD );
- TextAttribute DN_TEXT_ATTRIBUTE = geTextAttribute( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_DN );
- TextAttribute ATTRIBUTE_TEXT_ATTRIBUTE = geTextAttribute( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_ATTRIBUTE );
- TextAttribute VALUETYPE_TEXT_ATTRIBUTE = geTextAttribute( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_VALUETYPE );
- TextAttribute VALUE_TEXT_ATTRIBUTE = geTextAttribute( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_VALUE );
- TextAttribute ADD_TEXT_ATTRIBUTE = geTextAttribute( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_CHANGETYPEADD );
- TextAttribute MODIFY_TEXT_ATTRIBUTE = geTextAttribute( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_CHANGETYPEMODIFY );
- TextAttribute DELETE_TEXT_ATTRIBUTE = geTextAttribute( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_CHANGETYPEDELETE );
- TextAttribute MODDN_TEXT_ATTRIBUTE = geTextAttribute( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_CHANGETYPEMODDN );
-
- for ( int z = 0; z < containers.length; z++ )
- {
-
- LdifContainer container = containers[z];
-
- LdifPart[] parts = container.getParts();
-
- for ( int i = 0; i < parts.length; i++ )
- {
-
- // int offset = damage.getOffset() + parts[i].getOffset();
- int offset = parts[i].getOffset();
-
- if ( parts[i] instanceof LdifLineBase )
- {
- LdifLineBase line = ( LdifLineBase ) parts[i];
-
- // String debug = line.getClass().getName() +
- // "("+line.getOffset()+","+line.getLength()+"):
- // "+line.toString();
- // debug = debug.replaceAll("\n", "\\\\n");
- // debug = debug.replaceAll("\r", "\\\\r");
- // System.out.println(debug);
-
- if ( line instanceof LdifVersionLine )
- {
- this.addStyleRange( presentation, offset, line.getLength(), KEYWORD_TEXT_ATTRIBUTE );
- }
- else if ( line instanceof LdifCommentLine )
- {
- this.addStyleRange( presentation, offset, line.getLength(), COMMENT_TEXT_ATTRIBUTE );
- }
- else if ( line instanceof LdifDnLine )
- {
- LdifDnLine dnLine = ( LdifDnLine ) line;
- int dnSpecLength = dnLine.getRawDnSpec().length();
- int valueTypeLength = dnLine.getRawValueType().length();
- int dnLength = dnLine.getRawDn().length();
- this.addStyleRange( presentation, offset, dnSpecLength, DN_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + dnSpecLength, valueTypeLength,
- VALUETYPE_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + dnSpecLength + valueTypeLength, dnLength,
- DN_TEXT_ATTRIBUTE );
- }
- else if ( line instanceof LdifAttrValLine )
- {
- LdifAttrValLine attrValLine = ( LdifAttrValLine ) line;
- int attributeNameLength = attrValLine.getRawAttributeDescription().length();
- int valueTypeLength = attrValLine.getRawValueType().length();
- int valueLength = attrValLine.getRawValue().length();
- this.addStyleRange( presentation, offset, attributeNameLength, ATTRIBUTE_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + attributeNameLength, valueTypeLength,
- VALUETYPE_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + attributeNameLength + valueTypeLength, valueLength,
- VALUE_TEXT_ATTRIBUTE );
- }
- else if ( line instanceof LdifChangeTypeLine )
- {
- LdifChangeTypeLine changeTypeLine = ( LdifChangeTypeLine ) line;
- int changeTypeSpecLength = changeTypeLine.getRawChangeTypeSpec().length();
- int valueTypeLength = changeTypeLine.getRawValueType().length();
- int changeTypeLength = changeTypeLine.getRawChangeType().length();
- this.addStyleRange( presentation, offset, changeTypeSpecLength, KEYWORD_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + changeTypeSpecLength, valueTypeLength,
- VALUETYPE_TEXT_ATTRIBUTE );
-
- if ( container instanceof LdifChangeAddRecord )
- {
- this.addStyleRange( presentation, offset + changeTypeSpecLength + valueTypeLength,
- changeTypeLength, ADD_TEXT_ATTRIBUTE );
- }
- else if ( container instanceof LdifChangeModifyRecord )
- {
- this.addStyleRange( presentation, offset + changeTypeSpecLength + valueTypeLength,
- changeTypeLength, MODIFY_TEXT_ATTRIBUTE );
- }
- else if ( container instanceof LdifChangeModDnRecord )
- {
- this.addStyleRange( presentation, offset + changeTypeSpecLength + valueTypeLength,
- changeTypeLength, MODDN_TEXT_ATTRIBUTE );
- }
- else if ( container instanceof LdifChangeDeleteRecord )
- {
- this.addStyleRange( presentation, offset + changeTypeSpecLength + valueTypeLength,
- changeTypeLength, DELETE_TEXT_ATTRIBUTE );
- }
- }
- else if ( line instanceof LdifNewrdnLine )
- {
- LdifNewrdnLine newrdnLine = ( LdifNewrdnLine ) line;
- int newrdnSpecLength = newrdnLine.getRawNewrdnSpec().length();
- int valueTypeLength = newrdnLine.getRawValueType().length();
- int newrdnLength = newrdnLine.getRawNewrdn().length();
- this.addStyleRange( presentation, offset, newrdnSpecLength, KEYWORD_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + newrdnSpecLength, valueTypeLength,
- VALUETYPE_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + newrdnSpecLength + valueTypeLength, newrdnLength,
- VALUE_TEXT_ATTRIBUTE );
- }
- else if ( line instanceof LdifDeloldrdnLine )
- {
- LdifDeloldrdnLine deleteoldrdnLine = ( LdifDeloldrdnLine ) line;
- int deleteoldrdnSpecLength = deleteoldrdnLine.getRawDeleteOldrdnSpec().length();
- int valueTypeLength = deleteoldrdnLine.getRawValueType().length();
- int deleteoldrdnLength = deleteoldrdnLine.getRawDeleteOldrdn().length();
- this.addStyleRange( presentation, offset, deleteoldrdnSpecLength, KEYWORD_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + deleteoldrdnSpecLength, valueTypeLength,
- VALUETYPE_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + deleteoldrdnSpecLength + valueTypeLength,
- deleteoldrdnLength, VALUE_TEXT_ATTRIBUTE );
- }
- else if ( line instanceof LdifNewsuperiorLine )
- {
- LdifNewsuperiorLine newsuperiorLine = ( LdifNewsuperiorLine ) line;
- int newsuperiorSpecLength = newsuperiorLine.getRawNewSuperiorSpec().length();
- int valueTypeLength = newsuperiorLine.getRawValueType().length();
- int newsuperiorLength = newsuperiorLine.getRawNewSuperiorDn().length();
- this.addStyleRange( presentation, offset, newsuperiorSpecLength, KEYWORD_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + newsuperiorSpecLength, valueTypeLength,
- VALUETYPE_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + newsuperiorSpecLength + valueTypeLength,
- newsuperiorLength, VALUE_TEXT_ATTRIBUTE );
- }
- // else if(line instanceof LdifDeloldrdnLine) {
- // this.addStyleRange(presentation, offset,
- // line.getLength(), MODTYPE_TEXT_ATTRIBUTE);
- // }
- // else if(line instanceof LdifNewsuperiorLine) {
- // this.addStyleRange(presentation, offset,
- // line.getLength(), MODTYPE_TEXT_ATTRIBUTE);
- // }
- else if ( line instanceof LdifModSpecTypeLine )
- {
- LdifModSpecTypeLine modSpecTypeLine = ( LdifModSpecTypeLine ) line;
- int modTypeLength = modSpecTypeLine.getRawModType().length();
- int valueTypeLength = modSpecTypeLine.getRawValueType().length();
- int attributeDescriptionLength = modSpecTypeLine.getRawAttributeDescription().length();
- this.addStyleRange( presentation, offset, modTypeLength, KEYWORD_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + modTypeLength, valueTypeLength,
- VALUETYPE_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + modTypeLength + valueTypeLength,
- attributeDescriptionLength, ATTRIBUTE_TEXT_ATTRIBUTE );
- }
- else if ( line instanceof LdifModSpecSepLine )
- {
- this.addStyleRange( presentation, offset, line.getLength(), VALUETYPE_TEXT_ATTRIBUTE );
- }
- else if ( line instanceof LdifControlLine )
- {
- LdifControlLine controlLine = ( LdifControlLine ) line;
- int controlSpecLength = controlLine.getRawControlSpec().length();
- int controlTypeLength = controlLine.getRawControlType().length();
- int oidLength = controlLine.getRawOid().length();
- int critLength = controlLine.getRawCriticality().length();
- int valueTypeLength = controlLine.getRawControlValueType().length();
- int valueLength = controlLine.getRawControlValue().length();
- this.addStyleRange( presentation, offset, controlSpecLength, KEYWORD_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + controlSpecLength, controlTypeLength,
- VALUETYPE_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + controlSpecLength + controlTypeLength, oidLength,
- ATTRIBUTE_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + controlSpecLength + controlTypeLength + oidLength,
- critLength, KEYWORD_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + controlSpecLength + controlTypeLength + oidLength
- + critLength, valueTypeLength, VALUETYPE_TEXT_ATTRIBUTE );
- this.addStyleRange( presentation, offset + controlSpecLength + controlTypeLength + oidLength
- + critLength + valueTypeLength, valueLength, VALUE_TEXT_ATTRIBUTE );
- }
- else
- {
- // this.addStyleRange(presentation, offset,
- // line.getLength(), DEFAULT_TEXT_ATTRIBUTE);
- }
- }
- else if ( parts[i] instanceof LdifModSpec )
- {
- LdifModSpec modSpec = ( LdifModSpec ) parts[i];
- this.highlight( new LdifContainer[]
- { modSpec }, presentation, damage );
-
- }
- else if ( parts[i] instanceof LdifInvalidPart )
- {
- // LdifUnknownPart unknownPart =
- // (LdifUnknownPart)parts[i];
- // this.addStyleRange(presentation, offset,
- // unknownPart.getLength(), UNKNOWN_TEXT_ATTRIBUTE);
- // this.addStyleRange(presentation, offset,
- // parts[i].getLength(), DEFAULT_TEXT_ATTRIBUTE);
- }
- else if ( parts[i] instanceof LdifEOFPart )
- {
- // ignore
- }
- else
- {
- // TODO
- System.out.println( "LdifDamagerRepairer: Unspecified Token: " + parts[i].getClass() ); //$NON-NLS-1$
- }
-
- }
- }
-
- }
-
-
- private void addStyleRange( TextPresentation presentation, int offset, int length, TextAttribute textAttribute )
- {
- if ( offset >= 0 && length > 0 )
- {
- StyleRange range = new StyleRange( offset, length, textAttribute.getForeground(), textAttribute
- .getBackground(), textAttribute.getStyle() & ( SWT.BOLD | SWT.ITALIC ) );
- range.underline = ( textAttribute.getStyle() & TextAttribute.UNDERLINE ) != 0;
- range.strikeout = ( textAttribute.getStyle() & TextAttribute.STRIKETHROUGH ) != 0;
- presentation.addStyleRange( range );
- }
- }
+public class LdifDamagerRepairer {
}
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifDoubleClickStrategy.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifDoubleClickStrategy.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifDoubleClickStrategy.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifDoubleClickStrategy.java Fri Aug 20 17:07:19 2010
@@ -21,137 +21,7 @@
package org.apache.directory.studio.ldifeditor.editor.text;
-import org.apache.directory.studio.ldifeditor.LdifEditorActivator;
-import org.apache.directory.studio.ldifeditor.LdifEditorConstants;
-import org.apache.directory.studio.ldifparser.model.LdifEOFPart;
-import org.apache.directory.studio.ldifparser.model.LdifFile;
-import org.apache.directory.studio.ldifparser.model.LdifInvalidPart;
-import org.apache.directory.studio.ldifparser.model.LdifPart;
-import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
-import org.apache.directory.studio.ldifparser.model.lines.LdifLineBase;
-import org.apache.directory.studio.ldifparser.model.lines.LdifSepLine;
-import org.apache.directory.studio.ldifparser.model.lines.LdifValueLineBase;
-import org.apache.directory.studio.ldifparser.parser.LdifParser;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultTextDoubleClickStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextDoubleClickStrategy;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITypedRegion;
-
-
-public class LdifDoubleClickStrategy implements ITextDoubleClickStrategy
-{
-
- private static final int OFFSET = 0;
-
- private static final int LENGTH = 1;
-
- /**
- * Default double click strategy
- */
- private DefaultTextDoubleClickStrategy delegateDoubleClickStrategy;
-
-
- public LdifDoubleClickStrategy()
- {
- this.delegateDoubleClickStrategy = new DefaultTextDoubleClickStrategy();
- }
-
-
- public void doubleClicked( ITextViewer viewer )
- {
-
- if ( !LdifEditorActivator.getDefault().getPreferenceStore().getBoolean(
- LdifEditorConstants.PREFERENCE_LDIFEDITOR_DOUBLECLICK_USELDIFDOUBLECLICK ) )
- {
- delegateDoubleClickStrategy.doubleClicked( viewer );
- }
- else
- {
-
- int cursorPos = viewer.getSelectedRange().x;
- if ( cursorPos < 0 )
- {
- return;
- }
-
- try
- {
- LdifParser parser = new LdifParser();
- IDocument document = viewer.getDocument();
- ITypedRegion partition = document.getPartition( cursorPos );
-
- // now use position relative to partition
- int offset = partition.getOffset();
- int relativePos = cursorPos - offset;
-
- // parse partition
- String s = document.get( partition.getOffset(), partition.getLength() );
- LdifFile model = parser.parse( s );
- LdifContainer container = LdifFile.getContainer( model, relativePos );
- if ( container != null )
- {
- LdifPart part = LdifFile.getContainerContent( container, relativePos );
-
- if ( part != null && !( part instanceof LdifSepLine ) && !( part instanceof LdifInvalidPart )
- && !( part instanceof LdifEOFPart ) )
- {
-
- // calculate selected range
- int[] range = null;
- if ( part instanceof LdifValueLineBase )
- {
- LdifValueLineBase line = ( LdifValueLineBase ) part;
- range = getRange( relativePos, part.getOffset(), new String[]
- { line.getRawLineStart(), line.getRawValueType(), line.getRawValue() } );
- }
- else if ( part instanceof LdifLineBase )
- {
- LdifLineBase line = ( LdifLineBase ) part;
- range = new int[]
- { part.getOffset(), part.getLength() - line.getRawNewLine().length() };
- }
-
- // set range on viewer, add global offset
- int start = range != null ? range[OFFSET] : part.getOffset();
- start += offset;
- int length = range != null ? range[LENGTH] : part.getLength();
- viewer.setSelectedRange( start, length );
- }
- else
- {
- // use default double click strategy
- delegateDoubleClickStrategy.doubleClicked( viewer );
- }
- }
-
- }
- catch ( BadLocationException e )
- {
- e.printStackTrace();
- }
- }
- }
-
-
- private int[] getRange( int pos, int offset, String[] parts )
- {
-
- for ( int i = 0; i < parts.length; i++ )
- {
- if ( parts[i] != null )
- {
- if ( pos < offset + parts[i].length() )
- {
- return new int[]
- { offset, parts[i].length() };
- }
- offset += parts[i].length();
- }
- }
- return null;
- }
+public class LdifDoubleClickStrategy {
}
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifExternalAnnotationModel.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifExternalAnnotationModel.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifExternalAnnotationModel.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifExternalAnnotationModel.java Fri Aug 20 17:07:19 2010
@@ -21,10 +21,9 @@
package org.apache.directory.studio.ldifeditor.editor.text;
-import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
-public class LdifExternalAnnotationModel extends ProjectionAnnotationModel
+public class LdifExternalAnnotationModel
{
}
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifPartitionScanner.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifPartitionScanner.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifPartitionScanner.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifPartitionScanner.java Fri Aug 20 17:07:19 2010
@@ -21,37 +21,7 @@
package org.apache.directory.studio.ldifeditor.editor.text;
-import org.eclipse.jface.text.rules.IPredicateRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
-import org.eclipse.jface.text.rules.Token;
-public class LdifPartitionScanner extends RuleBasedPartitionScanner
-{
-
- public final static String LDIF_RECORD = "__ldif_record"; //$NON-NLS-1$
-
-
- public LdifPartitionScanner()
- {
- IToken record = new Token( LDIF_RECORD );
-
- IPredicateRule[] rules = new IPredicateRule[1];
- rules[0] = new LdifRecordRule( record );
-
- setPredicateRules( rules );
- }
-
-
- public int read()
- {
- return super.read();
- // try {
- // return super.read();
- // } finally {
- // fColumn = UNDEFINED;
- // }
- }
-
+public class LdifPartitionScanner {
}
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifRecordRule.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifRecordRule.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifRecordRule.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifRecordRule.java Fri Aug 20 17:07:19 2010
@@ -21,10 +21,6 @@
package org.apache.directory.studio.ldifeditor.editor.text;
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IPredicateRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.Token;
/**
@@ -33,190 +29,5 @@ import org.eclipse.jface.text.rules.Toke
*
*
*/
-public class LdifRecordRule implements IPredicateRule
-{
-
- private static char[] DN_SEQUENCE = new char[]
- { 'd', 'n', ':' };
-
- private IToken recordToken;
-
-
- public LdifRecordRule( IToken recordToken )
- {
- this.recordToken = recordToken;
- }
-
-
- public IToken getSuccessToken()
- {
- return this.recordToken;
- }
-
-
- /**
- * Checks for new line "\n", "\r" or "\r\n".
- *
- * @param scanner
- * @return
- */
- private int matchNewline( ICharacterScanner scanner )
- {
-
- int c = scanner.read();
-
- if ( c == '\r' )
- {
- c = scanner.read();
- if ( c == '\n' )
- {
- return 2;
- }
- else
- {
- scanner.unread();
- return 1;
- }
- }
- else if ( c == '\n' )
- {
- c = scanner.read();
- if ( c == '\r' )
- {
- return 2;
- }
- else
- {
- scanner.unread();
- return 1;
- }
- }
- else
- {
- scanner.unread();
- return 0;
- }
- }
-
-
- /**
- * Checks for "dn:".
- *
- * @param scanner
- * @return
- */
- private int matchDnAndColon( ICharacterScanner scanner )
- {
-
- for ( int i = 0; i < DN_SEQUENCE.length; i++ )
- {
-
- int c = scanner.read();
-
- if ( c != DN_SEQUENCE[i] )
- {
- while ( i >= 0 )
- {
- scanner.unread();
- i--;
- }
- return 0;
- }
-
- }
-
- return DN_SEQUENCE.length;
- }
-
-
- private boolean matchEOF( ICharacterScanner scanner )
- {
- int c = scanner.read();
- if ( c == ICharacterScanner.EOF )
- {
- return true;
- }
- else
- {
- scanner.unread();
- return false;
- }
- }
-
-
- public IToken evaluate( ICharacterScanner scanner, boolean resume )
- {
-
- if ( scanner.getColumn() != 0 )
- {
- return Token.UNDEFINED;
- }
-
- int c;
-
- do
- {
- c = scanner.read();
-
- if ( c == '\r' || c == '\n' )
- {
-
- // check end of record
- scanner.unread();
-
- if ( this.matchNewline( scanner ) > 0 )
- {
-
- int nlCount = this.matchNewline( scanner );
- if ( nlCount > 0 )
- {
- int dnCount = this.matchDnAndColon( scanner );
- if ( dnCount > 0 )
- {
- while ( dnCount > 0 )
- {
- scanner.unread();
- dnCount--;
- }
- return this.recordToken;
- }
- else if ( this.matchEOF( scanner ) )
- {
- return this.recordToken;
- }
- else
- {
- while ( nlCount > 0 )
- {
- scanner.unread();
- nlCount--;
- }
- }
- }
- else if ( this.matchEOF( scanner ) )
- {
- return this.recordToken;
- }
- }
- else if ( this.matchEOF( scanner ) )
- {
- return this.recordToken;
- }
-
- }
- else if ( c == ICharacterScanner.EOF )
- {
- return this.recordToken;
- }
- }
- while ( true );
-
- }
-
-
- public IToken evaluate( ICharacterScanner scanner )
- {
- return this.evaluate( scanner, false );
- }
-
+public class LdifRecordRule{
}
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifTextHover.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifTextHover.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifTextHover.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifTextHover.java Fri Aug 20 17:07:19 2010
@@ -21,67 +21,7 @@
package org.apache.directory.studio.ldifeditor.editor.text;
-import org.apache.directory.studio.ldifeditor.editor.ILdifEditor;
-import org.apache.directory.studio.ldifparser.model.LdifFile;
-import org.apache.directory.studio.ldifparser.model.LdifPart;
-import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
-import org.apache.directory.studio.ldifparser.model.lines.LdifValueLineBase;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-
-
-public class LdifTextHover implements ITextHover
-{
-
- private ILdifEditor editor;
-
-
- public LdifTextHover( ILdifEditor editor )
- {
- this.editor = editor;
- }
-
-
- public String getHoverInfo( ITextViewer textViewer, IRegion hoverRegion )
- {
-
- if ( this.editor != null )
- {
-
- LdifContainer container = LdifFile.getContainer( this.editor.getLdifModel(), hoverRegion.getOffset() );
- if ( container != null )
- {
- LdifPart part = LdifFile.getContainerContent( container, hoverRegion.getOffset() );
- if ( part != null )
- {
- if ( part instanceof LdifValueLineBase )
- {
- LdifValueLineBase line = ( LdifValueLineBase ) part;
- if ( line.isValueTypeBase64() )
- {
- return line.getValueAsString();
- }
- }
- }
- }
- }
-
- return null;
- }
-
-
- public IRegion getHoverRegion( ITextViewer textViewer, int offset )
- {
-
- if ( this.editor != null )
- {
- return new Region( offset, 0 );
- }
-
- return null;
- }
+public class LdifTextHover {
}
Modified: directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifValueRule.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifValueRule.java?rev=987577&r1=987576&r2=987577&view=diff
==============================================================================
--- directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifValueRule.java (original)
+++ directory/studio/branches/studio-rap/plugins/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/text/LdifValueRule.java Fri Aug 20 17:07:19 2010
@@ -21,101 +21,8 @@
package org.apache.directory.studio.ldifeditor.editor.text;
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.Token;
-public class LdifValueRule implements IRule
-{
-
- private IToken token;
-
-
- public LdifValueRule( IToken token )
- {
- this.token = token;
- }
-
-
- public IToken evaluate( ICharacterScanner scanner )
- {
-
- if ( matchContent( scanner ) )
- {
- return this.token;
- }
- else
- {
- return Token.UNDEFINED;
- }
-
- }
-
-
- protected boolean matchContent( ICharacterScanner scanner )
- {
-
- int count = 0;
-
- int c = scanner.read();
- while ( c != ICharacterScanner.EOF )
- {
-
- // check for folding
- if ( c == '\n' || c == '\r' )
- {
- StringBuffer temp = new StringBuffer( 3 );
- if ( c == '\r' )
- {
- c = scanner.read();
- if ( c == '\n' )
- {
- temp.append( c );
- }
- else
- {
- scanner.unread();
- }
- }
- else if ( c == '\n' )
- {
- c = scanner.read();
- if ( c == '\r' )
- {
- temp.append( c );
- }
- else
- {
- scanner.unread();
- }
- }
-
- c = scanner.read();
- if ( c == ' ' && c != ICharacterScanner.EOF )
- {
- // space after newline, continue
- temp.append( c );
- count += temp.length();
- c = scanner.read();
- }
- else
- {
- for ( int i = 0; i < temp.length(); i++ )
- scanner.unread();
- break;
- }
- }
- else
- {
- count++;
- c = scanner.read();
- }
- }
- scanner.unread();
-
- return count > 0;
- }
+public class LdifValueRule {
}