use of org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke in project scout.rt by eclipse.
the class AbstractTable method handleKeyStroke.
protected boolean handleKeyStroke(String keyName, char keyChar) {
if (keyName == null) {
return false;
}
keyName = keyName.toLowerCase();
// check if there is no menu keystroke with that name
for (IMenu m : getMenus()) {
if (m.getKeyStroke() != null && m.getKeyStroke().equalsIgnoreCase(keyName)) {
return false;
}
}
// check if there is no keystroke with that name (ticket 78234)
for (IKeyStroke k : getKeyStrokes()) {
if (k.getKeyStroke() != null && k.getKeyStroke().equalsIgnoreCase(keyName)) {
return false;
}
}
if (keyChar > ' ' && (!keyName.contains("control")) && (!keyName.contains("ctrl")) && (!keyName.contains("alt"))) {
// select first/next line with corresponding character
String newText = "" + Character.toLowerCase(keyChar);
m_keyStrokeBuffer.append(newText);
String prefix = m_keyStrokeBuffer.getText();
IColumn<?> col = getContextColumn();
if (col == null) {
List<IColumn<?>> sortCols = getColumnSet().getSortColumns();
if (sortCols.size() > 0) {
col = CollectionUtility.lastElement(sortCols);
} else {
TreeMap<CompositeObject, IColumn<?>> sortMap = new TreeMap<CompositeObject, IColumn<?>>();
int index = 0;
for (IColumn<?> c : getColumnSet().getVisibleColumns()) {
if (c.getDataType() == String.class) {
sortMap.put(new CompositeObject(1, index), c);
} else if (c.getDataType() == Boolean.class) {
sortMap.put(new CompositeObject(3, index), c);
} else {
sortMap.put(new CompositeObject(2, index), c);
}
index++;
}
if (sortMap.size() > 0) {
col = sortMap.get(sortMap.firstKey());
}
}
}
if (col != null) {
int colIndex = col.getColumnIndex();
String pattern = StringUtility.toRegExPattern(prefix.toLowerCase());
pattern = pattern + ".*";
if (LOG.isInfoEnabled()) {
LOG.info("finding regex: '{}' in column '{}'", pattern, getColumnSet().getColumn(colIndex).getHeaderCell().getText());
}
// loop over values and find matching one
int rowCount = getRowCount();
ITableRow selRow = getSelectedRow();
int startIndex = 0;
if (selRow != null) {
if (prefix.length() <= 1) {
startIndex = selRow.getRowIndex() + 1;
} else {
startIndex = selRow.getRowIndex();
}
}
for (int i = 0; i < rowCount; i++) {
ITableRow row = m_rows.get((startIndex + i) % rowCount);
String text = row.getCell(colIndex).getText();
if (text != null && text.toLowerCase().matches(pattern)) {
// handled
selectRow(row, false);
return true;
}
}
}
}
return false;
}
use of org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke in project scout.rt by eclipse.
the class AbstractTree method initConfig.
protected void initConfig() {
// default enabled
m_enabled = NamedBitMaskHelper.ALL_BITS_SET;
m_eventHistory = createEventHistory();
m_eventBuffer = createEventBuffer();
m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(createUIFacade(), ModelContext.copyCurrent());
m_contributionHolder = new ContributionComposite(this);
setEnabled(true);
setTitle(getConfiguredTitle());
setIconId(getConfiguredIconId());
setDefaultIconId(getConfiguredDefaultIconId());
setCssClass(getConfiguredCssClass());
setAutoTitle(getConfiguredAutoTitle());
setCheckable(getConfiguredCheckable());
setNodeHeightHint(getConfiguredNodeHeightHint());
setMultiCheck(getConfiguredMultiCheck());
setMultiSelect(getConfiguredMultiSelect());
setAutoDiscardOnDelete(getConfiguredAutoDiscardOnDelete());
setDragEnabled(getConfiguredDragEnabled());
setDragType(getConfiguredDragType());
setDropType(getConfiguredDropType());
setDropMaximumSize(getConfiguredDropMaximumSize());
setRootNodeVisible(getConfiguredRootNodeVisible());
setRootHandlesVisible(getConfiguredRootHandlesVisible());
setScrollToSelection(getConfiguredScrollToSelection());
setSaveAndRestoreScrollbars(getConfiguredSaveAndRestoreScrollbars());
setAutoCheckChildNodes(getConfiguredAutoCheckChildNodes());
setLazyExpandingEnabled(getConfiguredLazyExpandingEnabled());
setDisplayStyle(getConfiguredDisplayStyle());
setToggleBreadcrumbStyleEnabled(getConfiguredToggleBreadcrumbStyleEnabled());
setRootNode(new AbstractTreeNode() {
});
// add Convenience observer for drag & drop callbacks and event history
addTreeListener(new TreeAdapter() {
@Override
public void treeChanged(TreeEvent e) {
// event history
IEventHistory<TreeEvent> h = getEventHistory();
if (h != null) {
h.notifyEvent(e);
}
// dnd
switch(e.getType()) {
case TreeEvent.TYPE_NODES_DRAG_REQUEST:
{
m_lastSeenDropNode = null;
if (e.getDragObject() == null) {
try {
TransferObject transferObject = interceptDrag(e.getNode());
if (transferObject == null) {
transferObject = interceptDrag(e.getNodes());
}
e.setDragObject(transferObject);
} catch (Exception t) {
LOG.error("Drag", t);
}
}
break;
}
case TreeEvent.TYPE_NODE_DROP_ACTION:
{
m_lastSeenDropNode = null;
if (e.getDropObject() != null) {
try {
interceptDrop(e.getNode(), e.getDropObject());
} catch (Exception t) {
LOG.error("Drop", t);
}
}
break;
}
case TreeEvent.TYPE_NODES_SELECTED:
{
rebuildKeyStrokesInternal();
break;
}
case TreeEvent.TYPE_NODES_CHECKED:
{
try {
interceptNodesChecked(CollectionUtility.arrayList(e.getNodes()));
} catch (RuntimeException ex) {
BEANS.get(ExceptionHandler.class).handle(ex);
}
break;
}
case TreeEvent.TYPE_NODE_DROP_TARGET_CHANGED:
{
try {
if (m_lastSeenDropNode == null || m_lastSeenDropNode != e.getNode()) {
m_lastSeenDropNode = e.getNode();
interceptDropTargetChanged(e.getNode());
}
} catch (RuntimeException ex) {
LOG.error("DropTargetChanged", ex);
}
break;
}
case TreeEvent.TYPE_DRAG_FINISHED:
{
m_lastSeenDropNode = null;
}
}
}
});
// key shortcuts
List<Class<? extends IKeyStroke>> configuredKeyStrokes = getConfiguredKeyStrokes();
List<IKeyStroke> ksList = new ArrayList<IKeyStroke>(configuredKeyStrokes.size());
for (Class<? extends IKeyStroke> keystrokeClazz : configuredKeyStrokes) {
ksList.add(ConfigurationUtility.newInnerInstance(this, keystrokeClazz));
}
// ticket 87370: add ENTER key stroke when execNodeAction has an override
if (ConfigurationUtility.isMethodOverwrite(AbstractTree.class, "execNodeAction", new Class[] { ITreeNode.class }, this.getClass())) {
ksList.add(new KeyStroke("ENTER") {
@Override
protected void execAction() {
fireNodeAction(getSelectedNode());
}
});
}
List<IKeyStroke> contributedKeyStrokes = m_contributionHolder.getContributionsByClass(IKeyStroke.class);
contributedKeyStrokes.addAll(contributedKeyStrokes);
m_baseKeyStrokes = ksList;
setKeyStrokesInternal(m_baseKeyStrokes);
// menus
List<Class<? extends IMenu>> declaredMenus = getDeclaredMenus();
List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
OrderedCollection<IMenu> menus = new OrderedCollection<IMenu>();
for (Class<? extends IMenu> menuClazz : declaredMenus) {
IMenu menu = ConfigurationUtility.newInnerInstance(this, menuClazz);
menus.addOrdered(menu);
}
try {
injectMenusInternal(menus);
} catch (Exception e) {
LOG.error("Error occured while dynamically contributing menus.", e);
}
menus.addAllOrdered(contributedMenus);
new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
TreeContextMenu contextMenu = new TreeContextMenu(this, menus.getOrderedList());
setContextMenuInternal(contextMenu);
}
use of org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke 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;
}
use of org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke in project scout.rt by eclipse.
the class JsonDesktop method toJson.
@Override
public JSONObject toJson() {
JSONObject json = super.toJson();
json.put(IDesktop.PROP_DISPLAY_STYLE, getModel().getDisplayStyle());
putAdapterIdProperty(json, IDesktop.PROP_ACTIVE_FORM, getModel().getActiveForm());
putAdapterIdsProperty(json, "views", getModel().getViews(getModel()));
putAdapterIdsProperty(json, "dialogs", getModel().getDialogs(getModel(), false));
putAdapterIdsProperty(json, "messageBoxes", getModel().getMessageBoxes(getModel()));
putAdapterIdsProperty(json, "notifications", getModel().getNotifications());
putAdapterIdsProperty(json, "fileChoosers", getModel().getFileChoosers(getModel()));
putAdapterIdsProperty(json, "menus", getModel().getMenus(), new DisplayableActionFilter<IMenu>());
putAdapterIdsProperty(json, "addOns", getModel().getAddOns());
putAdapterIdsProperty(json, "keyStrokes", getModel().getKeyStrokes(), new DisplayableActionFilter<IKeyStroke>());
putAdapterIdsProperty(json, "viewButtons", getModel().getViewButtons(), new DisplayableActionFilter<IViewButton>());
putAdapterIdProperty(json, "outline", getModel().getOutline(), new DisplayableOutlineFilter<IOutline>());
if (getModel().getSelectedViews(getModel()).size() > 0) {
putAdapterIdsProperty(json, "selectedViewTabs", getModel().getSelectedViews(getModel()));
}
return json;
}
Aggregations