use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.
the class SideMenuBar method createSideNavigationPanel.
Container createSideNavigationPanel(Vector commands, String placement) {
Container menu = constructSideNavigationComponent();
if (getUIManager().isThemeConstant("paintsTitleBarBool", false)) {
Container bar = new Container();
bar.setUIID("StatusBarSideMenu");
addComponentToSideMenu(menu, bar);
}
if (!getUIManager().isThemeConstant("sideMenuTensileDragBool", true)) {
menu.setTensileDragEnabled(false);
}
for (int iter = commands.size() - 1; iter > -1; iter--) {
Command c = (Command) commands.elementAt(iter);
if (c.getClientProperty(COMMAND_PLACEMENT_KEY) != placement) {
continue;
}
Component cmp = (Component) c.getClientProperty(COMMAND_SIDE_COMPONENT);
if (cmp != null) {
if (cmp.getParent() != null) {
cmp.getParent().removeAll();
}
if (c.getClientProperty(COMMAND_ACTIONABLE) != null && c.getClientProperty(COMMAND_ACTIONABLE).equals(Boolean.TRUE)) {
Container cnt = new Container(new BorderLayout());
cnt.addComponent(BorderLayout.CENTER, cmp);
Button btn = createTouchCommandButton(c);
btn.setParent(cnt);
cnt.setLeadComponent(btn);
addComponentToSideMenu(menu, cnt);
} else {
addComponentToSideMenu(menu, cmp);
}
initTitleBarStatus();
} else {
// special case: hide back button that doesn't have text, icon or a side component entry
if (parent.getBackCommand() == c && (c.getCommandName() == null || c.getCommandName().length() == 0) && c.getIcon() == null) {
continue;
}
addComponentToSideMenu(menu, createTouchCommandButton(c));
}
}
boolean isRTLValue = isRTL();
if (placement == COMMAND_PLACEMENT_VALUE_RIGHT) {
isRTLValue = !isRTLValue;
}
UIManager uim = menu.getUIManager();
boolean shadowEnabled = uim.isThemeConstant("sideMenuShadowBool", true);
Image sh = (Image) uim.getThemeImageConstant("sideMenuShadowImage");
if (sh == null && shadowEnabled) {
sh = Resources.getSystemResource().getImage("sidemenu-shadow.png");
}
if (isRTLValue && sh != null) {
sh = sh.flipHorizontally(true);
}
final Image shadow = sh;
if (shadow == null) {
return menu;
} else {
Container main = new Container(new LayeredLayout());
Label shadowLabel = new Label();
shadowLabel.getStyle().setBackgroundType(Style.BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_CENTER);
shadowLabel.getStyle().setBgImage(shadow);
shadowLabel.getStyle().setPadding(0, 0, 0, 0);
shadowLabel.getStyle().setMargin(0, 0, 0, 0);
shadowLabel.getStyle().setBgTransparency(0);
Container c = new Container(new BorderLayout());
if (placement == COMMAND_PLACEMENT_VALUE_RIGHT) {
shadowLabel.setPreferredW(shadow.getWidth());
c.addComponent(BorderLayout.WEST, shadowLabel);
shadowLabel.getStyle().setBgImage(shadow.rotate180Degrees(true));
} else {
if (placement == COMMAND_PLACEMENT_VALUE_TOP) {
// shadowLabel.setPreferredH(shadow.getHeight());
// c.addComponent(BorderLayout.SOUTH, shadowLabel);
// shadowLabel.getStyle().setBgImage(shadow.rotate90Degrees(true));
} else {
shadowLabel.setPreferredW(shadow.getWidth());
c.addComponent(BorderLayout.EAST, shadowLabel);
}
}
main.addComponent(menu);
main.addComponent(c);
return main;
}
}
use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.
the class TextComponent method constructUI.
void constructUI() {
if (getComponentCount() == 0) {
if (isOnTopMode() && isFocusAnimation()) {
getLabel().setUIID("FloatingHint");
setLayout(new LayeredLayout());
Container tfContainer;
if (action != null) {
tfContainer = BorderLayout.center(LayeredLayout.encloseIn(field, FlowLayout.encloseRightMiddle(action)));
} else {
tfContainer = BorderLayout.center(field);
}
tfContainer.add(BorderLayout.NORTH, getLabel()).add(BorderLayout.SOUTH, LayeredLayout.encloseIn(getErrorMessage(), getDescriptionMessage()));
add(tfContainer);
Label errorMessageFiller = new Label();
Component.setSameSize(errorMessageFiller, getErrorMessage());
animationLayer = BorderLayout.south(errorMessageFiller);
add(animationLayer);
updateLabel();
} else {
super.constructUI();
}
}
}
use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.
the class List method calcPreferredSize.
/**
* {@inheritDoc}
*/
protected Dimension calcPreferredSize() {
if (shouldShowHint()) {
Label l = getHintLabelImpl();
if (l != null) {
Dimension d1 = getUIManager().getLookAndFeel().getListPreferredSize(this);
Dimension d2 = l.getPreferredSize();
return new Dimension(d1.getWidth() + d2.getWidth(), d1.getHeight() + d2.getHeight());
}
}
Dimension d = getUIManager().getLookAndFeel().getListPreferredSize(this);
if (spinnerOverlay != null) {
if (spinnerOverlay.getBorder() != null) {
d.setWidth(Math.max(spinnerOverlay.getBorder().getMinimumWidth(), d.getWidth()));
d.setHeight(Math.max(spinnerOverlay.getBorder().getMinimumHeight(), d.getHeight()));
}
}
return d;
}
use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.
the class AutoCapitalizationTest method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", BoxLayout.y());
hi.add(new Label("Hi World"));
TextField myTextField = new TextField();
myTextField.setSingleLineTextArea(false);
myTextField.setConstraint(TextArea.INITIAL_CAPS_SENTENCE);
myTextField.setGrowLimit(-1);
myTextField.setMaxSize(1600);
myTextField.setHint("Type Something...");
hi.add(myTextField);
hi.show();
}
use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.
the class FingerprintScannerSample method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", BoxLayout.y());
TextField keyName = new TextField();
TextField keyValue = new TextField();
Button addItem = new Button("Add Item");
Button getItem = new Button("Get Item");
Button deleteItem = new Button("Delete Item");
Button checkAvailable = new Button("Check Available");
checkAvailable.addActionListener(evt -> {
Container cnt = BoxLayout.encloseY(new Label("TouchID: " + Fingerprint.isTouchIDAvailable()), new Label("FaceID: " + Fingerprint.isFaceIDAvailable()));
Dialog.show("Capabilities", cnt, new Command("OK"));
});
addItem.addActionListener(evt -> {
if (!Fingerprint.isAvailable()) {
ToastBar.showErrorMessage("Fingerprint not avaiable on this platform");
return;
}
Fingerprint.addPassword("Adding secure item to keystore", keyName.getText(), keyValue.getText()).onResult((res, err) -> {
if (err != null) {
if (AsyncResource.isCancelled(err)) {
Log.p("addPassword request was cancelled");
return;
}
Log.e(err);
ToastBar.showErrorMessage(err.getMessage());
} else {
ToastBar.showInfoMessage("Result: " + res);
}
});
});
getItem.addActionListener(evt -> {
Fingerprint.getPassword("Getting secure item", keyName.getText()).onResult((res, err) -> {
if (err != null) {
if (AsyncResource.isCancelled(err)) {
Log.p("getPassword request was cancelled");
return;
}
Log.e(err);
if (err instanceof KeyRevokedException) {
ToastBar.showErrorMessage("Your key has been invalidated, likely due to adding new fingerprints");
} else {
ToastBar.showErrorMessage(err.getMessage());
}
} else {
keyValue.setText(res);
hi.revalidateWithAnimationSafety();
}
});
});
deleteItem.addActionListener(evt -> {
Fingerprint.deletePassword("Getting secure item", keyName.getText()).onResult((res, err) -> {
if (err != null) {
if (AsyncResource.isCancelled(err)) {
Log.p("deletePassword request was cancelled");
}
Log.e(err);
ToastBar.showErrorMessage(err.getMessage());
} else {
keyValue.setText("");
hi.revalidateWithAnimationSafety();
}
});
});
Button checkHardware = new Button("Check Hardware");
checkHardware.addActionListener(evt -> {
Fingerprint.isAvailable();
Dialog.show("Hardware", CN.getProperty("Fingerprint.types", "None"), "OK", null);
});
hi.addAll(checkHardware, new Label("Key:"), keyName, new Label("Value: "), keyValue, addItem, getItem, deleteItem, checkAvailable);
hi.show();
}
Aggregations