use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class FilterSelectWindow method init.
@SuppressWarnings("unchecked")
@Override
public void init(Map<String, Object> params) {
ThemeConstants theme = themeConstantsManager.getConstants();
getDialogOptions().setHeight(theme.get("cuba.gui.filterSelect.dialog.height")).setWidth(theme.get("cuba.gui.filterSelect.dialog.width")).setResizable(true);
filterEntitiesTable.addGeneratedColumn("name", entity -> {
Label<String> label = componentsFactory.createComponent(Label.class);
String caption;
if (Strings.isNullOrEmpty(entity.getCode())) {
caption = AppBeans.get(MetadataTools.class).getInstanceName(entity);
} else {
caption = messages.getMessage(entity.getCode());
}
label.setValue(caption);
captionsMap.put(entity, caption);
return label;
});
filterEntities = (List<FilterEntity>) params.get("filterEntities");
fillDatasource(null);
filterEntitiesTable.setItemClickAction(new AbstractAction("selectByDblClk") {
@Override
public void actionPerform(Component component) {
select();
}
@Override
public String getCaption() {
return messages.getMessage("filter.filterSelect.select");
}
});
FilterHelper filterHelper = AppBeans.get(FilterHelper.class);
filterHelper.addTextChangeListener(nameFilterField, new FilterHelper.TextChangeListener() {
@Override
public void textChanged(String text) {
fillDatasource(text);
}
});
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class ExecutionHistoryAction method actionPerform.
@Override
public void actionPerform(Component component) {
if (target != null && target.getFrame() != null) {
MetaClass metaClass = null;
DataUnit items = target.getItems();
if (items instanceof EntityDataUnit) {
metaClass = ((EntityDataUnit) items).getEntityMetaClass();
}
openLookup(target.getFrame().getFrameOwner(), metaClass);
} else if (component instanceof Component.BelongToFrame) {
FrameOwner screen = ComponentsHelper.getWindowNN((Component.BelongToFrame) component).getFrameOwner();
openLookup(screen, null);
} else {
throw new IllegalStateException("No target screen or component found for 'ExecutionHistoryAction'");
}
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class ListPrintFormAction method actionPerform.
@Override
public void actionPerform(Component component) {
DialogAction cancelAction = new DialogAction(DialogAction.Type.CANCEL);
ScreenContext screenContext = ComponentsHelper.getScreenContext(target);
Preconditions.checkState(screenContext != null, "Component is not attached to window");
Dialogs dialogs = screenContext.getDialogs();
Set selected = target.getSelected();
if (CollectionUtils.isNotEmpty(selected)) {
if (selected.size() > 1) {
Action printSelectedAction = new AbstractAction("actions.printSelected", Status.PRIMARY) {
@Override
public void actionPerform(Component component) {
printSelected(selected);
}
};
printSelectedAction.setIcon(JmixIcon.BARS.source());
printSelectedAction.setCaption(messages.getMessage(getClass(), "actions.printSelected"));
Action printAllAction = new AbstractAction("actions.printAll") {
@Override
public void actionPerform(Component component) {
printAll();
}
};
printAllAction.setIcon(JmixIcon.TABLE.source());
printAllAction.setCaption(messages.getMessage(getClass(), "actions.printAll"));
dialogs.createOptionDialog().withCaption(messages.getMessage(getClass(), "notifications.confirmPrintSelectedHeader")).withMessage(messages.getMessage(getClass(), "notifications.confirmPrintSelected")).withActions(printAllAction, printSelectedAction, cancelAction).show();
} else {
printSelected(selected);
}
} else {
if (isDataAvailable()) {
Action yesAction = new DialogAction(DialogAction.Type.OK) {
@Override
public void actionPerform(Component component) {
printAll();
}
};
cancelAction.setPrimary(true);
dialogs.createOptionDialog().withCaption(messages.getMessage(getClass(), "notifications.confirmPrintAllheader")).withMessage(messages.getMessage(getClass(), "notifications.confirmPrintAll")).withActions(yesAction, cancelAction).show();
} else {
Notifications notifications = screenContext.getNotifications();
notifications.create().withCaption(messages.getMessage(getClass(), "notifications.noSelectedEntity")).withType(Notifications.NotificationType.HUMANIZED).show();
}
}
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class SideMenuImpl method setSidePanelToggleButton.
@Override
public void setSidePanelToggleButton(@Nullable Button toggleButton) {
if (this.toggleButton != null) {
this.toggleButton.setAction(null);
}
if (toggleButton != null) {
AbstractAction toggleAction = new AbstractAction("toggleSideMenu") {
@Override
public void actionPerform(Component component) {
toggleSidePanel();
}
};
toggleAction.setCaption(toggleButton.getCaption());
toggleAction.setIcon(toggleButton.getIcon());
toggleAction.setDescription(toggleButton.getDescription());
toggleAction.setEnabled(toggleButton.isEnabled());
toggleAction.setVisible(toggleButton.isVisible());
toggleButton.setAction(toggleAction);
}
this.toggleButton = toggleButton;
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class InputDialogAction method actionPerform.
@Override
public void actionPerform(Component component) {
if (eventHub != null) {
InputDialog inputDialog = null;
if (component instanceof Component.BelongToFrame) {
Window window = ComponentsHelper.getWindow((Component.BelongToFrame) component);
if (window != null) {
inputDialog = (InputDialog) window.getFrameOwner();
}
}
if (!validationRequired || (inputDialog != null && inputDialog.isValid())) {
InputDialogActionPerformed event = new InputDialogActionPerformed(this, component, inputDialog);
eventHub.publish(InputDialogActionPerformed.class, event);
}
}
}
Aggregations