Package com.dubture.composer.ui.parts

Source Code of com.dubture.composer.ui.parts.WeblinkFormEntry

package com.dubture.composer.ui.parts;

import java.net.MalformedURLException;
import java.net.URL;

import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Hyperlink;

import com.dubture.composer.ui.editor.FormEntryAdapter;

public class WeblinkFormEntry extends FormEntry {

  public WeblinkFormEntry(Composite parent, FormToolkit toolkit, String labelText) {
    super(parent, toolkit, labelText, null, true);
   
    addFormEntryListener(new FormEntryAdapter() {
      public void textValueChanged(FormEntry entry) {
        try {
          Hyperlink link = (Hyperlink)entry.getLabel();
          URL url = new URL(entry.getValue());
          link.setHref(url);
        } catch (MalformedURLException e) {
//          e.printStackTrace();
        }
      }
     
      public void linkActivated(HyperlinkEvent e) {
        if (e.getHref() != null && e.getHref().toString() != null) {
          Program.launch(e.getHref().toString());
        }
      }

    });
  }
}
TOP

Related Classes of com.dubture.composer.ui.parts.WeblinkFormEntry

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.