use of org.eclipse.scout.rt.client.ui.desktop.outline.pages.ISearchForm in project scout.rt by eclipse.
the class DefaultPageChangeStrategy method pageChanged.
@Override
public void pageChanged(final IOutline outline, final IPage<?> deselectedPage, final IPage<?> selectedPage) {
if (outline == null) {
return;
}
outline.clearContextPage();
IForm detailForm = null;
ITable detailTable = null;
ISearchForm searchForm = null;
// new active page
outline.makeActivePageToContextPage();
IPage<?> activePage = outline.getActivePage();
if (activePage != null) {
try {
activePage.ensureChildrenLoaded();
} catch (RuntimeException | PlatformError e1) {
BEANS.get(ExceptionHandler.class).handle(e1);
}
if (activePage instanceof IPageWithTable) {
IPageWithTable tablePage = (IPageWithTable) activePage;
detailForm = activePage.getDetailForm();
if (activePage.isTableVisible()) {
detailTable = tablePage.getTable(false);
}
if (tablePage.isSearchActive()) {
searchForm = tablePage.getSearchFormInternal();
}
} else if (activePage instanceof IPageWithNodes) {
IPageWithNodes nodePage = (IPageWithNodes) activePage;
if (activePage.isDetailFormVisible()) {
detailForm = activePage.getDetailForm();
}
if (activePage.isTableVisible()) {
detailTable = nodePage.getTable(false);
}
}
}
// remove first
if (detailForm == null) {
outline.setDetailForm(null);
}
if (detailTable == null) {
outline.setDetailTable(null);
}
if (searchForm == null) {
outline.setSearchForm(null);
}
// add new
if (detailForm != null) {
outline.setDetailForm(detailForm);
}
if (detailTable != null) {
outline.setDetailTable(detailTable);
}
if (searchForm != null) {
outline.setSearchForm(searchForm);
}
}
use of org.eclipse.scout.rt.client.ui.desktop.outline.pages.ISearchForm in project scout.rt by eclipse.
the class BookmarkUtility method bmLoadTablePage.
private static IPage<?> bmLoadTablePage(IPageWithTable tablePage, TablePageState tablePageState, boolean leafState, boolean resetViewAndWarnOnFail) {
ITable table = tablePage.getTable();
if (tablePageState.getTableCustomizerData() != null && tablePage.getTable().getTableCustomizer() != null) {
byte[] newData = tablePageState.getTableCustomizerData();
ITableCustomizer tc = tablePage.getTable().getTableCustomizer();
byte[] curData = tc.getSerializedData();
if (ObjectUtility.notEquals(curData, newData)) {
tc.removeAllColumns();
tc.setSerializedData(newData);
table.resetColumnConfiguration();
tablePage.setChildrenLoaded(false);
}
}
// starts search form
tablePage.getSearchFilter();
// setup table
try {
table.setTableChanging(true);
restoreTableColumns(tablePage.getTable(), tablePageState.getAvailableColumns());
} finally {
table.setTableChanging(false);
}
// setup user filter
if (tablePageState.getUserFilterData() != null && tablePage.getTable().getUserFilterManager() != null) {
byte[] newData = tablePageState.getUserFilterData();
TableUserFilterManager ufm = tablePage.getTable().getUserFilterManager();
byte[] curData = ufm.getSerializedData();
if (ObjectUtility.notEquals(curData, newData)) {
try {
ufm.setSerializedData(newData);
} catch (RuntimeException e) {
LOG.error("User filters could not be restored. ", e);
}
}
}
// setup search
if (tablePageState.getSearchFormState() != null) {
ISearchForm searchForm = tablePage.getSearchFormInternal();
if (searchForm != null) {
boolean doSearch = true;
String newSearchFilterState = tablePageState.getSearchFilterState();
String oldSearchFilterState = "" + createSearchFilterCRC(searchForm.getSearchFilter());
if (ObjectUtility.equals(oldSearchFilterState, newSearchFilterState)) {
String newSearchFormState = tablePageState.getSearchFormState();
String oldSearchFormState = searchForm.storeToXmlString();
if (ObjectUtility.equals(oldSearchFormState, newSearchFormState)) {
doSearch = false;
}
}
// in case search form is in correct state, but no search has been executed, force search
if (tablePage.getTable().getRowCount() == 0) {
doSearch = true;
}
if (doSearch) {
searchForm.loadFromXmlString(tablePageState.getSearchFormState());
if (tablePageState.isSearchFilterComplete()) {
searchForm.doSaveWithoutMarkerChange();
}
}
}
}
IPage<?> childPage = null;
boolean loadChildren = !leafState;
if (tablePage.isChildrenDirty() || tablePage.isChildrenVolatile()) {
loadChildren = true;
tablePage.setChildrenLoaded(false);
}
if (loadChildren) {
tablePage.ensureChildrenLoaded();
tablePage.setChildrenDirty(false);
CompositeObject childPk = tablePageState.getExpandedChildPrimaryKey();
if (childPk != null) {
for (int r = 0; r < table.getRowCount(); r++) {
CompositeObject testPkLegacy = new CompositeObject(BookmarkUtility.makeSerializableKeys(table.getRowKeys(r), true));
CompositeObject testPk = new CompositeObject(BookmarkUtility.makeSerializableKeys(table.getRowKeys(r), false));
if (testPk.equals(childPk) || testPkLegacy.equals(childPk)) {
if (r < tablePage.getChildNodeCount()) {
childPage = tablePage.getChildPage(r);
}
break;
}
}
} else {
List<ITreeNode> filteredChildNodes = tablePage.getFilteredChildNodes();
if (filteredChildNodes.size() > 0) {
childPage = (IPage) CollectionUtility.firstElement(filteredChildNodes);
} else if (tablePage.getChildNodeCount() > 0) {
childPage = tablePage.getChildPage(0);
}
}
}
// load selections
if (leafState) {
if (tablePageState.getSelectedChildrenPrimaryKeys().size() > 0) {
tablePage.ensureChildrenLoaded();
HashSet<CompositeObject> selectionSet = new HashSet<CompositeObject>(tablePageState.getSelectedChildrenPrimaryKeys());
ArrayList<ITableRow> rowList = new ArrayList<ITableRow>();
for (ITableRow row : table.getRows()) {
CompositeObject testPkLegacy = new CompositeObject(BookmarkUtility.makeSerializableKeys(row.getKeyValues(), true));
CompositeObject testPk = new CompositeObject(BookmarkUtility.makeSerializableKeys(row.getKeyValues(), false));
if ((selectionSet.contains(testPk) || selectionSet.contains(testPkLegacy)) && row.isFilterAccepted()) {
rowList.add(row);
}
}
if (rowList.size() > 0) {
table.selectRows(rowList);
}
}
return childPage;
}
// check, whether table column filter must be reset
if (resetViewAndWarnOnFail) {
final boolean childPageHidden = childPage == null || (!childPage.isFilterAccepted() && table.getUserFilterManager() != null);
if (childPageHidden) {
table.getUserFilterManager().reset();
tablePage.setTableStatus(new Status(TEXTS.get("BookmarkResetColumnFilters"), IStatus.WARNING));
}
}
// child page is not available or filtered out
if (childPage == null || !childPage.isFilterAccepted()) {
if (resetViewAndWarnOnFail) {
// set appropriate warning
if (tablePage.isSearchActive() && tablePage.getSearchFormInternal() != null) {
tablePage.setTableStatus(new Status(TEXTS.get("BookmarkResolutionCanceledCheckSearchCriteria"), IStatus.ERROR));
} else {
tablePage.setTableStatus(new Status(TEXTS.get("BookmarkResolutionCanceled"), IStatus.ERROR));
}
}
childPage = null;
}
return childPage;
}
use of org.eclipse.scout.rt.client.ui.desktop.outline.pages.ISearchForm in project scout.rt by eclipse.
the class MobileDeviceTransformer method notifyPageSearchFormInit.
@Override
public void notifyPageSearchFormInit(final IPageWithTable<ITable> page) {
if (!getDeviceTransformationConfig().isTransformationEnabled(MobileDeviceTransformation.AUTO_CLOSE_SEARCH_FORM)) {
return;
}
ISearchForm searchForm = page.getSearchFormInternal();
searchForm.addFormListener(new FormListener() {
@Override
public void formChanged(FormEvent e) {
if (FormEvent.TYPE_STORE_AFTER == e.getType()) {
onSearchFormStored(page);
}
}
});
}
use of org.eclipse.scout.rt.client.ui.desktop.outline.pages.ISearchForm in project scout.rt by eclipse.
the class JsonObjectFactory method createJsonAdapter.
@SuppressWarnings("unchecked")
@Override
public IJsonAdapter<?> createJsonAdapter(Object model, IUiSession session, String id, IJsonAdapter<?> parent) {
// --- form fields ----
if (model instanceof IGroupBox) {
// we must distinct between normal group-boxes and group-boxes in tab-boxes
// the use the same model, but we need different adapters
IGroupBox groupBox = (IGroupBox) model;
if (groupBox.getParentField() instanceof ITabBox) {
return new JsonTabItem<IGroupBox>(groupBox, session, id, parent);
} else {
return new JsonGroupBox<IGroupBox>(groupBox, session, id, parent);
}
}
if (model instanceof ISequenceBox) {
return new JsonSequenceBox<ISequenceBox>((ISequenceBox) model, session, id, parent);
}
if (model instanceof ITabBox) {
return new JsonTabBox<ITabBox>((ITabBox) model, session, id, parent);
}
if (model instanceof IBooleanField) {
return new JsonCheckBoxField<IBooleanField>((IBooleanField) model, session, id, parent);
}
if (model instanceof ILabelField) {
return new JsonLabelField<ILabelField>((ILabelField) model, session, id, parent);
}
if (model instanceof IImageField) {
return new JsonImageField<IImageField>((IImageField) model, session, id, parent);
}
if (model instanceof ITableField<?>) {
return new JsonTableField<ITableField<? extends ITable>>((ITableField<?>) model, session, id, parent);
}
if (model instanceof IListBox<?>) {
return new JsonListBox((IListBox<?>) model, session, id, parent);
}
if (model instanceof ITreeField) {
return new JsonTreeField<ITreeField>((ITreeField) model, session, id, parent);
}
if (model instanceof ITreeBox<?>) {
return new JsonTreeBox<ITreeBox>((ITreeBox<?>) model, session, id, parent);
}
if (model instanceof IRadioButton<?>) {
return new JsonRadioButton<IRadioButton>((IRadioButton<?>) model, session, id, parent);
}
if (model instanceof IRadioButtonGroup<?>) {
return new JsonRadioButtonGroup<IRadioButtonGroup>((IRadioButtonGroup<?>) model, session, id, parent);
}
if (model instanceof IButton) {
return new JsonButton<IButton>((IButton) model, session, id, parent);
}
if (model instanceof IStringField) {
return new JsonStringField<IStringField>((IStringField) model, session, id, parent);
}
if (model instanceof INumberField<?>) {
return new JsonNumberField<INumberField>((INumberField<?>) model, session, id, parent);
}
if (model instanceof IProposalField2<?>) {
return new JsonProposalField2((IProposalField2<?>) model, session, id, parent);
}
if (model instanceof ISmartField2<?>) {
return new JsonSmartField2((ISmartField2<?>) model, session, id, parent);
}
if (model instanceof IContentAssistField<?, ?>) {
return new JsonSmartField((IContentAssistField<?, ?>) model, session, id, parent);
}
if (model instanceof IProposalChooser) {
return new JsonProposalChooser<IProposalChooser>((IProposalChooser) model, session, id, parent);
}
if (model instanceof IDateField) {
return new JsonDateField<IDateField>((IDateField) model, session, id, parent);
}
if (model instanceof ICalendarField<?>) {
return new JsonCalendarField<ICalendarField<? extends ICalendar>>((ICalendarField<?>) model, session, id, parent);
}
if (model instanceof IPlannerField<?>) {
return new JsonPlannerField((IPlannerField<?>) model, session, id, parent);
}
if (model instanceof IWrappedFormField<?>) {
return new JsonWrappedFormField<IWrappedFormField<? extends IForm>>((IWrappedFormField<?>) model, session, id, parent);
}
if (model instanceof ISplitBox) {
return new JsonSplitBox<ISplitBox>((ISplitBox) model, session, id, parent);
}
if (model instanceof IPlaceholderField) {
return new JsonPlaceholderField<IPlaceholderField>((IPlaceholderField) model, session, id, parent);
}
if (model instanceof IWizardProgressField) {
return new JsonWizardProgressField<IWizardProgressField>((IWizardProgressField) model, session, id, parent);
}
if (model instanceof IHtmlField) {
return new JsonHtmlField<IHtmlField>((IHtmlField) model, session, id, parent);
}
if (model instanceof IComposerField) {
return new JsonComposerField<IComposerField>((IComposerField) model, session, id, parent);
}
if (model instanceof IBeanField) {
return new JsonBeanField<IBeanField<?>>((IBeanField) model, session, id, parent);
}
if (model instanceof IFileChooserField) {
return new JsonFileChooserField<IFileChooserField>((IFileChooserField) model, session, id, parent);
}
if (model instanceof IColorField) {
return new JsonColorField<IColorField>((IColorField) model, session, id, parent);
}
if (model instanceof IBrowserField) {
return new JsonBrowserField<IBrowserField>((IBrowserField) model, session, id, parent);
}
if (model instanceof IClipboardField) {
return new JsonClipboardField<IClipboardField>((IClipboardField) model, session, id, parent);
}
// --- other model objects ---
if (model instanceof IDesktop) {
return new JsonDesktop<IDesktop>((IDesktop) model, session, id, parent);
}
if (model instanceof IFormMenu<?>) {
return new JsonFormMenu((IFormMenu<?>) model, session, id, parent);
}
if (model instanceof IMenu) {
return new JsonMenu<IMenu>((IMenu) model, session, id, parent);
}
if (model instanceof IKeyStroke) {
return new JsonKeyStroke<IKeyStroke>((IKeyStroke) model, session, id, parent);
}
if (model instanceof ISearchForm) {
return new JsonSearchForm<ISearchForm>((ISearchForm) model, session, id, parent);
}
if (model instanceof IForm) {
return new JsonForm<IForm>((IForm) model, session, id, parent);
}
if (model instanceof IMessageBox) {
return new JsonMessageBox<IMessageBox>((IMessageBox) model, session, id, parent);
}
if (model instanceof IDesktopNotification) {
return new JsonDesktopNotification<IDesktopNotification>((IDesktopNotification) model, session, id, parent);
}
if (model instanceof IOutlineViewButton) {
return new JsonOutlineViewButton<IOutlineViewButton>((IOutlineViewButton) model, session, id, parent);
}
if (model instanceof IViewButton) {
return new JsonViewButton<IViewButton>((IViewButton) model, session, id, parent);
}
if (model instanceof ISearchOutline) {
return new JsonSearchOutline<ISearchOutline>((ISearchOutline) model, session, id, parent);
}
if (model instanceof IOutline) {
return new JsonOutline<IOutline>((IOutline) model, session, id, parent);
}
if (model instanceof ITree) {
return new JsonTree<ITree>((ITree) model, session, id, parent);
}
if (model instanceof ITable) {
ITable table = (ITable) model;
IPage page = (IPage) table.getProperty(JsonOutlineTable.PROP_PAGE);
if (page != null) {
return new JsonOutlineTable<ITable>(table, session, id, parent, page);
}
return new JsonTable<ITable>(table, session, id, parent);
}
if (model instanceof IClientSession) {
return new JsonClientSession<IClientSession>((IClientSession) model, session, id, parent);
}
if (model instanceof ICalendar) {
return new JsonCalendar<ICalendar>((ICalendar) model, session, id, parent);
}
if (model instanceof CalendarComponent) {
return new JsonCalendarComponent<CalendarComponent>((CalendarComponent) model, session, id, parent);
}
if (model instanceof IPlanner<?, ?>) {
return new JsonPlanner<IPlanner>((IPlanner<?, ?>) model, session, id, parent);
}
if (model instanceof IFileChooser) {
return new JsonFileChooser<IFileChooser>((IFileChooser) model, session, id, parent);
}
if (model instanceof IAggregateTableControl) {
// needs to be before ITableControl
return new JsonAggregateTableControl<IAggregateTableControl>((IAggregateTableControl) model, session, id, parent);
}
if (model instanceof IFormTableControl) {
// needs to be before ITableControl
return new JsonFormTableControl<IFormTableControl>((IFormTableControl) model, session, id, parent);
}
if (model instanceof ITableControl) {
return new JsonTableControl<ITableControl>((ITableControl) model, session, id, parent);
}
if (model instanceof IStatusMenuMapping) {
return new JsonStatusMenuMapping<IStatusMenuMapping>((IStatusMenuMapping) model, session, id, parent);
}
return null;
}
Aggregations