Example usage for java.io File toURL

List of usage examples for java.io File toURL

Introduction

In this page you can find the example usage for java.io File toURL.

Prototype

@Deprecated
public URL toURL() throws MalformedURLException 

Source Link

Document

Converts this abstract pathname into a file: URL.

Usage

From source file:org.geoserver.wfs.response.ShapeZipTest.java

private SimpleFeatureType checkFieldsAreNotEmpty(InputStream in) throws IOException {
    ZipInputStream zis = new ZipInputStream(in);
    ZipEntry entry = null;/* w w  w  . ja v a  2 s  . c om*/

    File tempFolder = createTempFolder("shp_");
    String shapeFileName = "";
    while ((entry = zis.getNextEntry()) != null) {
        final String name = entry.getName();
        String outName = tempFolder.getAbsolutePath() + File.separatorChar + name;
        // store .shp file name
        if (name.toLowerCase().endsWith("shp"))
            shapeFileName = outName;
        // copy each file to temp folder

        FileOutputStream outFile = new FileOutputStream(outName);
        copyStream(zis, outFile);
        outFile.close();
        zis.closeEntry();
    }
    zis.close();

    // create a datastore reading the uncompressed shapefile
    File shapeFile = new File(shapeFileName);
    ShapefileDataStore ds = new ShapefileDataStore(shapeFile.toURL());
    SimpleFeatureSource fs = ds.getFeatureSource();
    SimpleFeatureCollection fc = fs.getFeatures();
    SimpleFeatureType schema = fc.getSchema();

    SimpleFeatureIterator iter = fc.features();
    try {
        // check that every field has a not null or "empty" value
        while (iter.hasNext()) {
            SimpleFeature f = iter.next();
            for (Object attrValue : f.getAttributes()) {
                assertNotNull(attrValue);
                if (Geometry.class.isAssignableFrom(attrValue.getClass()))
                    assertFalse("Empty geometry", ((Geometry) attrValue).isEmpty());
                else
                    assertFalse("Empty value for attribute", attrValue.toString().trim().equals(""));
            }

        }
    } finally {
        iter.close();
        tempFolder.delete();
    }

    return schema;

}

From source file:net.lightbody.bmp.proxy.jetty.xml.XmlParser.java

/**
 * Parse File.//w  w w  .  j  a v  a 2s  . co  m
 */
public synchronized Node parse(File file) throws IOException, SAXException {
    if (log.isDebugEnabled())
        log.debug("parse: " + file);
    return parse(new InputSource(file.toURL().toString()));
}

From source file:com.streamsets.datacollector.cluster.TestClusterProviderImpl.java

