1 20 21 package org.apache.directory.ldapstudio.schemas.view.wizards; 22 23 24 import org.apache.directory.ldapstudio.schemas.model.ObjectClass; 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.objectClass.ObjectClassEditor; 28 import org.apache.directory.ldapstudio.schemas.view.editors.objectClass.ObjectClassEditorInput; 29 import org.apache.directory.server.core.tools.schema.ObjectClassLiteral; 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 44 public class CreateANewObjectClassWizard extends Wizard implements INewWizard 45 { 46 47 private CreateANewObjectClassWizardPage page; 48 49 50 private String schemaName; 51 52 53 58 public CreateANewObjectClassWizard( String schemaName ) 59 { 60 super(); 61 this.schemaName = schemaName; 62 } 63 64 65 68 public boolean performFinish() 69 { 70 SchemaPool pool = SchemaPool.getInstance(); 72 73 Schema schema = pool.getSchema( schemaName ); 75 76 ObjectClassLiteral objectClassLiteral = new ObjectClassLiteral( this.page.getOidField() ); 78 objectClassLiteral.setNames( new String [] 79 { this.page.getNameField() } ); 80 objectClassLiteral.setSuperiors( new String [] 81 { "top" } ); ObjectClass objectClass = new ObjectClass( objectClassLiteral, schema ); 83 schema.addObjectClass( objectClass ); 84 85 ObjectClassEditorInput input = new ObjectClassEditorInput( objectClass ); 87 String editorId = ObjectClassEditor.ID; 88 try 89 { 90 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor( input, editorId ); 91 } 92 catch ( PartInitException e ) 93 { 94 } 95 96 return true; 97 } 98 99 100 103 public void addPages() 104 { 105 this.page = new CreateANewObjectClassWizardPage(); 106 addPage( page ); 107 } 108 109 110 113 public void init( IWorkbench workbench, IStructuredSelection selection ) 114 { 115 } 116 } 117 | Popular Tags |