1 20 21 package org.apache.directory.ldapstudio.browser.common.wizards; 22 23 24 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator; 25 import org.apache.directory.ldapstudio.browser.core.model.IEntry; 26 import org.eclipse.jface.viewers.IStructuredSelection; 27 import org.eclipse.jface.wizard.IWizardPage; 28 import org.eclipse.jface.wizard.Wizard; 29 import org.eclipse.jface.wizard.WizardPage; 30 import org.eclipse.swt.SWT; 31 import org.eclipse.swt.layout.GridData; 32 import org.eclipse.swt.layout.GridLayout; 33 import org.eclipse.swt.widgets.Composite; 34 import org.eclipse.ui.INewWizard; 35 import org.eclipse.ui.IWorkbench; 36 import org.eclipse.ui.PlatformUI; 37 38 39 46 public class AttributeWizard extends Wizard implements INewWizard 47 { 48 49 50 private AttributeTypeWizardPage typePage; 51 52 53 private AttributeOptionsWizardPage optionsPage; 54 55 56 private boolean initialShowSubschemaAttributesOnly; 57 58 59 private boolean initialHideExistingAttributes; 60 61 62 private String initialAttributeDescription; 63 64 65 private IEntry initialEntry; 66 67 68 private String finalAttributeDescription = null; 69 70 71 75 public AttributeWizard() 76 { 77 super.setWindowTitle( "New Attribute" ); 78 super.setNeedsProgressMonitor( false ); 79 this.initialShowSubschemaAttributesOnly = true; 80 this.initialHideExistingAttributes = true; 81 this.initialAttributeDescription = ""; 82 this.initialEntry = null; 83 } 84 85 86 95 public AttributeWizard( String title, boolean showSubschemaAttributesOnly, boolean hideExistingAttributes, 96 String attributeDescription, IEntry entry ) 97 { 98 super.setWindowTitle( title ); 99 super.setNeedsProgressMonitor( false ); 100 this.initialShowSubschemaAttributesOnly = showSubschemaAttributesOnly; 101 this.initialHideExistingAttributes = hideExistingAttributes; 102 this.initialAttributeDescription = attributeDescription; 103 this.initialEntry = entry; 104 } 105 106 107 112 public static String getId() 113 { 114 return AttributeWizard.class.getName(); 115 } 116 117 118 121 public void init( IWorkbench workbench, IStructuredSelection selection ) 122 { 123 } 124 125 126 129 public void addPages() 130 { 131 if ( initialEntry != null ) 132 { 133 typePage = new AttributeTypeWizardPage( AttributeTypeWizardPage.class.getName(), initialEntry, 134 initialAttributeDescription, initialShowSubschemaAttributesOnly, initialHideExistingAttributes, this ); 135 addPage( typePage ); 136 137 optionsPage = new AttributeOptionsWizardPage( AttributeOptionsWizardPage.class.getName(), 138 initialAttributeDescription, this ); 139 addPage( optionsPage ); 140 } 141 else 142 { 143 IWizardPage page = new DummyWizardPage(); 144 addPage( page ); 145 } 146 } 147 148 149 152 public void createPageControls( Composite pageContainer ) 153 { 154 super.createPageControls( pageContainer ); 155 156 PlatformUI.getWorkbench().getHelpSystem().setHelp( typePage.getControl(), 158 BrowserCommonActivator.PLUGIN_ID + "." + "tools_attribute_wizard" ); 159 PlatformUI.getWorkbench().getHelpSystem().setHelp( optionsPage.getControl(), 160 BrowserCommonActivator.PLUGIN_ID + "." + "tools_attribute_wizard" ); 161 } 162 163 169 class DummyWizardPage extends WizardPage 170 { 171 172 175 protected DummyWizardPage() 176 { 177 super( "" ); 178 super.setTitle( "No entry selected" ); 179 super.setDescription( "In order to use the attribute creation wizard please select an entry." ); 180 super.setPageComplete( true ); 182 } 183 184 185 188 public void createControl( Composite parent ) 189 { 190 Composite composite = new Composite( parent, SWT.NONE ); 191 GridLayout gl = new GridLayout( 1, false ); 192 composite.setLayout( gl ); 193 composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); 194 195 setControl( composite ); 196 } 197 } 198 199 200 203 public boolean performFinish() 204 { 205 finalAttributeDescription = getAttributeDescription(); 206 return true; 207 } 208 209 210 215 public String getAttributeDescription() 216 { 217 if ( finalAttributeDescription != null ) 218 { 219 return finalAttributeDescription; 220 } 221 222 return typePage.getAttributeType() + optionsPage.getAttributeOptions(); 223 } 224 225 } 226 | Popular Tags |