1 20 package org.apache.directory.ldapstudio.apacheds.configuration.editor; 21 22 23 import org.apache.directory.ldapstudio.apacheds.configuration.model.ExtendedOperation; 24 import org.eclipse.jface.viewers.ISelection; 25 import org.eclipse.jface.viewers.IStructuredSelection; 26 import org.eclipse.swt.SWT; 27 import org.eclipse.swt.events.ModifyEvent; 28 import org.eclipse.swt.events.ModifyListener; 29 import org.eclipse.swt.layout.GridData; 30 import org.eclipse.swt.layout.GridLayout; 31 import org.eclipse.swt.widgets.Composite; 32 import org.eclipse.swt.widgets.Text; 33 import org.eclipse.ui.forms.IDetailsPage; 34 import org.eclipse.ui.forms.IFormPart; 35 import org.eclipse.ui.forms.IManagedForm; 36 import org.eclipse.ui.forms.widgets.FormToolkit; 37 import org.eclipse.ui.forms.widgets.Section; 38 import org.eclipse.ui.forms.widgets.TableWrapData; 39 import org.eclipse.ui.forms.widgets.TableWrapLayout; 40 41 42 48 public class ExtendedOperationDetailsPage implements IDetailsPage 49 { 50 51 private ExtendedOperationsMasterDetailsBlock masterDetailsBlock; 52 53 54 private IManagedForm mform; 55 56 57 private ExtendedOperation input; 58 59 60 private boolean dirty = false; 61 62 private Text classTypeText; 64 65 67 private ModifyListener textModifyListener = new ModifyListener() 68 { 69 public void modifyText( ModifyEvent e ) 70 { 71 masterDetailsBlock.setEditorDirty(); 72 dirty = true; 73 } 74 }; 75 76 77 83 public ExtendedOperationDetailsPage( ExtendedOperationsMasterDetailsBlock emdb ) 84 { 85 masterDetailsBlock = emdb; 86 } 87 88 89 92 public void createContents( Composite parent ) 93 { 94 FormToolkit toolkit = mform.getToolkit(); 95 TableWrapLayout layout = new TableWrapLayout(); 96 layout.topMargin = 5; 97 layout.leftMargin = 5; 98 layout.rightMargin = 2; 99 layout.bottomMargin = 2; 100 parent.setLayout( layout ); 101 102 createDetailsSection( parent, toolkit ); 103 } 104 105 106 114 private void createDetailsSection( Composite parent, FormToolkit toolkit ) 115 { 116 Section section = toolkit.createSection( parent, Section.DESCRIPTION | Section.TITLE_BAR ); 117 section.marginWidth = 10; 118 section.setText( "Extended Operation Details" ); section.setDescription( "Set the properties of the extended operation." ); TableWrapData td = new TableWrapData( TableWrapData.FILL, TableWrapData.TOP ); 121 td.grabHorizontal = true; 122 section.setLayoutData( td ); 123 Composite client = toolkit.createComposite( section ); 124 toolkit.paintBordersFor( client ); 125 GridLayout glayout = new GridLayout( 3, false ); 126 client.setLayout( glayout ); 127 section.setClient( client ); 128 129 toolkit.createLabel( client, "Class:" ); 131 classTypeText = toolkit.createText( client, "" ); 132 classTypeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) ); 133 134 addListeners(); 135 } 136 137 138 141 private void addListeners() 142 { 143 classTypeText.addModifyListener( textModifyListener ); 144 } 145 146 147 150 private void removeListeners() 151 { 152 classTypeText.removeModifyListener( textModifyListener ); 153 } 154 155 156 159 public void selectionChanged( IFormPart part, ISelection selection ) 160 { 161 IStructuredSelection ssel = ( IStructuredSelection ) selection; 162 if ( ssel.size() == 1 ) 163 { 164 input = ( ExtendedOperation ) ssel.getFirstElement(); 165 } 166 else 167 { 168 input = null; 169 } 170 refresh(); 171 } 172 173 174 177 public void commit( boolean onSave ) 178 { 179 if ( input != null ) 180 { 181 input.setClassType( classTypeText.getText() ); 182 } 183 } 184 185 186 189 public void dispose() 190 { 191 } 192 193 194 197 public void initialize( IManagedForm form ) 198 { 199 this.mform = form; 200 } 201 202 203 206 public boolean isDirty() 207 { 208 return dirty; 209 } 210 211 212 215 public boolean isStale() 216 { 217 return false; 218 } 219 220 221 224 public void refresh() 225 { 226 removeListeners(); 227 228 classTypeText.setText( input.getClassType() ); 229 230 addListeners(); 231 } 232 233 234 237 public void setFocus() 238 { 239 classTypeText.setFocus(); 240 } 241 242 243 246 public boolean setFormInput( Object input ) 247 { 248 return false; 249 } 250 } 251 | Popular Tags |