directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r558768 - in /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor: controller/ controller/actions/ view/wizards/
Date Mon, 23 Jul 2007 15:17:25 GMT
Author: pamarcelot
Date: Mon Jul 23 08:17:24 2007
New Revision: 558768

URL: http://svn.apache.org/viewvc?view=rev&rev=558768
Log:
Added in the NewObjectClassWizard the ability to pre-select the selected schema.
Used this feature in the SchemaView for the NewObjectClassAction.

Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/DeleteSchemaElementAction.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/NewObjectClassAction.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewObjectClassWizard.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java?view=diff&rev=558768&r1=558767&r2=558768
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
Mon Jul 23 08:17:24 2007
@@ -23,7 +23,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.CollapseAllAction;
@@ -64,9 +63,9 @@
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.IWorkbenchPage;
@@ -258,8 +257,8 @@
          */
         public void schemaAdded( Schema schema )
         {
-            TreeNode rootNode = ( TreeNode ) viewer.getInput();
-            SchemaWrapper schemaWrapper = new SchemaWrapper( schema, rootNode );
+            final TreeNode rootNode = ( TreeNode ) viewer.getInput();
+            final SchemaWrapper schemaWrapper = new SchemaWrapper( schema, rootNode );
             rootNode.addChild( schemaWrapper );
 
             int group = Activator.getDefault().getPreferenceStore().getInt( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING
);
@@ -294,8 +293,14 @@
                 }
             }
 
-            viewer.refresh( rootNode );
-            viewer.setSelection( new StructuredSelection( schemaWrapper ) );
+            Display.getDefault().asyncExec( new Runnable()
+            {
+                public void run()
+                {
+                    viewer.refresh( rootNode );
+                    viewer.setSelection( new StructuredSelection( schemaWrapper ) );
+                }
+            } );
         }
 
 
@@ -364,7 +369,7 @@
         connect = new ConnectAction( view );
         newSchema = new NewSchemaAction();
         newAttributeType = new NewAttributeTypeAction();
-        newObjectClass = new NewObjectClassAction();
+        newObjectClass = new NewObjectClassAction( viewer );
         openElement = new OpenElementAction( viewer );
         deleteSchemaElement = new DeleteSchemaElementAction( viewer );
         importSchemasFromOpenLdap = new ImportSchemasFromOpenLdapAction();
@@ -622,58 +627,6 @@
                 }
             }
         } );
-    }
-
-
-    /**
-     * Finds the parent node of a given element (AT or OT).
-     *
-     * @param element
-     *      the element
-     * @return
-     *      the parent node of a given element (AT or OT)
-     */
-    private TreeNode findParentElement( SchemaObject element )
-    {
-        // Finding the associated SchemaWrapper
-        TreeNode schemaWrapper = findSchemaWrapperInTree( element.getSchema() );
-        if ( schemaWrapper == null )
-        {
-            return null;
-        }
-
-        // Finding the correct node
-        TreeNode parentNode = null;
-        int group = Activator.getDefault().getPreferenceStore().getInt( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING
);
-        if ( group == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_FOLDERS )
-        {
-            Object[] children = ( ( ITreeContentProvider ) viewer.getContentProvider() ).getChildren(
schemaWrapper );
-            for ( Object child : children )
-            {
-                Folder folder = ( Folder ) child;
-
-                if ( element instanceof AttributeTypeImpl )
-                {
-                    if ( folder.getType() == FolderType.ATTRIBUTE_TYPE )
-                    {
-                        parentNode = folder;
-                    }
-                }
-                else if ( element instanceof ObjectClassImpl )
-                {
-                    if ( folder.getType() == FolderType.OBJECT_CLASS )
-                    {
-                        parentNode = folder;
-                    }
-                }
-            }
-        }
-        else if ( group == PluginConstants.PREFS_SCHEMA_VIEW_GROUPING_MIXED )
-        {
-            parentNode = schemaWrapper;
-        }
-
-        return parentNode;
     }
 
 

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/DeleteSchemaElementAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/DeleteSchemaElementAction.java?view=diff&rev=558768&r1=558767&r2=558768
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/DeleteSchemaElementAction.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/DeleteSchemaElementAction.java
Mon Jul 23 08:17:24 2007
@@ -34,7 +34,6 @@
 import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.AttributeTypeWrapper;
-import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.Folder;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ObjectClassWrapper;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.SchemaWrapper;
 import org.eclipse.jface.action.Action;

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/NewObjectClassAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/NewObjectClassAction.java?view=diff&rev=558768&r1=558767&r2=558768
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/NewObjectClassAction.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/NewObjectClassAction.java
Mon Jul 23 08:17:24 2007
@@ -20,13 +20,22 @@
 package org.apache.directory.studio.apacheds.schemaeditor.controller.actions;
 
 