@Before
public void setup() throws Exception {
    tempDir = File.createTempFile(getClass().getSimpleName(), "");
    sparkManagerShell = new File(tempDir, "_cluster-manager");
    Assert.assertTrue(tempDir.delete());
    Assert.assertTrue(tempDir.mkdir());/*from  w  ww.jav a2  s.c o m*/
    providerTemp = new File(tempDir, "provider-temp");
    Assert.assertTrue(providerTemp.mkdir());
    Assert.assertTrue(sparkManagerShell.createNewFile());
    sparkManagerShell.setExecutable(true);
    MockSystemProcess.reset();
    etcDir = new File(tempDir, "etc-src");
    Assert.assertTrue(etcDir.mkdir());
    File sdcProperties = new File(etcDir, "sdc.properties");
    Assert.assertTrue(sdcProperties.createNewFile());
    File log4jPropertyDummyFile = new File(etcDir, SDC_TEST_PREFIX + RuntimeInfo.LOG4J_PROPERTIES);
    Assert.assertTrue(log4jPropertyDummyFile.createNewFile());
    resourcesDir = new File(tempDir, "resources-src");
    Assert.assertTrue(resourcesDir.mkdir());
    Assert.assertTrue((new File(resourcesDir, "dir")).mkdir());
    File resourcesSubDir = new File(resourcesDir, "dir");
    File resourceFile = new File(resourcesSubDir, "core-site.xml");
    resourceFile.createNewFile();
    Assert.assertTrue((new File(resourcesDir, "file")).createNewFile());
    webDir = new File(tempDir, "static-web-dir-src");
    Assert.assertTrue(webDir.mkdir());
    File someWebFile = new File(webDir, "somefile");
    Assert.assertTrue(someWebFile.createNewFile());
    bootstrapLibDir = new File(tempDir, "bootstrap-lib");
    Assert.assertTrue(bootstrapLibDir.mkdir());
    File bootstrapMainLibDir = new File(bootstrapLibDir, "main");
    Assert.assertTrue(bootstrapMainLibDir.mkdirs());
    File bootstrapSparkLibDir = new File(bootstrapLibDir, "spark");
    Assert.assertTrue(bootstrapSparkLibDir.mkdirs());
    File bootstrapMesosLibDir = new File(bootstrapLibDir, "mesos");
    Assert.assertTrue(bootstrapMesosLibDir.mkdirs());
    Assert.assertTrue(new File(bootstrapMainLibDir, "streamsets-datacollector-bootstrap.jar").createNewFile());
    Assert.assertTrue(
            new File(bootstrapSparkLibDir, "streamsets-datacollector-spark-bootstrap.jar").createNewFile());
    Assert.assertTrue(
            new File(bootstrapMesosLibDir, "streamsets-datacollector-mesos-bootstrap.jar").createNewFile());
    List<Config> configs = new ArrayList<Config>();
    configs.add(new Config("clusterSlaveMemory", 512));
    configs.add(new Config("clusterSlaveJavaOpts", ""));
    configs.add(new Config("clusterKerberos", false));
    configs.add(new Config("kerberosPrincipal", ""));
    configs.add(new Config("kerberosKeytab", ""));
    configs.add(new Config("executionMode", ExecutionMode.CLUSTER_YARN_STREAMING));
    pipelineConf = new PipelineConfiguration(PipelineStoreTask.SCHEMA_VERSION, PipelineConfigBean.VERSION,
            UUID.randomUUID(), null, configs, null, new ArrayList<StageConfiguration>(),
            MockStages.getErrorStageConfig(), MockStages.getStatsAggregatorStageConfig());
    pipelineConf
            .setPipelineInfo(new PipelineInfo("name", "desc", null, null, "aaa", null, null, null, true, null));
    File sparkKafkaJar = new File(tempDir, "spark-streaming-kafka-1.2.jar");
    File avroJar = new File(tempDir, "avro-1.7.7.jar");
    File avroMapReduceJar = new File(tempDir, "avro-mapred-1.7.7.jar");
    Assert.assertTrue(sparkKafkaJar.createNewFile());
    Assert.assertTrue(avroJar.createNewFile());
    Assert.assertTrue(avroMapReduceJar.createNewFile());
    classLoader = new URLClassLoader(
            new URL[] { sparkKafkaJar.toURL(), avroJar.toURL(), avroMapReduceJar.toURL() }) {
        public String getType() {
            return ClusterModeConstants.USER_LIBS;
        }
    };
    stageLibrary = MockStages.createStageLibrary(classLoader);
    env = new HashMap<>();
    sourceInfo = new HashMap<>();
    sourceInfo.put(ClusterModeConstants.NUM_EXECUTORS_KEY, "64");
    URLClassLoader emptyCL = new URLClassLoader(new URL[0]);
    RuntimeInfo runtimeInfo = new RuntimeInfo(SDC_TEST_PREFIX, null, Arrays.asList(emptyCL), tempDir);
    sparkProvider = new ClusterProviderImpl(runtimeInfo, null);
}

From source file:org.apache.cocoon.components.xslt.TraxProcessor.java

/**
 * Called by the processor when it encounters an xsl:include, xsl:import, or
 * document() function./*from   ww  w.  ja va  2 s .  c o m*/
 * 
 * @param href
 *            An href attribute, which may be relative or absolute.
 * @param base
 *            The base URI in effect when the href attribute was
 *            encountered.
 * 
 * @return A Source object, or null if the href cannot be resolved, and the
 *         processor should try to resolve the URI itself.
 * 
 * @throws TransformerException
 *             if an error occurs when trying to resolve the URI.
 */
