this.isMultiLine = isMultiLine;
- init(formFactory, labelString, initialText, textHeight, textLimit, isMultiLine, style, getLayoutComposite());
- }
+ initLabel(formFactory, labelString, isMultiLine, getLayoutComposite());
- protected void init(CdmFormFactory formFactory, String labelString, String initialText, Integer textHeight,
- Integer textLimit, boolean isMultiLine, int style, Composite layoutComposite) {
- if (labelString != null) {
- label = formFactory.createLabel(layoutComposite, CdmUtils.Nz(labelString), SWT.NULL);
- addControl(label);
- if(isMultiLine){
- label.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- }
- else{
- label.setLayoutData(LayoutConstants.LEFT());
- }
- }
+ initText(formFactory, initialText, textHeight, textLimit, isMultiLine, style, getLayoutComposite());
+ }
+ protected void initText(CdmFormFactory formFactory, String initialText, Integer textHeight, Integer textLimit,
+ boolean isMultiLine, int style, Composite layoutComposite) {
int scrollStyle = textHeight == null ? SWT.NULL : (SWT.V_SCROLL | SWT.MULTI);
int combinedStyle = style | SWT.BORDER | scrollStyle;
setText(initialText);
}
+ protected void initLabel(CdmFormFactory formFactory, String labelString, boolean isMultiLine, Composite layoutComposite) {
+ if (labelString != null) {
+ label = formFactory.createLabel(layoutComposite, CdmUtils.Nz(labelString), SWT.NULL);
+ addControl(label);
+ if(isMultiLine){
+ label.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ }
+ else{
+ label.setLayoutData(LayoutConstants.LEFT());
+ }
+ }
+ }
+
/**
* Get the text of this composites text composite
*
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
private final Label labelException;
private final Button btnOpenBrowser;
- private static final int NUM_COLUMNS = 3;
protected UriWithLabelElement(CdmFormFactory formFactory,
ICdmFormElement parentElement, String labelString,
URI initialUri, Integer textHeight, int style) {
super(formFactory, parentElement, false);
- Layout parentLayout = getLayoutComposite().getLayout();
- int parentNumColumns = 2;
- if(parentLayout instanceof TableWrapLayout){
- parentNumColumns = ((TableWrapLayout)parentLayout).numColumns;
- }
- Composite layoutComposite = formFactory.createComposite(getLayoutComposite());
- addControl(layoutComposite);
-
- layoutComposite.setLayout(LayoutConstants.LAYOUT(3, false));
- layoutComposite.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(parentNumColumns, 1));
+ initLabel(formFactory, labelString, false, getLayoutComposite());
- init(formFactory, labelString, null, textHeight, null, false, style, layoutComposite);
+ Composite textAndButton = formFactory.createComposite(getLayoutComposite(), style);
+ textAndButton.setLayout(LayoutConstants.LAYOUT(2, false));
+ textAndButton.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
- btnOpenBrowser = formFactory.createButton(layoutComposite, "", SWT.NONE);
+ btnOpenBrowser = formFactory.createButton(textAndButton, "", SWT.NONE);
btnOpenBrowser.setImage(ImageResources.getImage(ImageResources.ADD_CHILD_TAXON_ICON));
btnOpenBrowser.setToolTipText("Open in external browser");
btnOpenBrowser.addSelectionListener(new SelectionAdapter() {
});
btnOpenBrowser.setLayoutData(LayoutConstants.RIGHT());
- labelException = formFactory.createLabel(layoutComposite, "", SWT.WRAP);
- labelException.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(NUM_COLUMNS, 1));
+ initLabel(formFactory, labelString, false, textAndButton);
+
+ labelException = formFactory.createLabel(getLayoutComposite(), "", SWT.WRAP);
+ int numColumns = AbstractFormSection.DEFAULT_NUM_COLUMNS;
+ if(getLayoutComposite().getLayout() instanceof TableWrapLayout){
+ numColumns = ((TableWrapLayout)getLayoutComposite().getLayout()).numColumns;
+ }
+ labelException.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(numColumns, 1));
addControl(labelException);
setUri(initialUri);
}