use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.
the class DsContextImpl method get.
@Override
public Datasource get(String id) {
Preconditions.checkNotNullArgument(id, "Null datasource ID");
Datasource ds = null;
if (!id.contains(".")) {
ds = datasourceMap.get(id);
if (ds == null && parent != null) {
ds = parent.get(id);
}
} else {
if (windowContext != null) {
String nestedFramePath = id.substring(0, id.indexOf("."));
Component nestedFrame = getFrameContext().getFrame().getComponent(nestedFramePath);
if ((nestedFrame) != null && (nestedFrame instanceof Frame)) {
String nestedDsId = id.substring(id.indexOf(".") + 1);
ds = ((Frame) nestedFrame).getDsContext().get(nestedDsId);
}
}
}
return ds;
}
use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.
the class TaskHandlerImpl method kill.
/**
* Cancel without events for tasks
*/
public final void kill() {
uiAccessor.access(() -> {
Frame ownerFrame = getTask().getOwnerFrame();
detachCloseListener();
if (log.isTraceEnabled()) {
if (ownerFrame != null) {
String windowClass = ownerFrame.getClass().getCanonicalName();
log.trace("Task killed. Task: {}. User: {}. Frame: {}", taskExecutor.getTask(), getUserSession().getId(), windowClass);
} else {
log.trace("Task killed. Task: {}. User: {}", taskExecutor.getTask(), getUserSession().getId());
}
}
taskExecutor.cancelExecution();
});
}
use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.
the class TaskHandlerImpl method detachCloseListener.
private void detachCloseListener() {
// force remove close listener
Frame ownerFrame = getTask().getOwnerFrame();
if (ownerFrame != null) {
Window ownerWindow = ComponentsHelper.getWindowImplementation(ownerFrame);
if (ownerWindow != null) {
ownerWindow.removeCloseListener(closeListener);
String windowClass = ownerFrame.getClass().getCanonicalName();
log.trace("Resources were disposed. Task: {}. Frame: {}", taskExecutor.getTask(), windowClass);
} else {
log.trace("Empty ownerWindow. Resources were not disposed. Task: {}", taskExecutor.getTask());
}
} else {
log.trace("Empty ownerFrame. Resources were not disposed. Task: {}", taskExecutor.getTask());
}
closeListener = null;
}
use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.
the class DeclarativeColumnGenerator method generateCell.
@Override
public Component generateCell(Entity entity) {
if (unableToFindMethod) {
return null;
}
Frame frame = table.getFrame();
if (frame == null) {
throw new IllegalStateException("Table should be attached to frame");
}
Frame controller = ComponentsHelper.getFrameController(frame);
if (method == null) {
method = findGeneratorMethod(controller.getClass(), methodName);
if (method == null) {
this.unableToFindMethod = true;
String tableId = table.getId() == null ? "" : table.getId();
throw new IllegalStateException(String.format("No suitable method named %s for column generator of table %s", methodName, tableId));
}
}
try {
return (Component) method.invoke(controller, entity);
} catch (Exception e) {
throw new RuntimeException("Exception in declarative Table column generator " + methodName, e);
}
}
use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.
the class FilterLoader method loadComponent.
@Override
public void loadComponent() {
assignXmlDescriptor(resultComponent, element);
assignFrame(resultComponent);
loadAlign(resultComponent, element);
loadVisible(resultComponent, element);
loadEnable(resultComponent, element);
loadStyleName(resultComponent, element);
loadMargin(resultComponent, element);
loadIcon(resultComponent, element);
loadCaption(resultComponent, element);
loadDescription(resultComponent, element);
loadWidth(resultComponent, element, "100%");
loadCollapsible(resultComponent, element, true);
loadSettingsEnabled(resultComponent, element);
loadBorderVisible(resultComponent, element);
String useMaxResults = element.attributeValue("useMaxResults");
resultComponent.setUseMaxResults(useMaxResults == null || Boolean.parseBoolean(useMaxResults));
String textMaxResults = element.attributeValue("textMaxResults");
resultComponent.setTextMaxResults(Boolean.parseBoolean(textMaxResults));
final String manualApplyRequired = element.attributeValue("manualApplyRequired");
resultComponent.setManualApplyRequired(BooleanUtils.toBooleanObject(manualApplyRequired));
String editable = element.attributeValue("editable");
resultComponent.setEditable(editable == null || Boolean.parseBoolean(editable));
String columnsCount = element.attributeValue("columnsCount");
if (!Strings.isNullOrEmpty(columnsCount)) {
resultComponent.setColumnsCount(Integer.parseInt(columnsCount));
}
String folderActionsEnabled = element.attributeValue("folderActionsEnabled");
if (folderActionsEnabled != null) {
resultComponent.setFolderActionsEnabled(Boolean.parseBoolean(folderActionsEnabled));
}
String datasource = element.attributeValue("datasource");
if (!StringUtils.isBlank(datasource)) {
CollectionDatasource ds = (CollectionDatasource) context.getDsContext().get(datasource);
if (ds == null) {
throw new GuiDevelopmentException("Can't find datasource by name: " + datasource, context.getCurrentFrameId());
}
resultComponent.setDatasource(ds);
}
Frame frame = context.getFrame();
String applyTo = element.attributeValue("applyTo");
if (!StringUtils.isEmpty(applyTo)) {
context.addPostInitTask((context1, window) -> {
Component c = frame.getComponent(applyTo);
if (c == null) {
throw new GuiDevelopmentException("Can't apply component to component with ID: " + applyTo, context1.getFullFrameId());
}
resultComponent.setApplyTo(c);
});
}
String modeSwitchVisible = element.attributeValue("modeSwitchVisible");
resultComponent.setModeSwitchVisible(modeSwitchVisible == null || Boolean.parseBoolean(modeSwitchVisible));
context.addPostInitTask((context1, window) -> {
((FilterImplementation) resultComponent).loadFiltersAndApplyDefault();
String defaultMode = element.attributeValue("defaultMode");
if (defaultMode != null && "fts".equals(defaultMode)) {
resultComponent.switchFilterMode(FilterDelegate.FilterMode.FTS_MODE);
}
});
}
Aggregations