public javax.xml.transform.Source resolve(String href, String base) throws TransformerException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("resolve(href = " + href + ", base = " + base + "); resolver = " + m_resolver);
    }

    Source xslSource = null;
    try {
        if (base == null || href.indexOf(":") > 1) {
            // Null base - href must be an absolute URL
            xslSource = m_resolver.resolveURI(href);
        } else if (href.length() == 0) {
            // Empty href resolves to base
            xslSource = m_resolver.resolveURI(base);
        } else {
            // is the base a file or a real m_url
            if (!base.startsWith("file:")) {
                int lastPathElementPos = base.lastIndexOf('/');
                if (lastPathElementPos == -1) {
                    // this should never occur as the base should
                    // always be protocol:/....
                    return null; // we can't resolve this
                } else {
                    xslSource = m_resolver.resolveURI(base.substring(0, lastPathElementPos) + "/" + href);
                }
            } else {
                File parent = new File(base.substring(5));
                File parent2 = new File(parent.getParentFile(), href);
                xslSource = m_resolver.resolveURI(parent2.toURL().toExternalForm());
            }
        }

        InputSource is = getInputSource(xslSource);

        if (getLogger().isDebugEnabled()) {
            getLogger().debug("xslSource = " + xslSource + ", system id = " + xslSource.getURI());
        }

        if (m_checkIncludes) {
            // Populate included validities
            List includes = (List) m_includesMap.get(base);
            if (includes != null) {
                SourceValidity included = xslSource.getValidity();
                if (included != null) {
                    includes.add(new Object[] { xslSource.getURI(), xslSource.getValidity() });
                } else {
                    // One of the included stylesheets is not cacheable
                    m_includesMap.remove(base);
                }
            }
        }

        return new StreamSource(is.getByteStream(), is.getSystemId());
    } catch (SourceException e) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Failed to resolve " + href + "(base = " + base + "), return null", e);
        }

        // CZ: To obtain the same behaviour as when the resource is
        // transformed by the XSLT Transformer we should return null here.
        return null;
    } catch (java.net.MalformedURLException mue) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Failed to resolve " + href + "(base = " + base + "), return null", mue);
        }

        return null;
    } catch (IOException ioe) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Failed to resolve " + href + "(base = " + base + "), return null", ioe);
        }

        return null;
    } finally {
        m_resolver.release(xslSource);
    }
}

From source file:org.xchain.namespaces.sax.ResultCommand.java

/**
 * <p>Returns the Result object for the path attribute.</p>
 * @param context the JXPathContext to evaluate against.
 * @return a stream result for the path specified.
 *///from   w  ww . j  av  a  2s  . c o m
public Result createResultForPath(JXPathContext context) throws Exception {
    // set the system id.
    String path = getPath(context);

    // get the file object for the path.
    File file = new File(path);

    // create the directories leading up to the path.
    File parentFile = file.getParentFile();
    if (!parentFile.exists()) {
        parentFile.mkdirs();
    }

    // make sure that the file also exists.
    file.createNewFile();

    // create an output stream for this url.
    OutputStream out = new FileOutputStream(file);

    // create a stream result for the output stream.
    StreamResult streamResult = new StreamResult();
    streamResult.setSystemId(file.toURL().toExternalForm());
    streamResult.setOutputStream(out);

    return streamResult;
}

From source file:org.rhq.plugins.jbossas.helper.JBossInstanceInfo.java

