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 7425c634f14f0a4f70f033fa1e6877a45779772e..460c749bada0fd5120bb003349da9f648582758a 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 0000000000000000000000000000000000000000..d8ade5a6b5dc70c09a416eccf1a8d5a7dcfa4749 --- /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); + } +}