use of com.codename1.ui.Dialog in project CodenameOne by codenameone.
the class DefaultCrashReporter method exception.
/**
* {@inheritDoc}
*/
public void exception(Throwable t) {
Preferences.set("$CN1_pendingCrash", true);
if (promptUser) {
Dialog error = new Dialog("Error");
error.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
TextArea txt = new TextArea(errorText);
txt.setEditable(false);
txt.setUIID("DialogBody");
error.addComponent(txt);
CheckBox cb = new CheckBox(checkboxText);
cb.setUIID("DialogBody");
error.addComponent(cb);
Container grid = new Container(new GridLayout(1, 2));
error.addComponent(grid);
Command ok = new Command(sendButtonText);
Command dont = new Command(dontSendButtonText);
Button send = new Button(ok);
Button dontSend = new Button(dont);
grid.addComponent(send);
grid.addComponent(dontSend);
Command result = error.showPacked(BorderLayout.CENTER, true);
if (result == dont) {
if (cb.isSelected()) {
Preferences.set("$CN1_crashBlocked", true);
}
Preferences.set("$CN1_pendingCrash", false);
return;
} else {
if (cb.isSelected()) {
Preferences.set("$CN1_prompt", false);
}
}
}
Log.sendLog();
Preferences.set("$CN1_pendingCrash", false);
}
use of com.codename1.ui.Dialog in project CodenameOne by codenameone.
the class TestComponent method getComponentAt_int_int_browsercomponent.
private void getComponentAt_int_int_browsercomponent() {
int w = Display.getInstance().getDisplayWidth();
int h = Display.getInstance().getDisplayHeight();
Form mapDemo = new Form("Maps", new LayeredLayout());
Toolbar.setOnTopSideMenu(true);
Toolbar tb = new Toolbar();
mapDemo.setToolbar(tb);
mapDemo.setTitle("Maps");
tb.addCommandToSideMenu(new Command("Test") {
@Override
public void actionPerformed(ActionEvent e) {
// testNestedScrollingLabels();
}
});
BrowserComponent mc = new BrowserComponent();
mapDemo.add(mc);
mapDemo.show();
TestUtils.waitForFormTitle("Maps", 2000);
Component middleComponent = mapDemo.getComponentAt(w / 2, h / 2);
assertTrue(mc == middleComponent || mc.contains(middleComponent), "Wrong component found in middle. Expected " + mc + " but found " + middleComponent);
tb.openSideMenu();
// wait for side menu to open
TestUtils.waitFor(500);
Component res = null;
res = tb.getComponentAt(10, h / 2);
// System.out.println("tb size = "+tb.getAbsoluteX()+", "+tb.getAbsoluteY()+", "+tb.getWidth()+", "+tb.getHeight());
// System.out.println("mb size = "+tb.getMenuBar().getAbsoluteX()+", "+tb.getMenuBar().getAbsoluteY()+", "+tb.getMenuBar().getWidth()+", "+tb.getMenuBar().getHeight());
// System.out.println("res is "+res);
res = mapDemo.getComponentAt(10, h / 2);
// Let's find the interaction dialog on the form
Component interactionDialog = $("*", mapDemo).filter(c -> {
return c instanceof InteractionDialog;
}).asComponent();
assertTrue(((InteractionDialog) interactionDialog).contains(res), "Toolbar is open so getComponentAt() should return something on the toolbar. But received " + res + ". Toolbar is " + tb);
}
use of com.codename1.ui.Dialog 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.Dialog 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();
}
use of com.codename1.ui.Dialog in project CodenameOne by codenameone.
the class Toolbar method createOverflowCommandList.
/**
* Creates the list component containing the commands within the given
* vector used for showing the menu dialog
*
* @param commands list of command objects
* @return List object
*/
protected List createOverflowCommandList(Vector commands) {
List l = new List(commands);
l.setUIID("CommandList");
Component c = (Component) l.getRenderer();
c.setUIID("Command");
c = l.getRenderer().getListFocusComponent(l);
c.setUIID("CommandFocus");
l.setFixedSelection(List.FIXED_NONE_CYCLIC);
l.setScrollVisible(false);
((DefaultListCellRenderer) l.getRenderer()).setShowNumbers(false);
return l;
}
Aggregations