KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > editors > schemabrowser > AttributeTypeDescriptionDetailsPage


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.browser.ui.editors.schemabrowser;
22
23
24 import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
25 import org.apache.directory.ldapstudio.browser.core.model.schema.LdapSyntaxDescription;
26 import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleDescription;
27 import org.apache.directory.ldapstudio.browser.core.model.schema.ObjectClassDescription;
28 import org.eclipse.swt.SWT;
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.Label;
33 import org.eclipse.swt.widgets.Text;
34 import org.eclipse.ui.forms.events.ExpansionAdapter;
35 import org.eclipse.ui.forms.events.ExpansionEvent;
36 import org.eclipse.ui.forms.widgets.FormToolkit;
37 import org.eclipse.ui.forms.widgets.Hyperlink;
38 import org.eclipse.ui.forms.widgets.ScrolledForm;
39 import org.eclipse.ui.forms.widgets.Section;
40
41
42 /**
43  * The AttributeTypeDescriptionDetailsPage displays the details of an
44  * attribute type description.
45  *
46  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
47  * @version $Rev$, $Date$
48  */

49 public class AttributeTypeDescriptionDetailsPage extends SchemaDetailsPage
50 {
51
52     /** The main section, contains oid, names, desc and usage */
53     private Section mainSection;
54
55     /** The numeric oid field */
56     private Text numericOidText;
57
58     /** The names field */
59     private Text namesText;
60
61     /** The description field */
62     private Text descText;
63
64     /** The usage field */
65     private Text usageText;
66
67     /** The flag section, contains sv, obsolete, collective and read-only */
68     private Section flagSection;
69
70     /** The single-valued field */
71     private Label singleValuedText;
72
73     /** The obsolete field */
74     private Label isObsoleteText;
75
76     /** The collective field */
77     private Label collectiveText;
78
79     /** The no-user-modification field */
80     private Label noUserModificationText;
81
82     /** The syntax section, contains syntax description, lenth and a link to the syntax */
83     private Section syntaxSection;
84
85     /** The syntax description field */
86     private Text syntaxDescText;
87
88     /** The syntax length field */
89     private Text lengthText;
90
91     /** The link to the syntax */
92     private Hyperlink syntaxLink;
93
94     /** The matching rules section, contains links to matching rules */
95     private Section matchingRulesSection;
96
97     /** The link to the equality matching rule */
98     private Hyperlink equalityLink;
99
100     /** The link to the substring matching rule */
101     private Hyperlink substringLink;
102
103     /** The link to the ordering matching rule */
104     private Hyperlink orderingLink;
105
106     /** The section with other matching rules */
107     private Section otherMatchSection;
108
109     /** The links to other matching rules applicaple to the selected attribute */
110     private Hyperlink[] otherMatchLinks;
111
112     /** The section with links to object classes using the selected attribute as must */
113     private Section usedAsMustSection;
114
115     /** The links to object classes using the selected attribute as must */
116     private Hyperlink[] usedAsMustLinks;
117
118     /** The section with links to object classes using the selected attribute as may */
119     private Section usedAsMaySection;
120
121     /** The links to object classes using the selected attribute as may */
122     private Hyperlink[] usedAsMayLinks;
123
124     /** The section with a link to the superior attribute type */
125     private Section supertypeSection;
126
127     /** The link to the superior attribute type */
128     private Hyperlink superLink;
129
130     /** The section with links to the derived attribute types */
131     private Section subtypesSection;
132
133     /** The links to derived attribute types */
134     private Hyperlink[] subAttributeTypeLinks;
135
136
137     /**
138      * Creates a new instance of AttributeTypeDescriptionDetailsPage.
139      *
140      * @param schemaPage the master schema page
141      * @param toolkit the toolkit used to create controls
142      */

143     public AttributeTypeDescriptionDetailsPage( SchemaPage schemaPage, FormToolkit toolkit )
144     {
145         super( schemaPage, toolkit );
146     }
147
148
149     /**
150      * {@inheritDoc}
151      */

152     protected void createContents( final ScrolledForm detailForm )
153     {
154
155         this.detailForm = detailForm;
156         detailForm.getBody().setLayout( new GridLayout() );
157
158         // create main section
159
mainSection = toolkit.createSection( detailForm.getBody(), SWT.NONE );
160         mainSection.setText( "Details" );
161         mainSection.marginWidth = 0;
162         mainSection.marginHeight = 0;
163         mainSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
164         toolkit.createCompositeSeparator( mainSection );
165
166         // create flag section
167
flagSection = toolkit.createSection( detailForm.getBody(), SWT.NONE );
168         flagSection.setText( "Flags" );
169         flagSection.marginWidth = 0;
170         flagSection.marginHeight = 0;
171         flagSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
172         toolkit.createCompositeSeparator( flagSection );
173
174         // create flags content
175
Composite flagClient = toolkit.createComposite( flagSection, SWT.WRAP );
176         GridLayout flagLayout = new GridLayout();
177         flagLayout.numColumns = 4;
178         flagLayout.marginWidth = 0;
179         flagLayout.marginHeight = 0;
180         flagClient.setLayout( flagLayout );
181         flagSection.setClient( flagClient );
182
183         singleValuedText = toolkit.createLabel( flagClient, "Single valued", SWT.CHECK );
184         singleValuedText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
185         singleValuedText.setEnabled( false );
186
187         noUserModificationText = toolkit.createLabel( flagClient, "Read only", SWT.CHECK );
188         noUserModificationText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
189         noUserModificationText.setEnabled( false );
190
191         collectiveText = toolkit.createLabel( flagClient, "Collective", SWT.CHECK );
192         collectiveText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
193         collectiveText.setEnabled( false );
194
195         isObsoleteText = toolkit.createLabel( flagClient, "Obsolete", SWT.CHECK );
196         isObsoleteText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
197         isObsoleteText.setEnabled( false );
198
199         // create syntax section
200
syntaxSection = toolkit.createSection( detailForm.getBody(), SWT.NONE );
201         syntaxSection.setText( "Syntax" );
202         syntaxSection.marginWidth = 0;
203         syntaxSection.marginHeight = 0;
204         syntaxSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
205         toolkit.createCompositeSeparator( syntaxSection );
206
207         // create syntax content
208
Composite syntaxClient = toolkit.createComposite( syntaxSection, SWT.WRAP );
209         GridLayout syntaxLayout = new GridLayout();
210         syntaxLayout.numColumns = 2;
211         syntaxLayout.marginWidth = 0;
212         syntaxLayout.marginHeight = 0;
213         syntaxClient.setLayout( syntaxLayout );
214         syntaxSection.setClient( syntaxClient );
215
216         toolkit.createLabel( syntaxClient, "Syntax OID:", SWT.NONE );
217         syntaxLink = toolkit.createHyperlink( syntaxClient, "", SWT.WRAP );
218         syntaxLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
219         syntaxLink.addHyperlinkListener( this );
220
221         toolkit.createLabel( syntaxClient, "Syntax Description:", SWT.NONE );
222         syntaxDescText = toolkit.createText( syntaxClient, "", SWT.NONE );
223         syntaxDescText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
224         syntaxDescText.setEditable( false );
225
226         toolkit.createLabel( syntaxClient, "Length:", SWT.NONE );
227         lengthText = toolkit.createText( syntaxClient, "", SWT.NONE );
228         lengthText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
229         lengthText.setEditable( false );
230
231         // create matching rules section
232
matchingRulesSection = toolkit.createSection( detailForm.getBody(), SWT.NONE );
233         matchingRulesSection.setText( "Matching Rules" );
234         matchingRulesSection.marginWidth = 0;
235         matchingRulesSection.marginHeight = 0;
236         matchingRulesSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
237         toolkit.createCompositeSeparator( matchingRulesSection );
238
239         // create matching rules content
240
Composite matchClient = toolkit.createComposite( matchingRulesSection, SWT.WRAP );
241         GridLayout matchLayout = new GridLayout();
242         matchLayout.numColumns = 2;
243         matchLayout.marginWidth = 0;
244         matchLayout.marginHeight = 0;
245         matchClient.setLayout( matchLayout );
246         matchingRulesSection.setClient( matchClient );
247
248         toolkit.createLabel( matchClient, "Equality match:", SWT.NONE );
249         equalityLink = toolkit.createHyperlink( matchClient, "", SWT.WRAP );
250         equalityLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
251         equalityLink.addHyperlinkListener( this );
252
253         toolkit.createLabel( matchClient, "Substring match:", SWT.NONE );
254         substringLink = toolkit.createHyperlink( matchClient, "", SWT.WRAP );
255         substringLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
256         substringLink.addHyperlinkListener( this );
257
258         toolkit.createLabel( matchClient, "Ordering match:", SWT.NONE );
259         orderingLink = toolkit.createHyperlink( matchClient, "", SWT.WRAP );
260         orderingLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
261         orderingLink.addHyperlinkListener( this );
262
263         // create other matching rules section
264
otherMatchSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
265         otherMatchSection.setText( "Other Matching Rules" );
266         otherMatchSection.marginWidth = 0;
267         otherMatchSection.marginHeight = 0;
268         otherMatchSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
269         toolkit.createCompositeSeparator( otherMatchSection );
270         otherMatchSection.addExpansionListener( new ExpansionAdapter()
271         {
272             public void expansionStateChanged( ExpansionEvent e )
273             {
274                 detailForm.reflow( true );
275             }
276         } );
277
278         // create used as must section
279
usedAsMustSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
280         usedAsMustSection.setText( "Used as MUST" );
281         usedAsMustSection.marginWidth = 0;
282         usedAsMustSection.marginHeight = 0;
283         usedAsMustSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
284         toolkit.createCompositeSeparator( usedAsMustSection );
285         usedAsMustSection.addExpansionListener( new ExpansionAdapter()
286         {
287             public void expansionStateChanged( ExpansionEvent e )
288             {
289                 detailForm.reflow( true );
290             }
291         } );
292
293         // create used as may section
294
usedAsMaySection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
295         usedAsMaySection.setText( "Used as MAY" );
296         usedAsMaySection.marginWidth = 0;
297         usedAsMaySection.marginHeight = 0;
298         usedAsMaySection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
299         toolkit.createCompositeSeparator( usedAsMaySection );
300         usedAsMaySection.addExpansionListener( new ExpansionAdapter()
301         {
302             public void expansionStateChanged( ExpansionEvent e )
303             {
304                 detailForm.reflow( true );
305             }
306         } );
307
308         // create supertype section
309
supertypeSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
310         supertypeSection.setText( "Supertype" );
311         supertypeSection.marginWidth = 0;
312         supertypeSection.marginHeight = 0;
313         supertypeSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
314         toolkit.createCompositeSeparator( supertypeSection );
315         supertypeSection.addExpansionListener( new ExpansionAdapter()
316         {
317             public void expansionStateChanged( ExpansionEvent e )
318             {
319                 detailForm.reflow( true );
320             }
321         } );
322
323         // create subtypes section
324
subtypesSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
325         subtypesSection.setText( "Subtypes" );
326         subtypesSection.marginWidth = 0;
327         subtypesSection.marginHeight = 0;
328         subtypesSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
329         toolkit.createCompositeSeparator( subtypesSection );
330         subtypesSection.addExpansionListener( new ExpansionAdapter()
331         {
332             public void expansionStateChanged( ExpansionEvent e )
333             {
334                 detailForm.reflow( true );
335             }
336         } );
337
338         // create raw section
339
createRawSection();
340     }
341
342
343     /**
344      * {@inheritDoc}
345      */

346     public void setInput( Object JavaDoc input )
347     {
348         AttributeTypeDescription atd = null;
349         if ( input instanceof AttributeTypeDescription )
350         {
351             atd = ( AttributeTypeDescription ) input;
352         }
353
354         // create main content
355
createMainContent( atd );
356
357         // set flags
358
singleValuedText.setEnabled( atd != null && atd.isSingleValued() );
359         isObsoleteText.setEnabled( atd != null && atd.isObsolete() );
360         collectiveText.setEnabled( atd != null && atd.isCollective() );
361         noUserModificationText.setEnabled( atd != null && atd.isNoUserModification() );
362         flagSection.layout();
363
364         // set syntax content
365
String JavaDoc lsdOid = null;
366         LdapSyntaxDescription lsd = null;
367         String JavaDoc lsdLength = null;
368         if ( atd != null )
369         {
370             lsdOid = atd.getSyntaxDescriptionNumericOIDTransitive();
371             if ( lsdOid != null && atd.getSchema().hasLdapSyntaxDescription( lsdOid ) )
372             {
373                 lsd = atd.getSchema().getLdapSyntaxDescription( lsdOid );
374             }
375             lsdLength = atd.getSyntaxDescriptionLengthTransitive();
376         }
377         syntaxLink.setText( getNonNullString( lsd != null ? lsd.getNumericOID() : lsdOid ) );
378         syntaxLink.setHref( lsd );
379         syntaxLink.setUnderlined( lsd != null );
380         syntaxLink.setEnabled( lsd != null );
381         syntaxDescText.setText( getNonNullString( lsd != null ? lsd.getDesc() : null ) );
382         lengthText.setText( getNonNullString( lsdLength ) );
383         syntaxSection.layout();
384
385         // set matching rules content
386
String JavaDoc emrOid = null;
387         MatchingRuleDescription emr = null;
388         if ( atd != null )
389         {
390             emrOid = atd.getEqualityMatchingRuleDescriptionOIDTransitive();
391             if ( emrOid != null && atd.getSchema().hasMatchingRuleDescription( emrOid ) )
392             {
393                 emr = atd.getSchema().getMatchingRuleDescription( emrOid );
394             }
395         }
396         equalityLink.setText( getNonNullString( emr != null ? emr.toString() : emrOid ) );
397         equalityLink.setHref( emr );
398         equalityLink.setUnderlined( emr != null );
399         equalityLink.setEnabled( emr != null );
400
401         String JavaDoc smrOid = null;
402         MatchingRuleDescription smr = null;
403         if ( atd != null )
404         {
405             smrOid = atd.getSubstringMatchingRuleDescriptionOIDTransitive();
406             if ( smrOid != null && atd.getSchema().hasMatchingRuleDescription( smrOid ) )
407             {
408                 smr = atd.getSchema().getMatchingRuleDescription( smrOid );
409             }
410         }
411         substringLink.setText( getNonNullString( smr != null ? smr.toString() : smrOid ) );
412         substringLink.setHref( smr );
413         substringLink.setUnderlined( smr != null );
414         substringLink.setEnabled( smr != null );
415
416         String JavaDoc omrOid = null;
417         MatchingRuleDescription omr = null;
418         if ( atd != null )
419         {
420             omrOid = atd.getOrderingMatchingRuleDescriptionOIDTransitive();
421             if ( omrOid != null && atd.getSchema().hasMatchingRuleDescription( omrOid ) )
422             {
423                 omr = atd.getSchema().getMatchingRuleDescription( omrOid );
424             }
425         }
426         orderingLink.setText( getNonNullString( omr != null ? omr.toString() : omrOid ) );
427         orderingLink.setHref( omr );
428         orderingLink.setUnderlined( omr != null );
429         orderingLink.setEnabled( omr != null );
430         matchingRulesSection.layout();
431
432         // create contents of dynamic sections
433
createOtherMatchContent( atd );
434         createUsedAsMustContent( atd );
435         createUsedAsMayContent( atd );
436         createSupertypeContent( atd );
437         createSubtypesContent( atd );
438         createRawContents( atd );
439
440         detailForm.reflow( true );
441     }
442
443
444     /**
445      * Creates the content of the main section. It is newly created
446      * on every input change to ensure a proper layout of
447      * multilined descriptions.
448      *
449      * @param atd the attribute type description
450      */

451     private void createMainContent( AttributeTypeDescription atd )
452     {
453         // dispose old content
454
if ( mainSection.getClient() != null )
455         {
456             mainSection.getClient().dispose();
457         }
458
459         // create new client
460
Composite mainClient = toolkit.createComposite( mainSection, SWT.WRAP );
461         GridLayout mainLayout = new GridLayout( 2, false );
462         mainClient.setLayout( mainLayout );
463         mainSection.setClient( mainClient );
464
465         // create new content
466
if ( atd != null )
467         {
468             toolkit.createLabel( mainClient, "Numeric OID:", SWT.NONE );
469             numericOidText = toolkit.createText( mainClient, getNonNullString( atd.getNumericOID() ), SWT.NONE );
470             numericOidText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
471             numericOidText.setEditable( false );
472
473             toolkit.createLabel( mainClient, "Attribute names:", SWT.NONE );
474             namesText = toolkit.createText( mainClient, getNonNullString( atd.toString() ), SWT.NONE );
475             namesText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
476             namesText.setEditable( false );
477
478             toolkit.createLabel( mainClient, "Descripton:", SWT.WRAP );
479             descText = toolkit.createText( mainClient, getNonNullString( atd.getDesc() ), SWT.WRAP | SWT.MULTI );
480             GridData gd = new GridData( GridData.FILL_HORIZONTAL );
481             gd.widthHint = detailForm.getForm().getSize().x - 100 - 60;
482             descText.setLayoutData( gd );
483             descText.setEditable( false );
484
485             toolkit.createLabel( mainClient, "Usage:", SWT.NONE );
486             usageText = toolkit.createText( mainClient, getNonNullString( atd.getUsage() ), SWT.NONE );
487             usageText.setLayoutData( new GridData( GridData.GRAB_HORIZONTAL ) );
488             usageText.setEditable( false );
489
490         }
491
492         mainSection.layout();
493     }
494
495
496     /**
497      * Creates the content of the other matching rules section.
498      * It is newly created on every input change because the content
499      * of this section is dynamic.
500      *
501      * @param atd the attribute type description
502      */

503     private void createOtherMatchContent( AttributeTypeDescription atd )
504     {
505         // dispose old content
506
if ( otherMatchSection.getClient() != null )
507         {
508             otherMatchSection.getClient().dispose();
509         }
510
511         // create new client
512
Composite otherMatchClient = toolkit.createComposite( otherMatchSection, SWT.WRAP );
513         otherMatchClient.setLayout( new GridLayout() );
514         otherMatchSection.setClient( otherMatchClient );
515
516         // create new content, either links to other matching rules
517
// or a dash if no other matching rules exist.
518
if ( atd != null )
519         {
520             String JavaDoc[] names = atd.getOtherMatchingRuleDescriptionNames();
521             if ( names != null && names.length > 0 )
522             {
523                 otherMatchSection.setText( "Other Matching Rules (" + names.length + ")" );
524                 otherMatchLinks = new Hyperlink[names.length];
525                 for ( int i = 0; i < names.length; i++ )
526                 {
527                     if ( atd.getSchema().hasMatchingRuleDescription( names[i] ) )
528                     {
529                         MatchingRuleDescription mrd = atd.getSchema().getMatchingRuleDescription( names[i] );
530                         otherMatchLinks[i] = toolkit.createHyperlink( otherMatchClient, mrd.toString(), SWT.WRAP );
531                         otherMatchLinks[i].setHref( mrd );
532                         otherMatchLinks[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
533                         otherMatchLinks[i].setUnderlined( true );
534                         otherMatchLinks[i].setEnabled( true );
535                         otherMatchLinks[i].addHyperlinkListener( this );
536                     }
537                     else
538                     {
539                         otherMatchLinks[i] = toolkit.createHyperlink( otherMatchClient, names[i], SWT.WRAP );
540                         otherMatchLinks[i].setHref( null );
541                         otherMatchLinks[i].setUnderlined( false );
542                         otherMatchLinks[i].setEnabled( false );
543                     }
544                 }
545             }
546             else
547             {
548                 otherMatchSection.setText( "Other Matching Rules (0)" );
549                 otherMatchLinks = new Hyperlink[0];
550                 Text otherText = toolkit.createText( otherMatchClient, getNonNullString( null ), SWT.NONE );
551                 otherText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
552                 otherText.setEditable( false );
553             }
554         }
555         else
556         {
557             otherMatchSection.setText( "Other Matching Rules" );
558         }
559
560         otherMatchSection.layout();
561     }
562
563
564     /**
565      * Creates the content of the supertype section.
566      * It is newly created on every input change because the content
567      * of this section is dynamic.
568      *
569      * @param atd the attribute type description
570      */

571     private void createSupertypeContent( AttributeTypeDescription atd )
572     {
573         // dispose old content
574
if ( supertypeSection.getClient() != null )
575         {
576             supertypeSection.getClient().dispose();
577         }
578
579         // create new client
580
Composite superClient = toolkit.createComposite( supertypeSection, SWT.WRAP );
581         superClient.setLayout( new GridLayout() );
582         supertypeSection.setClient( superClient );
583
584         // create new content, either a link to the superior attribute type
585
// or a dash if no supertype exists.
586
if ( atd != null )
587         {
588             String JavaDoc superName = atd.getSuperiorAttributeTypeDescriptionName();
589             if ( superName != null )
590             {
591                 supertypeSection.setText( "Supertype (" + "1" + ")" );
592                 if ( atd.getSchema().hasAttributeTypeDescription( superName ) )
593                 {
594                     AttributeTypeDescription supAtd = atd.getSchema().getAttributeTypeDescription( superName );
595                     superLink = toolkit.createHyperlink( superClient, supAtd.toString(), SWT.WRAP );
596                     superLink.setHref( supAtd );
597                     superLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
598                     superLink.setUnderlined( true );
599                     superLink.setEnabled( true );
600                     superLink.addHyperlinkListener( this );
601                 }
602                 else
603                 {
604                     superLink = toolkit.createHyperlink( superClient, superName, SWT.WRAP );
605                     superLink.setHref( null );
606                     superLink.setUnderlined( false );
607                     superLink.setEnabled( false );
608                 }
609             }
610             else
611             {
612                 supertypeSection.setText( "Supertype (0)" );
613                 superLink = null;
614                 Text supText = toolkit.createText( superClient, getNonNullString( null ), SWT.NONE );
615                 supText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
616                 supText.setEditable( false );
617             }
618         }
619         else
620         {
621             supertypeSection.setText( "Supertype" );
622         }
623
624         supertypeSection.layout();
625     }
626
627
628     /**
629      * Creates the content of the subtypes.
630      * It is newly created on every input change because the content
631      * of this section is dynamic.
632      *
633      * @param atd the attribute type description
634      */

635     private void createSubtypesContent( AttributeTypeDescription atd )
636     {
637         // dispose old content
638
if ( subtypesSection.getClient() != null )
639         {
640             subtypesSection.getClient().dispose();
641         }
642
643         // create new client
644
Composite subClient = toolkit.createComposite( subtypesSection, SWT.WRAP );
645         subClient.setLayout( new GridLayout() );
646         subtypesSection.setClient( subClient );
647
648         // create new content, either links to subtypes or a dash if no subtypes exist.
649
if ( atd != null )
650         {
651             AttributeTypeDescription[] subATDs = atd.getDerivedAttributeTypeDescriptions();
652             if ( subATDs != null && subATDs.length > 0 )
653             {
654                 subtypesSection.setText( "Subtypes (" + subATDs.length + ")" );
655                 subAttributeTypeLinks = new Hyperlink[subATDs.length];
656                 for ( int i = 0; i < subATDs.length; i++ )
657                 {
658                     subAttributeTypeLinks[i] = toolkit.createHyperlink( subClient, subATDs[i].toString(), SWT.WRAP );
659                     subAttributeTypeLinks[i].setHref( subATDs[i] );
660                     subAttributeTypeLinks[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
661                     subAttributeTypeLinks[i].setUnderlined( true );
662                     subAttributeTypeLinks[i].setEnabled( true );
663                     subAttributeTypeLinks[i].addHyperlinkListener( this );
664                 }
665             }
666             else
667             {
668                 subtypesSection.setText( "Subtypes (0)" );
669                 subAttributeTypeLinks = new Hyperlink[0];
670                 Text subText = toolkit.createText( subClient, getNonNullString( null ), SWT.NONE );
671                 subText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
672                 subText.setEditable( false );
673             }
674         }
675         else
676         {
677             subtypesSection.setText( "Subtypes" );
678         }
679
680         subtypesSection.layout();
681
682     }
683
684
685     /**
686      * Creates the content of the used as must section.
687      * It is newly created on every input change because the content
688      * of this section is dynamic.
689      *
690      * @param atd the attribute type description
691      */

692     private void createUsedAsMustContent( AttributeTypeDescription atd )
693     {
694         // dispose old content
695
if ( usedAsMustSection.getClient() != null )
696         {
697             usedAsMustSection.getClient().dispose();
698         }
699
700         // create new client
701
Composite mustClient = toolkit.createComposite( usedAsMustSection, SWT.WRAP );
702         mustClient.setLayout( new GridLayout() );
703         usedAsMustSection.setClient( mustClient );
704
705         // create new content, either links to objectclasses or a dash
706
if ( atd != null )
707         {
708             ObjectClassDescription[] usedAsMusts = atd.getUsedAsMust();
709             if ( usedAsMusts != null && usedAsMusts.length > 0 )
710             {
711                 usedAsMustSection.setText( "Used as MUST (" + usedAsMusts.length + ")" );
712                 usedAsMustLinks = new Hyperlink[usedAsMusts.length];
713                 for ( int i = 0; i < usedAsMusts.length; i++ )
714                 {
715                     usedAsMustLinks[i] = toolkit.createHyperlink( mustClient, usedAsMusts[i].toString(), SWT.WRAP );
716                     usedAsMustLinks[i].setHref( usedAsMusts[i] );
717                     usedAsMustLinks[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
718                     usedAsMustLinks[i].setUnderlined( true );
719                     usedAsMustLinks[i].setEnabled( true );
720                     usedAsMustLinks[i].addHyperlinkListener( this );
721                 }
722             }
723             else
724             {
725                 usedAsMustSection.setText( "Used as MUST (0)" );
726                 usedAsMustLinks = new Hyperlink[0];
727                 Text mustText = toolkit.createText( mustClient, getNonNullString( null ), SWT.NONE );
728                 mustText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
729                 mustText.setEditable( false );
730             }
731         }
732         else
733         {
734             usedAsMustSection.setText( "Used as MUST" );
735         }
736
737         usedAsMustSection.layout();
738
739     }
740
741
742     /**
743      * Creates the content of the used as may section.
744      * It is newly created on every input change because the content
745      * of this section is dynamic.
746      *
747      * @param atd the attribute type description
748      */

749     private void createUsedAsMayContent( AttributeTypeDescription atd )
750     {
751         // dispose old content
752
if ( usedAsMaySection.getClient() != null )
753         {
754             usedAsMaySection.getClient().dispose();
755         }
756
757         // create new client
758
Composite mayClient = toolkit.createComposite( usedAsMaySection, SWT.WRAP );
759         mayClient.setLayout( new GridLayout() );
760         usedAsMaySection.setClient( mayClient );
761
762         // create new content, either links to objectclasses or a dash
763
if ( atd != null )
764         {
765             ObjectClassDescription[] usedAsMays = atd.getUsedAsMay();
766             if ( usedAsMays != null && usedAsMays.length > 0 )
767             {
768                 usedAsMaySection.setText( "Used as MAY (" + usedAsMays.length + ")" );
769                 usedAsMayLinks = new Hyperlink[usedAsMays.length];
770                 for ( int i = 0; i < usedAsMays.length; i++ )
771                 {
772                     usedAsMayLinks[i] = toolkit.createHyperlink( mayClient, usedAsMays[i].toString(), SWT.WRAP );
773                     usedAsMayLinks[i].setHref( usedAsMays[i] );
774                     usedAsMayLinks[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
775                     usedAsMayLinks[i].setUnderlined( true );
776                     usedAsMayLinks[i].setEnabled( true );
777                     usedAsMayLinks[i].addHyperlinkListener( this );
778                 }
779             }
780             else
781             {
782                 usedAsMaySection.setText( "Used as MAY (0)" );
783                 usedAsMayLinks = new Hyperlink[0];
784                 Text mayText = toolkit.createText( mayClient, getNonNullString( null ), SWT.NONE );
785                 mayText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
786                 mayText.setEditable( false );
787             }
788         }
789         else
790         {
791             usedAsMaySection.setText( "Used as MAY" );
792         }
793
794         usedAsMaySection.layout();
795     }
796
797 }
798
Popular Tags