use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline in project scout.rt by eclipse.
the class PageWithTableAndPageBeanTest method prepareTest.
private PageWithTable prepareTest() {
IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
assertNotNull(desktop);
desktop.setAvailableOutlines(Collections.singletonList(new PageWithTableOutline()));
desktop.setOutline(PageWithTableOutline.class);
desktop.activateFirstPage();
IOutline outline = desktop.getOutline();
assertNotNull(outline);
assertSame(PageWithTableOutline.class, outline.getClass());
IPage<?> page = outline.getActivePage();
assertNotNull(page);
assertSame(PageWithTable.class, page.getClass());
return (PageWithTable) page;
}
use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline in project scout.rt by eclipse.
the class BookmarkUtility method createBookmark.
@SuppressWarnings("squid:S1643")
public static Bookmark createBookmark(IPage<?> page) {
if (page == null || page.getOutline() == null) {
return null;
}
IBookmarkAdapter bookmarkAdapter = getBookmarkAdapter(page);
IOutline outline = page.getOutline();
Bookmark b = new Bookmark();
b.setIconId(bookmarkAdapter.getIconId());
// outline
b.setOutlineClassName(bookmarkAdapter.getOutlineClassName());
ArrayList<IPage<?>> path = new ArrayList<IPage<?>>();
ArrayList<String> titleSegments = new ArrayList<String>();
while (page != null) {
IBookmarkAdapter currentBookmarkAdapter = getBookmarkAdapter(page);
path.add(0, page);
String s = currentBookmarkAdapter.getTitle();
if (s != null) {
titleSegments.add(0, s);
}
// next
page = (IPage) page.getParentNode();
}
if (bookmarkAdapter.getOutlineTitle() != null) {
titleSegments.add(0, bookmarkAdapter.getOutlineTitle());
}
// title
int len = 0;
if (titleSegments.size() > 0) {
len += titleSegments.get(0).length();
}
if (titleSegments.size() > 1) {
len += titleSegments.get(titleSegments.size() - 1).length();
}
for (int i = titleSegments.size() - 1; i > 0; i--) {
if (len > 200) {
titleSegments.remove(i);
} else if (len + titleSegments.get(i).length() <= 200) {
len += titleSegments.get(i).length();
} else {
titleSegments.set(i, "...");
len = 201;
}
}
StringBuilder buf = new StringBuilder();
for (String s : titleSegments) {
if (buf.length() > 0) {
buf.append(" - ");
}
buf.append(s);
}
b.setTitle(buf.toString());
// text
StringBuilder text = new StringBuilder();
// add constraints texts
String prefix = "";
for (int i = 0; i < path.size(); i++) {
page = path.get(i);
IBookmarkAdapter currentBookmarkAdapter = getBookmarkAdapter(page);
if (i > 0 || outline.isRootNodeVisible()) {
text.append(prefix + currentBookmarkAdapter.getText());
text.append("\n");
if (page instanceof IPageWithTable) {
IPageWithTable tablePage = (IPageWithTable) page;
SearchFilter search = tablePage.getSearchFilter();
if (search != null) {
for (String s : search.getDisplayTexts()) {
if (s != null) {
String indent = prefix + " ";
s = s.trim().replaceAll("[\\n]", "\n" + indent);
if (s.length() > 0) {
text.append(indent + s);
text.append("\n");
}
}
}
}
}
prefix += " ";
}
}
b.setText(text.toString().trim());
// path
for (int i = 0; i < path.size(); i++) {
page = path.get(i);
if (page instanceof IPageWithTable) {
IPageWithTable tablePage = (IPageWithTable) page;
IPage<?> childPage = null;
if (i + 1 < path.size()) {
childPage = path.get(i + 1);
}
b.addPathElement(bmStoreTablePage(tablePage, childPage));
} else if (page instanceof IPageWithNodes) {
IPageWithNodes nodePage = (IPageWithNodes) page;
b.addPathElement(bmStoreNodePage(nodePage));
}
}
return b;
}
use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline 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.outline.IOutline in project scout.rt by eclipse.
the class AbstractDesktop method activateOutline.
@Override
public void activateOutline(IOutline outline) {
final IOutline newOutline = resolveOutline(outline);
if (m_outline == newOutline || m_outlineChanging) {
return;
}
try {
m_outlineChanging = true;
setOutlineInternal(newOutline);
} finally {
m_outlineChanging = false;
}
}
use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline in project scout.rt by eclipse.
the class AbstractDesktop method initConfig.
protected void initConfig() {
m_eventHistory = createEventHistory();
// add convenience observer for event history
addDesktopListener(new DesktopListener() {
@Override
public void desktopChanged(DesktopEvent e) {
IEventHistory<DesktopEvent> h = getEventHistory();
if (h != null) {
h.notifyEvent(e);
}
}
});
ClientSessionProvider.currentSession().getMemoryPolicy().registerDesktop(this);
BEANS.get(IDeviceTransformationService.class).install(this);
initDesktopExtensions();
setTitle(getConfiguredTitle());
setCssClass(getConfiguredCssClass());
setSelectViewTabsKeyStrokesEnabled(getConfiguredSelectViewTabsKeyStrokesEnabled());
setSelectViewTabsKeyStrokeModifier(getConfiguredSelectViewTabsKeyStrokeModifier());
setLogoId(getConfiguredLogoId());
setDisplayStyle(getConfiguredDisplayStyle());
initDisplayStyle(getDisplayStyle());
setCacheSplitterPosition(getConfiguredCacheSplitterPosition());
List<IDesktopExtension> extensions = getDesktopExtensions();
m_contributionHolder = new ContributionComposite(this);
// outlines
OrderedCollection<IOutline> outlines = new OrderedCollection<IOutline>();
for (IDesktopExtension ext : extensions) {
try {
ext.contributeOutlines(outlines);
} catch (Exception t) {
LOG.error("contributing outlines by {}", ext, t);
}
}
List<IOutline> contributedOutlines = m_contributionHolder.getContributionsByClass(IOutline.class);
outlines.addAllOrdered(contributedOutlines);
// move outlines
ExtensionUtility.moveModelObjects(outlines);
setAvailableOutlines(outlines.getOrderedList());
// actions (keyStroke, menu, viewButton, toolButton)
List<IAction> actionList = new ArrayList<IAction>();
for (IDesktopExtension ext : extensions) {
try {
ext.contributeActions(actionList);
} catch (Exception t) {
LOG.error("contributing actions by {}", ext, t);
}
}
List<IAction> contributedActions = m_contributionHolder.getContributionsByClass(IAction.class);
actionList.addAll(contributedActions);
// build complete menu and viewButton lists
// only top level menus
OrderedComparator orderedComparator = new OrderedComparator();
List<IMenu> menuList = new ActionFinder().findActions(actionList, IMenu.class, false);
ExtensionUtility.moveModelObjects(menuList);
Collections.sort(menuList, orderedComparator);
m_menus = menuList;
List<IViewButton> viewButtonList = new ActionFinder().findActions(actionList, IViewButton.class, false);
ExtensionUtility.moveModelObjects(viewButtonList);
Collections.sort(viewButtonList, orderedComparator);
m_viewButtons = viewButtonList;
// add dynamic keyStrokes
List<IKeyStroke> ksList = new ActionFinder().findActions(actionList, IKeyStroke.class, true);
for (IKeyStroke ks : ksList) {
try {
ks.initAction();
} catch (RuntimeException | PlatformError e) {
LOG.error("could not initialize key stroke '{}'.", ks, e);
}
}
addKeyStrokes(ksList.toArray(new IKeyStroke[ksList.size()]));
// init outlines
for (IOutline o : m_availableOutlines) {
try {
o.initTree();
} catch (Exception e) {
LOG.error("Could not init outline {}", o, e);
}
}
addPropertyChangeListener(new P_LocalPropertyChangeListener());
}
Aggregations