Source:
private void expandComment(FormToolkit toolkit, Composite composite, boolean expanded) { buttonComposite.setVisible(expanded); if (expanded && composite.getData(KEY_EDITOR) == null) { TaskAttribute textAttribute = getTaskData().getAttributeMapper() .getAssoctiatedAttribute(taskComment.getTaskAttribute()); TaskAttribute userImageAttribute = commentAttribute.getAttribute("who"); boolean showAvatar = Boolean.parseBoolean(getModel().getTaskRepository() .getProperty(TaskEditorExtensions.REPOSITORY_PROPERTY_AVATAR_SUPPORT)); if (showAvatar) { userImageComposite = toolkit.createComposite(composite); userImageComposite.setLayout(new GridLayout(1, false)); GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.BEGINNING).applyTo(userImageComposite); toolkit.paintBordersFor(userImageComposite); userImage = new UserAttributeEditor(getModel(), userImageAttribute, 30); } commentTextEditor = createAttributeEditor(textAttribute); if (commentTextEditor != null) { commentTextEditor.setDecorationEnabled(false); if (showAvatar) { userImage.createControl(userImageComposite, toolkit); GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.BEGINNING).applyTo(userImage.getControl()); userImage.refresh(); } commentTextEditor.createControl(composite, toolkit); GridDataFactory.swtDefaults() .align(SWT.LEFT, SWT.BEGINNING) .applyTo(commentTextEditor.getControl()); commentTextEditor.getControl().addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { getTaskEditorPage().selectionChanged(taskComment); } }); composite.setData(KEY_EDITOR, commentTextEditor); getTaskEditorPage().getAttributeEditorToolkit().adapt(commentTextEditor); reflow(); } } else if (!expanded && composite.getData(KEY_EDITOR) != null) { AbstractAttributeEditor editor = (AbstractAttributeEditor) composite.getData(KEY_EDITOR); editor.getControl().setMenu(null); editor.getControl().dispose(); if (userImageComposite != null) { userImageComposite.dispose(); } if (userImage != null) { userImage.getControl().dispose(); } composite.setData(KEY_EDITOR, null); reflow(); } if (!suppressSelectionChanged) { getTaskEditorPage().selectionChanged(taskComment); } }

Target:
private void expandComment(FormToolkit toolkit, Composite composite, boolean expanded) { buttonComposite.setVisible(expanded); if (expanded && composite.getData(KEY_EDITOR) == null) { TaskAttribute textAttribute = getTaskData().getAttributeMapper() .getAssoctiatedAttribute(taskComment.getTaskAttribute()); TaskAttribute userImageAttribute = commentAttribute.getAttribute("who"); boolean showAvatar = Boolean.parseBoolean(getModel().getTaskRepository() .getProperty(TaskEditorExtensions.REPOSITORY_PROPERTY_AVATAR_SUPPORT)); if (showAvatar) { userImageComposite = toolkit.createComposite(composite); userImageComposite.setLayout(new GridLayout(1, false)); GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.BEGINNING).applyTo(userImageComposite); toolkit.paintBordersFor(userImageComposite); userImage = new UserAttributeEditor(getModel(), userImageAttribute, 30); } commentTextEditor = createAttributeEditor(textAttribute); if (commentTextEditor != null) { commentTextEditor.setDecorationEnabled(false); if (showAvatar) { userImage.createControl(userImageComposite, toolkit); GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.BEGINNING).applyTo(userImage.getControl()); userImage.refresh(); } commentTextEditor.createControl(composite, toolkit); GridDataFactory.swtDefaults() .align(SWT.LEFT, SWT.BEGINNING) .applyTo(commentTextEditor.getControl()); commentTextEditor.getControl().addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { getTaskEditorPage().selectionChanged(taskComment); } }); composite.setData(KEY_EDITOR, commentTextEditor); getTaskEditorPage().getAttributeEditorToolkit().adapt(commentTextEditor); reflow(); } } else if (!expanded && composite.getData(KEY_EDITOR) != null) { AbstractAttributeEditor editor = (AbstractAttributeEditor) composite.getData(KEY_EDITOR); editor.getControl().setMenu(null); editor.getControl().dispose(); if (userImageComposite != null) { userImageComposite.setMenu(null); userImageComposite.dispose(); } composite.setData(KEY_EDITOR, null); reflow(); } if (!suppressSelectionChanged) { getTaskEditorPage().selectionChanged(taskComment); } }