directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r558772 - 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:23:03 GMT
Author: pamarcelot
Date: Mon Jul 23 08:23:03 2007
New Revision: 558772

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

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/NewAttributeTypeAction.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/NewAttributeTypeGeneralWizardPage.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewAttributeTypeWizard.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=558772&r1=558771&r2=558772
==============================================================================
--- 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:23:03 2007
@@ -368,7 +368,7 @@
     {
         connect = new ConnectAction( view );
         newSchema = new NewSchemaAction();
-        newAttributeType = new NewAttributeTypeAction();
+        newAttributeType = new NewAttributeTypeAction( viewer );
         newObjectClass = new NewObjectClassAction( viewer );
         openElement = new OpenElementAction( viewer );
         deleteSchemaElement = new DeleteSchemaElementAction( viewer );

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/NewAttributeTypeAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/NewAttributeTypeAction.java?view=diff&rev=558772&r1=558771&r2=558772
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/NewAttributeTypeAction.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/NewAttributeTypeAction.java
Mon Jul 23 08:23:03 2007
@@ -22,11 +22,18 @@
 
 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.NewAttributeTypeWizard;
+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 +49,14 @@
  */
 public class NewAttributeTypeAction extends Action implements IWorkbenchWindowActionDelegate
 {
+    /** The associated viewer */
+    private TreeViewer viewer;
+
+
     /**
      * Creates a new instance of NewAttributeTypeAction.
      */
-    public NewAttributeTypeAction()
+    public NewAttributeTypeAction( TreeViewer viewer )
     {
         super( "New Attribute Type" );
         setToolTipText( getText() );
@@ -53,6 +64,7 @@
         setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
             PluginConstants.IMG_ATTRIBUTE_TYPE_NEW ) );
         setEnabled( false );
+        this.viewer = viewer;
     }
 
 
@@ -61,9 +73,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
         NewAttributeTypeWizard wizard = new NewAttributeTypeWizard();
         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/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=558772&r1=558771&r2=558772
==============================================================================
--- 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:23:03 2007
@@ -20,8 +20,6 @@
 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;

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java?view=diff&rev=558772&r1=558771&r2=558772
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java
Mon Jul 23 08:23:03 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/NewAttributeTypeWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewAttributeTypeWizard.java?view=diff&rev=558772&r1=558771&r2=558772
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewAttributeTypeWizard.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/NewAttributeTypeWizard.java
Mon Jul 23 08:23:03 2007
@@ -22,6 +22,7 @@
 
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
+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 NewAttributeTypeWizard extends Wizard implements INewWizard
 {
+    /** The selected schema */
+    private Schema selectedSchema;
+
     // The pages of the wizards
     private NewAttributeTypeGeneralWizardPage generalPage;
     private NewAttributeTypeContentWizardPage contentPage;
@@ -49,6 +53,7 @@
     {
         // Creating pages
         generalPage = new NewAttributeTypeGeneralWizardPage();
+        generalPage.setSelectedSchema( selectedSchema );
         contentPage = new NewAttributeTypeContentWizardPage();
         matchingRulesPage = new NewAttributeTypeMatchingRulesWizardPage();
 
@@ -79,12 +84,12 @@
         newAT.setEqualityName( matchingRulesPage.getEqualityMatchingRuleValue() );
         newAT.setOrderingName( matchingRulesPage.getOrderingMatchingRuleValue() );
         newAT.setSubstrName( matchingRulesPage.getSubstringMatchingRuleValue() );
-        
+
         Activator.getDefault().getSchemaHandler().addAttributeType( newAT );
-        
+
         return true;
     }
-    
+
 
     /* (non-Javadoc)
      * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
@@ -92,5 +97,17 @@
     public void init( IWorkbench workbench, IStructuredSelection selection )
     {
         // Nothing to do.
+    }
+
+
+    /**
+     * Sets the selected schema.
+     *
+     * @param schema
+     *      the selected schema
+     */
+    public void setSelectedSchema( Schema schema )
+    {
+        selectedSchema = schema;
     }
 }



Mime
View raw message