OrderPreferencePage_NewNavigatorWindowRequired=After changing the order of the taxon nodes, closing and reopen of the taxon navigator is required.\r
OrderPreferencePage_PleaseReopenNavigator=Please close and reopen the taxon navigator.\r
UriWithLabelElement_URL_NOT_SAVED=URL won't be saved\! \r
+UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Could not open external browser. URL is invalid.\r
+UriWithLabelElement_INVALID_URL=Invalid URL\r
+UriWithLabelElement_OPEN_EXTERNAL_BROWSER=Open in external browser\r
LanguageEditorPreferencePage_PleaseRestart=Bitte neu starten\r
LanguageEditorPreferencePage_RestartRequired=Nach dem Wechsel der Standardsprache ist ein Neustart erforderlich.\r
OrderPreferencePage_NewNavigatorWindowRequired=Nach dem Ändern der Taxon Sortierung, ist das Schließen und erneute Öffnen des taxon Navigators erforderlich.\r
-UriWithLabelElement_URL_NOT_SAVED=URL wird nicht gespeichert\!
\ No newline at end of file
+UriWithLabelElement_URL_NOT_SAVED=URL wird nicht gespeichert\!\r
+UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Externer Browser konnt nicht geöffnet werden. URL is ung\u00FCtlig.\r
+UriWithLabelElement_INVALID_URL=Ung\u00FCltiger URL\r
+UriWithLabelElement_OPEN_EXTERNAL_BROWSER=Im Browser öffnen
\ No newline at end of file
public static String CdmDataSourceViewPart_7;
public static String CdmDataSourceViewPart_8;
public static String CdmDataSourceViewPart_9;
+ public static String UriWithLabelElement_COULD_NOT_OPEN_BROWSER;
+ public static String UriWithLabelElement_INVALID_URL;
+ public static String UriWithLabelElement_OPEN_EXTERNAL_BROWSER;
public static String UriWithLabelElement_URL_NOT_SAVED;
static {
// initialize resource bundle
public static final String CHARACTER_DATA_DERIVATE = "character_data_derivate";
+ public static final String WEB = "web";
/***************************************************************************
registerImage(registry, CHARACTER_DATA_DERIVATE,
"character_data_derivate-16x16-32.png");
+ registerImage(registry, WEB,
+ "web.gif");
+
}
private void registerImage(ImageRegistry registry, String key,
//TODO shouldn't ENTITY be bound with super class ICdmBase for example (AbstractFormSection<ENTITY extends ICdmBase>)?
public abstract class AbstractFormSection<ENTITY> extends Section implements ISelectionChangedListener, IEntityElement<ENTITY>, IConversationEnabled {
+ /**
+ * The default number of columns in detail sections
+ */
+ public static final int DEFAULT_NUM_COLUMNS = 2;
+
private ISelectionProvider selectionProvider;
private ENTITY entity;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import eu.etaxonomy.taxeditor.preference.Resources;
/**
- * <p>
- * TextWithLabelElement class.
- * </p>
- *
* @author n.hoffmann
* @version $Id: $
*/
private final boolean isMultiLine;
- /** Constant <code>MAX_HEIGHT=0</code> */
public static final int MAX_HEIGHT = 0;
- /** Constant <code>SINGLE=-1</code> */
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);
this(formFactory, parentElement, labelString, initialText, textHeight, textLimit, false, style);
}
- /**
- * <p>
- * Constructor for TextWithLabelElement.
- * </p>
- *
- * @param formFactory
- * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
- * object.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param initialText
- * a {@link java.lang.String} object.
- * @param textHeight
- * a {@link java.lang.Integer} object.
- * @param textLimit max characters allowed to enter
- * @param style
- * a int.
- * @wbp.parser.entryPoint
- */
protected TextWithLabelElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString,
String initialText, Integer textHeight, Integer textLimit, boolean isMultiLine, int style) {
super(formFactory, parentElement);
this.isMultiLine = isMultiLine;
- if (labelString != null) {
- label = formFactory.createLabel(getLayoutComposite(), CdmUtils.Nz(labelString), SWT.NULL);
- addControl(label);
- if(isMultiLine){
- label.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- }
- else{
- label.setLayoutData(LayoutConstants.LEFT());
- }
- }
+ initLabel(formFactory, labelString, isMultiLine, getLayoutComposite());
+ 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;
combinedStyle = combinedStyle | SWT.WRAP;
}
- text = formFactory.createText(getLayoutComposite(), "", combinedStyle);
+ text = formFactory.createText(layoutComposite, "", combinedStyle);
text.setTextLimit(textLimit!=null?textLimit:Text.LIMIT);
addControl(text);
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
*
}
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events
- * .ModifyEvent)
- */
/** {@inheritDoc} */
@Override
public void modifyText(ModifyEvent e) {
text.setForeground(getColor(symbolicName));
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement#isEnabled()
- */
@Override
public boolean isEnabled() {
return text.isEnabled();
setBackground(selected ? SELECTED : getPersistentBackground());
}
- /*
- * (non-Javadoc)
- *
- * @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#setFocus()
- */
/** {@inheritDoc} */
@Override
public void setFocus() {
text.setFocus();
}
- /**
- * <p>
- * getMainControl
- * </p>
- *
- * @return a {@link org.eclipse.swt.widgets.Control} object.
- */
public Control getMainControl() {
return text;
}
- /**
- * <p>
- * setTextLimit
- * </p>
- *
- * @param limit
- * a int.
- */
public void setTextLimit(int limit) {
text.setTextLimit(limit);
}
package eu.etaxonomy.taxeditor.ui.element;
+import java.net.MalformedURLException;
import java.net.URI;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.JFaceResources;
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.TableWrapLayout;
import eu.etaxonomy.taxeditor.Messages;
+import eu.etaxonomy.taxeditor.model.ImageResources;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
/**
* @author n.hoffmann
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);
+
+ //label
+ initLabel(formFactory, labelString, false, getLayoutComposite());
+
+ //composite(uri + button)
+ Composite textAndButton = formFactory.createComposite(getLayoutComposite(), style);
+ textAndButton.setLayout(LayoutConstants.LAYOUT(2, false));
+ textAndButton.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
+
+ //uri text
+ initText(formFactory, null, textHeight, null, false, style, textAndButton);
+
+ //button
+ btnOpenBrowser = formFactory.createButton(textAndButton, "", SWT.NONE); //$NON-NLS-1$
+ btnOpenBrowser.setImage(ImageResources.getImage(ImageResources.WEB));
+ btnOpenBrowser.setToolTipText(Messages.UriWithLabelElement_OPEN_EXTERNAL_BROWSER);
+ btnOpenBrowser.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String errorTitle = Messages.UriWithLabelElement_INVALID_URL;
+ String errorText = Messages.UriWithLabelElement_COULD_NOT_OPEN_BROWSER;
+
+ URI uri = getUri();
+ if(uri!=null){
+ try {
+ PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(uri.toURL());
+ } catch (PartInitException pie) {
+ MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, pie));
+ } catch (MalformedURLException mue) {
+ MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, mue));
+ } catch (IllegalArgumentException iae) {
+ MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, iae));
+ }
+ }
+ else{
+ MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, null));
+ }
+ }
+ });
+ btnOpenBrowser.setLayoutData(LayoutConstants.RIGHT());
labelException = formFactory.createLabel(getLayoutComposite(), "", SWT.WRAP); //$NON-NLS-1$
- labelException.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ 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);
}
protected void createControlsByType(AbstractCdmDetailSection<ENTITY> formElement, Class<ENTITY> entityClass, int style) {
TableWrapLayout layout = (TableWrapLayout) getLayoutComposite().getLayout();
layout.topMargin = 10;
- layout.numColumns = 2;
+ layout.numColumns = DEFAULT_NUM_COLUMNS;
getLayoutComposite().setLayout(layout);
if(entityClass==null){