private void finalizeSysProps() throws Exception {
    File homeDir;
    if (this.sysProps.containsKey(JBossProperties.HOME_DIR)) {
        homeDir = new File(this.sysProps.getProperty(JBossProperties.HOME_DIR));
    } else {//ww w.  ja  va 2  s.c  o m
        homeDir = getHomeDir();
        this.sysProps.setProperty(JBossProperties.HOME_DIR, homeDir.toString());
    }
    if (!this.sysProps.containsKey(JBossProperties.HOME_URL)) {
        this.sysProps.setProperty(JBossProperties.HOME_URL, homeDir.toURL().toString());
    }
    File serverBaseDir;
    if (!sysProps.containsKey(JBossProperties.SERVER_BASE_DIR)) {
        serverBaseDir = new File(homeDir, "server");
        this.sysProps.setProperty(JBossProperties.SERVER_BASE_DIR, serverBaseDir.toString());
    } else {
        serverBaseDir = new File(this.sysProps.getProperty(JBossProperties.SERVER_BASE_DIR));
    }
    if (!this.sysProps.containsKey(JBossProperties.SERVER_BASE_URL)) {
        this.sysProps.setProperty(JBossProperties.SERVER_BASE_URL, serverBaseDir.toURL().toString());
    }
    this.installInfo = new JBossInstallationInfo(homeDir);
    if (!this.sysProps.containsKey(JBossProperties.SERVER_NAME)) {
        this.sysProps.setProperty(JBossProperties.SERVER_NAME,
                this.installInfo.getProductType().DEFAULT_CONFIG_NAME);
    }
    String serverName = this.sysProps.getProperty(JBossProperties.SERVER_NAME);
    if (!this.sysProps.containsKey(JBossProperties.SERVER_HOME_DIR)) {
        this.sysProps.setProperty(JBossProperties.SERVER_HOME_DIR, serverBaseDir + File.separator + serverName);
    }
    if (!this.sysProps.containsKey(JBossProperties.SERVER_HOME_URL)) {
        String serverHomeDir = this.sysProps.getProperty(JBossProperties.SERVER_HOME_DIR);
        this.sysProps.setProperty(JBossProperties.SERVER_HOME_URL, new File(serverHomeDir).toURL().toString());
    }

    if (!this.sysProps.containsKey(JBossProperties.BIND_ADDRESS)) {
        this.sysProps.setProperty(JBossProperties.BIND_ADDRESS, this.installInfo.getDefaultBindAddress());
    }
    String bindAddress = this.sysProps.getProperty(JBossProperties.BIND_ADDRESS); // this will not be null
    String remoteAddress = getRemoteAddress(bindAddress);
    String jgroupsBindAddress = this.sysProps.getProperty(JBossProperties.JGROUPS_BIND_ADDRESS);
    String jgroupsBindAddr = this.sysProps.getProperty(JBossProperties.JGROUPS_BIND_ADDR);
    if (jgroupsBindAddress == null) {
        jgroupsBindAddress = (jgroupsBindAddr != null) ? jgroupsBindAddr : remoteAddress;
        this.sysProps.setProperty(JBossProperties.JGROUPS_BIND_ADDRESS, jgroupsBindAddress);
    }
    if (jgroupsBindAddr == null) {
        this.sysProps.setProperty(JBossProperties.JGROUPS_BIND_ADDR, jgroupsBindAddress);
    }
    if (!this.sysProps.contains(JavaSystemProperties.JAVA_RMI_SERVER_HOSTNAME)) {
        this.sysProps.setProperty(JavaSystemProperties.JAVA_RMI_SERVER_HOSTNAME, remoteAddress);
    }
}

From source file:org.apache.catalina.ant.ValidatorTask.java

/**
 * Execute the specified command.  This logic only performs the common
 * attribute validation required by all subclasses; it does not perform
 * any functional logic directly./*from   w w w. j a va2  s.com*/
 *
 * @exception BuildException if a validation error occurs
 */
public void execute() throws BuildException {

    if (path == null) {
        throw new BuildException("Must specify 'path'");
    }

    File file = new File(path, Constants.ApplicationWebXml);
    if ((!file.exists()) || (!file.canRead())) {
        throw new BuildException("Cannot find web.xml");
    }

    // Commons-logging likes having the context classloader set
    ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(ValidatorTask.class.getClassLoader());

    Digester digester = DigesterFactory.newDigester(true, true, null);
    try {
        file = file.getCanonicalFile();
        InputStream stream = new BufferedInputStream(new FileInputStream(file));
        InputSource is = new InputSource(file.toURL().toExternalForm());
        is.setByteStream(stream);
        digester.parse(is);
        System.out.println("web.xml validated");
    } catch (Throwable t) {
        throw new BuildException("Validation failure", t);
    } finally {
        Thread.currentThread().setContextClassLoader(oldCL);
    }

}

From source file:org.apache.maven.plugin.checkstyle.DefaultCheckstyleExecutor.java

