From 72d3beefed9e732e3903d6394d03d4bf3cd2e83c Mon Sep 17 00:00:00 2001 From: Vincent Aravantinos <aravantinos@fortiss.org> Date: Wed, 20 Dec 2017 14:06:11 +0000 Subject: [PATCH] commits Hernan's changes refs 2556 --- .../base/ui/utils/TableViewerUtils.java | 20 ++++++++ .../base/ui/utils/TreeViewerUtils.java | 49 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/TreeViewerUtils.java diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/TableViewerUtils.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/TableViewerUtils.java index 7425c634f..460c749ba 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/TableViewerUtils.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/TableViewerUtils.java @@ -19,11 +19,16 @@ import org.eclipse.jface.layout.TableColumnLayout; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.ColumnViewerEditor; +import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy; import org.eclipse.jface.viewers.ColumnWeightData; import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter; import org.eclipse.jface.viewers.ICellEditorValidator; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.TableViewerEditor; +import org.eclipse.jface.viewers.TableViewerFocusCellManager; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; @@ -240,4 +245,19 @@ public class TableViewerUtils { return null; } } + + /** Allows to move between the columns of the table by pressing TAB. */ + public static void allowTabing(TableViewer table) { + TableViewerFocusCellManager focusCellManager = + new TableViewerFocusCellManager(table, new FocusCellOwnerDrawHighlighter(table)); + + ColumnViewerEditorActivationStrategy activationSupport = + new ColumnViewerEditorActivationStrategy(table); + + TableViewerEditor.create(table, focusCellManager, activationSupport, + ColumnViewerEditor.TABBING_HORIZONTAL | + ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | + ColumnViewerEditor.TABBING_VERTICAL | + ColumnViewerEditor.KEYBOARD_ACTIVATION); + } } diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/TreeViewerUtils.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/TreeViewerUtils.java new file mode 100644 index 000000000..d8ade5a6b --- /dev/null +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/TreeViewerUtils.java @@ -0,0 +1,49 @@ +/*-------------------------------------------------------------------------+ +| Copyright 2011 fortiss GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.base.ui.utils; + +import org.eclipse.jface.viewers.ColumnViewerEditor; +import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy; +import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.TreeViewerEditor; +import org.eclipse.jface.viewers.TreeViewerFocusCellManager; + +/** + * Utility methods for JFace {@link TreeViewer}s. + * + * @author ponce + */ +public class TreeViewerUtils { + /** + * Allows to move between the columns of the table by pressing TAB. + * + * @param tree + */ + public static void allowTabing(TreeViewer tree) { + TreeViewerFocusCellManager focusCellManager = + new TreeViewerFocusCellManager(tree, new FocusCellOwnerDrawHighlighter(tree)); + + ColumnViewerEditorActivationStrategy activationSupport = + new ColumnViewerEditorActivationStrategy(tree); + + TreeViewerEditor.create(tree, focusCellManager, activationSupport, + ColumnViewerEditor.TABBING_HORIZONTAL | + ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | + ColumnViewerEditor.TABBING_VERTICAL | + ColumnViewerEditor.KEYBOARD_ACTIVATION); + } +} -- GitLab