use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.
the class TaskHandlerImpl method cancel.
@Override
public final boolean cancel() {
checkState(started, "Task is not running. Task: " + taskExecutor.getTask().toString());
boolean canceled = taskExecutor.cancelExecution();
if (canceled) {
detachCloseListener();
BackgroundTask<T, V> task = taskExecutor.getTask();
task.canceled();
// Notify listeners
for (BackgroundTask.ProgressListener listener : task.getProgressListeners()) {
listener.onCancel();
}
if (log.isTraceEnabled()) {
Frame ownerFrame = getTask().getOwnerFrame();
if (ownerFrame != null) {
String windowClass = ownerFrame.getClass().getCanonicalName();
log.trace("Task was cancelled. Task: {}. User: {}. Frame: {}", taskExecutor.getTask(), getUserSession().getId(), windowClass);
} else {
log.trace("Task was cancelled. Task: {}. User: {}", taskExecutor.getTask(), getUserSession().getId());
}
}
} else {
log.trace("Task wasn't cancelled. Execution is already cancelled. Task: {}", taskExecutor.getTask());
}
return canceled;
}
use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.
the class TaskHandlerImpl method ownerWindowClosed.
private void ownerWindowClosed() {
if (log.isTraceEnabled()) {
Frame ownerFrame = getTask().getOwnerFrame();
String windowClass = ownerFrame.getClass().getCanonicalName();
log.trace("Window closed. User: {}. Window: {}", getUserSession().getId(), windowClass);
}
taskExecutor.cancelExecution();
}
use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.
the class TaskHandlerImpl method timeoutExceeded.
/**
* Cancel with timeout exceeded event
*/
public final void timeoutExceeded() {
uiAccessor.access(() -> {
Frame ownerFrame = getTask().getOwnerFrame();
if (log.isTraceEnabled()) {
if (ownerFrame != null) {
String windowClass = ownerFrame.getClass().getCanonicalName();
log.trace("Task timeout exceeded. Task: {}. Frame: {}", taskExecutor.getTask(), windowClass);
} else {
log.trace("Task timeout exceeded. Task: {}", taskExecutor.getTask());
}
}
checkState(started, "Task is not running");
boolean canceled = taskExecutor.cancelExecution();
if (canceled || timeoutHappens) {
detachCloseListener();
BackgroundTask<T, V> task = taskExecutor.getTask();
boolean handled = task.handleTimeoutException();
if (!handled) {
log.error("Unhandled timeout exception in background task. Task: " + task.toString());
events.publish(new BackgroundTaskTimeoutEvent(this, task));
}
}
if (log.isTraceEnabled()) {
if (ownerFrame != null) {
String windowClass = ownerFrame.getClass().getCanonicalName();
log.trace("Timeout was processed. Task: {}. Frame: {}", taskExecutor.getTask(), windowClass);
} else {
log.trace("Timeout was processed. Task: {}", taskExecutor.getTask());
}
}
});
}
use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.
the class DeclarativeFieldGenerator method generateField.
@Override
public Component generateField(Datasource datasource, String propertyId) {
Frame frame = fieldGroup.getFrame();
if (frame == null) {
throw new IllegalStateException("Table should be attached to frame");
}
Frame controller = ComponentsHelper.getFrameController(frame);
Class<? extends Frame> cCls = controller.getClass();
Method exactMethod = getAccessibleMethod(cCls, methodName, new Class[] { Datasource.class, String.class });
if (exactMethod != null) {
checkGeneratorMethodResultType(exactMethod, frame);
try {
return (Component) exactMethod.invoke(controller, datasource, propertyId);
} catch (Exception e) {
throw new RuntimeException("Exception in declarative FieldGroup Field generator " + methodName, e);
}
}
Method dsMethod = getAccessibleMethod(cCls, methodName, new Class[] { Datasource.class });
if (dsMethod != null) {
checkGeneratorMethodResultType(dsMethod, frame);
try {
return (Component) dsMethod.invoke(controller, datasource);
} catch (Exception e) {
throw new RuntimeException("Exception in declarative FieldGroup Field generator " + methodName, e);
}
}
Method parameterLessMethod = getAccessibleMethod(cCls, methodName, new Class[] {});
if (parameterLessMethod != null) {
checkGeneratorMethodResultType(parameterLessMethod, frame);
try {
return (Component) parameterLessMethod.invoke(controller);
} catch (Exception e) {
throw new RuntimeException("Exception in declarative FieldGroup Field generator " + methodName, e);
}
}
String fieldGroupId = fieldGroup.getId() == null ? "" : fieldGroup.getId();
throw new IllegalStateException(String.format("No suitable method named %s for column generator of table %s", methodName, fieldGroupId));
}
use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.
the class FrameLoader method createComponent.
@Override
public void createComponent() {
// noinspection unchecked
Frame clientSpecificFrame = (T) factory.createComponent(Frame.NAME);
clientSpecificFrame.setId(frameId);
loadMessagesPack(clientSpecificFrame, element);
ComponentLoaderContext parentContext = (ComponentLoaderContext) getContext();
String frameId = parentContext.getCurrentFrameId();
if (parentContext.getFullFrameId() != null) {
frameId = parentContext.getFullFrameId() + "." + frameId;
}
innerContext = new ComponentLoaderContext(context.getParams());
innerContext.setCurrentFrameId(parentContext.getCurrentFrameId());
innerContext.setFullFrameId(frameId);
innerContext.setFrame(clientSpecificFrame);
innerContext.setParent(parentContext);
setContext(innerContext);
layoutElement = element.element("layout");
if (layoutElement == null) {
throw new GuiDevelopmentException("Required element 'layout' is not found", this.context.getFullFrameId());
}
createSubComponents(clientSpecificFrame, layoutElement);
setContext(parentContext);
// noinspection unchecked
resultComponent = (T) wrapByCustomClass(clientSpecificFrame);
}
Aggregations