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/08/28 18:32:12 UTC
svn commit: r570479 - in
/directory/studio/trunk/studio-apacheds-schemaeditor: resources/icons/
src/main/java/org/apache/directory/studio/apacheds/schemaeditor/
src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/
src/main/java/o...
Author: pamarcelot
Date: Tue Aug 28 09:32:10 2007
New Revision: 570479
URL: http://svn.apache.org/viewvc?rev=570479&view=rev
Log:
Added the DependenciesComputer class.
Improved CommitChanges wizard.
Added:
directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/warning_32x32.png (with props)
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/DependenciesComputer.java
Modified:
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/SchemaImpl.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesInformationWizardPage.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesWizard.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizard.java
Added: directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/warning_32x32.png
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/warning_32x32.png?rev=570479&view=auto
==============================================================================
Binary file - no diff available.
Propchange: directory/studio/trunk/studio-apacheds-schemaeditor/resources/icons/warning_32x32.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java?rev=570479&r1=570478&r2=570479&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/PluginConstants.java Tue Aug 28 09:32:10 2007
@@ -103,6 +103,7 @@
public static final String IMG_SORTING = "resources/icons/sorting.gif";
public static final String IMG_TOOLBAR_MENU = "resources/icons/toolbar_menu.gif";
public static final String IMG_TRANSPARENT_16X16 = "resources/icons/transparent_16x16.gif";
+ public static final String IMG_WARNING_32X32 = "resources/icons/warning_32x32.png";
// Commands
public static final String CMD_COMMIT_CHANGES = Activator.PLUGIN_ID + ".commands.commitChanges";
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java?rev=570479&r1=570478&r2=570479&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java Tue Aug 28 09:32:10 2007
@@ -489,7 +489,6 @@
for ( AttributeTypeImpl at : schema.getAttributeTypes() )
{
addSchemaObject( at );
-
}
// Adding its matching rules
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/DependenciesComputer.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/DependenciesComputer.java?rev=570479&view=auto
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/DependenciesComputer.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/DependenciesComputer.java Tue Aug 28 09:32:10 2007
@@ -0,0 +1,473 @@
+/*
+ * 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.model;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+
+import org.apache.commons.collections.MultiMap;
+import org.apache.commons.collections.map.MultiValueMap;
+import org.apache.directory.shared.ldap.schema.SchemaObject;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandler;
+
+
+/**
+ * This class represents the DependenciesComputer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DependenciesComputer
+{
+ /** The schemas List */
+ private List<Schema> schemasList;
+
+ /** The dependency ordered schemas List */
+ private List<Schema> dependencyOrderedSchemasList;
+
+ /** The SchemaHandler */
+ private SchemaHandler schemaHandler;
+
+ // The dependencies MultiMaps
+ private MultiMap schemasDependencies;
+ private MultiMap attributeTypesDependencies;
+ private MultiMap objectClassesDependencies;
+
+
+ /**
+ * Creates a new instance of DependenciesComputer.
+ *
+ * @param schemasList
+ * the schemasList
+ * @throws DependencyComputerException
+ */
+ public DependenciesComputer( List<Schema> schemas ) throws DependencyComputerException
+ {
+ this.schemasList = schemas;
+
+ // Creating the SchemaHandler
+ schemaHandler = new SchemaHandler();
+
+ // Creating the dependencies MultiMaps
+ schemasDependencies = new MultiValueMap();
+ attributeTypesDependencies = new MultiValueMap();
+ objectClassesDependencies = new MultiValueMap();
+
+ if ( schemas != null )
+ {
+ // Adding the schemasList in the SchemaHandler
+ for ( Schema schema : this.schemasList )
+ {
+ schemaHandler.addSchema( schema );
+ }
+
+ // Computing dependencies
+ for ( Schema schema : this.schemasList )
+ {
+ List<AttributeTypeImpl> attributeTypes = schema.getAttributeTypes();
+ if ( attributeTypes != null )
+ {
+ for ( AttributeTypeImpl attributeType : attributeTypes )
+ {
+ computeDependencies( schema, attributeType );
+ }
+ }
+
+ List<ObjectClassImpl> objectClasses = schema.getObjectClasses();
+ if ( objectClasses != null )
+ {
+ for ( ObjectClassImpl objectClass : objectClasses )
+ {
+ computeDependencies( schema, objectClass );
+ }
+ }
+ }
+
+ // Ordering the schemas
+ orderSchemasBasedOnDependencies();
+ }
+ }
+
+
+ /**
+ * Computes the dependencies for the given attribute type.
+ *
+ * @param schema
+ * the schema
+ * @param attributeType
+ * the attribute type
+ * @throws DependencyComputerException
+ */
+ private void computeDependencies( Schema schema, AttributeTypeImpl attributeType )
+ throws DependencyComputerException
+ {
+ // Superior
+ String superior = attributeType.getSuperiorName();
+ if ( superior != null )
+ {
+ AttributeTypeImpl superiorAT = schemaHandler.getAttributeType( superior );
+ if ( superiorAT == null )
+ {
+ throw new DependencyComputerException( "The superior attribute type '" + superior
+ + "' does not exists in the Schema." );
+ }
+ else
+ {
+ // Adding a dependency on the superior attribute type
+ attributeTypesDependencies.put( attributeType, superiorAT );
+
+ // Computing the schema dependency
+ computeSchemaDependency( schema, superiorAT );
+ }
+ }
+
+ // Syntax OID
+ String syntaxOID = attributeType.getSyntaxOid();
+ if ( syntaxOID != null )
+ {
+ SyntaxImpl syntax = schemaHandler.getSyntax( syntaxOID );
+ if ( syntax == null )
+ {
+ throw new DependencyComputerException( "The syntax with OID '" + syntaxOID
+ + "' does not exists in the Schema." );
+ }
+ else
+ {
+ // Adding a dependency on the syntax
+ attributeTypesDependencies.put( attributeType, syntax );
+
+ // Computing the schema dependency
+ computeSchemaDependency( schema, syntax );
+ }
+ }
+
+ // Equality Matching Rule
+ String equalityName = attributeType.getEqualityName();
+ if ( equalityName != null )
+ {
+ MatchingRuleImpl equalityMatchingRule = schemaHandler.getMatchingRule( equalityName );
+ if ( equalityMatchingRule == null )
+ {
+ throw new DependencyComputerException( "The equality matching rule '" + equalityName
+ + "' does not exists in the Schema." );
+ }
+ else
+ {
+ // Adding a dependency on the syntax
+ attributeTypesDependencies.put( attributeType, equalityMatchingRule );
+
+ // Computing the schema dependency
+ computeSchemaDependency( schema, equalityMatchingRule );
+ }
+ }
+
+ // Ordering Matching Rule
+ String orderingName = attributeType.getEqualityName();
+ if ( orderingName != null )
+ {
+ MatchingRuleImpl orderingMatchingRule = schemaHandler.getMatchingRule( orderingName );
+ if ( orderingMatchingRule == null )
+ {
+ throw new DependencyComputerException( "The ordering matching rule '" + orderingName
+ + "' does not exists in the Schema." );
+ }
+ else
+ {
+ // Adding a dependency on the syntax
+ attributeTypesDependencies.put( attributeType, orderingMatchingRule );
+
+ // Computing the schema dependency
+ computeSchemaDependency( schema, orderingMatchingRule );
+ }
+ }
+
+ // Substring Matching Rule
+ String substringName = attributeType.getEqualityName();
+ if ( substringName != null )
+ {
+ MatchingRuleImpl substringMatchingRule = schemaHandler.getMatchingRule( substringName );
+ if ( substringMatchingRule == null )
+ {
+ throw new DependencyComputerException( "The substring matching rule '" + substringName
+ + "' does not exists in the Schema." );
+ }
+ else
+ {
+ // Adding a dependency on the syntax
+ attributeTypesDependencies.put( attributeType, substringMatchingRule );
+
+ // Computing the schema dependency
+ computeSchemaDependency( schema, substringMatchingRule );
+ }
+ }
+ }
+
+
+ /**
+ * Computes the dependencies for the given object Class.
+ *
+ * @param schema
+ * the schema
+ * @param objectClass
+ * the object class
+ * @throws DependencyComputerException
+ */
+ private void computeDependencies( Schema schema, ObjectClassImpl objectClass ) throws DependencyComputerException
+ {
+ // Super Classes
+ String[] superClassesNames = objectClass.getSuperClassesNames();
+ if ( superClassesNames != null )
+ {
+ for ( String superClassName : superClassesNames )
+ {
+ ObjectClassImpl superObjectClass = schemaHandler.getObjectClass( superClassName );
+ if ( superObjectClass == null )
+ {
+ throw new DependencyComputerException( "The superior object class '" + superClassName
+ + "' does not exists in the Schema." );
+ }
+ else
+ {
+ // Adding a dependency on the syntax
+ objectClassesDependencies.put( objectClass, superObjectClass );
+
+ // Computing the schema dependency
+ computeSchemaDependency( schema, superObjectClass );
+ }
+ }
+ }
+
+ // Optional attribute types
+ String[] optionalAttributeTypes = objectClass.getMayNamesList();
+ if ( optionalAttributeTypes != null )
+ {
+ for ( String optionalAttributeTypeName : optionalAttributeTypes )
+ {
+ AttributeTypeImpl optionalAttributeType = schemaHandler.getAttributeType( optionalAttributeTypeName );
+ if ( optionalAttributeType == null )
+ {
+ throw new DependencyComputerException( "The optional attribute type '" + optionalAttributeType
+ + "' does not exists in the Schema." );
+ }
+ else
+ {
+ // Adding a dependency on the syntax
+ objectClassesDependencies.put( objectClass, optionalAttributeType );
+
+ // Computing the schema dependency
+ computeSchemaDependency( schema, optionalAttributeType );
+ }
+ }
+ }
+
+ // Mandatory attribute types
+ String[] mandatoryAttributeTypes = objectClass.getMustNamesList();
+ if ( mandatoryAttributeTypes != null )
+ {
+ for ( String mandatoryAttributeTypeName : mandatoryAttributeTypes )
+ {
+ AttributeTypeImpl mandatoryAttributeType = schemaHandler.getAttributeType( mandatoryAttributeTypeName );
+ if ( mandatoryAttributeType == null )
+ {
+ throw new DependencyComputerException( "The mandatory attribute type '"
+ + mandatoryAttributeTypeName + "' does not exists in the Schema." );
+ }
+ else
+ {
+ // Adding a dependency on the syntax
+ objectClassesDependencies.put( objectClass, mandatoryAttributeType );
+
+ // Computing the schema dependency
+ computeSchemaDependency( schema, mandatoryAttributeType );
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Computes the Schema Dependency.
+ *
+ * @param schema
+ * the schema
+ * @param object
+ * the SchemaObject
+ * @throws DependencyComputerException
+ */
+ private void computeSchemaDependency( Schema schema, SchemaObject object ) throws DependencyComputerException
+ {
+ String schemaName = object.getSchema();
+ if ( !schemaName.equalsIgnoreCase( schema.getName() ) )
+ {
+ Schema schemaFromSuperiorAT = schemaHandler.getSchema( schemaName );
+ if ( schemaFromSuperiorAT == null )
+ {
+ throw new DependencyComputerException( "The schema '" + schemaName + "' does not exists in the Schema." );
+ }
+ else
+ {
+ // Adding a dependency on the schema of schema object
+ schemasDependencies.put( schema, schemaFromSuperiorAT );
+ }
+ }
+ }
+
+
+ /**
+ * Orders the schemas based on their dependencies.
+ */
+ private void orderSchemasBasedOnDependencies()
+ {
+ dependencyOrderedSchemasList = new ArrayList<Schema>();
+
+ int counter = 0;
+ schemasLoop: while ( dependencyOrderedSchemasList.size() != schemasList.size() )
+ {
+ Schema schema = schemasList.get( counter );
+
+ if ( !dependencyOrderedSchemasList.contains( schema ) )
+ {
+
+ List<Schema> dependencies = getDependencies( schema );
+ if ( dependencies == null )
+ {
+ dependencyOrderedSchemasList.add( schema );
+ }
+ else
+ {
+ for ( Schema dependency : dependencies )
+ {
+ if ( !dependencyOrderedSchemasList.contains( dependency ) )
+ {
+ counter = ++counter % schemasList.size();
+
+ continue schemasLoop;
+ }
+ }
+
+ dependencyOrderedSchemasList.add( schema );
+ }
+ }
+
+ counter = ++counter % schemasList.size();
+ }
+
+ }
+
+
+ /**
+ * Gets the dependencies of the given schema.
+ *
+ * @param schema
+ * the schema
+ * @return
+ * the dependencies of the schema
+ */
+ @SuppressWarnings("unchecked")
+ private List<Schema> getDependencies( Schema schema )
+ {
+ List<Schema> dependencies = ( List<Schema> ) schemasDependencies.get( schema );
+
+ HashSet<Schema> set = new HashSet<Schema>();
+
+ if ( dependencies != null )
+ {
+ set.addAll( dependencies );
+ }
+
+ return Arrays.asList( set.toArray( new Schema[0] ) );
+ }
+
+
+ /**
+ * Gets the List of the schemas ordered according to their
+ * dependencies.
+ *
+ * @return
+ * the List of the schemas ordered according to their
+ * dependencies
+ */
+ public List<Schema> getDependencyOrderedSchemasList()
+ {
+ return dependencyOrderedSchemasList;
+ }
+
+
+ /**
+ * Gets the schemasList dependencies MultiMap.
+ *
+ * @return
+ * the schemasList dependencies MultiMap
+ */
+ public MultiMap getSchemasDependencies()
+ {
+ return schemasDependencies;
+ }
+
+
+ /**
+ * Get the attribute types dependencies MultiMap.
+ *
+ * @return
+ * the attribute types dependencies MultiMap
+ */
+ public MultiMap getAttributeTypesDependencies()
+ {
+ return attributeTypesDependencies;
+ }
+
+
+ /**
+ * Gets the object classes dependencies MultiMap.
+ *
+ * @return
+ * the object classes dependencies MultiMap
+ */
+ public MultiMap getObjectClassesDependencies()
+ {
+ return objectClassesDependencies;
+ }
+
+ /**
+ * This class represents the DependencyComputerException.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ public class DependencyComputerException extends Exception
+ {
+ private static final long serialVersionUID = 1L;
+
+
+ /**
+ * Creates a new instance of DependencyComputerException.
+ *
+ * @param message
+ * the message
+ */
+ public DependencyComputerException( String message )
+ {
+ super( message );
+ }
+ }
+}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/SchemaImpl.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/SchemaImpl.java?rev=570479&r1=570478&r2=570479&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/SchemaImpl.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/SchemaImpl.java Tue Aug 28 09:32:10 2007
@@ -296,4 +296,13 @@
{
this.name = name;
}
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return getName();
+ }
}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java?rev=570479&r1=570478&r2=570479&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java Tue Aug 28 09:32:10 2007
@@ -72,11 +72,6 @@
differencesWidget = new DifferencesWidget();
differencesWidget.createWidget( composite );
- Project project = Activator.getDefault().getProjectsHandler().getOpenProject();
-
- differencesWidget.setInput( DifferenceEngine.getDifferences( project.getSchemaBackup(), project
- .getSchemaHandler().getSchemas() ) );
-
initFields();
setControl( composite );
@@ -88,7 +83,10 @@
*/
private void initFields()
{
+ Project project = Activator.getDefault().getProjectsHandler().getOpenProject();
+ differencesWidget.setInput( DifferenceEngine.getDifferences( project.getSchemaBackup(), project
+ .getSchemaHandler().getSchemas() ) );
}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesInformationWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesInformationWizardPage.java?rev=570479&r1=570478&r2=570479&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesInformationWizardPage.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesInformationWizardPage.java Tue Aug 28 09:32:10 2007
@@ -65,7 +65,7 @@
Composite composite = new Composite( parent, SWT.NULL );
GridLayout layout = new GridLayout();
composite.setLayout( layout );
- composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+ 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"
@@ -74,6 +74,12 @@
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 );
}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesWizard.java?rev=570479&r1=570478&r2=570479&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesWizard.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesWizard.java Tue Aug 28 09:32:10 2007
@@ -20,7 +20,16 @@
package org.apache.directory.studio.apacheds.schemaeditor.view.wizards;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
import org.apache.directory.studio.apacheds.schemaeditor.Activator;
+import org.apache.directory.studio.apacheds.schemaeditor.model.DependenciesComputer;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
+import org.apache.directory.studio.apacheds.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;
@@ -35,8 +44,15 @@
*/
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 DependenciesComputer */
+ private DependenciesComputer dependenciesComputer;
+
// The pages of the wizard
private CommitChangesInformationWizardPage commitChangesInformation;
private CommitChangesDifferencesWizardPage commitChangesDifferences;
@@ -62,7 +78,45 @@
*/
public boolean performFinish()
{
- // TODO Implement
+ final List<Schema> orderedSchemas = dependenciesComputer.getDependencyOrderedSchemasList();
+
+ try
+ {
+ getContainer().run( true, true, new IRunnableWithProgress()
+ {
+ public void run( IProgressMonitor monitor )
+ {
+ monitor.beginTask( "Committing changes:", orderedSchemas.size() );
+
+ for ( Schema schema : orderedSchemas )
+ {
+ monitor.subTask( "Committing schema '" + schema.getName() + "'" );
+
+ try
+ {
+ Thread.sleep( 500 );
+ }
+ catch ( InterruptedException e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // TODO implement
+ }
+ }
+ } );
+ }
+ catch ( InvocationTargetException e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch ( InterruptedException e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
return true;
}
@@ -73,7 +127,14 @@
*/
public boolean canFinish()
{
- return ( getContainer().getCurrentPage() instanceof CommitChangesDifferencesWizardPage );
+ if ( schemaContainsErrors )
+ {
+ return false;
+ }
+ else
+ {
+ return ( getContainer().getCurrentPage() instanceof CommitChangesDifferencesWizardPage );
+ }
}
@@ -82,5 +143,40 @@
*/
public void init( IWorkbench workbench, IStructuredSelection selection )
{
+ setNeedsProgressMonitor( true );
+
+ Project 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;
}
}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizard.java?rev=570479&r1=570478&r2=570479&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizard.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewProjectWizard.java Tue Aug 28 09:32:10 2007
@@ -26,11 +26,10 @@
import org.apache.directory.studio.apacheds.schemaeditor.PluginUtils;
import org.apache.directory.studio.apacheds.schemaeditor.controller.ProjectsHandler;
import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
-import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
import org.apache.directory.studio.apacheds.schemaeditor.model.ProjectType;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.StudioProgressMonitor;
-import org.apache.directory.studio.connection.core.io.jndi.JNDIConnectionWrapper;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;