|
What this is
Other links
The source code/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.test.editor.app;
import org.netbeans.test.editor.app.core.*;
import org.netbeans.test.editor.app.util.*;
import org.netbeans.test.editor.app.gui.actions.*;
import org.netbeans.test.editor.app.gui.*;
import org.netbeans.test.editor.app.core.actions.*;
import org.netbeans.test.editor.app.core.cookies.*;
import org.openide.loaders.XMLDataObject;
import org.openide.xml.XMLUtil;
import org.netbeans.modules.editor.options.JavaOptions;
import org.openide.options.SystemOption;
import java.beans.*;
import java.io.*;
import java.net.URL;
import javax.swing.SwingUtilities;
import java.util.*;
import javax.xml.parsers.*; //!!!
import org.w3c.dom.*;
import org.w3c.dom.Document;
import org.apache.xerces.parsers.DOMParser;
import org.netbeans.modules.editor.html.HTMLKit;
import org.netbeans.modules.editor.java.JavaKit;
import org.netbeans.modules.editor.options.BaseOptions;
import org.netbeans.modules.editor.options.HTMLOptions;
import org.openide.util.Lookup;
import org.openide.util.lookup.ProxyLookup;
import org.xml.sax.InputSource;
/** Static class for execution of Editor Test Application.
* @author ehucka
* @version 2.0
*/
public class Main extends java.lang.Object {
public static Test test;
public static TestEditorFrame frame;
private static boolean changed=false;
private static String fileName = null;
public static PrintStream log;
private static PrintStream oldErr;
private static boolean debug = true;
private static boolean compAutoPopup;
private static boolean docAutoPopup;
private static boolean htmlAutoPopup;
private static boolean succeded = false;
public static Thread mainThread=null;
private static void registerActions() {
ActionRegistry.clear();
ActionRegistry.getDefault().addAction(PerformCookie.class, new TestExecuteAction());
ActionRegistry.getDefault().addAction(LoggingCookie.class, new TestStartLoggingAction());
ActionRegistry.getDefault().addAction(LoggingCookie.class, new TestStopLoggingAction());
ActionRegistry.getDefault().addAction(PackCookie.class, new TestPackAction());
TestGroup.createNewTypes();
}
public static boolean getSucceded() {
return succeded;
}
private static void performTest(String[] args) {
int count = args.length;
String lastOpened = null;
if (count % 2 == 1)
count--;
for (int cntr = 0; cntr < count; cntr += 2) {
if (args[cntr] == null) {
Main.log("Supposed to open *null* file - impossible!");
succeded = false;
return;
}
if (!args[cntr].equals(lastOpened)) {
if (!openTest(args[cntr])) {
Main.log("While trying to open file: " + args[0] + " an unexcpected error occurs.");
succeded = false;
return;
} else {
lastOpened = args[cntr];
}
}
if (args[cntr + 1].length() > 0) {
Test.setTesting();
test.perform(args[cntr + 1]);
}
}
succeded = true;
}
private static void backupAndSettings() {
OutputStream file = null;
try {
log = new PrintStream(new MultipleOutputStream(new OutputStream[] {
new OutputStream() {
char[] buffer=new char[512];
int i=0;
public void write(int b) {
buffer[i++]=(char)b;
if (b == '\n') {
if (frame != null) {
frame.appendHistory(new String(buffer,0,i));
}
i=0;
} else if (i == 512) {
if (frame != null) {
frame.appendHistory(new String(buffer));
}
i=0;
}
}
}, System.err
}));
} catch (Exception ex) {
ex.printStackTrace();
}
oldErr = System.err;
System.setErr(log);
Main.log("Setting log file finished.");
JavaOptions opts = (JavaOptions)(SystemOption.findObject(JavaOptions.class));
if (opts == null) {
System.err.println("Didn't find Java options from SystemOptions. Try Lookup for Base Options...");
BaseOptions bo;
bo=(BaseOptions)(Lookup.getDefault().lookup(BaseOptions.class));
opts = (JavaOptions)(bo.getOptions(JavaKit.class));
if (opts == null) {
System.err.println("Base Options don't contain JavaKit Options.");
return;
}
}
compAutoPopup = opts.getCompletionAutoPopup();
opts.setCompletionAutoPopup(false);
docAutoPopup = opts.getJavaDocAutoPopup();
opts.setJavaDocAutoPopup(false);
HTMLOptions hopts = (HTMLOptions)(SystemOption.findObject(HTMLOptions.class));
if (hopts == null) {
System.err.println("Didn't find HTML options from SystemOptions. Try Lookup for Base Options...");
BaseOptions bo;
bo=(BaseOptions)(Lookup.getDefault().lookup(BaseOptions.class));
hopts = (HTMLOptions)(bo.getOptions(HTMLKit.class));
if (hopts == null) {
System.err.println("Base Options don't contain JavaKit Options.");
return;
}
}
htmlAutoPopup = hopts.getCompletionAutoPopup();
hopts.setCompletionAutoPopup(false);
}
/** Start Editor Test Application. It must be started by Internal Execurion in IDE.
* User can starts it either for test design or for automated test execution.
* For automated test execution
|
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.