-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HybridManager: add context element converters for table rows and columns
- Add a 'col:' and 'row:' prefix to element ids to be able to identify the correct converter on the other side. - Add utility methods to add and remove prefixes/suffixes from strings. 389630
- Loading branch information
1 parent
331e695
commit 025d0e3
Showing
13 changed files
with
394 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
eclipse-scout-core/src/desktop/hybrid/converter/TableColumnContextElementConverter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2010, 2025 BSI Business Systems Integration AG | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
import {Column, HybridActionContextElementConverter, HybridActionContextElementConverters, ModelAdapter, objects, scout, strings, TableAdapter} from '../../../index'; | ||
|
||
export class TableColumnContextElementConverter extends HybridActionContextElementConverter<TableAdapter, string, Column> { | ||
|
||
static JSON_ELEMENT_PREFIX = 'col:'; | ||
|
||
override _acceptAdapter(adapter: ModelAdapter): adapter is TableAdapter { | ||
return adapter instanceof TableAdapter; | ||
} | ||
|
||
override _acceptJsonElement(jsonElement: any): jsonElement is string { | ||
return objects.isString(jsonElement) && strings.startsWith(jsonElement, TableColumnContextElementConverter.JSON_ELEMENT_PREFIX); | ||
} | ||
|
||
override _acceptModelElement(element: any): element is Column { | ||
return element instanceof Column; | ||
} | ||
|
||
override _jsonToElement(adapter: TableAdapter, jsonElement: string): Column { | ||
let table = adapter.widget; | ||
let columnId = strings.removePrefix(jsonElement, TableColumnContextElementConverter.JSON_ELEMENT_PREFIX); | ||
return scout.assertValue(table.columnById(columnId), `Unknown column with id "${columnId}" in table ${adapter.id}`); | ||
} | ||
|
||
override _elementToJson(adapter: TableAdapter, element: Column): string { | ||
let columnId = element.id; | ||
return strings.addPrefix(columnId, TableColumnContextElementConverter.JSON_ELEMENT_PREFIX); | ||
} | ||
} | ||
|
||
HybridActionContextElementConverters.get().register(TableColumnContextElementConverter); |
40 changes: 40 additions & 0 deletions
40
eclipse-scout-core/src/desktop/hybrid/converter/TableRowContextElementConverter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2010, 2025 BSI Business Systems Integration AG | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
import {HybridActionContextElementConverter, HybridActionContextElementConverters, ModelAdapter, objects, scout, strings, TableAdapter, TableRow} from '../../../index'; | ||
|
||
export class TableRowContextElementConverter extends HybridActionContextElementConverter<TableAdapter, string, TableRow> { | ||
|
||
static JSON_ELEMENT_PREFIX = 'row:'; | ||
|
||
override _acceptAdapter(adapter: ModelAdapter): adapter is TableAdapter { | ||
return adapter instanceof TableAdapter; | ||
} | ||
|
||
override _acceptJsonElement(jsonElement: any): jsonElement is string { | ||
return objects.isString(jsonElement) && strings.startsWith(jsonElement, TableRowContextElementConverter.JSON_ELEMENT_PREFIX); | ||
} | ||
|
||
override _acceptModelElement(element: any): element is TableRow { | ||
return element instanceof TableRow; | ||
} | ||
|
||
override _jsonToElement(adapter: TableAdapter, jsonElement: string): TableRow { | ||
let table = adapter.widget; | ||
let rowId = strings.removePrefix(jsonElement, TableRowContextElementConverter.JSON_ELEMENT_PREFIX); | ||
return scout.assertValue(table.rowById(rowId), `Unknown row with id "${rowId}" in table ${adapter.id}`); | ||
} | ||
|
||
override _elementToJson(adapter: TableAdapter, element: TableRow): string { | ||
let rowId = element.id; | ||
return strings.addPrefix(rowId, TableRowContextElementConverter.JSON_ELEMENT_PREFIX); | ||
} | ||
} | ||
|
||
HybridActionContextElementConverters.get().register(TableRowContextElementConverter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.