From: Patrick Plitzner
SINGLE=-1
*/
public static final int SINGLE = -1;
+ protected TextWithLabelElement(CdmFormFactory formFactory, ICdmFormElement parentElement, boolean isMultiLine) {
+ super(formFactory, parentElement);
+ this.isMultiLine = isMultiLine;
+ }
+
protected TextWithLabelElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString,
String initialText, Integer textHeight, int style) {
this(formFactory, parentElement, labelString, initialText, textHeight, null, false, style);
@@ -82,8 +88,23 @@ public class TextWithLabelElement extends AbstractCdmFormElement implements Modi
this.isMultiLine = isMultiLine;
+ init(formFactory, labelString, initialText, textHeight, textLimit, isMultiLine, style, getLayoutComposite());
+ }
+
+ /**
+ * @param formFactory
+ * @param labelString
+ * @param initialText
+ * @param textHeight
+ * @param textLimit
+ * @param isMultiLine
+ * @param style
+ * @param layoutComposite
+ */
+ 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(getLayoutComposite(), CdmUtils.Nz(labelString), SWT.NULL);
+ label = formFactory.createLabel(layoutComposite, CdmUtils.Nz(labelString), SWT.NULL);
addControl(label);
if(isMultiLine){
label.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
@@ -102,7 +123,7 @@ public class TextWithLabelElement extends AbstractCdmFormElement implements Modi
combinedStyle = combinedStyle | SWT.WRAP;
}
- text = formFactory.createText(getLayoutComposite(), "", combinedStyle);
+ text = formFactory.createText(layoutComposite, "", combinedStyle);
text.setTextLimit(textLimit!=null?textLimit:Text.LIMIT);
addControl(text);
@@ -133,6 +154,7 @@ public class TextWithLabelElement extends AbstractCdmFormElement implements Modi
}
else{
layoutData = LayoutConstants.FILL();
+ layoutData.grabHorizontal = true;
}
if (textHeight != null && textHeight > 0) {
(layoutData).heightHint = textHeight;
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/UriWithLabelElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/UriWithLabelElement.java
index e7ef5ec0b..e42490f5f 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/UriWithLabelElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/UriWithLabelElement.java
@@ -10,11 +10,21 @@
package eu.etaxonomy.taxeditor.ui.element;
+import java.net.MalformedURLException;
import java.net.URI;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+
+import eu.etaxonomy.taxeditor.model.ImageResources;
/**
* @author n.hoffmann
@@ -24,14 +34,44 @@ import org.eclipse.swt.widgets.Label;
public class UriWithLabelElement extends TextWithLabelElement {
private final Label labelException;
+ private final Button btnOpenBrowser;
protected UriWithLabelElement(CdmFormFactory formFactory,
ICdmFormElement parentElement, String labelString,
URI initialUri, Integer textHeight, int style) {
- super(formFactory, parentElement, labelString, null, textHeight, style);
+ super(formFactory, parentElement, false);
+
+ Composite layoutComposite = formFactory.createComposite(getLayoutComposite());
+ layoutComposite.setLayout(LayoutConstants.LAYOUT(3, false));
+ layoutComposite.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2,1));
+ init(formFactory, labelString, null, textHeight, null, false, style, layoutComposite);
+
+
+ btnOpenBrowser = formFactory.createButton(layoutComposite, "", SWT.NONE);
+ btnOpenBrowser.setImage(ImageResources.getImage(ImageResources.ADD_CHILD_TAXON_ICON));
+ TableWrapData layoutData = LayoutConstants.RIGHT();
+ layoutData.grabHorizontal = false;
+ btnOpenBrowser.setLayoutData(layoutData);
+ btnOpenBrowser.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ URI uri = getUri();
+ if(uri!=null){
+ try {
+ PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(uri.toURL());
+ } catch (PartInitException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+ }
+ });
- labelException = formFactory.createLabel(getLayoutComposite(), "", SWT.WRAP);
- labelException.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ labelException = formFactory.createLabel(layoutComposite, "", SWT.WRAP);
+ labelException.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(3, 1));
addControl(labelException);
setUri(initialUri);
}