1 20 21 package org.apache.directory.ldapstudio.schemas.view.wizards; 22 23 24 import org.apache.directory.ldapstudio.schemas.model.AttributeType; 25 import org.apache.directory.ldapstudio.schemas.model.Schema; 26 import org.apache.directory.ldapstudio.schemas.model.SchemaPool; 27 import org.apache.directory.ldapstudio.schemas.view.editors.attributeType.AttributeTypeEditor; 28 import org.apache.directory.ldapstudio.schemas.view.editors.attributeType.AttributeTypeEditorInput; 29 import org.apache.directory.server.core.tools.schema.AttributeTypeLiteral; 30 import org.eclipse.jface.viewers.IStructuredSelection; 31 import org.eclipse.jface.wizard.Wizard; 32 import org.eclipse.ui.INewWizard; 33 import org.eclipse.ui.IWorkbench; 34 import org.eclipse.ui.PartInitException; 35 import org.eclipse.ui.PlatformUI; 36 37 38 41 public class CreateANewAttributeTypeWizard extends Wizard implements INewWizard 42 { 43 44 private CreateANewAttributeTypeWizardPage page; 45 46 47 private String schemaName; 48 49 50 57 public CreateANewAttributeTypeWizard( String schemaName ) 58 { 59 super(); 60 this.schemaName = schemaName; 61 } 62 63 64 67 public boolean performFinish() 68 { 69 SchemaPool pool = SchemaPool.getInstance(); 71 72 Schema schema = pool.getSchema( schemaName ); 74 75 AttributeTypeLiteral attributeTypeLiteral = new AttributeTypeLiteral( this.page.getOidField() ); 77 attributeTypeLiteral.setNames( new String [] 78 { this.page.getNameField() } ); 79 AttributeType attributeType = new AttributeType( attributeTypeLiteral, schema ); 80 schema.addAttributeType( attributeType ); 81 82 AttributeTypeEditorInput input = new AttributeTypeEditorInput( attributeType ); 84 String editorId = AttributeTypeEditor.ID; 85 try 86 { 87 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor( input, editorId ); 88 } 89 catch ( PartInitException e ) 90 { 91 } 93 94 return true; 95 } 96 97 98 101 public void addPages() 102 { 103 this.page = new CreateANewAttributeTypeWizardPage(); 104 addPage( page ); 105 } 106 107 108 111 public void init( IWorkbench workbench, IStructuredSelection selection ) 112 { 113 } 114 } 115 | Popular Tags |