public CheckstyleResults executeCheckstyle(CheckstyleExecutorRequest request)
        throws CheckstyleExecutorException, CheckstyleException {
    // checkstyle will always use the context classloader in order
    // to load resources (dtds),
    // so we have to fix it
    // olamy this hack is not anymore needed in maven 3.x
    ClassLoader checkstyleClassLoader = PackageNamesLoader.class.getClassLoader();
    Thread.currentThread().setContextClassLoader(checkstyleClassLoader);

    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executeCheckstyle start headerLocation : " + request.getHeaderLocation());
    }//from   w  ww . j a  v a  2  s  . c o  m

    MavenProject project = request.getProject();

    configureResourceLocator(locator, request);

    configureResourceLocator(licenseLocator, request);

    File[] files;
    try {
        files = getFilesToProcess(request);
    } catch (IOException e) {
        throw new CheckstyleExecutorException("Error getting files to process", e);
    }

    final String suppressionsFilePath = getSuppressionsFilePath(request);
    FilterSet filterSet = getSuppressionsFilterSet(suppressionsFilePath);

    Checker checker = new Checker();

    // setup classloader, needed to avoid "Unable to get class information
    // for ..." errors
    List<String> classPathStrings = new ArrayList<String>();
    List<String> outputDirectories = new ArrayList<String>();
    File sourceDirectory = request.getSourceDirectory();
    File testSourceDirectory = request.getTestSourceDirectory();
    if (request.isAggregate()) {
        for (MavenProject childProject : request.getReactorProjects()) {
            prepareCheckstylePaths(request, childProject, classPathStrings, outputDirectories,
                    new File(childProject.getBuild().getSourceDirectory()),
                    new File(childProject.getBuild().getTestSourceDirectory()));
        }
    } else {
        prepareCheckstylePaths(request, project, classPathStrings, outputDirectories, sourceDirectory,
                testSourceDirectory);
    }

    List<URL> urls = new ArrayList<URL>(classPathStrings.size());

    for (String path : classPathStrings) {
        try {
            urls.add(new File(path).toURL());
        } catch (MalformedURLException e) {
            throw new CheckstyleExecutorException(e.getMessage(), e);
        }
    }

    for (String outputDirectoryString : outputDirectories) {
        try {
            if (outputDirectoryString != null) {
                File outputDirectoryFile = new File(outputDirectoryString);
                if (outputDirectoryFile.exists()) {
                    URL outputDirectoryUrl = outputDirectoryFile.toURL();
                    request.getLog().debug("Adding the outputDirectory " + outputDirectoryUrl.toString()
                            + " to the Checkstyle class path");
                    urls.add(outputDirectoryUrl);
                }
            }
        } catch (MalformedURLException e) {
            throw new CheckstyleExecutorException(e.getMessage(), e);
        }
    }

    URLClassLoader projectClassLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), null);
    checker.setClassloader(projectClassLoader);

    checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());

    if (filterSet != null) {
        checker.addFilter(filterSet);
    }
    Configuration configuration = getConfiguration(request);
    checker.configure(configuration);

    AuditListener listener = request.getListener();

    if (listener != null) {
        checker.addListener(listener);
    }

    if (request.isConsoleOutput()) {
        checker.addListener(request.getConsoleListener());
    }

    CheckstyleReportListener sinkListener = new CheckstyleReportListener(configuration);
    if (request.isAggregate()) {
        for (MavenProject childProject : request.getReactorProjects()) {
            addSourceDirectory(sinkListener, new File(childProject.getBuild().getSourceDirectory()),
                    new File(childProject.getBuild().getTestSourceDirectory()), childProject.getResources(),
                    request);
        }
    } else {
        addSourceDirectory(sinkListener, sourceDirectory, testSourceDirectory, request.getResources(), request);
    }

    checker.addListener(sinkListener);

    List<File> filesList = Arrays.asList(files);
    int nbErrors = checker.process(filesList);

    checker.destroy();

    if (projectClassLoader instanceof Closeable) {
        try {
            ((Closeable) projectClassLoader).close();
        } catch (IOException ex) {
            // Nothing we can do - and not detrimental to the build (save running out of file handles).
            getLogger().info("Failed to close custom Classloader - this indicated a bug in the code.", ex);
        }
    }

    if (request.getStringOutputStream() != null) {
        request.getLog().info(request.getStringOutputStream().toString());
    }

    if (request.isFailsOnError() && nbErrors > 0) {
        // TODO: should be a failure, not an error. Report is not meant to
        // throw an exception here (so site would
        // work regardless of config), but should record this information
        throw new CheckstyleExecutorException("There are " + nbErrors + " checkstyle errors.");
    } else if (nbErrors > 0) {
        request.getLog().info("There are " + nbErrors + " checkstyle errors.");
    }

    return sinkListener.getResults();
}

From source file:org.apache.ode.bpel.compiler.BpelC.java

/**
 * <p>//w w w .  j a  v a2s.co  m
 * Compile a BPEL process from a file.  This method uses a {@link BpelObjectFactory}
 * to parse the XML and then calls {@link #compile(Process,String)}.
 * </p>
 * @param bpelFile the file of the BPEL process to be compiled.
 * @param version the version of the BPEL file.
 * @throws IOException if one occurs while reading the BPEL process or writing the
 * output.
 * @throws CompilationException if one occurs while compiling the process.
 */
