You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/11/05 18:15:02 UTC
svn commit: r592094 [23/35] - in
/directory/sandbox/felixk/studio-schemaeditor: ./ META-INF/ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/directory/
src/main/java/org/apache/directory/studio/ src/m...
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/PropertySorter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/PropertySorter.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/PropertySorter.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/PropertySorter.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,247 @@
+/*
+ * 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.schemaeditor.view.widget;
+
+
+import java.util.Comparator;
+
+import org.apache.directory.studio.schemaeditor.model.difference.AliasDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.ClassTypeDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.CollectiveDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.DescriptionDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.EqualityDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.MandatoryATDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.NoUserModificationDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.ObsoleteDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.OptionalATDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.OrderingDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.PropertyDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SingleValueDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SubstringDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SuperiorATDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SuperiorOCDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SyntaxDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SyntaxLengthDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.UsageDifference;
+
+
+/**
+ * This class is used to compare, group and sort Differences by 'Property'
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PropertySorter implements Comparator<PropertyDifference>
+{
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare( PropertyDifference diff1, PropertyDifference diff2 )
+ {
+ return getWeight( diff1 ) - getWeight( diff2 );
+ }
+
+
+ /**
+ * Gets the weight of the given difference
+ *
+ * @param diff
+ * the difference
+ * @return
+ * the weight of the difference
+ */
+ private int getWeight( PropertyDifference diff )
+ {
+ if ( diff instanceof AliasDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 1;
+ case REMOVED:
+ return 2;
+ }
+ }
+ else if ( diff instanceof ClassTypeDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 18;
+ }
+ }
+ else if ( diff instanceof CollectiveDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 21;
+ }
+ }
+ else if ( diff instanceof DescriptionDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 3;
+ case MODIFIED:
+ return 4;
+ case REMOVED:
+ return 5;
+ }
+ }
+ else if ( diff instanceof EqualityDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 23;
+ case MODIFIED:
+ return 24;
+ case REMOVED:
+ return 25;
+ }
+ }
+ else if ( diff instanceof MandatoryATDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 32;
+ case REMOVED:
+ return 33;
+ }
+ }
+ else if ( diff instanceof NoUserModificationDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 22;
+ }
+ }
+ else if ( diff instanceof ObsoleteDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 19;
+ }
+ }
+ else if ( diff instanceof OptionalATDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 34;
+ case REMOVED:
+ return 35;
+ }
+ }
+ else if ( diff instanceof OrderingDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 26;
+ case MODIFIED:
+ return 27;
+ case REMOVED:
+ return 28;
+ }
+ }
+ else if ( diff instanceof SingleValueDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 20;
+ }
+ }
+ else if ( diff instanceof SubstringDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 29;
+ case MODIFIED:
+ return 30;
+ case REMOVED:
+ return 31;
+ }
+ }
+ else if ( diff instanceof SuperiorATDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 6;
+ case MODIFIED:
+ return 7;
+ case REMOVED:
+ return 8;
+ }
+ }
+ else if ( diff instanceof SuperiorOCDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 9;
+ case REMOVED:
+ return 10;
+ }
+ }
+ else if ( diff instanceof SyntaxDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 12;
+ case MODIFIED:
+ return 13;
+ case REMOVED:
+ return 14;
+ }
+ }
+ else if ( diff instanceof SyntaxLengthDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 15;
+ case MODIFIED:
+ return 16;
+ case REMOVED:
+ return 17;
+ }
+ }
+ else if ( diff instanceof UsageDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 11;
+ }
+ }
+
+ return 0;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/PropertySorter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaCodeScanner.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaCodeScanner.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaCodeScanner.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaCodeScanner.java Mon Nov 5 09:14:24 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.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 ) );
+ }
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaCodeScanner.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaDifferenceSorter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaDifferenceSorter.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaDifferenceSorter.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaDifferenceSorter.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,85 @@
+/*
+ * 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.schemaeditor.view.widget;
+
+
+import java.util.Comparator;
+
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.difference.SchemaDifference;
+
+
+/**
+ * This class is used to compare and sort ascending two Schemas
+ */
+public class SchemaDifferenceSorter implements Comparator<Object>
+{
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare( Object o1, Object o2 )
+ {
+ if ( ( o1 instanceof SchemaDifference ) && ( o2 instanceof SchemaDifference ) )
+ {
+ SchemaDifference sd1 = ( SchemaDifference ) o1;
+ SchemaDifference sd2 = ( SchemaDifference ) o2;
+
+ String name1 = "";
+ String name2 = "";
+ switch ( sd1.getType() )
+ {
+ case ADDED:
+ name1 = ( ( Schema ) sd1.getDestination() ).getName();
+ break;
+ case MODIFIED:
+ name1 = ( ( Schema ) sd1.getDestination() ).getName();
+ break;
+ case REMOVED:
+ name1 = ( ( Schema ) sd1.getSource() ).getName();
+ break;
+ case IDENTICAL:
+ name1 = ( ( Schema ) sd1.getDestination() ).getName();
+ break;
+ }
+
+ switch ( sd2.getType() )
+ {
+ case ADDED:
+ name2 = ( ( Schema ) sd2.getDestination() ).getName();
+ break;
+ case MODIFIED:
+ name2 = ( ( Schema ) sd2.getDestination() ).getName();
+ break;
+ case REMOVED:
+ name2 = ( ( Schema ) sd2.getSource() ).getName();
+ break;
+ case IDENTICAL:
+ name2 = ( ( Schema ) sd2.getDestination() ).getName();
+ break;
+ }
+
+ return name1.compareToIgnoreCase( name2 );
+ }
+
+ // Default
+ return o1.toString().compareToIgnoreCase( o2.toString() );
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaDifferenceSorter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaSourceViewer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaSourceViewer.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaSourceViewer.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaSourceViewer.java Mon Nov 5 09:14:24 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.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() );
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaSourceViewer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java Mon Nov 5 09:14:24 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.schemaeditor.view.widget;
+
+
+import org.apache.directory.studio.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.getDefault().getSchemaCodeScanner() );
+ reconciler.setDamager( dr, IDocument.DEFAULT_CONTENT_TYPE );
+ reconciler.setRepairer( dr, IDocument.DEFAULT_CONTENT_TYPE );
+
+ return reconciler;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaTextAttributeProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaTextAttributeProvider.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaTextAttributeProvider.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaTextAttributeProvider.java Mon Nov 5 09:14:24 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.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;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/SchemaTextAttributeProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/TypeSorter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/TypeSorter.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/TypeSorter.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/TypeSorter.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,247 @@
+/*
+ * 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.schemaeditor.view.widget;
+
+
+import java.util.Comparator;
+
+import org.apache.directory.studio.schemaeditor.model.difference.AliasDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.ClassTypeDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.CollectiveDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.DescriptionDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.EqualityDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.MandatoryATDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.NoUserModificationDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.ObsoleteDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.OptionalATDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.OrderingDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.PropertyDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SingleValueDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SubstringDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SuperiorATDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SuperiorOCDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SyntaxDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.SyntaxLengthDifference;
+import org.apache.directory.studio.schemaeditor.model.difference.UsageDifference;
+
+
+/**
+ * This class is used to compare, group and sort Differences by 'Type'
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class TypeSorter implements Comparator<PropertyDifference>
+{
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare( PropertyDifference diff1, PropertyDifference diff2 )
+ {
+ return getWeight( diff1 ) - getWeight( diff2 );
+ }
+
+
+ /**
+ * Gets the weight of the given difference
+ *
+ * @param diff
+ * the difference
+ * @return
+ * the weight of the difference
+ */
+ private int getWeight( PropertyDifference diff )
+ {
+ if ( diff instanceof AliasDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 1;
+ case REMOVED:
+ return 25;
+ }
+ }
+ else if ( diff instanceof ClassTypeDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 17;
+ }
+ }
+ else if ( diff instanceof CollectiveDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 20;
+ }
+ }
+ else if ( diff instanceof DescriptionDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 2;
+ case MODIFIED:
+ return 12;
+ case REMOVED:
+ return 26;
+ }
+ }
+ else if ( diff instanceof EqualityDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 7;
+ case MODIFIED:
+ return 22;
+ case REMOVED:
+ return 31;
+ }
+ }
+ else if ( diff instanceof MandatoryATDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 10;
+ case REMOVED:
+ return 34;
+ }
+ }
+ else if ( diff instanceof NoUserModificationDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 21;
+ }
+ }
+ else if ( diff instanceof ObsoleteDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 18;
+ }
+ }
+ else if ( diff instanceof OptionalATDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 11;
+ case REMOVED:
+ return 35;
+ }
+ }
+ else if ( diff instanceof OrderingDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 8;
+ case MODIFIED:
+ return 23;
+ case REMOVED:
+ return 32;
+ }
+ }
+ else if ( diff instanceof SingleValueDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 19;
+ }
+ }
+ else if ( diff instanceof SubstringDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 9;
+ case MODIFIED:
+ return 24;
+ case REMOVED:
+ return 33;
+ }
+ }
+ else if ( diff instanceof SuperiorATDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 3;
+ case MODIFIED:
+ return 13;
+ case REMOVED:
+ return 27;
+ }
+ }
+ else if ( diff instanceof SuperiorOCDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 4;
+ case REMOVED:
+ return 28;
+ }
+ }
+ else if ( diff instanceof SyntaxDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 5;
+ case MODIFIED:
+ return 15;
+ case REMOVED:
+ return 29;
+ }
+ }
+ else if ( diff instanceof SyntaxLengthDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case ADDED:
+ return 6;
+ case MODIFIED:
+ return 16;
+ case REMOVED:
+ return 30;
+ }
+ }
+ else if ( diff instanceof UsageDifference )
+ {
+ switch ( diff.getType() )
+ {
+ case MODIFIED:
+ return 14;
+ }
+ }
+
+ return 0;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/widget/TypeSorter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,102 @@
+/*
+ * 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.schemaeditor.view.wizards;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.model.Project;
+import org.apache.directory.studio.schemaeditor.model.difference.DifferenceEngine;
+import org.apache.directory.studio.schemaeditor.view.widget.DifferencesWidget;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the WizardPage of the ExportProjectsWizard.
+ * <p>
+ * It is used to let the user enter the informations about the
+ * schemas projects he wants to export and where to export.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CommitChangesDifferencesWizardPage extends WizardPage
+{
+ // UI Fields
+ private DifferencesWidget differencesWidget;
+
+
+ /**
+ * Creates a new instance of ExportSchemasAsXmlWizardPage.
+ */
+ protected CommitChangesDifferencesWizardPage()
+ {
+ super( "CommitChangesDifferencesWizardPage" );
+ setTitle( "Commit Changes" );
+ setDescription( "Displays the modifications made on the schema." );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_COMMIT_CHANGES_WIZARD ) );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl( Composite parent )
+ {
+ Composite composite = new Composite( parent, SWT.NULL );
+ GridLayout layout = new GridLayout();
+ composite.setLayout( layout );
+
+ differencesWidget = new DifferencesWidget();
+ differencesWidget.createWidget( composite );
+
+ initFields();
+
+ setControl( composite );
+ }
+
+
+ /**
+ * Initializes the UI Fields.
+ */
+ private void initFields()
+ {
+ Project project = Activator.getDefault().getProjectsHandler().getOpenProject();
+
+ differencesWidget.setInput( DifferenceEngine.getDifferences( project.getSchemaBackup(), project
+ .getSchemaHandler().getSchemas() ) );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+ */
+ public void dispose()
+ {
+ differencesWidget.dispose();
+
+ super.dispose();
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesInformationWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesInformationWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesInformationWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesInformationWizardPage.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,87 @@
+/*
+ * 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.schemaeditor.view.wizards;
+
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the InformationWizardPage of the CommitChangesWizard.
+ * <p>
+ * It is used to let the user enter the informations about the
+ * schemas projects he wants to export and where to export.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CommitChangesInformationWizardPage extends WizardPage
+{
+ // UI Fields
+
+ /**
+ * Creates a new instance of ExportSchemasAsXmlWizardPage.
+ */
+ protected CommitChangesInformationWizardPage()
+ {
+ super( "CommitChangesInformationWizardPage" );
+ setTitle( "Commit Changes" );
+ setDescription( "Please read the following information before committing the changes made on the schema." );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_COMMIT_CHANGES_WIZARD ) );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl( Composite parent )
+ {
+ Composite composite = new Composite( parent, SWT.NULL );
+ GridLayout layout = new GridLayout();
+ composite.setLayout( layout );
+ composite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Information Label
+ String informationString = "You are about to commit changes to Apache Directory Server." + "\n\n"
+ + "Please carefully review the changes made on the schema on the next page." + "\n\n"
+ + "Commiting changes with an inconsistent schema may corrupt you server.";
+ Label informationLabel = new Label( composite, SWT.WRAP );
+ informationLabel.setText( informationString );
+ informationLabel.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, true ) );
+
+ // Warning Label
+ Label warningLabel = new Label( composite, SWT.NONE );
+ warningLabel.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_WARNING_32X32 ).createImage() );
+ warningLabel.setLayoutData( new GridData( SWT.CENTER, SWT.BOTTOM, true, true ) );
+
+ setControl( composite );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesInformationWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesWizard.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesWizard.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesWizard.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,169 @@
+/*
+ * 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.schemaeditor.view.wizards;
+
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.model.DependenciesComputer;
+import org.apache.directory.studio.schemaeditor.model.Project;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.DependenciesComputer.DependencyComputerException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+/**
+ * This class represents the wizard to commit changes to the Apache Directory Server.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CommitChangesWizard extends Wizard implements IExportWizard
+{
+ /** The wizard's ID */
+ public static final String ID = Activator.PLUGIN_ID + ".wizards.CommitChangesWizard";
+
+ /** The flag to know if the Schema contains errors */
+ private boolean schemaContainsErrors = false;
+
+ /** The project */
+ private Project project;
+
+ /** The DependenciesComputer */
+ private DependenciesComputer dependenciesComputer;
+
+ // The pages of the wizard
+ private CommitChangesInformationWizardPage commitChangesInformation;
+ private CommitChangesDifferencesWizardPage commitChangesDifferences;
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ public void addPages()
+ {
+ // Creating pages
+ commitChangesInformation = new CommitChangesInformationWizardPage();
+ commitChangesDifferences = new CommitChangesDifferencesWizardPage();
+
+ // Adding pages
+ addPage( commitChangesInformation );
+ addPage( commitChangesDifferences );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ public boolean performFinish()
+ {
+ final List<Schema> orderedSchemas = dependenciesComputer.getDependencyOrderedSchemasList();
+
+ try
+ {
+ getContainer().run( true, true, new IRunnableWithProgress()
+ {
+ public void run( IProgressMonitor monitor )
+ {
+ //TODO
+ }
+ } );
+ }
+ catch ( InvocationTargetException e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch ( InterruptedException e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#canFinish()
+ */
+ public boolean canFinish()
+ {
+ if ( schemaContainsErrors )
+ {
+ return false;
+ }
+ else
+ {
+ return ( getContainer().getCurrentPage() instanceof CommitChangesDifferencesWizardPage );
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init( IWorkbench workbench, IStructuredSelection selection )
+ {
+ setNeedsProgressMonitor( true );
+
+ project = Activator.getDefault().getProjectsHandler().getOpenProject();
+
+ try
+ {
+ dependenciesComputer = new DependenciesComputer( project.getSchemaHandler().getSchemas() );
+ }
+ catch ( DependencyComputerException e )
+ {
+ schemaContainsErrors = true;
+ }
+ }
+
+
+ /**
+ * Gets the SchemaContainsErrors flag.
+ *
+ * @return
+ * the SchemaContainsErrors flag
+ */
+ public boolean isSchemaContainsErrors()
+ {
+ return schemaContainsErrors;
+ }
+
+
+ /**
+ * Gets the DependenciesComputer.
+ *
+ * @return
+ * the DependenciesComputer
+ */
+ public DependenciesComputer getDependenciesComputer()
+ {
+ return dependenciesComputer;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesWizard.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizard.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizard.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizard.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,161 @@
+/*
+ * 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.schemaeditor.view.wizards;
+
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
+import org.apache.directory.studio.schemaeditor.model.Project;
+import org.apache.directory.studio.schemaeditor.model.io.ProjectsExporter;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+/**
+ * This class represents the wizard to export schema projects.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportProjectsWizard extends Wizard implements IExportWizard
+{
+ public static final String ID = Activator.PLUGIN_ID + ".wizards.ExportProjectsWizard";
+
+ /** The selected projects */
+ private Project[] selectedProjects = new Project[0];
+
+ // The pages of the wizard
+ private ExportProjectsWizardPage page;
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ public void addPages()
+ {
+ // Creating pages
+ page = new ExportProjectsWizardPage();
+ page.setSelectedProjects( selectedProjects );
+
+ // Adding pages
+ addPage( page );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ public boolean performFinish()
+ {
+ final Project[] selectedProjects = page.getSelectedProjects();
+
+ final String exportDirectory = page.getExportDirectory();
+ try
+ {
+ getContainer().run( true, true, new IRunnableWithProgress()
+ {
+ public void run( IProgressMonitor monitor )
+ {
+ monitor.beginTask( "Exporting project: ", selectedProjects.length );
+ for ( Project project : selectedProjects )
+ {
+ monitor.subTask( project.getName() );
+
+ try
+ {
+ OutputFormat outformat = OutputFormat.createPrettyPrint();
+ outformat.setEncoding( "UTF-8" );
+ XMLWriter writer = new XMLWriter( new FileOutputStream( exportDirectory + "/"
+ + project.getName() + ".schemaproject" ), outformat );
+ writer.write( ProjectsExporter.toDocument( project ) );
+ writer.flush();
+ }
+ catch ( UnsupportedEncodingException e )
+ {
+ PluginUtils.logError(
+ "An error occured when saving the project " + project.getName() + ".", e );
+ ViewUtils.displayErrorMessageBox( "Error", "An error occured when saving the project "
+ + project.getName() + "." );
+ }
+ catch ( FileNotFoundException e )
+ {
+ PluginUtils.logError(
+ "An error occured when saving the project " + project.getName() + ".", e );
+ ViewUtils.displayErrorMessageBox( "Error", "An error occured when saving the project "
+ + project.getName() + "." );
+ }
+ catch ( IOException e )
+ {
+ PluginUtils.logError(
+ "An error occured when saving the project " + project.getName() + ".", e );
+ ViewUtils.displayErrorMessageBox( "Error", "An error occured when saving the project "
+ + project.getName() + "." );
+ }
+ monitor.worked( 1 );
+ }
+ monitor.done();
+ }
+ } );
+ }
+ catch ( InvocationTargetException e )
+ {
+ // Nothing to do (it will never occur)
+ }
+ catch ( InterruptedException e )
+ {
+ // Nothing to do.
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Sets the selected projects.
+ *
+ * @param projects
+ * the projects
+ */
+ public void setSelectedProjects( Project[] projects )
+ {
+ selectedProjects = projects;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init( IWorkbench workbench, IStructuredSelection selection )
+ {
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizard.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizardPage.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizardPage.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizardPage.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,365 @@
+/*
+ * 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.schemaeditor.view.wizards;
+
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.model.Project;
+import org.apache.directory.studio.schemaeditor.model.ProjectType;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class represents the WizardPage of the ExportProjectsWizard.
+ * <p>
+ * It is used to let the user enter the informations about the
+ * schemas projects he wants to export and where to export.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportProjectsWizardPage extends WizardPage
+{
+ /** The selected projects */
+ private Project[] selectedProjects = new Project[0];
+
+ // UI Fields
+ private CheckboxTableViewer projectsTableViewer;
+ private Button projectsTableSelectAllButton;
+ private Button projectsTableDeselectAllButton;
+ private Label exportDirectoryLabel;
+ private Text exportDirectoryText;
+ private Button exportDirectoryButton;
+
+
+ /**
+ * Creates a new instance of ExportSchemasAsXmlWizardPage.
+ */
+ protected ExportProjectsWizardPage()
+ {
+ super( "ExportProjectsWizardPage" );
+ setTitle( "Export schema projects" );
+ setDescription( "Please select the schema projects to export." );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_PROJECT_EXPORT_WIZARD ) );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl( Composite parent )
+ {
+ Composite composite = new Composite( parent, SWT.NULL );
+ GridLayout layout = new GridLayout();
+ composite.setLayout( layout );
+
+ // Projects Group
+ Group schemaProjectsGroup = new Group( composite, SWT.NONE );
+ schemaProjectsGroup.setText( "Schema projects" );
+ schemaProjectsGroup.setLayout( new GridLayout( 2, false ) );
+ schemaProjectsGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ // Projects TableViewer
+ Label projectsLabel = new Label( schemaProjectsGroup, SWT.NONE );
+ projectsLabel.setText( "Select the schema projects to export:" );
+ projectsLabel.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+ projectsTableViewer = new CheckboxTableViewer( new Table( schemaProjectsGroup, SWT.BORDER | SWT.CHECK
+ | SWT.FULL_SELECTION ) );
+ GridData projectsTableViewerGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 2 );
+ projectsTableViewerGridData.heightHint = 125;
+ projectsTableViewer.getTable().setLayoutData( projectsTableViewerGridData );
+ projectsTableViewer.setContentProvider( new ArrayContentProvider() );
+ projectsTableViewer.setLabelProvider( new LabelProvider()
+ {
+ public String getText( Object element )
+ {
+ if ( element instanceof Project )
+ {
+ return ( ( Project ) element ).getName();
+ }
+
+ // Default
+ return super.getText( element );
+ }
+
+
+ public Image getImage( Object element )
+ {
+ if ( element instanceof Project )
+ {
+ ProjectType type = ( ( Project ) element ).getType();
+ switch ( type )
+ {
+ case OFFLINE:
+ return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_PROJECT_OFFLINE_CLOSED ).createImage();
+ case ONLINE:
+ return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ PluginConstants.IMG_PROJECT_ONLINE_CLOSED ).createImage();
+ }
+ }
+
+ // Default
+ return super.getImage( element );
+ }
+ } );
+ projectsTableViewer.addCheckStateListener( new ICheckStateListener()
+ {
+ /**
+ * Notifies of a change to the checked state of an element.
+ *
+ * @param event
+ * event object describing the change
+ */
+ public void checkStateChanged( CheckStateChangedEvent event )
+ {
+ dialogChanged();
+ }
+ } );
+ projectsTableSelectAllButton = new Button( schemaProjectsGroup, SWT.PUSH );
+ projectsTableSelectAllButton.setText( "Select All" );
+ projectsTableSelectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+ projectsTableSelectAllButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ projectsTableViewer.setAllChecked( true );
+ dialogChanged();
+ }
+ } );
+ projectsTableDeselectAllButton = new Button( schemaProjectsGroup, SWT.PUSH );
+ projectsTableDeselectAllButton.setText( "Deselect All" );
+ projectsTableDeselectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) );
+ projectsTableDeselectAllButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ projectsTableViewer.setAllChecked( false );
+ dialogChanged();
+ }
+ } );
+
+ // Export Destination Group
+ Group exportDestinationGroup = new Group( composite, SWT.NULL );
+ exportDestinationGroup.setText( "Export Destination" );
+ exportDestinationGroup.setLayout( new GridLayout( 3, false ) );
+ exportDestinationGroup.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+
+ exportDirectoryLabel = new Label( exportDestinationGroup, SWT.NONE );
+ exportDirectoryLabel.setText( "Directory:" );
+ exportDirectoryText = new Text( exportDestinationGroup, SWT.BORDER );
+ exportDirectoryText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) );
+ exportDirectoryText.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ dialogChanged();
+ }
+ } );
+ exportDirectoryButton = new Button( exportDestinationGroup, SWT.PUSH );
+ exportDirectoryButton.setText( "Browse..." );
+ exportDirectoryButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ chooseExportDirectory();
+ dialogChanged();
+ }
+ } );
+
+ initFields();
+
+ setControl( composite );
+ }
+
+
+ /**
+ * Initializes the UI Fields.
+ */
+ private void initFields()
+ {
+ // Filling the Schemas table
+ List<Project> projects = new ArrayList<Project>();
+ projects.addAll( Activator.getDefault().getProjectsHandler().getProjects() );
+ Collections.sort( projects, new Comparator<Project>()
+ {
+ public int compare( Project o1, Project o2 )
+ {
+ return o1.getName().compareToIgnoreCase( o2.getName() );
+ }
+
+ } );
+ projectsTableViewer.setInput( projects );
+
+ // Setting the selected projects
+ projectsTableViewer.setCheckedElements( selectedProjects );
+
+ displayErrorMessage( null );
+ setPageComplete( false );
+ }
+
+
+ /**
+ * This method is called when the exportMultipleFiles 'browse' button is selected.
+ */
+ private void chooseExportDirectory()
+ {
+ DirectoryDialog dialog = new DirectoryDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
+ dialog.setText( "Choose Folder" );
+ dialog.setMessage( "Select the folder in which export the files." );
+
+ String selectedDirectory = dialog.open();
+ if ( selectedDirectory != null )
+ {
+ exportDirectoryText.setText( selectedDirectory );
+ }
+ }
+
+
+ /**
+ * This method is called when the user modifies something in the UI.
+ */
+ private void dialogChanged()
+ {
+ // Schemas table
+ if ( projectsTableViewer.getCheckedElements().length == 0 )
+ {
+ displayErrorMessage( "One or several schema projects must be selected." );
+ return;
+ }
+
+ // Export Directory
+ String directory = exportDirectoryText.getText();
+ if ( ( directory == null ) || ( directory.equals( "" ) ) )
+ {
+ displayErrorMessage( "A directory must be selected." );
+ return;
+ }
+ else
+ {
+ File directoryFile = new File( directory );
+ if ( !directoryFile.exists() )
+ {
+ displayErrorMessage( "The selected directory does not exist." );
+ return;
+ }
+ else if ( !directoryFile.isDirectory() )
+ {
+ displayErrorMessage( "The selected directory is not a directory." );
+ return;
+ }
+ else if ( !directoryFile.canWrite() )
+ {
+ displayErrorMessage( "The selected directory is not writable." );
+ return;
+ }
+ }
+
+ displayErrorMessage( null );
+ }
+
+
+ /**
+ * Displays an error message and set the page status as incomplete
+ * if the message is not null.
+ *
+ * @param message
+ * the message to display
+ */
+ private void displayErrorMessage( String message )
+ {
+ setErrorMessage( message );
+ setPageComplete( message == null );
+ }
+
+
+ /**
+ * Gets the selected projects.
+ *
+ * @return
+ * the selected projects
+ */
+ public Project[] getSelectedProjects()
+ {
+ Object[] selectedProjects = projectsTableViewer.getCheckedElements();
+
+ List<Project> schemas = new ArrayList<Project>();
+ for ( Object project : selectedProjects )
+ {
+ schemas.add( ( Project ) project );
+ }
+
+ return schemas.toArray( new Project[0] );
+ }
+
+
+ /**
+ * Sets the selected projects.
+ *
+ * @param projects
+ * the projects
+ */
+ public void setSelectedProjects( Project[] projects )
+ {
+ selectedProjects = projects;
+ }
+
+
+ /**
+ * Gets the export directory.
+ *
+ * @return
+ * the export directory
+ */
+ public String getExportDirectory()
+ {
+ return exportDirectoryText.getText();
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportProjectsWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsOpenLdapWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsOpenLdapWizard.java?rev=592094&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsOpenLdapWizard.java (added)
+++ directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsOpenLdapWizard.java Mon Nov 5 09:14:24 2007
@@ -0,0 +1,143 @@
+/*
+ * 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.schemaeditor.view.wizards;
+
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
+import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.io.OpenLdapSchemaFileExporter;
+import org.apache.directory.studio.schemaeditor.view.ViewUtils;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+
+
+/**
+ * This class represents the wizard to export schemas as OpenLdap format.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExportSchemasAsOpenLdapWizard extends Wizard implements IExportWizard
+{
+ public static final String ID = Activator.PLUGIN_ID + ".wizards.ExportSchemasAsOpenLdapWizard";
+
+ /** The selected schemas */
+ private Schema[] selectedSchemas = new Schema[0];
+
+ // The pages of the wizard
+ private ExportSchemasAsOpenLdapWizardPage page;
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ public void addPages()
+ {
+ // Creating pages
+ page = new ExportSchemasAsOpenLdapWizardPage();
+ page.setSelectedSchemas( selectedSchemas );
+
+ // Adding pages
+ addPage( page );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ public boolean performFinish()
+ {
+ final Schema[] selectedSchemas = page.getSelectedSchemas();
+
+ final String exportDirectory = page.getExportDirectory();
+ try
+ {
+ getContainer().run( true, true, new IRunnableWithProgress()
+ {
+ public void run( IProgressMonitor monitor )
+ {
+ monitor.beginTask( "Exporting schemas: ", selectedSchemas.length );
+ for ( Schema schema : selectedSchemas )
+ {
+ monitor.subTask( schema.getName() );
+
+ try
+ {
+ BufferedWriter buffWriter = new BufferedWriter( new FileWriter( exportDirectory + "/"
+ + schema.getName() + ".schema" ) );
+ buffWriter.write( OpenLdapSchemaFileExporter.toSourceCode( schema ) );
+ buffWriter.close();
+ }
+ catch ( IOException e )
+ {
+ PluginUtils.logError( "An error occured when saving the schema " + schema.getName() + ".",
+ e );
+ ViewUtils.displayErrorMessageBox( "Error", "An error occured when saving the schema "
+ + schema.getName() + "." );
+ }
+ monitor.worked( 1 );
+ }
+ monitor.done();
+ }
+ } );
+ }
+ catch ( InvocationTargetException e )
+ {
+ // Nothing to do (it will never occur)
+ }
+ catch ( InterruptedException e )
+ {
+ // Nothing to do.
+ }
+
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init( IWorkbench workbench, IStructuredSelection selection )
+ {
+ setNeedsProgressMonitor( true );
+ }
+
+
+ /**
+ * Sets the selected projects.
+ *
+ * @param schemas
+ * the schemas
+ */
+ public void setSelectedSchemas( Schema[] schemas )
+ {
+ selectedSchemas = schemas;
+ }
+}
Propchange: directory/sandbox/felixk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasAsOpenLdapWizard.java
------------------------------------------------------------------------------
svn:eol-style = native