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 2007/07/04 15:05:20 UTC
svn commit: r553196 [5/5] - in
/directory/studio/trunk/studio-apacheds-schemaeditor: ./ META-INF/
src/main/java/org/apache/directory/studio/apacheds/schemaeditor/
src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/
src/main/java...
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java?view=auto&rev=553196
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java Wed Jul 4 06:05:16 2007
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.apacheds.schemaeditor.view.editors.schema;
+
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.PluginUtils;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener;
+import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
+import org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.view.widget.SchemaSourceViewer;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+
+/**
+ * This class is the Source Code Page of the Schema Editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaEditorSourceCodePage extends FormPage
+{
+ /** The page ID */
+ public static final String ID = SchemaEditor.ID + "sourceCode"; //$NON-NLS-1$
+
+ /** The page title */
+ public static final String TITLE = "Source Code";
+
+ /** The associated schema */
+ private Schema schema;
+
+ // UI Field
+ private SchemaSourceViewer schemaSourceViewer;
+
+ // Listerner
+ private SchemaListener schemaListener = new SchemaListener()
+ {
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#attributeTypeAdded(org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl)
+ */
+ public void attributeTypeAdded( AttributeTypeImpl at )
+ {
+ fillInUiFields();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#attributeTypeModified(org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl)
+ */
+ public void attributeTypeModified( AttributeTypeImpl at )
+ {
+ fillInUiFields();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#attributeTypeRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl)
+ */
+ public void attributeTypeRemoved( AttributeTypeImpl at )
+ {
+ fillInUiFields();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#matchingRuleAdded(org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl)
+ */
+ public void matchingRuleAdded( MatchingRuleImpl mr )
+ {
+ fillInUiFields();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#matchingRuleModified(org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl)
+ */
+ public void matchingRuleModified( MatchingRuleImpl mr )
+ {
+ fillInUiFields();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#matchingRuleRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl)
+ */
+ public void matchingRuleRemoved( MatchingRuleImpl mr )
+ {
+ fillInUiFields();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#objectClassAdded(org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl)
+ */
+ public void objectClassAdded( ObjectClassImpl oc )
+ {
+ fillInUiFields();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#objectClassModified(org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl)
+ */
+ public void objectClassModified( ObjectClassImpl oc )
+ {
+ fillInUiFields();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#objectClassRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl)
+ */
+ public void objectClassRemoved( ObjectClassImpl oc )
+ {
+ fillInUiFields();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#syntaxAdded(org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl)
+ */
+ public void syntaxAdded( SyntaxImpl syntax )
+ {
+ fillInUiFields();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#syntaxModified(org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl)
+ */
+ public void syntaxModified( SyntaxImpl syntax )
+ {
+ fillInUiFields();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaListener#syntaxRemoved(org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl)
+ */
+ public void syntaxRemoved( SyntaxImpl syntax )
+ {
+ fillInUiFields();
+ }
+ };
+
+
+ /**
+ * Creates a new instance of SchemaFormEditorSourceCodePage.
+ *
+ * @param editor
+ * the associated editor
+ */
+ public SchemaEditorSourceCodePage( FormEditor editor )
+ {
+ super( editor, ID, TITLE );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ protected void createFormContent( IManagedForm managedForm )
+ {
+ schema = ( ( SchemaEditor ) getEditor() ).getSchema();
+ Activator.getDefault().getSchemaHandler().addListener( schema, schemaListener );
+
+ ScrolledForm form = managedForm.getForm();
+ FormToolkit toolkit = managedForm.getToolkit();
+ GridLayout layout = new GridLayout();
+ form.getBody().setLayout( layout );
+ toolkit.paintBordersFor( form.getBody() );
+
+ // SOURCE CODE Field
+ schemaSourceViewer = new SchemaSourceViewer( form.getBody(), null, null, false, SWT.BORDER | SWT.H_SCROLL
+ | SWT.V_SCROLL );
+ GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+ gd.heightHint = 10;
+ schemaSourceViewer.getTextWidget().setLayoutData( gd );
+ schemaSourceViewer.getTextWidget().setEditable( false );
+
+ // set text font
+ Font font = JFaceResources.getFont( JFaceResources.TEXT_FONT );
+ schemaSourceViewer.getTextWidget().setFont( font );
+
+ IDocument document = new Document();
+ schemaSourceViewer.setDocument( document );
+
+ // Initializes the UI from the schema
+ fillInUiFields();
+ }
+
+
+ /**
+ * Fills in the fields of the User Interface.
+ */
+ private void fillInUiFields()
+ {
+ StringBuffer sb = new StringBuffer();
+
+ for ( AttributeTypeImpl at : schema.getAttributeTypes() )
+ {
+ sb.append( PluginUtils.toSourceCode( at ) );
+ sb.append( "\n" ); //$NON-NLS-1$
+ }
+
+ for ( ObjectClassImpl oc : schema.getObjectClasses() )
+ {
+ sb.append( PluginUtils.toSourceCode( oc ) );
+ sb.append( "\n" ); //$NON-NLS-1$
+ }
+
+ schemaSourceViewer.getDocument().set( sb.toString() );
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaCodeScanner.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaCodeScanner.java?view=auto&rev=553196
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaCodeScanner.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaCodeScanner.java Wed Jul 4 06:05:16 2007
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.apacheds.schemaeditor.view.widget;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWhitespaceDetector;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.SingleLineRule;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WhitespaceRule;
+import org.eclipse.jface.text.rules.WordRule;
+
+
+/**
+ * Scanner used to analyse Schema code. Allows syntax coloring.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaCodeScanner extends RuleBasedScanner
+{
+ String attributype = "attributetype"; //$NON-NLS-1$
+
+ String objectclass = "objectclass"; //$NON-NLS-1$
+
+ String[] keywords = new String[]
+ { "NAME", "DESC", "OBSOLETE", "SUP", "EQUALITY", "ORDERING", "MUST", "MAY", "STRUCTURAL", "SUBSTR", "SYNTAX", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
+ "SINGLE-VALUE", "COLLECTIVE", "NO-USER-MODIFICATION", "USAGE", "userApplications", "directoryOperation", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "distributedOperation", "dSAOperation", "ABSTRACT", "STRUCTURAL", "AUXILIARY", "MUST", "MAY" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+
+
+ public SchemaCodeScanner( SchemaTextAttributeProvider provider )
+ {
+ List<IRule> rules = new ArrayList<IRule>();
+
+ IToken keyword = new Token( provider.getAttribute( SchemaTextAttributeProvider.KEYWORD_ATTRIBUTE ) );
+ IToken string = new Token( provider.getAttribute( SchemaTextAttributeProvider.STRING_ATTRIBUTE ) );
+ IToken undefined = new Token( provider.getAttribute( SchemaTextAttributeProvider.DEFAULT_ATTRIBUTE ) );
+ IToken ATToken = new Token( provider.getAttribute( SchemaTextAttributeProvider.ATTRIBUTETYPE_ATTRIBUTE ) );
+ IToken OCToken = new Token( provider.getAttribute( SchemaTextAttributeProvider.OBJECTCLASS_ATTRIBUTE ) );
+ IToken oid = new Token( provider.getAttribute( SchemaTextAttributeProvider.OID_ATTRIBUTE ) );
+
+ // Rules for Strings
+ rules.add( new SingleLineRule( "\"", "\"", string, '\0', true ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ rules.add( new SingleLineRule( "'", "'", string, '\0', true ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ // Generic rule for whitespaces
+ rules.add( new WhitespaceRule( new IWhitespaceDetector()
+ {
+ /**
+ * Indicates if the given character is a whitespace
+ * @param c the character to analyse
+ * @return <code>true</code> if the character is to be considered as a whitespace, <code>false</code> if not.
+ * @see org.eclipse.jface.text.rules.IWhitespaceDetector#isWhitespace(char)
+ */
+ public boolean isWhitespace( char c )
+ {
+ return Character.isWhitespace( c );
+ }
+ } ) );
+
+ WordRule wrOID = new WordRule( new SchemaOIDDetector(), oid );
+
+ rules.add( wrOID );
+
+ // If the word isn't in the List, returns undefined
+ WordRule wr = new WordRule( new SchemaWordDetector(), undefined );
+
+ // 'attributetype' rule
+ wr.addWord( attributype, ATToken );
+
+ // 'objectclass' rule
+ wr.addWord( objectclass, OCToken );
+
+ // Adding Keywords
+ for ( String kw : keywords )
+ {
+ wr.addWord( kw, keyword );
+ }
+
+ rules.add( wr );
+
+ IRule[] param = new IRule[rules.size()];
+ rules.toArray( param );
+ setRules( param );
+ }
+
+ /**
+ * This class implements a word detector for Schema
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ static class SchemaWordDetector implements IWordDetector
+ {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.rules.IWordDetector#isWordPart(char)
+ */
+ public boolean isWordPart( char c )
+ {
+ return ( Character.isLetterOrDigit( c ) || c == '_' || c == '-' || c == '$' || c == '#' || c == '@'
+ || c == '~' || c == '.' || c == '?' );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.rules.IWordDetector#isWordStart(char)
+ */
+ public boolean isWordStart( char c )
+ {
+ return ( Character.isLetter( c ) || c == '.' || c == '_' || c == '?' || c == '$' );
+ }
+ }
+
+ /**
+ * This class implements an OID detector for Schema
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ static class SchemaOIDDetector implements IWordDetector
+ {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.rules.IWordDetector#isWordPart(char)
+ */
+ public boolean isWordPart( char c )
+ {
+ return ( Character.isDigit( c ) || c == '.' );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.rules.IWordDetector#isWordStart(char)
+ */
+ public boolean isWordStart( char c )
+ {
+ return ( Character.isDigit( c ) );
+ }
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewer.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewer.java?view=auto&rev=553196
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewer.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewer.java Wed Jul 4 06:05:16 2007
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.apacheds.schemaeditor.view.widget;
+
+
+import org.eclipse.jface.text.source.IOverviewRuler;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * Implementation of a SourceViewer for displaying Schema files source code.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaSourceViewer extends SourceViewer
+{
+ /**
+ * Creates a new instance of SchemaSourceViewer.
+ *
+ * @param parent
+ * the parent of the viewer's control
+ * @param verticalRuler
+ * the vertical ruler used by this source viewer
+ * @param overviewRuler
+ * the overview ruler
+ * @param showAnnotationsOverview
+ * true if the overview ruler should be visible, false otherwise
+ * @param styles
+ * the SWT style bits
+ */
+ public SchemaSourceViewer( Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
+ boolean showAnnotationsOverview, int styles )
+ {
+ super( parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles );
+ this.configure( new SchemaSourceViewerConfiguration() );
+ }
+
+
+ /**
+ * Creates a new instance of SchemaSourceViewer.
+ *
+ * @param parent
+ * the parent of the viewer's control
+ * @param ruler
+ * the vertical ruler used by this source viewer
+ * @param styles
+ * the SWT style bits
+ */
+ public SchemaSourceViewer( Composite parent, IVerticalRuler ruler, int styles )
+ {
+ super( parent, ruler, styles );
+ this.configure( new SchemaSourceViewerConfiguration() );
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java?view=auto&rev=553196
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java Wed Jul 4 06:05:16 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.apacheds.schemaeditor.view.widget;
+
+
+import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+
+
+/**
+ * This class is used to handle the display (syntax highlighting, etc.) of Schema files in the SchemaSourceViewer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaSourceViewerConfiguration extends SourceViewerConfiguration
+{
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
+ */
+ public IPresentationReconciler getPresentationReconciler( ISourceViewer sourceViewer )
+ {
+ PresentationReconciler reconciler = new PresentationReconciler();
+ reconciler.setDocumentPartitioning( getConfiguredDocumentPartitioning( sourceViewer ) );
+
+ // Creating the damager/repairer for code
+ DefaultDamagerRepairer dr = new DefaultDamagerRepairer( Activator.getSchemaCodeScanner() );
+ reconciler.setDamager( dr, IDocument.DEFAULT_CONTENT_TYPE );
+ reconciler.setRepairer( dr, IDocument.DEFAULT_CONTENT_TYPE );
+
+ return reconciler;
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaTextAttributeProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaTextAttributeProvider.java?view=auto&rev=553196
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaTextAttributeProvider.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaTextAttributeProvider.java Wed Jul 4 06:05:16 2007
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.apacheds.schemaeditor.view.widget;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * This class provides the TextAttributes elements for each kind of attribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaTextAttributeProvider
+{
+ public static final String DEFAULT_ATTRIBUTE = "__pos_schema_default_attribute"; //$NON-NLS-1$
+ public static final String STRING_ATTRIBUTE = "__pos_schema_string_attribute"; //$NON-NLS-1$
+ public static final String KEYWORD_ATTRIBUTE = "__pos_schema_keyword_attribute"; //$NON-NLS-1$
+ public static final String ATTRIBUTETYPE_ATTRIBUTE = "__pos_schema_attributetype_attribute"; //$NON-NLS-1$
+ public static final String OBJECTCLASS_ATTRIBUTE = "__pos_schema_objectclass_attribute"; //$NON-NLS-1$
+ public static final String OID_ATTRIBUTE = "__pos_schema_oid_attribute"; //$NON-NLS-1$
+
+ private Map<String, TextAttribute> attributes = new HashMap<String, TextAttribute>();
+
+
+ /**
+ * Creates a new instance of SchemaTextAttributeProvider.
+ *
+ */
+ public SchemaTextAttributeProvider()
+ {
+ attributes.put( DEFAULT_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 0, 0, 0 ) ) ) );
+
+ attributes.put( KEYWORD_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 127, 0, 85 ) ),
+ null, SWT.BOLD ) );
+
+ attributes.put( STRING_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 0, 0, 255 ) ) ) );
+
+ attributes.put( ATTRIBUTETYPE_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 89, 71,
+ 158 ) ), null, SWT.BOLD ) );
+
+ attributes.put( OBJECTCLASS_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(),
+ new RGB( 45, 124, 68 ) ), null, SWT.BOLD ) );
+
+ attributes.put( OID_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 255, 0, 0 ) ) ) );
+ }
+
+
+ /**
+ * Gets the correct TextAttribute for the given type
+ *
+ * @param type
+ * the type of element
+ * @return
+ * the correct TextAttribute for the given type
+ */
+ public TextAttribute getAttribute( String type )
+ {
+ TextAttribute attr = ( TextAttribute ) attributes.get( type );
+ if ( attr == null )
+ {
+ attr = ( TextAttribute ) attributes.get( DEFAULT_ATTRIBUTE );
+ }
+ return attr;
+ }
+}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/AttributeTypeWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/AttributeTypeWrapper.java?view=diff&rev=553196&r1=553195&r2=553196
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/AttributeTypeWrapper.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/AttributeTypeWrapper.java Wed Jul 4 06:05:16 2007
@@ -20,7 +20,7 @@
package org.apache.directory.studio.apacheds.schemaeditor.view.wrappers;
-import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
/**
@@ -32,7 +32,7 @@
public class AttributeTypeWrapper extends AbstractTreeNode
{
/** The wrapped AttributeType */
- private AttributeType attributeType;
+ private AttributeTypeImpl attributeType;
/**
@@ -41,7 +41,7 @@
* @param at
* the wrapped AttributeType
*/
- public AttributeTypeWrapper( AttributeType at )
+ public AttributeTypeWrapper( AttributeTypeImpl at )
{
super( null );
attributeType = at;
@@ -56,7 +56,7 @@
* @param parent
* the parent TreeNode
*/
- public AttributeTypeWrapper( AttributeType at, TreeNode parent )
+ public AttributeTypeWrapper( AttributeTypeImpl at, TreeNode parent )
{
super( parent );
attributeType = at;
@@ -69,7 +69,7 @@
* @return
* the wrapped AttributeType
*/
- public AttributeType getAttributeType()
+ public AttributeTypeImpl getAttributeType()
{
return attributeType;
}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/ObjectClassWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/ObjectClassWrapper.java?view=diff&rev=553196&r1=553195&r2=553196
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/ObjectClassWrapper.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/ObjectClassWrapper.java Wed Jul 4 06:05:16 2007
@@ -21,6 +21,7 @@
import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
/**
@@ -32,7 +33,7 @@
public class ObjectClassWrapper extends AbstractTreeNode
{
/** The wrapped ObjectClass */
- private ObjectClass objectClass;
+ private ObjectClassImpl objectClass;
/**
@@ -41,7 +42,7 @@
* @param oc
* the wrapped ObjectClass
*/
- public ObjectClassWrapper( ObjectClass oc )
+ public ObjectClassWrapper( ObjectClassImpl oc )
{
super( null );
objectClass = oc;
@@ -56,7 +57,7 @@
* @param parent
* the parent TreeNode
*/
- public ObjectClassWrapper( ObjectClass oc, TreeNode parent )
+ public ObjectClassWrapper( ObjectClassImpl oc, TreeNode parent )
{
super( parent );
objectClass = oc;
@@ -69,7 +70,7 @@
* @return
* the wrapped ObjectClass
*/
- public ObjectClass getObjectClass()
+ public ObjectClassImpl getObjectClass()
{
return objectClass;
}