1 20 21 package org.apache.directory.ldapstudio.browser.ui.wizards; 22 23 24 import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils; 25 import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyEvent; 26 import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyListener; 27 import org.apache.directory.ldapstudio.browser.common.widgets.search.EntryWidget; 28 import org.apache.directory.ldapstudio.browser.core.model.DN; 29 import org.apache.directory.ldapstudio.browser.core.model.IEntry; 30 import org.eclipse.jface.wizard.WizardPage; 31 import org.eclipse.swt.SWT; 32 import org.eclipse.swt.events.ModifyEvent; 33 import org.eclipse.swt.events.ModifyListener; 34 import org.eclipse.swt.layout.GridData; 35 import org.eclipse.swt.layout.GridLayout; 36 import org.eclipse.swt.widgets.Composite; 37 import org.eclipse.swt.widgets.Text; 38 39 40 47 public class NewBookmarkMainWizardPage extends WizardPage implements WidgetModifyListener 48 { 49 50 51 private IEntry entry; 52 53 54 private Text bookmarkNameText; 55 56 57 private EntryWidget bookmarkEntryWidget; 58 59 60 67 public NewBookmarkMainWizardPage( String pageName, IEntry entry, NewBookmarkWizard wizard ) 68 { 69 super( pageName ); 70 setTitle( "New Bookmark" ); 71 setDescription( "Please enter the bookmark parameters." ); 72 setPageComplete( false ); 74 75 this.entry = entry; 76 } 77 78 79 82 public void dispose() 83 { 84 super.dispose(); 85 bookmarkEntryWidget.removeWidgetModifyListener( this ); 86 } 87 88 89 92 private void validate() 93 { 94 if ( bookmarkNameText != null && !bookmarkNameText.isDisposed() ) 95 { 96 setPageComplete( bookmarkEntryWidget.getDn() != null && !"".equals( bookmarkNameText.getText() ) ); 97 } 98 } 99 100 101 104 public void setVisible( boolean visible ) 105 { 106 super.setVisible( visible ); 107 if ( visible ) 108 { 109 validate(); 110 } 111 } 112 113 114 117 public void createControl( Composite parent ) 118 { 119 Composite composite = new Composite( parent, SWT.NONE ); 120 GridLayout gl = new GridLayout( 1, false ); 121 composite.setLayout( gl ); 122 composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); 123 124 Composite innerComposite = BaseWidgetUtils.createColumnContainer( composite, 3, 1 ); 125 126 BaseWidgetUtils.createLabel( innerComposite, "Bookmark Name:", 1 ); 127 bookmarkNameText = BaseWidgetUtils.createText( innerComposite, entry.getDn().toString(), 2 ); 128 bookmarkNameText.setFocus(); 129 bookmarkNameText.addModifyListener( new ModifyListener() 130 { 131 public void modifyText( ModifyEvent e ) 132 { 133 validate(); 134 } 135 } ); 136 137 BaseWidgetUtils.createLabel( innerComposite, "Bookmark DN:", 1 ); 138 bookmarkEntryWidget = new EntryWidget(); 139 bookmarkEntryWidget.addWidgetModifyListener( this ); 140 bookmarkEntryWidget.createWidget( innerComposite ); 141 bookmarkEntryWidget.setInput( entry.getConnection(), entry.getDn() ); 142 143 setControl( composite ); 144 } 145 146 147 150 public void widgetModified( WidgetModifyEvent event ) 151 { 152 validate(); 153 } 154 155 156 161 public DN getBookmarkDn() 162 { 163 return bookmarkEntryWidget.getDn(); 164 } 165 166 167 172 public String getBookmarkName() 173 { 174 return bookmarkNameText.getText(); 175 } 176 177 178 181 public void saveDialogSettings() 182 { 183 bookmarkEntryWidget.saveDialogSettings(); 184 } 185 186 } 187 | Popular Tags |