33 |
33 |
import org.eclipse.swt.widgets.Event;
|
34 |
34 |
import org.eclipse.swt.widgets.Label;
|
35 |
35 |
import org.eclipse.ui.forms.IFormColors;
|
|
36 |
import org.eclipse.ui.forms.widgets.ExpandableComposite;
|
36 |
37 |
import org.eclipse.ui.forms.widgets.FormToolkit;
|
37 |
38 |
import org.eclipse.ui.forms.widgets.Section;
|
38 |
39 |
import org.eclipse.ui.internal.forms.widgets.FormFonts;
|
... | ... | |
93 |
94 |
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
94 |
95 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
95 |
96 |
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
|
96 |
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
|
97 |
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
97 |
98 |
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
|
98 |
99 |
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
99 |
100 |
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
|
... | ... | |
102 |
103 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
103 |
104 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
|
104 |
105 |
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
|
106 |
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
105 |
107 |
import eu.etaxonomy.taxeditor.ui.section.EmptyElement;
|
106 |
108 |
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement;
|
107 |
109 |
import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection;
|
... | ... | |
262 |
264 |
*/
|
263 |
265 |
public class CdmFormFactory extends FormToolkit {
|
264 |
266 |
|
265 |
|
private BoldFontHolder2 boldFontHolder2;
|
266 |
|
private MouseListener selectionMouseHandler;
|
267 |
|
private FocusListener selectionFocusHandler;
|
|
267 |
private BoldFontHolder2 boldFontHolder2;
|
|
268 |
private MouseListener selectionMouseHandler;
|
|
269 |
private FocusListener selectionFocusHandler;
|
268 |
270 |
|
269 |
|
private final Set selectionListenerList = new HashSet();
|
|
271 |
private final Set selectionListenerList = new HashSet();
|
270 |
272 |
|
271 |
|
private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
|
|
273 |
private final List<IPropertyChangeListener> propertyChangeListeners = new ArrayList<IPropertyChangeListener>();
|
272 |
274 |
|
273 |
|
private final int orientation = Window.getDefaultOrientation();
|
274 |
|
private ISelectionProvider selectionProvider;
|
|
275 |
private final int orientation = Window.getDefaultOrientation();
|
|
276 |
private ISelectionProvider selectionProvider;
|
275 |
277 |
|
276 |
|
/** Constant <code>EMPTY_SELECTION</code> */
|
277 |
|
public static ISelection EMPTY_SELECTION = new ISelection() {
|
278 |
|
@Override
|
279 |
|
public boolean isEmpty() {
|
280 |
|
return true;
|
281 |
|
}
|
282 |
|
};
|
|
278 |
/** Constant <code>EMPTY_SELECTION</code> */
|
|
279 |
public static ISelection EMPTY_SELECTION = new ISelection() {
|
|
280 |
@Override
|
|
281 |
public boolean isEmpty() {
|
|
282 |
return true;
|
|
283 |
}
|
|
284 |
};
|
|
285 |
|
|
286 |
/**
|
|
287 |
*
|
|
288 |
* @author n.hoffmann
|
|
289 |
* @date Jan 25, 2010
|
|
290 |
*
|
|
291 |
*/
|
|
292 |
private class SelectionMouseHandler extends MouseAdapter {
|
|
293 |
@Override
|
|
294 |
public void mouseDown(MouseEvent e) {
|
|
295 |
notifySelectionListeners(e);
|
|
296 |
}
|
|
297 |
}
|
|
298 |
|
|
299 |
/**
|
|
300 |
*
|
|
301 |
* @author n.hoffmann
|
|
302 |
* @date Jan 25, 2010
|
|
303 |
*
|
|
304 |
*/
|
|
305 |
private class SelectionFocusHandler extends FocusAdapter {
|
|
306 |
@Override
|
|
307 |
public void focusGained(FocusEvent e) {
|
|
308 |
notifySelectionListeners(e);
|
|
309 |
}
|
|
310 |
}
|
283 |
311 |
|
284 |
|
/**
|
285 |
|
*
|
286 |
|
* @author n.hoffmann
|
287 |
|
* @date Jan 25, 2010
|
288 |
|
*
|
289 |
|
*/
|
290 |
|
private class SelectionMouseHandler extends MouseAdapter {
|
291 |
|
@Override
|
292 |
|
public void mouseDown(MouseEvent e) {
|
293 |
|
notifySelectionListeners(e);
|
294 |
|
}
|
295 |
|
}
|
296 |
|
|
297 |
|
/**
|
298 |
|
*
|
299 |
|
* @author n.hoffmann
|
300 |
|
* @date Jan 25, 2010
|
301 |
|
*
|
302 |
|
*/
|
303 |
|
private class SelectionFocusHandler extends FocusAdapter {
|
304 |
|
@Override
|
305 |
|
public void focusGained(FocusEvent e) {
|
306 |
|
notifySelectionListeners(e);
|
307 |
|
}
|
308 |
|
}
|
309 |
|
|
310 |
|
private void notifySelectionListeners(TypedEvent e) {
|
311 |
|
Event event = new Event();
|
312 |
|
event.widget = e.widget;
|
313 |
|
SelectionEvent selectionEvent = new SelectionEvent(event);
|
314 |
|
|
315 |
|
for (Object listener : selectionListenerList) {
|
316 |
|
((SelectionListener) listener).widgetSelected(selectionEvent);
|
317 |
|
}
|
318 |
|
}
|
319 |
|
|
320 |
|
/**
|
321 |
|
* <p>
|
322 |
|
* Constructor for CdmFormFactory.
|
323 |
|
* </p>
|
324 |
|
*
|
325 |
|
* @param display
|
326 |
|
* a {@link org.eclipse.swt.widgets.Display} object.
|
327 |
|
* @param selectionProvider
|
328 |
|
* a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
|
329 |
|
*/
|
330 |
|
public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
|
331 |
|
super(display);
|
332 |
|
this.selectionProvider = selectionProvider;
|
333 |
|
init();
|
334 |
|
}
|
335 |
|
|
336 |
|
/**
|
337 |
|
* <p>
|
338 |
|
* Constructor for CdmFormFactory.
|
339 |
|
* </p>
|
340 |
|
*
|
341 |
|
* @param display
|
342 |
|
* a {@link org.eclipse.swt.widgets.Display} object.
|
343 |
|
*/
|
344 |
|
public CdmFormFactory(Display display) {
|
345 |
|
super(display);
|
346 |
|
init();
|
347 |
|
}
|
|
312 |
private void notifySelectionListeners(TypedEvent e) {
|
|
313 |
Event event = new Event();
|
|
314 |
event.widget = e.widget;
|
|
315 |
SelectionEvent selectionEvent = new SelectionEvent(event);
|
348 |
316 |
|
349 |
|
/**
|
350 |
|
*
|
351 |
|
*/
|
352 |
|
private void init() {
|
353 |
|
boldFontHolder2 = new BoldFontHolder2();
|
354 |
|
selectionMouseHandler = new SelectionMouseHandler();
|
355 |
|
selectionFocusHandler = new SelectionFocusHandler();
|
356 |
|
}
|
357 |
|
|
358 |
|
/**
|
359 |
|
* Creates an instance initialized with the correct selectionProvider
|
360 |
|
*
|
361 |
|
* Make sure to remove the instance when the entityComposite disposes via
|
362 |
|
* destroySelectionArbitrator(..)
|
363 |
|
*
|
364 |
|
* @param entityElement
|
365 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
|
366 |
|
* object.
|
367 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
|
368 |
|
* object.
|
369 |
|
*/
|
370 |
|
public SelectionArbitrator createSelectionArbitrator(
|
371 |
|
IEntityElement entityElement) {
|
372 |
|
SelectionArbitrator selectionArbitrator = new SelectionArbitrator(
|
373 |
|
entityElement);
|
374 |
|
selectionArbitrator.addSelectionProvider(selectionProvider);
|
375 |
|
selectionProvider.addSelectionChangedListener(selectionArbitrator);
|
376 |
|
addSelectionListener(selectionArbitrator);
|
377 |
|
return selectionArbitrator;
|
378 |
|
}
|
379 |
|
|
380 |
|
/**
|
381 |
|
* <p>
|
382 |
|
* destroySelectionArbitrator
|
383 |
|
* </p>
|
384 |
|
*
|
385 |
|
* @param selectionArbitrator
|
386 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
|
387 |
|
* object.
|
388 |
|
*/
|
389 |
|
public void destroySelectionArbitrator(
|
390 |
|
SelectionArbitrator selectionArbitrator) {
|
391 |
|
removeSelectionListener(selectionArbitrator);
|
392 |
|
if (selectionProvider != null) {
|
393 |
|
selectionProvider
|
394 |
|
.removeSelectionChangedListener(selectionArbitrator);
|
395 |
|
} else {
|
396 |
|
StoreUtil
|
397 |
|
.error(this.getClass(),
|
398 |
|
"Tried to destroy a selection listener from this factories listeners but was null",
|
399 |
|
null);
|
400 |
|
}
|
401 |
|
}
|
402 |
|
|
403 |
|
/** {@inheritDoc} */
|
404 |
|
@Override
|
405 |
|
public void adapt(Composite composite) {
|
406 |
|
composite.addMouseListener(selectionMouseHandler);
|
407 |
|
super.adapt(composite);
|
408 |
|
}
|
409 |
|
|
410 |
|
/**
|
411 |
|
* <p>
|
412 |
|
* Adapts the {@link AbstractCdmFormElement}:<br>
|
413 |
|
* - sets the {@link IPropertyChangeListener}s handled by this class
|
414 |
|
* </p>
|
415 |
|
*
|
416 |
|
* @param formElement
|
417 |
|
* a
|
418 |
|
* {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
|
419 |
|
* object.
|
420 |
|
*/
|
421 |
|
public void adapt(AbstractCdmFormElement formElement) {
|
422 |
|
formElement.setPropertyChangeListeners(propertyChangeListeners);
|
423 |
|
}
|
424 |
|
|
425 |
|
/** {@inheritDoc} */
|
426 |
|
@Override
|
427 |
|
public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
|
428 |
|
if (trackFocus) {
|
429 |
|
control.addFocusListener(selectionFocusHandler);
|
430 |
|
}
|
431 |
|
super.adapt(control, trackFocus, trackKeyboard);
|
432 |
|
}
|
433 |
|
|
434 |
|
/**
|
435 |
|
* <p>
|
436 |
|
* destroyElement
|
437 |
|
* </p>
|
438 |
|
*
|
439 |
|
* @param formElement
|
440 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
441 |
|
* object.
|
442 |
|
*/
|
443 |
|
public void destroyElement(ICdmFormElement formElement) {
|
444 |
|
// return if element was not initialized
|
445 |
|
if (formElement == null) {
|
446 |
|
return;
|
447 |
|
}
|
448 |
|
// destroy selection arbitrator, if any
|
449 |
|
if (formElement instanceof ISelectableElement) {
|
450 |
|
destroySelectionArbitrator(((ISelectableElement) formElement)
|
451 |
|
.getSelectionArbitrator());
|
452 |
|
}
|
453 |
|
// remove this element form its parents list of elements
|
454 |
|
// ICdmFormElement parentElement = formElement.getParentElement();
|
455 |
|
// if(parentElement != null){
|
456 |
|
// parentElement.removeElement(formElement);
|
457 |
|
// }
|
458 |
|
// call destroy on child elements recursively
|
459 |
|
for (ICdmFormElement childElement : formElement.getElements()) {
|
460 |
|
destroyElement(childElement);
|
461 |
|
}
|
462 |
|
// dispose of the controls
|
463 |
|
for (Control control : formElement.getControls()) {
|
464 |
|
// we added the layoutComposite of the parental element as the
|
465 |
|
// layout composite to this formElement
|
466 |
|
// but we do not want to destroy it.
|
467 |
|
if (control.equals(formElement.getLayoutComposite())) {
|
468 |
|
continue;
|
469 |
|
} else {
|
470 |
|
control.dispose();
|
471 |
|
control = null;
|
472 |
|
}
|
473 |
|
}
|
474 |
|
}
|
475 |
|
|
476 |
|
/**
|
477 |
|
* <p>
|
478 |
|
* createEmptyCell
|
479 |
|
* </p>
|
480 |
|
*
|
481 |
|
* @param parent
|
482 |
|
* a {@link org.eclipse.swt.widgets.Composite} object.
|
483 |
|
* @return a {@link org.eclipse.swt.widgets.Label} object.
|
484 |
|
*/
|
485 |
|
public Label createEmptyCell(Composite parent) {
|
486 |
|
return this.createLabel(parent, null);
|
487 |
|
}
|
488 |
|
|
489 |
|
/**
|
490 |
|
* <p>
|
491 |
|
* createMultilineTextWithLabel
|
492 |
|
* </p>
|
493 |
|
*
|
494 |
|
* @param labelString
|
495 |
|
* a {@link java.lang.String} object.
|
496 |
|
* @param textHeight
|
497 |
|
* a int.
|
498 |
|
* @param style
|
499 |
|
* a int.
|
500 |
|
* @param parentElement
|
501 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
502 |
|
* object.
|
503 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
|
504 |
|
* object.
|
505 |
|
*/
|
506 |
|
public TextWithLabelElement createMultilineTextWithLabel(
|
507 |
|
ICdmFormElement parentElement, String labelString, int textHeight,
|
508 |
|
int style) {
|
509 |
|
TextWithLabelElement element = new TextWithLabelElement(this,
|
510 |
|
parentElement, labelString, "", textHeight, style);
|
511 |
|
adapt(element);
|
512 |
|
parentElement.addElement(element);
|
513 |
|
return element;
|
514 |
|
}
|
515 |
|
|
516 |
|
/**
|
517 |
|
* <p>
|
518 |
|
* createMultiLanguageTextElement
|
519 |
|
* </p>
|
520 |
|
*
|
521 |
|
* @param parentElement
|
522 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
523 |
|
* object.
|
524 |
|
* @param labelString
|
525 |
|
* a {@link java.lang.String} object.
|
526 |
|
* @param multilanguageText
|
527 |
|
* a {@link java.util.Map} object.
|
528 |
|
* @param textHeight
|
529 |
|
* a int.
|
530 |
|
* @param style
|
531 |
|
* a int.
|
532 |
|
* @return a
|
533 |
|
* {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
|
534 |
|
* object.
|
535 |
|
*/
|
536 |
|
public MultilanguageTextElement createMultiLanguageTextElement(
|
537 |
|
ICdmFormElement parentElement, String labelString,
|
538 |
|
Map<Language, LanguageString> multilanguageText, int textHeight,
|
539 |
|
int style) {
|
540 |
|
MultilanguageTextElement element = new MultilanguageTextElement(this,
|
541 |
|
parentElement, labelString, multilanguageText, textHeight,
|
542 |
|
style);
|
543 |
|
adapt(element);
|
544 |
|
parentElement.addElement(element);
|
545 |
|
return element;
|
546 |
|
}
|
547 |
|
|
548 |
|
public KeyStatementElement createKeyStatementElement(
|
549 |
|
ICdmFormElement parentElement, String labelString,
|
550 |
|
KeyStatement keyStatement, int textHeight, int style) {
|
551 |
|
KeyStatementElement element = new KeyStatementElement(this,
|
552 |
|
parentElement, labelString, keyStatement, textHeight, style);
|
553 |
|
adapt(element);
|
554 |
|
parentElement.addElement(element);
|
555 |
|
return element;
|
556 |
|
}
|
557 |
|
|
558 |
|
/**
|
559 |
|
* <p>
|
560 |
|
* createTextWithLabelElement
|
561 |
|
* </p>
|
562 |
|
*
|
563 |
|
* @param labelString
|
564 |
|
* a {@link java.lang.String} object.
|
565 |
|
* @param initialText
|
566 |
|
* a {@link java.lang.String} object.
|
567 |
|
* @param style
|
568 |
|
* a int.
|
569 |
|
* @param parentElement
|
570 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
571 |
|
* object.
|
572 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
|
573 |
|
* object.
|
574 |
|
*/
|
575 |
|
public TextWithLabelElement createTextWithLabelElement(
|
576 |
|
ICdmFormElement parentElement, String labelString,
|
577 |
|
String initialText, int style) {
|
578 |
|
TextWithLabelElement element = new TextWithLabelElement(this,
|
579 |
|
parentElement, labelString, initialText, null, style);
|
580 |
|
adapt(element);
|
581 |
|
parentElement.addElement(element);
|
582 |
|
return element;
|
583 |
|
}
|
584 |
|
|
585 |
|
public UriWithLabelElement createUriWithLabelElement(
|
586 |
|
ICdmFormElement parentElement, String labelString, URI initialUri,
|
587 |
|
int style) {
|
588 |
|
UriWithLabelElement element = new UriWithLabelElement(this,
|
589 |
|
parentElement, labelString, initialUri, null, style);
|
590 |
|
adapt(element);
|
591 |
|
parentElement.addElement(element);
|
592 |
|
return element;
|
593 |
|
}
|
594 |
|
|
595 |
|
/**
|
596 |
|
* @param element
|
597 |
|
* @param string
|
598 |
|
* @param uri
|
599 |
|
* @param style
|
600 |
|
* @return
|
601 |
|
*/
|
602 |
|
public OpenUrlSelectorElement createOpenUrlSelectorElement(
|
603 |
|
ICdmFormElement parentElement, String labelString,
|
604 |
|
IOpenUrlEnabled openUrlEnabled, int style) {
|
605 |
|
OpenUrlSelectorElement element = new OpenUrlSelectorElement(this,
|
606 |
|
parentElement, labelString, openUrlEnabled, style);
|
607 |
|
adapt(element);
|
608 |
|
parentElement.addElement(element);
|
609 |
|
return element;
|
610 |
|
}
|
611 |
|
|
612 |
|
/**
|
613 |
|
*
|
614 |
|
* @param parentElement
|
615 |
|
* @param labelString
|
616 |
|
* @param conversationEnabled
|
617 |
|
* @param user
|
618 |
|
* @param style
|
619 |
|
* @return
|
620 |
|
*/
|
621 |
|
public EditPasswordElement createEditPasswordElement(
|
622 |
|
ICdmFormElement parentElement, String labelString,
|
623 |
|
ConversationHolder conversation, User user, int style) {
|
624 |
|
EditPasswordElement element = new EditPasswordElement(this,
|
625 |
|
parentElement, labelString, user, conversation);
|
626 |
|
adapt(element);
|
627 |
|
parentElement.addElement(element);
|
628 |
|
return element;
|
629 |
|
}
|
630 |
|
|
631 |
|
/**
|
632 |
|
* <p>
|
633 |
|
* createIntegerTextWithLabelElement
|
634 |
|
* </p>
|
635 |
|
*
|
636 |
|
* @param parentElement
|
637 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
638 |
|
* object.
|
639 |
|
* @param labelString
|
640 |
|
* a {@link java.lang.String} object.
|
641 |
|
* @param initialInteger
|
642 |
|
* a {@link java.lang.Integer} object.
|
643 |
|
* @param style
|
644 |
|
* a int.
|
645 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
|
646 |
|
* object.
|
647 |
|
*/
|
648 |
|
public NumberWithLabelElement createIntegerTextWithLabelElement(
|
649 |
|
ICdmFormElement parentElement, String labelString,
|
650 |
|
Integer initialInteger, int style) {
|
651 |
|
NumberWithLabelElement element = new NumberWithLabelElement(this,
|
652 |
|
parentElement, labelString, initialInteger, style);
|
653 |
|
adapt(element);
|
654 |
|
parentElement.addElement(element);
|
655 |
|
return element;
|
656 |
|
}
|
657 |
|
|
658 |
|
/**
|
659 |
|
* <p>
|
660 |
|
* createFloatTextWithLabelElement
|
661 |
|
* </p>
|
662 |
|
*
|
663 |
|
* @param parentElement
|
664 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
665 |
|
* object.
|
666 |
|
* @param labelString
|
667 |
|
* a {@link java.lang.String} object.
|
668 |
|
* @param initialFloat
|
669 |
|
* a float.
|
670 |
|
* @param style
|
671 |
|
* a int.
|
672 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
|
673 |
|
* object.
|
674 |
|
*/
|
675 |
|
public NumberWithLabelElement createFloatTextWithLabelElement(
|
676 |
|
ICdmFormElement parentElement, String labelString,
|
677 |
|
float initialFloat, int style) {
|
678 |
|
NumberWithLabelElement element = new NumberWithLabelElement(this,
|
679 |
|
parentElement, labelString, initialFloat, style);
|
680 |
|
adapt(element);
|
681 |
|
parentElement.addElement(element);
|
682 |
|
return element;
|
683 |
|
}
|
684 |
|
|
685 |
|
/**
|
686 |
|
* <p>
|
687 |
|
* createLanguageStringWithLabelElement
|
688 |
|
* </p>
|
689 |
|
*
|
690 |
|
* @param parentElement
|
691 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
692 |
|
* object.
|
693 |
|
* @param labelString
|
694 |
|
* a {@link java.lang.String} object.
|
695 |
|
* @param languageString
|
696 |
|
* a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
|
697 |
|
* @param style
|
698 |
|
* a int.
|
699 |
|
* @return a
|
700 |
|
* {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
|
701 |
|
* object.
|
702 |
|
*/
|
703 |
|
public LanguageStringWithLabelElement createLanguageStringWithLabelElement(
|
704 |
|
ICdmFormElement parentElement, String labelString,
|
705 |
|
LanguageString languageString, int style) {
|
706 |
|
LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(
|
707 |
|
this, parentElement, labelString, languageString, style);
|
708 |
|
adapt(element);
|
709 |
|
parentElement.addElement(element);
|
710 |
|
return element;
|
711 |
|
}
|
712 |
|
|
713 |
|
/**
|
714 |
|
* <p>
|
715 |
|
* createLanguageStringWithLabelElement
|
716 |
|
* </p>
|
717 |
|
*
|
718 |
|
* @param parentElement
|
719 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
720 |
|
* object.
|
721 |
|
* @param labelString
|
722 |
|
* a {@link java.lang.String} object.
|
723 |
|
* @param languageString
|
724 |
|
* a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
|
725 |
|
* @param height
|
726 |
|
* a int.
|
727 |
|
* @param style
|
728 |
|
* a int.
|
729 |
|
* @return a
|
730 |
|
* {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
|
731 |
|
* object.
|
732 |
|
*/
|
733 |
|
public LanguageStringWithLabelElement createLanguageStringWithLabelElement(
|
734 |
|
ICdmFormElement parentElement, String labelString,
|
735 |
|
LanguageString languageString, int height, int style) {
|
736 |
|
LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(
|
737 |
|
this, parentElement, labelString, languageString, height, style);
|
738 |
|
adapt(element);
|
739 |
|
parentElement.addElement(element);
|
740 |
|
return element;
|
741 |
|
}
|
742 |
|
|
743 |
|
/**
|
744 |
|
* <p>
|
745 |
|
* createTextElement
|
746 |
|
* </p>
|
747 |
|
*
|
748 |
|
* @param parentElement
|
749 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
750 |
|
* object.
|
751 |
|
* @param initialText
|
752 |
|
* a {@link java.lang.String} object.
|
753 |
|
* @param style
|
754 |
|
* a int.
|
755 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
|
756 |
|
* object.
|
757 |
|
*/
|
758 |
|
public TextWithLabelElement createTextElement(
|
759 |
|
ICdmFormElement parentElement, String initialText, int style) {
|
760 |
|
TextWithLabelElement element = new TextWithLabelElement(this,
|
761 |
|
parentElement, null, initialText, null, style);
|
762 |
|
adapt(element);
|
763 |
|
parentElement.addElement(element);
|
764 |
|
return element;
|
765 |
|
}
|
766 |
|
|
767 |
|
/**
|
768 |
|
* <p>
|
769 |
|
* createKeyValueViewerElement
|
770 |
|
* </p>
|
771 |
|
*
|
772 |
|
* @param parentElement
|
773 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
774 |
|
* object.
|
775 |
|
* @param keyHeading
|
776 |
|
* a {@link java.lang.String} object.
|
777 |
|
* @param valueHeading
|
778 |
|
* a {@link java.lang.String} object.
|
779 |
|
* @param map
|
780 |
|
* a {@link java.util.Map} object.
|
781 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
|
782 |
|
* object.
|
783 |
|
*/
|
784 |
|
public KeyValueViewerElement createKeyValueViewerElement(
|
785 |
|
ICdmFormElement parentElement, String keyHeading,
|
786 |
|
String valueHeading, Map<Object, Object> map) {
|
787 |
|
KeyValueViewerElement element = new KeyValueViewerElement(this,
|
788 |
|
parentElement, keyHeading, valueHeading, map);
|
789 |
|
adapt(element);
|
790 |
|
parentElement.addElement(element);
|
791 |
|
return element;
|
792 |
|
}
|
793 |
|
|
794 |
|
/**
|
795 |
|
* <p>
|
796 |
|
* createTermComboElement
|
797 |
|
* </p>
|
|
317 |
for (Object listener : selectionListenerList) {
|
|
318 |
((SelectionListener) listener).widgetSelected(selectionEvent);
|
|
319 |
}
|
|
320 |
}
|
|
321 |
|
|
322 |
/**
|
|
323 |
* <p>
|
|
324 |
* Constructor for CdmFormFactory.
|
|
325 |
* </p>
|
|
326 |
*
|
|
327 |
* @param display
|
|
328 |
* a {@link org.eclipse.swt.widgets.Display} object.
|
|
329 |
* @param selectionProvider
|
|
330 |
* a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
|
|
331 |
*/
|
|
332 |
public CdmFormFactory(Display display, ISelectionProvider selectionProvider) {
|
|
333 |
super(display);
|
|
334 |
this.selectionProvider = selectionProvider;
|
|
335 |
init();
|
|
336 |
}
|
|
337 |
|
|
338 |
/**
|
|
339 |
* <p>
|
|
340 |
* Constructor for CdmFormFactory.
|
|
341 |
* </p>
|
|
342 |
*
|
|
343 |
* @param display
|
|
344 |
* a {@link org.eclipse.swt.widgets.Display} object.
|
|
345 |
*/
|
|
346 |
public CdmFormFactory(Display display) {
|
|
347 |
super(display);
|
|
348 |
init();
|
|
349 |
}
|
|
350 |
|
|
351 |
/**
|
798 |
352 |
*
|
799 |
|
* @param termComboType
|
800 |
|
* a
|
801 |
|
* {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
|
802 |
|
* object.
|
803 |
|
* @param parentElement
|
804 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
805 |
|
* object.
|
806 |
|
* @param labelString
|
807 |
|
* a {@link java.lang.String} object.
|
808 |
|
* @param selection
|
809 |
|
* a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
|
810 |
|
* object.
|
811 |
|
* @param style
|
812 |
|
* a int.
|
813 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
|
814 |
|
* object.
|
815 |
353 |
*/
|
|
354 |
private void init() {
|
|
355 |
boldFontHolder2 = new BoldFontHolder2();
|
|
356 |
selectionMouseHandler = new SelectionMouseHandler();
|
|
357 |
selectionFocusHandler = new SelectionFocusHandler();
|
|
358 |
}
|
|
359 |
|
|
360 |
/**
|
|
361 |
* Creates an instance initialized with the correct selectionProvider
|
|
362 |
*
|
|
363 |
* Make sure to remove the instance when the entityComposite disposes via
|
|
364 |
* destroySelectionArbitrator(..)
|
|
365 |
*
|
|
366 |
* @param entityElement
|
|
367 |
* a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement}
|
|
368 |
* object.
|
|
369 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
|
|
370 |
* object.
|
|
371 |
*/
|
|
372 |
public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) {
|
|
373 |
SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement);
|
|
374 |
selectionArbitrator.addSelectionProvider(selectionProvider);
|
|
375 |
selectionProvider.addSelectionChangedListener(selectionArbitrator);
|
|
376 |
addSelectionListener(selectionArbitrator);
|
|
377 |
return selectionArbitrator;
|
|
378 |
}
|
|
379 |
|
|
380 |
/**
|
|
381 |
* <p>
|
|
382 |
* destroySelectionArbitrator
|
|
383 |
* </p>
|
|
384 |
*
|
|
385 |
* @param selectionArbitrator
|
|
386 |
* a
|
|
387 |
* {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
|
|
388 |
* object.
|
|
389 |
*/
|
|
390 |
public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) {
|
|
391 |
removeSelectionListener(selectionArbitrator);
|
|
392 |
if (selectionProvider != null) {
|
|
393 |
selectionProvider.removeSelectionChangedListener(selectionArbitrator);
|
|
394 |
} else {
|
|
395 |
AbstractUtility.error(this.getClass(),
|
|
396 |
"Tried to destroy a selection listener from this factories listeners but was null", null);
|
|
397 |
}
|
|
398 |
}
|
|
399 |
|
|
400 |
/** {@inheritDoc} */
|
|
401 |
@Override
|
|
402 |
public void adapt(Composite composite) {
|
|
403 |
composite.addMouseListener(selectionMouseHandler);
|
|
404 |
super.adapt(composite);
|
|
405 |
}
|
|
406 |
|
|
407 |
/**
|
|
408 |
* <p>
|
|
409 |
* Adapts the {@link AbstractCdmFormElement}:<br>
|
|
410 |
* - sets the {@link IPropertyChangeListener}s handled by this class
|
|
411 |
* </p>
|
|
412 |
*
|
|
413 |
* @param formElement
|
|
414 |
* a
|
|
415 |
* {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement}
|
|
416 |
* object.
|
|
417 |
*/
|
|
418 |
public void adapt(AbstractCdmFormElement formElement) {
|
|
419 |
formElement.setPropertyChangeListeners(propertyChangeListeners);
|
|
420 |
}
|
|
421 |
|
|
422 |
/** {@inheritDoc} */
|
|
423 |
@Override
|
|
424 |
public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) {
|
|
425 |
if (trackFocus) {
|
|
426 |
control.addFocusListener(selectionFocusHandler);
|
|
427 |
}
|
|
428 |
super.adapt(control, trackFocus, trackKeyboard);
|
|
429 |
}
|
|
430 |
|
|
431 |
/**
|
|
432 |
* <p>
|
|
433 |
* destroyElement
|
|
434 |
* </p>
|
|
435 |
*
|
|
436 |
* @param formElement
|
|
437 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
438 |
* object.
|
|
439 |
*/
|
|
440 |
public void destroyElement(ICdmFormElement formElement) {
|
|
441 |
// return if element was not initialized
|
|
442 |
if (formElement == null) {
|
|
443 |
return;
|
|
444 |
}
|
|
445 |
// destroy selection arbitrator, if any
|
|
446 |
if (formElement instanceof ISelectableElement) {
|
|
447 |
destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator());
|
|
448 |
}
|
|
449 |
// remove this element form its parents list of elements
|
|
450 |
// ICdmFormElement parentElement = formElement.getParentElement();
|
|
451 |
// if(parentElement != null){
|
|
452 |
// parentElement.removeElement(formElement);
|
|
453 |
// }
|
|
454 |
// call destroy on child elements recursively
|
|
455 |
for (ICdmFormElement childElement : formElement.getElements()) {
|
|
456 |
destroyElement(childElement);
|
|
457 |
}
|
|
458 |
// dispose of the controls
|
|
459 |
for (Control control : formElement.getControls()) {
|
|
460 |
// we added the layoutComposite of the parental element as the
|
|
461 |
// layout composite to this formElement
|
|
462 |
// but we do not want to destroy it.
|
|
463 |
if (control.equals(formElement.getLayoutComposite())) {
|
|
464 |
continue;
|
|
465 |
} else {
|
|
466 |
control.dispose();
|
|
467 |
control = null;
|
|
468 |
}
|
|
469 |
}
|
|
470 |
}
|
|
471 |
|
|
472 |
/**
|
|
473 |
* <p>
|
|
474 |
* createEmptyCell
|
|
475 |
* </p>
|
|
476 |
*
|
|
477 |
* @param parent
|
|
478 |
* a {@link org.eclipse.swt.widgets.Composite} object.
|
|
479 |
* @return a {@link org.eclipse.swt.widgets.Label} object.
|
|
480 |
*/
|
|
481 |
public Label createEmptyCell(Composite parent) {
|
|
482 |
return this.createLabel(parent, null);
|
|
483 |
}
|
|
484 |
|
|
485 |
/**
|
|
486 |
* <p>
|
|
487 |
* createMultilineTextWithLabel
|
|
488 |
* </p>
|
|
489 |
*
|
|
490 |
* @param labelString
|
|
491 |
* a {@link java.lang.String} object.
|
|
492 |
* @param textHeight
|
|
493 |
* a int.
|
|
494 |
* @param style
|
|
495 |
* a int.
|
|
496 |
* @param parentElement
|
|
497 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
498 |
* object.
|
|
499 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
|
|
500 |
* object.
|
|
501 |
*/
|
|
502 |
public TextWithLabelElement createMultilineTextWithLabel(ICdmFormElement parentElement, String labelString,
|
|
503 |
int textHeight, int style) {
|
|
504 |
TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, style);
|
|
505 |
adapt(element);
|
|
506 |
parentElement.addElement(element);
|
|
507 |
return element;
|
|
508 |
}
|
|
509 |
|
|
510 |
/**
|
|
511 |
* <p>
|
|
512 |
* createMultiLanguageTextElement
|
|
513 |
* </p>
|
|
514 |
*
|
|
515 |
* @param parentElement
|
|
516 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
517 |
* object.
|
|
518 |
* @param labelString
|
|
519 |
* a {@link java.lang.String} object.
|
|
520 |
* @param multilanguageText
|
|
521 |
* a {@link java.util.Map} object.
|
|
522 |
* @param textHeight
|
|
523 |
* a int.
|
|
524 |
* @param style
|
|
525 |
* a int.
|
|
526 |
* @return a
|
|
527 |
* {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement}
|
|
528 |
* object.
|
|
529 |
*/
|
|
530 |
public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString,
|
|
531 |
Map<Language, LanguageString> multilanguageText, int textHeight, int style) {
|
|
532 |
MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString,
|
|
533 |
multilanguageText, textHeight, style);
|
|
534 |
adapt(element);
|
|
535 |
parentElement.addElement(element);
|
|
536 |
return element;
|
|
537 |
}
|
|
538 |
|
|
539 |
public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString,
|
|
540 |
KeyStatement keyStatement, int textHeight, int style) {
|
|
541 |
KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement,
|
|
542 |
textHeight, style);
|
|
543 |
adapt(element);
|
|
544 |
parentElement.addElement(element);
|
|
545 |
return element;
|
|
546 |
}
|
|
547 |
|
|
548 |
/**
|
|
549 |
* <p>
|
|
550 |
* createTextWithLabelElement
|
|
551 |
* </p>
|
|
552 |
*
|
|
553 |
* @param labelString
|
|
554 |
* a {@link java.lang.String} object.
|
|
555 |
* @param initialText
|
|
556 |
* a {@link java.lang.String} object.
|
|
557 |
* @param style
|
|
558 |
* a int.
|
|
559 |
* @param parentElement
|
|
560 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
561 |
* object.
|
|
562 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
|
|
563 |
* object.
|
|
564 |
*/
|
|
565 |
public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString,
|
|
566 |
String initialText, int style) {
|
|
567 |
TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null,
|
|
568 |
style);
|
|
569 |
adapt(element);
|
|
570 |
parentElement.addElement(element);
|
|
571 |
return element;
|
|
572 |
}
|
|
573 |
|
|
574 |
public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString,
|
|
575 |
URI initialUri, int style) {
|
|
576 |
UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style);
|
|
577 |
adapt(element);
|
|
578 |
parentElement.addElement(element);
|
|
579 |
return element;
|
|
580 |
}
|
|
581 |
|
|
582 |
/**
|
|
583 |
* @param element
|
|
584 |
* @param string
|
|
585 |
* @param uri
|
|
586 |
* @param style
|
|
587 |
* @return
|
|
588 |
*/
|
|
589 |
public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString,
|
|
590 |
IOpenUrlEnabled openUrlEnabled, int style) {
|
|
591 |
OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled,
|
|
592 |
style);
|
|
593 |
adapt(element);
|
|
594 |
parentElement.addElement(element);
|
|
595 |
return element;
|
|
596 |
}
|
|
597 |
|
|
598 |
/**
|
|
599 |
*
|
|
600 |
* @param parentElement
|
|
601 |
* @param labelString
|
|
602 |
* @param conversationEnabled
|
|
603 |
* @param user
|
|
604 |
* @param style
|
|
605 |
* @return
|
|
606 |
*/
|
|
607 |
public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString,
|
|
608 |
ConversationHolder conversation, User user, int style) {
|
|
609 |
EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation);
|
|
610 |
adapt(element);
|
|
611 |
parentElement.addElement(element);
|
|
612 |
return element;
|
|
613 |
}
|
|
614 |
|
|
615 |
/**
|
|
616 |
* <p>
|
|
617 |
* createIntegerTextWithLabelElement
|
|
618 |
* </p>
|
|
619 |
*
|
|
620 |
* @param parentElement
|
|
621 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
622 |
* object.
|
|
623 |
* @param labelString
|
|
624 |
* a {@link java.lang.String} object.
|
|
625 |
* @param initialInteger
|
|
626 |
* a {@link java.lang.Integer} object.
|
|
627 |
* @param style
|
|
628 |
* a int.
|
|
629 |
* @return a
|
|
630 |
* {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
|
|
631 |
* object.
|
|
632 |
*/
|
|
633 |
public NumberWithLabelElement createIntegerTextWithLabelElement(ICdmFormElement parentElement, String labelString,
|
|
634 |
Integer initialInteger, int style) {
|
|
635 |
NumberWithLabelElement element = new NumberWithLabelElement(this, parentElement, labelString, initialInteger,
|
|
636 |
style);
|
|
637 |
adapt(element);
|
|
638 |
parentElement.addElement(element);
|
|
639 |
return element;
|
|
640 |
}
|
|
641 |
|
|
642 |
/**
|
|
643 |
* <p>
|
|
644 |
* createFloatTextWithLabelElement
|
|
645 |
* </p>
|
|
646 |
*
|
|
647 |
* @param parentElement
|
|
648 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
649 |
* object.
|
|
650 |
* @param labelString
|
|
651 |
* a {@link java.lang.String} object.
|
|
652 |
* @param initialFloat
|
|
653 |
* a float.
|
|
654 |
* @param style
|
|
655 |
* a int.
|
|
656 |
* @return a
|
|
657 |
* {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement}
|
|
658 |
* object.
|
|
659 |
*/
|
|
660 |
public NumberWithLabelElement createFloatTextWithLabelElement(ICdmFormElement parentElement, String labelString,
|
|
661 |
float initialFloat, int style) {
|
|
662 |
NumberWithLabelElement element = new NumberWithLabelElement(this, parentElement, labelString, initialFloat,
|
|
663 |
style);
|
|
664 |
adapt(element);
|
|
665 |
parentElement.addElement(element);
|
|
666 |
return element;
|
|
667 |
}
|
|
668 |
|
|
669 |
/**
|
|
670 |
* <p>
|
|
671 |
* createLanguageStringWithLabelElement
|
|
672 |
* </p>
|
|
673 |
*
|
|
674 |
* @param parentElement
|
|
675 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
676 |
* object.
|
|
677 |
* @param labelString
|
|
678 |
* a {@link java.lang.String} object.
|
|
679 |
* @param languageString
|
|
680 |
* a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
|
|
681 |
* @param style
|
|
682 |
* a int.
|
|
683 |
* @return a
|
|
684 |
* {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
|
|
685 |
* object.
|
|
686 |
*/
|
|
687 |
public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
|
|
688 |
String labelString, LanguageString languageString, int style) {
|
|
689 |
LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
|
|
690 |
languageString, style);
|
|
691 |
adapt(element);
|
|
692 |
parentElement.addElement(element);
|
|
693 |
return element;
|
|
694 |
}
|
|
695 |
|
|
696 |
/**
|
|
697 |
* <p>
|
|
698 |
* createLanguageStringWithLabelElement
|
|
699 |
* </p>
|
|
700 |
*
|
|
701 |
* @param parentElement
|
|
702 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
703 |
* object.
|
|
704 |
* @param labelString
|
|
705 |
* a {@link java.lang.String} object.
|
|
706 |
* @param languageString
|
|
707 |
* a {@link eu.etaxonomy.cdm.model.common.LanguageString} object.
|
|
708 |
* @param height
|
|
709 |
* a int.
|
|
710 |
* @param style
|
|
711 |
* a int.
|
|
712 |
* @return a
|
|
713 |
* {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement}
|
|
714 |
* object.
|
|
715 |
*/
|
|
716 |
public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement,
|
|
717 |
String labelString, LanguageString languageString, int height, int style) {
|
|
718 |
LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString,
|
|
719 |
languageString, height, style);
|
|
720 |
adapt(element);
|
|
721 |
parentElement.addElement(element);
|
|
722 |
return element;
|
|
723 |
}
|
|
724 |
|
|
725 |
/**
|
|
726 |
* <p>
|
|
727 |
* createTextElement
|
|
728 |
* </p>
|
|
729 |
*
|
|
730 |
* @param parentElement
|
|
731 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
732 |
* object.
|
|
733 |
* @param initialText
|
|
734 |
* a {@link java.lang.String} object.
|
|
735 |
* @param style
|
|
736 |
* a int.
|
|
737 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
|
|
738 |
* object.
|
|
739 |
*/
|
|
740 |
public TextWithLabelElement createTextElement(ICdmFormElement parentElement, String initialText, int style) {
|
|
741 |
TextWithLabelElement element = new TextWithLabelElement(this, parentElement, null, initialText, null, style);
|
|
742 |
adapt(element);
|
|
743 |
parentElement.addElement(element);
|
|
744 |
return element;
|
|
745 |
}
|
|
746 |
|
|
747 |
/**
|
|
748 |
* <p>
|
|
749 |
* createKeyValueViewerElement
|
|
750 |
* </p>
|
|
751 |
*
|
|
752 |
* @param parentElement
|
|
753 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
754 |
* object.
|
|
755 |
* @param keyHeading
|
|
756 |
* a {@link java.lang.String} object.
|
|
757 |
* @param valueHeading
|
|
758 |
* a {@link java.lang.String} object.
|
|
759 |
* @param map
|
|
760 |
* a {@link java.util.Map} object.
|
|
761 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement}
|
|
762 |
* object.
|
|
763 |
*/
|
|
764 |
public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading,
|
|
765 |
String valueHeading, Map<Object, Object> map) {
|
|
766 |
KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map);
|
|
767 |
adapt(element);
|
|
768 |
parentElement.addElement(element);
|
|
769 |
return element;
|
|
770 |
}
|
|
771 |
|
|
772 |
/**
|
|
773 |
* <p>
|
|
774 |
* createTermComboElement
|
|
775 |
* </p>
|
|
776 |
*
|
|
777 |
* @param termComboType
|
|
778 |
* a
|
|
779 |
* {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType}
|
|
780 |
* object.
|
|
781 |
* @param parentElement
|
|
782 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
783 |
* object.
|
|
784 |
* @param labelString
|
|
785 |
* a {@link java.lang.String} object.
|
|
786 |
* @param selection
|
|
787 |
* a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase}
|
|
788 |
* object.
|
|
789 |
* @param style
|
|
790 |
* a int.
|
|
791 |
* @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
|
|
792 |
* object.
|
|
793 |
*/
|
|
794 |
|
|
795 |
public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(Class<T> termComboType,
|
|
796 |
ICdmFormElement parentElement, String labelString, T selection, int style) {
|
|
797 |
TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString,
|
|
798 |
selection, style);
|
|
799 |
adapt(element);
|
|
800 |
parentElement.addElement(element);
|
|
801 |
return element;
|
|
802 |
}
|
|
803 |
|
|
804 |
/**
|
|
805 |
* <p>
|
|
806 |
* createEnumComboElement
|
|
807 |
* </p>
|
|
808 |
*
|
|
809 |
* @param enumComboType
|
|
810 |
* a
|
|
811 |
* {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
|
|
812 |
* object.
|
|
813 |
* @param parentElement
|
|
814 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
815 |
* object.
|
|
816 |
* @param style
|
|
817 |
* a int.
|
|
818 |
* @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
|
|
819 |
* object.
|
|
820 |
*/
|
|
821 |
public <T extends IDefinedTerm> EnumComboElement<T> createEnumComboElement(Class<T> enumComboType,
|
|
822 |
ICdmFormElement parentElement, int style) {
|
|
823 |
EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
|
|
824 |
adapt(element);
|
|
825 |
parentElement.addElement(element);
|
|
826 |
return element;
|
|
827 |
}
|
|
828 |
|
|
829 |
/**
|
|
830 |
* <p>
|
|
831 |
* createBrowserElement
|
|
832 |
* </p>
|
|
833 |
*
|
|
834 |
* @param imageUri
|
|
835 |
* a {@link java.net.URI} object.
|
|
836 |
* @param style
|
|
837 |
* a int.
|
|
838 |
* @param parentElement
|
|
839 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
840 |
* object.
|
|
841 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement}
|
|
842 |
* object.
|
|
843 |
*/
|
|
844 |
public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) {
|
|
845 |
BrowserElement element = new BrowserElement(this, parentElement, imageUri, style);
|
|
846 |
adapt(element);
|
|
847 |
parentElement.addElement(element);
|
|
848 |
return element;
|
|
849 |
}
|
|
850 |
|
|
851 |
/**
|
|
852 |
* <p>
|
|
853 |
* createImageElement
|
|
854 |
* </p>
|
|
855 |
*
|
|
856 |
* @param parentElement
|
|
857 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
858 |
* object.
|
|
859 |
* @param imageUri
|
|
860 |
* a {@link java.net.URI} object.
|
|
861 |
* @param style
|
|
862 |
* a int.
|
|
863 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
|
|
864 |
*/
|
|
865 |
public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) {
|
|
866 |
ImageElement element = new ImageElement(this, parentElement, imageUri, style);
|
|
867 |
adapt(element);
|
|
868 |
parentElement.addElement(element);
|
|
869 |
return element;
|
|
870 |
}
|
|
871 |
|
|
872 |
/**
|
|
873 |
* <p>
|
|
874 |
* createTextActionElement
|
|
875 |
* </p>
|
|
876 |
*
|
|
877 |
* @param labelString
|
|
878 |
* a {@link java.lang.String} object.
|
|
879 |
* @param initialText
|
|
880 |
* a {@link java.lang.String} object.
|
|
881 |
* @param style
|
|
882 |
* a int.
|
|
883 |
* @param parentElement
|
|
884 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
885 |
* object.
|
|
886 |
* @param buttonLabel
|
|
887 |
* a {@link java.lang.String} object.
|
|
888 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
|
|
889 |
* object.
|
|
890 |
*/
|
|
891 |
public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString,
|
|
892 |
String buttonLabel, String initialText, int style) {
|
|
893 |
TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText,
|
|
894 |
style);
|
|
895 |
adapt(element);
|
|
896 |
parentElement.addElement(element);
|
|
897 |
return element;
|
|
898 |
}
|
|
899 |
|
|
900 |
/**
|
|
901 |
* <p>
|
|
902 |
* createCheckbox
|
|
903 |
* </p>
|
|
904 |
*
|
|
905 |
* @param parentElement
|
|
906 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
|
907 |
* object.
|
|
908 |
* @param label
|
|
909 |
* a {@link java.lang.String} object.
|
|
910 |
* @param initialState
|
|
911 |
* a boolean.
|
|
912 |
* @param style
|
|
913 |
* a int.
|
|
914 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement}
|
|
915 |
* object.
|
|
916 |
*/
|
|
917 |
public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, boolean initialState, int style) {
|
|
918 |
CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation);
|
|
919 |
adapt(element);
|
|
920 |
parentElement.addElement(element);
|
|
921 |
return element;
|
|
922 |
}
|
|
923 |
|
|
924 |
/**
|
|
925 |
* Creates a section as a part of the form.
|
|
926 |
*
|
|
927 |
* @return the section widget
|
|
928 |
* @param section
|
|
929 |
* a
|
|
930 |
* {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
|
|
931 |
* object.
|
|
932 |
*/
|
|
933 |
public Section adapt(AbstractFormSection section) {
|
|
934 |
section.setMenu(section.getLayoutComposite().getMenu());
|
|
935 |
adapt(section, true, true);
|
|
936 |
|
|
937 |
// handle focus and property change events for cdm use
|
|
938 |
section.addFocusListener(selectionFocusHandler);
|
|
939 |
section.setPropertyChangeListeners(propertyChangeListeners);
|
|
940 |
|
|
941 |
if (section.getToggle() != null) {
|
|
942 |
section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
|
|
943 |
section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE));
|
|
944 |
}
|
816 |
945 |
|
817 |
|
public <T extends DefinedTermBase> TermComboElement<T> createTermComboElement(
|
818 |
|
Class<T> termComboType, ICdmFormElement parentElement,
|
819 |
|
String labelString, T selection, int style) {
|
820 |
|
TermComboElement<T> element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, style);
|
821 |
|
adapt(element);
|
822 |
|
parentElement.addElement(element);
|
823 |
|
return element;
|
824 |
|
}
|
825 |
|
|
826 |
|
/**
|
827 |
|
* <p>
|
828 |
|
* createEnumComboElement
|
829 |
|
* </p>
|
830 |
|
*
|
831 |
|
* @param enumComboType
|
832 |
|
* a
|
833 |
|
* {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType}
|
834 |
|
* object.
|
835 |
|
* @param parentElement
|
836 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
837 |
|
* object.
|
838 |
|
* @param style
|
839 |
|
* a int.
|
840 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement}
|
841 |
|
* object.
|
842 |
|
*/
|
843 |
|
public <T extends IDefinedTerm> EnumComboElement<T> createEnumComboElement(
|
844 |
|
Class<T> enumComboType, ICdmFormElement parentElement,
|
845 |
|
int style) {
|
846 |
|
EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
|
847 |
|
adapt(element);
|
848 |
|
parentElement.addElement(element);
|
849 |
|
return element;
|
850 |
|
}
|
851 |
|
|
852 |
|
/**
|
853 |
|
* <p>
|
854 |
|
* createBrowserElement
|
855 |
|
* </p>
|
856 |
|
*
|
857 |
|
* @param imageUri
|
858 |
|
* a {@link java.net.URI} object.
|
859 |
|
* @param style
|
860 |
|
* a int.
|
861 |
|
* @param parentElement
|
862 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
863 |
|
* object.
|
864 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement} object.
|
865 |
|
*/
|
866 |
|
public BrowserElement createBrowserElement(ICdmFormElement parentElement,
|
867 |
|
URI imageUri, int style) {
|
868 |
|
BrowserElement element = new BrowserElement(this, parentElement,
|
869 |
|
imageUri, style);
|
870 |
|
adapt(element);
|
871 |
|
parentElement.addElement(element);
|
872 |
|
return element;
|
873 |
|
}
|
874 |
|
|
875 |
|
/**
|
876 |
|
* <p>
|
877 |
|
* createImageElement
|
878 |
|
* </p>
|
879 |
|
*
|
880 |
|
* @param parentElement
|
881 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
882 |
|
* object.
|
883 |
|
* @param imageUri
|
884 |
|
* a {@link java.net.URI} object.
|
885 |
|
* @param style
|
886 |
|
* a int.
|
887 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object.
|
888 |
|
*/
|
889 |
|
public ImageElement createImageElement(ICdmFormElement parentElement,
|
890 |
|
URI imageUri, int style) {
|
891 |
|
ImageElement element = new ImageElement(this, parentElement, imageUri,
|
892 |
|
style);
|
893 |
|
adapt(element);
|
894 |
|
parentElement.addElement(element);
|
895 |
|
return element;
|
896 |
|
}
|
897 |
|
|
898 |
|
/**
|
899 |
|
* <p>
|
900 |
|
* createTextActionElement
|
901 |
|
* </p>
|
902 |
|
*
|
903 |
|
* @param labelString
|
904 |
|
* a {@link java.lang.String} object.
|
905 |
|
* @param initialText
|
906 |
|
* a {@link java.lang.String} object.
|
907 |
|
* @param style
|
908 |
|
* a int.
|
909 |
|
* @param parentElement
|
910 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
911 |
|
* object.
|
912 |
|
* @param buttonLabel
|
913 |
|
* a {@link java.lang.String} object.
|
914 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement}
|
915 |
|
* object.
|
916 |
|
*/
|
917 |
|
public TextActionElement createTextActionElement(
|
918 |
|
ICdmFormElement parentElement, String labelString,
|
919 |
|
String buttonLabel, String initialText, int style) {
|
920 |
|
TextActionElement element = new TextActionElement(this, parentElement,
|
921 |
|
labelString, buttonLabel, initialText, style);
|
922 |
|
adapt(element);
|
923 |
|
parentElement.addElement(element);
|
924 |
|
return element;
|
925 |
|
}
|
926 |
|
|
927 |
|
/**
|
928 |
|
* <p>
|
929 |
|
* createCheckbox
|
930 |
|
* </p>
|
931 |
|
*
|
932 |
|
* @param parentElement
|
933 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
934 |
|
* object.
|
935 |
|
* @param label
|
936 |
|
* a {@link java.lang.String} object.
|
937 |
|
* @param initialState
|
938 |
|
* a boolean.
|
939 |
|
* @param style
|
940 |
|
* a int.
|
941 |
|
* @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement} object.
|
942 |
|
*/
|
943 |
|
public CheckboxElement createCheckbox(ICdmFormElement parentElement,
|
944 |
|
String label, boolean initialState, int style) {
|
945 |
|
CheckboxElement element = new CheckboxElement(this, parentElement,
|
946 |
|
label, initialState, style | orientation);
|
947 |
|
adapt(element);
|
948 |
|
parentElement.addElement(element);
|
949 |
|
return element;
|
950 |
|
}
|
951 |
|
|
952 |
|
/**
|
953 |
|
* Creates a section as a part of the form.
|
954 |
|
*
|
955 |
|
* @return the section widget
|
956 |
|
* @param section
|
957 |
|
* a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
|
958 |
|
* object.
|
959 |
|
*/
|
960 |
|
public Section adapt(AbstractFormSection section) {
|
961 |
|
section.setMenu(section.getLayoutComposite().getMenu());
|
962 |
|
adapt(section, true, true);
|
963 |
|
|
964 |
|
// handle focus and property change events for cdm use
|
965 |
|
section.addFocusListener(selectionFocusHandler);
|
966 |
|
section.setPropertyChangeListeners(propertyChangeListeners);
|
967 |
|
|
968 |
|
if (section.getToggle() != null) {
|
969 |
|
section.getToggle().setHoverDecorationColor(
|
970 |
|
getColors().getColor(IFormColors.TB_TOGGLE_HOVER));
|
971 |
|
section.getToggle().setDecorationColor(
|
972 |
|
getColors().getColor(IFormColors.TB_TOGGLE));
|
973 |
|
}
|
974 |
|
|
975 |
|
section.setFont(boldFontHolder2.getBoldFont(section
|
976 |
|
.getLayoutComposite().getFont()));
|
977 |
|
|
978 |
|
if ((section.getStyle() & Section.TITLE_BAR) != 0
|
979 |
|
|| (section.getStyle() & Section.SHORT_TITLE_BAR) != 0) {
|
980 |
|
getColors().initializeSectionToolBarColors();
|
981 |
|
section.setTitleBarBackground(getColors().getColor(
|
982 |
|
IFormColors.TB_BG));
|
983 |
|
section.setTitleBarBorderColor(getColors().getColor(
|
984 |
|
IFormColors.TB_BORDER));
|
985 |
|
}
|