use of ca.weblite.shared.components.PopupMenu in project CodeRAD by shannah.
the class NodeUtilFunctions method buildActionsBar.
static void buildActionsBar(Node node, Container target, Entity entity, Actions right, Actions left, Actions overflow, Actions middle) {
Container actionsBar = new Container(new BorderLayout());
Container actionsBarRight = new Container(new BorderLayout());
if (middle != null && middle.size() > 0) {
GridLayout layout = new GridLayout(middle.size());
Container cnt = new Container(layout);
middle.addToContainer(cnt, entity);
actionsBar.add(BorderLayout.CENTER, cnt);
}
if (left != null) {
Container cnt = new Container(BoxLayout.x());
for (ActionNode action : left) {
cnt.add(action.getViewFactory().createActionView(entity, action));
}
if (actionsBar.getComponentCount() > 0) {
actionsBar.add(BorderLayout.WEST, cnt);
} else {
actionsBar.add(BorderLayout.CENTER, cnt);
}
}
if (right != null) {
Container cnt = new Container(BoxLayout.x());
$(cnt).setAlignment(RIGHT);
for (ActionNode action : right) {
// System.out.println("right node "+action);
cnt.add(action.getViewFactory().createActionView(entity, action));
}
// System.out.println("Adding to right "+cnt);
actionsBarRight.add(BorderLayout.CENTER, cnt);
}
if (overflow != null && !overflow.isEmpty()) {
PopupMenu popup = new PopupMenu();
for (ActionNode action : overflow) {
Property.Label label = action.getLabel();
String labelStr = label != null ? label.getValue() : "";
Command cmd = new Command(labelStr) {
@Override
public void actionPerformed(ActionEvent evt) {
action.fireEvent(entity, target);
}
};
if (action.getImageIcon() != null) {
cmd.setIcon(action.getImageIcon().getValue());
} else if (action.getMaterialIcon() != null) {
cmd.setMaterialIcon(action.getMaterialIcon().getValue());
}
popup.addCommand(cmd);
}
actionsBarRight.add(BorderLayout.EAST, new Button(popup.getCommand()));
}
if (actionsBarRight.getComponentCount() > 0) {
actionsBar.add(BorderLayout.EAST, actionsBarRight);
}
if (actionsBar.getComponentCount() > 0) {
target.add(actionsBar);
}
}
use of ca.weblite.shared.components.PopupMenu in project CodenameOne by codenameone.
the class PopupMenuSample method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", BoxLayout.y());
PopupMenu addMenu = new PopupMenu();
addMenu.addCommand(Command.createMaterial("Add Task", FontImage.MATERIAL_ADD_TASK, evt -> {
// do adding task stuff
}));
addMenu.addCommand(Command.createMaterial("Add Chart", FontImage.MATERIAL_ADD_CHART, evt -> {
// Do adding chart stuff
}));
addMenu.setMaterialIcon(FontImage.MATERIAL_MORE);
addMenu.setCommandLabel("More Options");
hi.add(new Button(addMenu.getCommand()));
hi.show();
}
Aggregations