+import java.util.Iterator;
+
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wizards.NewObjectClassWizard;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.AttributeTypeWrapper;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.Folder;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ObjectClassWrapper;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.SchemaWrapper;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.TreeNode;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
@@ -42,10 +51,14 @@
  */
 public class NewObjectClassAction extends Action implements IWorkbenchWindowActionDelegate
 {
+    /** The associated viewer */
+    private TreeViewer viewer;
+
+
     /**
      * Creates a new instance of NewObjectClassAction.
      */
-    public NewObjectClassAction()
+    public NewObjectClassAction( TreeViewer viewer )
     {
         super( "New Object Class" );
         setToolTipText( getText() );
@@ -53,6 +66,7 @@
         setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
             PluginConstants.IMG_OBJECT_CLASS_NEW ) );
         setEnabled( false );
+        this.viewer = viewer;
     }
 
 
@@ -61,9 +75,53 @@
      */
     public void run()
     {
+        // Getting the selection
+        Schema selectedSchema = null;
+        StructuredSelection selection = ( StructuredSelection ) viewer.getSelection();
+        if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
+        {
+            Object firstElement = selection.getFirstElement();
+            if ( firstElement instanceof SchemaWrapper )
+            {
+                selectedSchema = ( ( SchemaWrapper ) firstElement ).getSchema();
+            }
+            else if ( firstElement instanceof Folder )
+            {
+                selectedSchema = ( ( SchemaWrapper ) ( ( Folder ) firstElement ).getParent()
).getSchema();
+            }
+            else if ( firstElement instanceof AttributeTypeWrapper )
+            {
+                TreeNode parent = ( ( AttributeTypeWrapper ) firstElement ).getParent();
+
+                if ( parent instanceof Folder )
+                {
+                    selectedSchema = ( ( SchemaWrapper ) ( ( Folder ) parent ).getParent()
).getSchema();
+
+                }
+                else if ( parent instanceof SchemaWrapper )
+                {
+                    selectedSchema = ( ( SchemaWrapper ) parent ).getSchema();
+                }
+            }
+            else if ( firstElement instanceof ObjectClassWrapper )
+            {
+                TreeNode parent = ( ( ObjectClassWrapper ) firstElement ).getParent();
+
+                if ( parent instanceof Folder )
+                {
+                    selectedSchema = ( ( SchemaWrapper ) ( ( Folder ) parent ).getParent()
).getSchema();
+                }
+                else if ( parent instanceof SchemaWrapper )
+                {
+                    selectedSchema = ( ( SchemaWrapper ) parent ).getSchema();
+                }
+            }
+        }
+
         // Instantiates and initializes the wizard
         NewObjectClassWizard wizard = new NewObjectClassWizard();
         wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY );
+        wizard.setSelectedSchema( selectedSchema );
         // Instantiates the wizard container with the wizard and opens it
         WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
wizard );
         dialog.create();

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java?view=diff&rev=558768&r1=558767&r2=558768
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java
Mon Jul 23 08:17:24 2007
@@ -68,6 +68,9 @@
     /** The aliases */
     private String[] aliases;
 
+    /** The selected schema */
+    private Schema selectedSchema;
+
     // UI fields
     private ComboViewer schemaComboViewer;
     private Text oidText;
@@ -222,6 +225,11 @@
     private void initFields()
     {
         schemaComboViewer.setInput( schemaHandler.getSchemas() );
+
+        if ( selectedSchema != null )
+        {
+            schemaComboViewer.setSelection( new StructuredSelection( selectedSchema ) );
+        }
     }
 
 
@@ -359,5 +367,17 @@
     public String getDescriptionValue()
     {
         return descriptionText.getText();
+    }
+
+
+    /**
+     * Sets the selected schema.
+     *
+     * @param schema
+     *      the selected schema
+     */
+    public void setSelectedSchema( Schema schema )
+    {
+        selectedSchema = schema;
     }
 }

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewObjectClassWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewObjectClassWizard.java?view=diff&rev=558768&r1=558767&r2=558768
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewObjectClassWizard.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewObjectClassWizard.java
Mon Jul 23 08:17:24 2007
@@ -22,6 +22,7 @@
 
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.INewWizard;
@@ -36,6 +37,9 @@
  */
 public class NewObjectClassWizard extends Wizard implements INewWizard
 {
+    /** The selected schema */
+    private Schema selectedSchema;
+
     // The pages of the wizards
     private NewObjectClassGeneralPageWizardPage generalPage;
     private NewObjectClassContentWizardPage contentPage;
@@ -50,6 +54,7 @@
     {
         // Creating pages
         generalPage = new NewObjectClassGeneralPageWizardPage();
+        generalPage.setSelectedSchema( selectedSchema );
         contentPage = new NewObjectClassContentWizardPage();
         mandatoryAttributesPage = new NewObjectClassMandatoryAttributesPage();
         optionalAttributesPage = new NewObjectClassOptionalAttributesPage();
@@ -113,5 +118,17 @@
     public NewObjectClassOptionalAttributesPage getOptionalAttributesPage()
     {
         return optionalAttributesPage;
+    }
+
+
+    /**
+     * Sets the selected schema.
+     *
+     * @param schema
+     *      the selected schema
+     */
+    public void setSelectedSchema( Schema schema )
+    {
+        selectedSchema = schema;
     }
 }



Mime
View raw message