use of com.codename1.ui.util.xml.Data in project CodenameOne by codenameone.
the class PerformanceMonitor method refreshFrameActionPerformed.
// GEN-LAST:event_runGCActionPerformed
private void refreshFrameActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_refreshFrameActionPerformed
componentHierarchy.setModel(new ComponentTreeModel(Display.getInstance().getCurrent()));
componentHierarchy.setCellRenderer(new DefaultTreeCellRenderer() {
@Override
public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
String s = value.toString();
if (value instanceof Component) {
s = ((Component) value).getUIID() + ": " + s;
}
// To change body of generated methods, choose Tools | Templates.
return super.getTreeCellRendererComponent(tree, s, sel, expanded, leaf, row, hasFocus);
}
});
Display.getInstance().callSerially(new Runnable() {
public void run() {
trackDrawing = true;
Display.getInstance().getCurrent().repaint();
Display.getInstance().callSerially(new Runnable() {
public void run() {
// data collected
trackDrawing = false;
renderedItems.setModel(createTableModel());
}
});
}
});
}
use of com.codename1.ui.util.xml.Data in project CodenameOne by codenameone.
the class TestRunner method init.
private void init(String[] argv) {
try {
if (argv[0].startsWith("-") || argv[0].startsWith("/")) {
printUsage();
return;
}
try {
mainClass = argv[0];
int pos = 1;
while (pos < argv.length) {
String s = argv[pos];
if (s.equalsIgnoreCase("-testCases")) {
pos++;
testCases = argv[pos].split(",");
pos++;
continue;
}
if (s.equalsIgnoreCase("-skins")) {
pos++;
skins = argv[pos].split(",");
pos++;
continue;
}
if (s.equalsIgnoreCase("-quietMode")) {
quietMode = true;
pos++;
continue;
}
if (s.equalsIgnoreCase("-junitXML")) {
TestReporting.setInstance(new JUnitXMLReporting());
}
if (s.equalsIgnoreCase("-cleanMode")) {
cleanMode = true;
pos++;
continue;
}
System.out.println("Unrecognized argument: " + s);
printUsage();
System.exit(1);
return;
}
} catch (Exception err) {
err.printStackTrace();
printUsage();
return;
}
String[] tests;
if (testCases == null || testCases.length == 0) {
InputStream is = getClass().getResourceAsStream("/tests.dat");
if (is == null) {
System.err.println("Test data not found in the file, make sure the ant task was executed in full");
System.exit(2);
return;
}
DataInputStream di = new DataInputStream(is);
int version = di.readInt();
if (version > VERSION) {
System.err.println("Tests were built with a new version of Codename One and can't be executed with this runner");
System.exit(4);
return;
}
tests = new String[di.readInt()];
for (int iter = 0; iter < tests.length; iter++) {
tests[iter] = di.readUTF();
}
di.close();
} else {
tests = testCases;
}
System.out.println("Preparing to execute " + tests.length + " tests");
StringTokenizer t = new StringTokenizer(System.getProperty("java.class.path"), File.pathSeparator);
File[] files = new File[t.countTokens()];
for (int iter = 0; iter < files.length; iter++) {
files[iter] = new File(t.nextToken());
}
int passedTests = 0;
int failedTests = 0;
if (cleanMode) {
for (String currentTestClass : tests) {
ClassLoader ldr = new ClassPathLoader(files);
Class c = Class.forName("com.codename1.impl.javase.TestExecuter", true, ldr);
Method m = c.getDeclaredMethod("runTest", String.class, String.class, Boolean.TYPE);
Boolean passed = (Boolean) m.invoke(null, mainClass, currentTestClass, quietMode);
if (passed.booleanValue()) {
passedTests++;
} else {
failedTests++;
if (stopOnFail) {
System.exit(100);
return;
}
}
}
} else {
ClassLoader ldr = new ClassPathLoader(files);
Class c = Class.forName("com.codename1.impl.javase.TestExecuter", true, ldr);
for (String currentTestClass : tests) {
Method m = c.getDeclaredMethod("runTest", String.class, String.class, Boolean.TYPE);
Boolean passed = (Boolean) m.invoke(null, mainClass, currentTestClass, quietMode);
if (passed.booleanValue()) {
System.out.println(currentTestClass + " passed!");
passedTests++;
} else {
System.out.println(currentTestClass + " failed!");
failedTests++;
if (stopOnFail) {
System.exit(100);
return;
}
}
}
}
TestReporting.getInstance().testExecutionFinished();
if (failedTests > 0) {
System.out.println("Test execution finished, some failed tests occured. Passed: " + passedTests + " tests. Failed: " + failedTests + " tests.");
} else {
System.out.println("All tests passed. Total " + passedTests + " tests passed");
}
System.exit(0);
} catch (Exception ex) {
ex.printStackTrace();
System.exit(3);
}
}
use of com.codename1.ui.util.xml.Data in project CodenameOne by codenameone.
the class Image method createIndexed.
/**
* Creates an indexed image with byte data this method may return a native indexed image rather than
* an instance of the IndexedImage class
*
* @param width image width
* @param height image height
* @param palette the color palette to use with the byte data
* @param data byte data containing palette offsets to map to ARGB colors
* @deprecated try to avoid using indexed images explicitly
*/
public static Image createIndexed(int width, int height, int[] palette, byte[] data) {
IndexedImage i = new IndexedImage(width, height, palette, data);
CodenameOneImplementation impl = Display.impl;
if (impl.isNativeIndexed()) {
return new Image(impl.createNativeIndexed(i));
}
return i;
}
use of com.codename1.ui.util.xml.Data in project CodenameOne by codenameone.
the class SignIn method showGoogleUser.
private void showGoogleUser(String token) {
ConnectionRequest req = new ConnectionRequest();
req.addRequestHeader("Authorization", "Bearer " + token);
req.setUrl("https://www.googleapis.com/plus/v1/people/me");
req.setPost(false);
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
NetworkManager.getInstance().addToQueueAndWait(req);
d.dispose();
byte[] data = req.getResponseData();
JSONParser parser = new JSONParser();
Map map = null;
try {
map = parser.parseJSON(new InputStreamReader(new ByteArrayInputStream(data), "UTF-8"));
} catch (IOException ex) {
ex.printStackTrace();
}
String name = (String) map.get("displayName");
Map im = (Map) map.get("image");
String url = (String) im.get("url");
Form userForm = new UserForm(name, (EncodedImage) theme.getImage("user.png"), url);
userForm.show();
}
use of com.codename1.ui.util.xml.Data in project CodenameOne by codenameone.
the class SignIn method showFacebookUser.
private void showFacebookUser(String token) {
ConnectionRequest req = new ConnectionRequest();
req.setPost(false);
req.setUrl("https://graph.facebook.com/v2.3/me");
req.addArgumentNoEncoding("access_token", token);
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
NetworkManager.getInstance().addToQueueAndWait(req);
byte[] data = req.getResponseData();
JSONParser parser = new JSONParser();
Map map = null;
try {
map = parser.parseJSON(new InputStreamReader(new ByteArrayInputStream(data), "UTF-8"));
} catch (IOException ex) {
ex.printStackTrace();
}
String name = (String) map.get("name");
d.dispose();
Form userForm = new UserForm(name, (EncodedImage) theme.getImage("user.png"), "https://graph.facebook.com/v2.3/me/picture?access_token=" + token);
userForm.show();
}
Aggregations