public void compile(File bpelFile, long version) throws CompilationException, IOException {
    if (__log.isDebugEnabled()) {
        __log.debug("compile(URL)");
    }

    if (bpelFile == null) {
        this.invalidate();
        throw new IllegalArgumentException("Null bpelFile");
    }

    _bpelFile = bpelFile;
    Process process;
    try {
        InputSource isrc = new InputSource(new ByteArrayInputStream(StreamUtils.read(bpelFile.toURL())));
        isrc.setSystemId(bpelFile.getAbsolutePath());

        process = BpelObjectFactory.getInstance().parse(isrc, _bpelFile.toURI());
    } catch (Exception e) {
        CompilationMessage cmsg = __cmsgs.errBpelParseErr().setSource(new SourceLocationImpl(bpelFile.toURI()));
        this.invalidate();
        throw new CompilationException(cmsg, e);
    }

    assert process != null;

    // Output file = bpel file with a cbp extension
    String bpelPath = bpelFile.getAbsolutePath();
    String cbpPath = bpelPath.substring(0, bpelPath.lastIndexOf(".")) + ".cbp";

    compile(process, cbpPath, version);
    this.invalidate();
}

From source file:com.amalto.workbench.dialogs.ProcessResultsDialog.java

@Override
protected Control createDialogArea(Composite parent) {

    try {/*from  w w  w . j  a v a  2  s.  c o m*/

        parent.getShell().setText(title);

        Composite composite = (Composite) super.createDialogArea(parent);
        GridLayout layout = (GridLayout) composite.getLayout();
        layout.numColumns = 2;
        ((GridData) composite.getLayoutData()).widthHint = 800;

        Label variableLabel = new Label(composite, SWT.NONE);
        variableLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
        variableLabel.setText(Messages.ProcessResultsDialog_PipelineVariables);

        variablesCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
        variablesCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));

        /*
         * variablesCombo.addKeyListener( new KeyListener() { public void keyPressed(KeyEvent e) {} public void
         * keyReleased(KeyEvent e) { if ((e.stateMask==0) && (e.character == SWT.CR)) {
         * ProcessResultsPage.this.variablesViewer.setDocument(new Document(getText(variablesCombo.getText()))); }
         * }//keyReleased }//keyListener );
         */

        variablesViewer = new SourceViewer(composite, new VerticalRuler(10), SWT.V_SCROLL | SWT.H_SCROLL);
        variablesViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 2, 1));
        variablesViewer.configure(new TextSourceViewerConfiguration());
        ((GridData) variablesViewer.getControl().getLayoutData()).minimumHeight = 500;

        final Button seeInBrowser = new Button(composite, SWT.PUSH);
        seeInBrowser.setText(Messages.ProcessResultsDialog_display);
        seeInBrowser.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                String htmlContent = variablesViewer.getTextWidget().getText();
                IFile file = FileProvider.createdTempFile(htmlContent, Messages.ProcessResultsDialog_temphtml,
                        null);

                File htmlFile = file.getLocation().toFile();
                String SHARED_ID = "org.eclipse.ui.browser"; //$NON-NLS-1$
                try {
                    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();

                    if (WebBrowserPreference.getBrowserChoice() == WebBrowserPreference.INTERNAL) {
                        support.createBrowser(IWorkbenchBrowserSupport.AS_EDITOR,
                                file.getLocation().toPortableString(), null, null).openURL(htmlFile.toURL());
                    } else {
                        support.createBrowser(IWorkbenchBrowserSupport.AS_EXTERNAL, SHARED_ID, null, null)
                                .openURL(htmlFile.toURL());
                    }
                } catch (Exception e1) {
                    log.error(e1.getMessage(), e1);
                }
            }
        });

        variablesCombo.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                String output = variablesCombo.getText();
                if (output.startsWith(TransformerMainPage.DEFAULT_DISPLAY)) {
                    output = DEFAULT_DISPLAY_TEXT;// TransformerMainPage.DEFAULT_VAR+output.substring(TransformerMainPage.DEFAULT_DISPLAY.length());
                }
                String text = variablesCombo.getText();
                if (text.equals(DEFAULT_DISPLAY_TEXT)) {
                    text = TransformerMainPage.DEFAULT_DISPLAY;
                }
                variablesViewer.setDocument(new Document(getText(text)));

                seeInBrowser.setEnabled("html".equals(text)); //$NON-NLS-1$
            }
        });

        variablesCombo.setFocus();

        refreshData();

        return composite;

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getShell(), Messages._Error,
                Messages.bind(Messages.ProcessResultsDialog_ErrorMsg, e.getLocalizedMessage()));
        return null;
    }

}