use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class DeepLinkUriBuilder method createBrowserHistoryEntry.
public BrowserHistoryEntry createBrowserHistoryEntry() {
if (m_path == null) {
throw new IllegalStateException("Cannot create BrowserHistoryEntry without deep-link path");
}
IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
StringBuilder title = new StringBuilder(desktop.getTitle());
if (StringUtility.hasText(m_info)) {
title.append(" - ").append(m_info);
}
return new BrowserHistoryEntry(m_builder.createURI(), title.toString(), m_path);
}
use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class OutlineDeepLinkHandler method handleImpl.
@Override
public void handleImpl(Matcher matcher) throws DeepLinkException {
String outlineId = matcher.group(1);
IOutline selectedOutline = null;
IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
for (IOutline outline : desktop.getAvailableOutlines()) {
String tmpOutlineId = outlineId(outline);
if (tmpOutlineId.equals(outlineId)) {
selectedOutline = outline;
break;
}
}
if (selectedOutline == null) {
throw new DeepLinkException("No outline with ID " + outlineId + " found");
}
if (!selectedOutline.isVisible() || !selectedOutline.isEnabled()) {
throw new DeepLinkException("Outline ID " + outlineId + " is not enabled or visible");
}
desktop.activateOutline(selectedOutline);
}
use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class AbstractForm method startInternal.
/**
* This method is called from the implemented handler methods in a explicit form subclass
*/
protected IForm startInternal(final IFormHandler handler) {
ClientRunContexts.copyCurrent().withForm(this).run(new IRunnable() {
@Override
public void run() throws Exception {
if (isBlockingInternal()) {
throw new IllegalStateException("The form " + getFormId() + " has already been started");
}
// Ensure that boolean is set not only once by the constructor
setFormLoading(true);
setHandler(handler);
m_closeType = IButton.SYSTEM_TYPE_NONE;
m_blockingCondition.setBlocking(true);
try {
initForm();
loadStateInternal();
// if form was disposed during initForm() or loadStateInternal()
if (!isBlockingInternal()) {
return;
}
if (getHandler().isGuiLess()) {
// make sure the form is storing since it is not showing
storeStateInternal();
markSaved();
doFinally();
disposeFormInternal();
return;
}
} catch (RuntimeException | PlatformError e) {
disposeFormInternal();
PlatformException pe = BEANS.get(PlatformExceptionTranslator.class).translate(e).withContextInfo("form", AbstractForm.this.getClass().getName());
if (pe instanceof VetoException) {
VetoException ve = (VetoException) pe;
interceptOnVetoException(ve, ve.getStatus().getCode());
}
throw pe;
}
setButtonsArmed(true);
setCloseTimerArmed(true);
setFormStarted(true);
// Notify the UI to display this form.
if (isShowOnStart()) {
IDesktop desktop = getDesktop();
if (desktop == null || !desktop.isOpened()) {
throw new ProcessingException("There is no desktop or it is not open in the UI.");
} else {
desktop.showForm(AbstractForm.this);
}
}
}
});
return this;
}
use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class AbstractPage method disposeInternal.
@Override
public void disposeInternal() {
super.disposeInternal();
try {
interceptDisposePage();
disposeDetailForm();
disposeTable();
fireAfterPageDispose();
} catch (RuntimeException | PlatformError e) {
BEANS.get(ExceptionHandler.class).handle(e);
}
// automatically remove all data change listeners
ITree tree = getTree();
if (tree != null) {
tree.removeTreeListener(m_treeListener);
}
if (m_internalDataChangeListener != null) {
IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
if (desktop != null) {
desktop.removeDataChangeListener(m_internalDataChangeListener);
}
}
}
use of org.eclipse.scout.rt.client.ui.desktop.IDesktop in project scout.rt by eclipse.
the class AbstractPageWithTable method loadChildrenImpl.
/**
* load tree children<br>
* this method delegates to the table reload<br>
* when the table is loaded and this node is not a leaf node then the table rows are mirrored in child nodes
*/
@Override
protected final void loadChildrenImpl() {
ITree tree = getTree();
try {
if (tree != null) {
tree.setTreeChanging(true);
}
//
// backup currently selected tree node and its path to root
boolean oldSelectionOwned = false;
int oldSelectionDirectChildIndex = -1;
ITreeNode oldSelectedNode = null;
if (tree != null) {
oldSelectedNode = tree.getSelectedNode();
}
List<Object> oldSelectedRowKeys = null;
if (oldSelectedNode != null) {
ITreeNode t = oldSelectedNode;
while (t != null && t.getParentNode() != null) {
if (t.getParentNode() == this) {
oldSelectionOwned = true;
oldSelectedRowKeys = getTableRowFor(t).getKeyValues();
oldSelectionDirectChildIndex = t.getChildNodeIndex();
break;
}
t = t.getParentNode();
}
}
//
setChildrenLoaded(false);
fireBeforeDataLoaded();
try {
loadTableDataImpl();
} catch (ThreadInterruptedError | FutureCancelledError e) {
// NOSONAR
// NOOP
} finally {
fireAfterDataLoaded();
}
setChildrenLoaded(true);
setChildrenDirty(false);
// table events will handle automatic tree changes in case table is mirrored in tree.
// restore currently selected tree node when it was owned by our table rows.
// in case selection was lost, try to select similar index as before
T table = getTable();
if (tree != null && table != null && oldSelectionOwned && tree.getSelectedNode() == null) {
ITreeNode newSelectedNode = null;
ITableRow row = table.getSelectedRow();
if (row != null) {
newSelectedNode = getTreeNodeFor(row);
} else {
row = table.findRowByKey(oldSelectedRowKeys);
if (row != null) {
newSelectedNode = getTreeNodeFor(row);
} else if (oldSelectedNode != null && oldSelectedNode.getTree() == tree) {
// NOSONAR
newSelectedNode = oldSelectedNode;
} else {
int index = Math.max(-1, Math.min(oldSelectionDirectChildIndex, getChildNodeCount() - 1));
if (index >= 0 && index < getChildNodeCount()) {
newSelectedNode = getChildNode(index);
} else {
newSelectedNode = this;
}
}
}
if (newSelectedNode != null) {
tree.selectNode(newSelectedNode);
}
}
} finally {
if (tree != null) {
tree.setTreeChanging(false);
}
}
IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
if (desktop != null) {
desktop.afterTablePageLoaded(this);
}
}
Aggregations