diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/.classpath b/widgets/grid/org.eclipse.nebula.jface.gridviewer/.classpath deleted file mode 100644 index 751c8f2e5..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/.project b/widgets/grid/org.eclipse.nebula.jface.gridviewer/.project deleted file mode 100644 index e90a542a0..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.nebula.jface.gridviewer - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/.settings/org.eclipse.jdt.core.prefs b/widgets/grid/org.eclipse.nebula.jface.gridviewer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 0c6328a65..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Fri Mar 30 11:39:28 EDT 2007 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.4 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.source=1.3 diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/META-INF/MANIFEST.MF b/widgets/grid/org.eclipse.nebula.jface.gridviewer/META-INF/MANIFEST.MF deleted file mode 100644 index 62fc26d26..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/META-INF/MANIFEST.MF +++ /dev/null @@ -1,10 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Nebula Grid Viewer -Bundle-SymbolicName: org.eclipse.nebula.jface.gridviewer -Bundle-Version: 1.0.0 -Bundle-Vendor: Eclipse.org -Require-Bundle: org.eclipse.nebula.widgets.grid, - org.eclipse.jface -Export-Package: org.eclipse.nebula.jface.gridviewer -Automatic-Module-Name: org.eclipse.nebula.jface.gridviewer diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/about.html b/widgets/grid/org.eclipse.nebula.jface.gridviewer/about.html deleted file mode 100644 index 5748defff..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/about.html +++ /dev/null @@ -1,42 +0,0 @@ - - - -About - - - -

About This Content

- -

June 6, 2018

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-2.0. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- -

Third Party Content

- -

The Content includes items that have been sourced from third parties -as set out below. If you did not receive this Content directly from -the Eclipse Foundation, the following is provided for informational -purposes only, and you should look to the Redistributor's license -for terms and conditions of use.

- -

FontAwesome 4.5.0

- -

This plugin includes images created from rasterized glyphs from -Font Awesome -4.5.0 at different resolutions. FontAwesome is available under -the SIL Open Font License.

- - - \ No newline at end of file diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/build.properties b/widgets/grid/org.eclipse.nebula.jface.gridviewer/build.properties deleted file mode 100644 index 17daa5b49..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - about.html diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/pom.xml b/widgets/grid/org.eclipse.nebula.jface.gridviewer/pom.xml deleted file mode 100644 index af0a3f843..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - 4.0.0 - - - org.eclipse.nebula - grid - 1.1.0-SNAPSHOT - - - org.eclipse.nebula.jface.gridviewer - eclipse-plugin - diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/CheckEditingSupport.java b/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/CheckEditingSupport.java deleted file mode 100644 index 3bc744c51..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/CheckEditingSupport.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * chris.gross@us.ibm.com - initial API and implementation - *******************************************************************************/ - -package org.eclipse.nebula.jface.gridviewer; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.EditingSupport; - -/** - * . - */ -public abstract class CheckEditingSupport extends EditingSupport -{ - /** - * Checkbox editing support. - * - * @param viewer column to add check box support for. - */ - public CheckEditingSupport(ColumnViewer viewer) - { - super(viewer); - } - - /** {@inheritDoc} */ - protected boolean canEdit(Object element) - { - return false; - } - - /** {@inheritDoc} */ - protected CellEditor getCellEditor(Object element) - { - return null; - } - - /** {@inheritDoc} */ - protected Object getValue(Object element) - { - return null; - } - - /** {@inheritDoc} */ - public abstract void setValue(Object element, Object value); -} diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridColumnLabelProvider.java b/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridColumnLabelProvider.java deleted file mode 100644 index 891a43c02..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridColumnLabelProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Tom Schindl and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Tom Schindl - initial API and implementation - *******************************************************************************/ - -package org.eclipse.nebula.jface.gridviewer; - -import org.eclipse.jface.viewers.ColumnLabelProvider; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.nebula.widgets.grid.GridItem; - -/** - * A label provider that provides hooks for extra functionality in the {@link Grid}. This is currently - * limited to supplying the row header text. - *

- * Only one from all {@link GridColumnLabelProvider} in a viewer should - * return a none null - *

- */ -public class GridColumnLabelProvider extends ColumnLabelProvider { - - /** - * Returns the row header text for this element. - * - * @param element - * the model element - * @return the text displayed in the row-header or null if - * this label provider would not like to modify the default text - */ - public String getRowHeaderText(Object element) { - return null; - } - - public void update(ViewerCell cell) { - super.update(cell); - String rowText = getRowHeaderText(cell.getElement()); - - if (rowText != null) { - ((GridItem) cell.getViewerRow().getItem()).setHeaderText(rowText); - } - } - -} diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridTableViewer.java b/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridTableViewer.java deleted file mode 100644 index c7c7e8c33..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridTableViewer.java +++ /dev/null @@ -1,335 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * rmcamara@us.ibm.com - initial API and implementation - * tom.schindl@bestsolution.at - various significant contributions - *******************************************************************************/ - -package org.eclipse.nebula.jface.gridviewer; - -import org.eclipse.jface.viewers.AbstractTableViewer; -import org.eclipse.jface.viewers.CellLabelProvider; -import org.eclipse.jface.viewers.ColumnViewerEditor; -import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.jface.viewers.ViewerRow; -import org.eclipse.nebula.widgets.grid.Grid; -import org.eclipse.nebula.widgets.grid.GridItem; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Widget; - -/** - * A concrete viewer based on an Grid control. - *

- * This class is not intended to be subclassed outside the viewer framework. It - * is designed to be instantiated with a pre-existing Grid control and - * configured with a domain-specific content provider, label provider, element - * filter (optional), and element sorter (optional). - *

- * Content providers for grid table viewers must not implement the - * {@code ITreeContentProvider} interface. Instead a {@link GridTreeViewer} - * should be used. - *

- */ -public class GridTableViewer extends AbstractTableViewer { - /** This viewer's grid control. */ - private Grid grid; - - private GridViewerRow cachedRow; - - private CellLabelProvider rowHeaderLabelProvider; - - /** - * If true, this grid viewer will ensure that the grid's rows / GridItems - * are always sized to their preferred height. - */ - private boolean autoPreferredHeight = false; - - /** - * Creates a grid viewer on a newly-created grid control under the given - * parent. The grid control is created using the SWT style bits - * MULTI, H_SCROLL, V_SCROLL, and BORDER. The - * viewer has no input, no content provider, a default label provider, no - * sorter, and no filters. - * - * @param parent - * the parent control - */ - public GridTableViewer(Composite parent) { - this(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - } - - /** - * Creates a grid viewer on a newly-created grid control under the given - * parent. The grid control is created using the given SWT style bits. The - * viewer has no input, no content provider, a default label provider, no - * sorter, and no filters. - * - * @param parent - * the parent control - * @param style - * the SWT style bits used to create the grid. - */ - public GridTableViewer(Composite parent, int style) { - this(new Grid(parent, style)); - } - - /** - * Creates a grid viewer on the given grid control. The viewer has no input, - * no content provider, a default label provider, no sorter, and no filters. - * - * @param grid - * the grid control - */ - public GridTableViewer(Grid grid) { - this.grid = grid; - hookControl(grid); - } - - /** - * Returns the underlying Grid Control. - * - * @return grid control. - */ - public Grid getGrid() { - return grid; - } - - /** {@inheritDoc} */ - protected ViewerRow internalCreateNewRowPart(int style, int rowIndex) { - GridItem item; - - if (rowIndex >= 0) { - item = new GridItem(grid, style, rowIndex); - } else { - item = new GridItem(grid, style); - } - - return getViewerRowFromItem(item); - } - - /** {@inheritDoc} */ - protected ColumnViewerEditor createViewerEditor() { - return new GridViewerEditor(this, - new ColumnViewerEditorActivationStrategy(this), - ColumnViewerEditor.DEFAULT); - } - - /** {@inheritDoc} */ - protected void doClear(int index) { - // TODO Fix when grid supports virtual - } - - /** {@inheritDoc} */ - protected void doClearAll() { - // TODO Fix when grid supports virtual - } - - /** {@inheritDoc} */ - protected void doSetItemCount(int count) { - // TODO Once grid supports virtual - } - - /** {@inheritDoc} */ - protected void doDeselectAll() { - grid.deselectAll(); - } - - /** {@inheritDoc} */ - protected Widget doGetColumn(int index) { - return grid.getColumn(index); - } - - /** {@inheritDoc} */ - protected int doGetColumnCount() { - return grid.getColumnCount(); - } - - /** {@inheritDoc} */ - protected Item doGetItem(int index) { - return grid.getItem(index); - } - - /** {@inheritDoc} */ - protected int doGetItemCount() { - return grid.getItemCount(); - } - - /** {@inheritDoc} */ - protected Item[] doGetItems() { - return grid.getItems(); - } - - /** {@inheritDoc} */ - protected Item[] doGetSelection() { - return grid.getSelection(); - } - - /** {@inheritDoc} */ - protected int[] doGetSelectionIndices() { - return grid.getSelectionIndices(); - } - - /** {@inheritDoc} */ - protected int doIndexOf(Item item) { - return grid.indexOf((GridItem) item); - } - - /** {@inheritDoc} */ - protected void doRemove(int[] indices) { - grid.remove(indices); - } - - /** {@inheritDoc} */ - protected void doRemove(int start, int end) { - grid.remove(start, end); - } - - /** {@inheritDoc} */ - protected void doRemoveAll() { - grid.removeAll(); - } - - /** {@inheritDoc} */ - protected void doSetSelection(Item[] items) { - GridItem[] items2 = new GridItem[items.length]; - for (int i = 0; i < items.length; i++) { - items2[i] = (GridItem) items[i]; - } - grid.setSelection(items2); - } - - /** {@inheritDoc} */ - protected void doSetSelection(int[] indices) { - grid.setSelection(indices); - } - - /** {@inheritDoc} */ - protected void doShowItem(Item item) { - grid.showItem((GridItem) item); - } - - /** {@inheritDoc} */ - protected void doShowSelection() { - grid.showSelection(); - } - - /** {@inheritDoc} */ - protected Item getItemAt(Point point) { - return grid.getItem(point); - } - - /** {@inheritDoc} */ - public Control getControl() { - return grid; - } - - /** {@inheritDoc} */ - protected ViewerRow getViewerRowFromItem(Widget item) { - if (cachedRow == null) { - cachedRow = new GridViewerRow((GridItem) item); - } else { - cachedRow.setItem((GridItem) item); - } - - return cachedRow; - } - - /** - * {@inheritDoc} - */ - protected void doResetItem(Item item) { - GridItem gridItem = (GridItem) item; - int columnCount = Math.max(1, grid.getColumnCount()); - for (int i = 0; i < columnCount; i++) { - gridItem.setText(i, ""); //$NON-NLS-1$ - gridItem.setImage(null); - } - } - - protected void doSelect(int[] indices) { - grid.select(indices); - } - - /** - * When set to true, this grid viewer will ensure that each of the grid's - * items is always automatically sized to its preferred height. The default - * is false. - *

- * Since this mechanism usually leads to a grid with rows of different - * heights and thus to a grid with decreased performance, it should only be - * applied if that is intended. To set the height of all items to a specific - * value, use {@link Grid#setItemHeight(int)} instead. - *

- * When a column with activated word wrapping is resized by dragging the - * column resizer, the items are only auto-resized properly if you use - * {@link GridViewerColumn} to create the columns. - *

- * When this method is called, existing rows are not resized to their - * preferred height. Therefore it is suggested that this method be called - * before rows are populated (i.e. before setInput). - */ - public void setAutoPreferredHeight(boolean autoPreferredHeight) { - this.autoPreferredHeight = autoPreferredHeight; - } - - /** - * @return true if this grid viewer sizes its rows to their preferred height - * @see #setAutoPreferredHeight(boolean) - */ - public boolean getAutoPreferredHeight() { - return autoPreferredHeight; - } - - /** {@inheritDoc} */ - protected void doUpdateItem(Widget widget, Object element, boolean fullMap) { - super.doUpdateItem(widget, element, fullMap); - updateRowHeader(widget); - if (autoPreferredHeight && !widget.isDisposed()) - ((GridItem) widget).pack(); - } - - private void updateRowHeader(Widget widget) { - if (rowHeaderLabelProvider != null) { - ViewerCell cell = getViewerRowFromItem(widget).getCell( - Integer.MAX_VALUE); - rowHeaderLabelProvider.update(cell); - } - } - - public void setRowHeaderLabelProvider( - CellLabelProvider rowHeaderLabelProvider) { - this.rowHeaderLabelProvider = rowHeaderLabelProvider; - } - - /** - * Refresh row headers only - * - * @param element - * the element to start or null if all rows should - * be refreshed - */ - public void refreshRowHeaders(Object element) { - boolean refresh = element == null; - - GridItem[] items = getGrid().getItems(); - for (int i = 0; i < items.length; i++) { - if (refresh || element.equals(items[i].getData())) { - refresh = true; - updateRowHeader(items[i]); - } - } - } -} \ No newline at end of file diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridTreeViewer.java b/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridTreeViewer.java deleted file mode 100644 index 2d9bd931e..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridTreeViewer.java +++ /dev/null @@ -1,320 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Michael Houston - initial API and implementation - * Tom Schindl - bug fix in: 191216 - *******************************************************************************/ -package org.eclipse.nebula.jface.gridviewer; - -import java.util.List; - -import org.eclipse.jface.viewers.AbstractTreeViewer; -import org.eclipse.jface.viewers.ColumnViewerEditor; -import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.ViewerRow; -import org.eclipse.nebula.widgets.grid.Grid; -import org.eclipse.nebula.widgets.grid.GridItem; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.TreeListener; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Widget; - -/** - * A concrete viewer based on an Grid control. - *

- * This class is not intended to be subclassed outside the viewer framework. It - * is designed to be instantiated with a pre-existing Grid control and - * configured with a domain-specific content provider, label provider, element - * filter (optional), and element sorter (optional). - *

- * Content providers for grid tree viewers must implement the - * {@link ITreeContentProvider} interface. - *

The current implementation does not support lazy content providers.

- */ -public class GridTreeViewer extends AbstractTreeViewer { - - /** This viewer's grid control. */ - private Grid grid; - - private GridViewerRow cachedRow; - - /** - * If true, this grid viewer will ensure that the grid's - * rows / GridItems are always sized to their preferred height. - */ - private boolean autoPreferredHeight = false; - - - /** - * Creates a grid tree viewer on a newly-created grid control under the given - * parent. The grid control is created using the SWT style bits - * MULTI, H_SCROLL, V_SCROLL, and BORDER. The - * viewer has no input, no content provider, a default label provider, no - * sorter, and no filters. - * - * @param parent - * the parent control - */ - public GridTreeViewer(Composite parent) { - this(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - } - - /** - * Creates a grid tree viewer on a newly-created grid control under the given - * parent. The grid control is created using the given SWT style bits. The - * viewer has no input, no content provider, a default label provider, no - * sorter, and no filters. - * - * @param parent - * the parent control - * @param style - * the SWT style bits used to create the grid. - */ - public GridTreeViewer(Composite parent, int style) { - this(new Grid(parent, style)); - } - - /** - * Creates a grid tree viewer on the given grid control. The viewer has no - * input, no content provider, a default label provider, no sorter, and no - * filters. - * - * @param grid - * the grid control - */ - public GridTreeViewer(Grid grid) { - this.grid = grid; - hookControl(grid); - } - - /** - * Returns the underlying {@link Grid} Control. - * - * @return grid control. - */ - public Grid getGrid() { - return grid; - } - - /** {@inheritDoc} */ - protected Item getItemAt(Point point) { - return grid.getItem(point); - } - - /** {@inheritDoc} */ - protected ColumnViewerEditor createViewerEditor() { - return new GridViewerEditor(this, - new ColumnViewerEditorActivationStrategy(this), - ColumnViewerEditor.DEFAULT); - } - - /** {@inheritDoc} */ - protected void addTreeListener(Control control, TreeListener listener) { - ((Grid) control).addTreeListener(listener); - } - - /** {@inheritDoc} */ - protected Item[] getChildren(Widget o) { - if (o instanceof GridItem) { - return ((GridItem) o).getItems(); - } - if (o instanceof Grid) { - return ((Grid) o).getRootItems(); - } - return null; - } - - /** {@inheritDoc} */ - protected boolean getExpanded(Item item) { - return ((GridItem) item).isExpanded(); - } - - /** {@inheritDoc} */ - protected int getItemCount(Control control) { - return ((Grid) control).getItemCount(); - } - - /** {@inheritDoc} */ - protected int getItemCount(Item item) { - return ((GridItem) item).getItemCount(); - } - - /** {@inheritDoc} */ - protected Item[] getItems(Item item) { - return ((GridItem) item).getItems(); - } - - /** {@inheritDoc} */ - protected Item getParentItem(Item item) { - return ((GridItem) item).getParentItem(); - } - - /** {@inheritDoc} */ - protected Item[] getSelection(Control control) { - return ((Grid) control).getSelection(); - } - - /** {@inheritDoc} */ - protected Item newItem(Widget parent, int style, int index) { - GridItem item; - - if (parent instanceof GridItem) { - item = (GridItem) createNewRowPart(getViewerRowFromItem(parent), - style, index).getItem(); - } else { - item = (GridItem) createNewRowPart(null, style, index).getItem(); - } - - return item; - } - - /** - * Create a new ViewerRow at rowIndex - * - * @param parent - * the parent row - * @param style - * the style bits to use for the new row - * @param rowIndex - * the index at which the new row should be created under the parent - * @return ViewerRow - * the new row - */ - private ViewerRow createNewRowPart(ViewerRow parent, int style, int rowIndex) { - if (parent == null) { - if (rowIndex >= 0) { - return getViewerRowFromItem(new GridItem(grid, style, rowIndex)); - } - return getViewerRowFromItem(new GridItem(grid, style)); - } - - if (rowIndex >= 0) { - return getViewerRowFromItem(new GridItem((GridItem) parent - .getItem(), SWT.NONE, rowIndex)); - } - - return getViewerRowFromItem(new GridItem((GridItem) parent.getItem(), - SWT.NONE)); - } - - /** {@inheritDoc} */ - protected void removeAll(Control control) { - ((Grid) control).removeAll(); - } - - /** {@inheritDoc} */ - protected void setExpanded(Item item, boolean expand) { - ((GridItem) item).setExpanded(expand); - } - - /** {@inheritDoc} */ - protected void setSelection(List items) { - Item[] current = getSelection(getGrid()); - - // Don't bother resetting the same selection - if (isSameSelection(items, current)) { - return; - } - - GridItem[] newItems = new GridItem[items.size()]; - items.toArray(newItems); - getGrid().setSelection(newItems); - } - - /** {@inheritDoc} */ - protected void showItem(Item item) { - getGrid().showItem((GridItem) item); - - } - - /** {@inheritDoc} */ - public Control getControl() { - return getGrid(); - } - - /** {@inheritDoc} */ - protected ViewerRow getViewerRowFromItem(Widget item) { - if (cachedRow == null) { - cachedRow = new GridViewerRow((GridItem) item); - } else { - cachedRow.setItem((GridItem) item); - } - - return cachedRow; - } - - /** {@inheritDoc} */ - protected Widget getColumnViewerOwner(int columnIndex) { - if (columnIndex < 0 - || (columnIndex > 0 && columnIndex >= getGrid() - .getColumnCount())) { - return null; - } - - if (getGrid().getColumnCount() == 0)// Hang it off the table if it - return getGrid(); - - return getGrid().getColumn(columnIndex); - } - - /** - * Returns the number of columns of this viewer. - * - * @return the number of columns - */ - protected int doGetColumnCount() { - return grid.getColumnCount(); - } - - /** - * When set to true, this grid viewer will ensure that each of - * the grid's items is always automatically sized to its preferred - * height. The default is false. - *

- * Since this mechanism usually leads to a grid with rows of - * different heights and thus to a grid with decreased performance, - * it should only be applied if that is intended. To set the - * height of all items to a specific value, use {@link Grid#setItemHeight(int)} - * instead. - *

- * When a column with activated word wrapping is resized - * by dragging the column resizer, the items are only auto-resized - * properly if you use {@link GridViewerColumn} to create the - * columns. - *

- * When this method is called, existing rows are not resized to their - * preferred height. Therefore it is suggested that this method be called - * before rows are populated (i.e. before setInput). - */ - public void setAutoPreferredHeight(boolean autoPreferredHeight) { - this.autoPreferredHeight = autoPreferredHeight; - } - - /** - * @return true if this grid viewer sizes its rows to their - * preferred height - * @see #setAutoPreferredHeight(boolean) - */ - public boolean getAutoPreferredHeight() { - return autoPreferredHeight; - } - - /** {@inheritDoc} */ - protected void doUpdateItem(final Item item, Object element) { - super.doUpdateItem(item, element); - if(autoPreferredHeight && !item.isDisposed()) - ((GridItem)item).pack(); - } -} diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridViewerColumn.java b/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridViewerColumn.java deleted file mode 100644 index ac34e4761..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridViewerColumn.java +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * rmcamara@us.ibm.com - initial API and implementation - * Tom Schindl - various significant contributions - * Mark-Oliver Reiser - support for differing row heights ; fix in bug 191216 - *******************************************************************************/ - -package org.eclipse.nebula.jface.gridviewer; - -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.jface.viewers.ViewerColumn; -import org.eclipse.nebula.widgets.grid.Grid; -import org.eclipse.nebula.widgets.grid.GridColumn; -import org.eclipse.nebula.widgets.grid.GridItem; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; - -/** - * The concrete implementation of the ColumnViewer for the grid. - */ -public final class GridViewerColumn extends ViewerColumn -{ - /** This is either a GridTableViewer or a GridTreeViewer. */ - private ColumnViewer viewer; - - /** The concrete grid column that is being represented by the {@code ViewerColumn}.*/ - private GridColumn column; - - /** Editor support for handling check events. */ - private CheckEditingSupport checkEditingSupport; - - protected Listener columnResizeListener = null; - - - /** - * Create a new column in the {@link GridTableViewer} - * - * @param viewer - * the viewer the column belongs to - * @param style - * the style used to create the column for style bits see - * {@link GridColumn} - * @see GridColumn#GridColumn(Grid, int) - */ - public GridViewerColumn(GridTableViewer viewer, int style) - { - this(viewer, style, -1); - } - - /** - * Create a new column in the {@link GridTreeViewer} - * - * @param viewer - * the viewer the column belongs to - * @param style - * the style used to create the column for style bits see - * {@link GridColumn} - * @see GridColumn#GridColumn(Grid, int) - */ - public GridViewerColumn(GridTreeViewer viewer, int style) { - this(viewer, style, -1); - } - - /** - * Create a new column in the {@link GridTableViewer} - * - * @param viewer - * the viewer the column belongs to - * @param style - * the style used to create the column for style bits see - * {@link GridColumn} - * @param index - * the index of the newly created column - * @see GridColumn#GridColumn(Grid, int, int) - */ - public GridViewerColumn(GridTableViewer viewer, int style, int index) - { - this(viewer, createColumn((Grid) viewer.getControl(), style, index)); - } - - /** - * Create a new column in the {@link GridTreeViewer} - * - * @param viewer - * the viewer the column belongs to - * @param style - * the style used to create the column for style bits see - * {@link GridColumn} - * @param index - * the index of the newly created column - * @see GridColumn#GridColumn(Grid, int, int) - */ - public GridViewerColumn(GridTreeViewer viewer, int style, int index) - { - this(viewer, createColumn((Grid) viewer.getControl(), style, index)); - } - - /** - * - * @param viewer - * the viewer the column belongs to - * @param column - * the column the viewer is attached to - */ - public GridViewerColumn(GridTreeViewer viewer, GridColumn column) - { - this((ColumnViewer)viewer,column); - } - - /** - * - * @param viewer - * the viewer the column belongs to - * @param column - * the column the viewer is attached to - */ - public GridViewerColumn(GridTableViewer viewer, GridColumn column) - { - this((ColumnViewer)viewer,column); - } - - GridViewerColumn(ColumnViewer viewer, GridColumn column) { - super(viewer, column); - this.viewer = viewer; - this.column = column; - hookColumnResizeListener(); - } - - private static GridColumn createColumn(Grid table, int style, int index) - { - if (index >= 0) - { - return new GridColumn(table, style, index); - } - - return new GridColumn(table, style); - } - - /** - * Returns the underlying column. - * - * @return the underlying Nebula column - */ - public GridColumn getColumn() - { - return column; - } - - /** {@inheritDoc} */ - public void setEditingSupport(EditingSupport editingSupport) - { - if (editingSupport instanceof CheckEditingSupport) - { - if (checkEditingSupport == null) - { - final int colIndex = getColumn().getParent().indexOf(getColumn()); - - getColumn().getParent().addListener(SWT.Selection, new Listener() - { - public void handleEvent(Event event) - { - if (event.detail == SWT.CHECK && event.index == colIndex) - { - GridItem item = (GridItem)event.item; - Object element = item.getData(); - checkEditingSupport.setValue(element, new Boolean(item.getChecked(colIndex))); - } - } - }); - } - checkEditingSupport = (CheckEditingSupport)editingSupport; - } - else - { - super.setEditingSupport(editingSupport); - } - } - - - protected void hookColumnResizeListener() { - if (columnResizeListener == null) - { - columnResizeListener = new Listener() { - public void handleEvent(Event event) - { - boolean autoPreferredSize=false; - if(viewer instanceof GridTableViewer) - autoPreferredSize = ((GridTableViewer)viewer).getAutoPreferredHeight(); - if(viewer instanceof GridTreeViewer) - autoPreferredSize = ((GridTreeViewer)viewer).getAutoPreferredHeight(); - - if(autoPreferredSize && column.getWordWrap()) - { - Grid grid = column.getParent(); - for(int cnt=0;cnt - various significant contributions - * bug fix in: 191216 - *******************************************************************************/ - -package org.eclipse.nebula.jface.gridviewer; - -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.ColumnViewerEditor; -import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent; -import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.jface.viewers.ViewerRow; -import org.eclipse.jface.viewers.CellEditor.LayoutData; -import org.eclipse.nebula.widgets.grid.Grid; -import org.eclipse.nebula.widgets.grid.GridColumn; -import org.eclipse.nebula.widgets.grid.GridEditor; -import org.eclipse.nebula.widgets.grid.GridItem; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Item; - -public class GridViewerEditor extends ColumnViewerEditor { - /** Editor support for tables. */ - private GridEditor gridEditor; - - GridViewerEditor(ColumnViewer viewer, - ColumnViewerEditorActivationStrategy editorActivationStrategy, - int feature) { - super(viewer, editorActivationStrategy, feature); - this.gridEditor = new GridEditor((Grid) viewer.getControl()); - } - - protected StructuredSelection createSelection(Object element) - { - return new StructuredSelection(element); - } - - protected void setEditor(Control w, Item item, int fColumnNumber) - { - gridEditor.setEditor(w, (GridItem) item, fColumnNumber); - } - - protected void setLayoutData(LayoutData layoutData) - { - gridEditor.grabHorizontal = layoutData.grabHorizontal; - gridEditor.horizontalAlignment = layoutData.horizontalAlignment; - gridEditor.minimumWidth = layoutData.minimumWidth; - } - - public ViewerCell getFocusCell() { - Grid grid = (Grid)getViewer().getControl(); - - if( grid.getCellSelectionEnabled() ) { - Point p = grid.getFocusCell(); - - if( p.x >= 0 && p.y >= 0 ) { - GridItem item = grid.getItem(p.y); - if( item != null ) { - ViewerRow row = getViewerRowFromItem(item); - return row.getCell(p.x); - } - } - } - - return null; - } - - private ViewerRow getViewerRowFromItem(GridItem item) { - if( getViewer() instanceof GridTableViewer ) { - return ((GridTableViewer)getViewer()).getViewerRowFromItem(item); - } else { - return ((GridTreeViewer)getViewer()).getViewerRowFromItem(item); - } - } - - protected void updateFocusCell(ViewerCell focusCell, ColumnViewerEditorActivationEvent event) { - if (event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC - || event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL) { - Grid grid = ((Grid)getViewer().getControl()); - grid.deselectAllCells(); - grid.setFocusColumn(grid.getColumn(focusCell.getColumnIndex())); - grid.setFocusItem((GridItem) focusCell.getItem()); - grid.setCellSelection(new Point(focusCell.getColumnIndex(),grid.indexOf((GridItem) focusCell.getItem()))); - } - } - - public static void create(GridTableViewer viewer, - ColumnViewerEditorActivationStrategy editorActivationStrategy, - int feature) { - viewer.setColumnViewerEditor(new GridViewerEditor(viewer,editorActivationStrategy,feature)); - } - - public static void create(GridTreeViewer viewer, - ColumnViewerEditorActivationStrategy editorActivationStrategy, - int feature) { - viewer.setColumnViewerEditor(new GridViewerEditor(viewer,editorActivationStrategy,feature)); - } -} diff --git a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridViewerRow.java b/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridViewerRow.java deleted file mode 100644 index a54f308b8..000000000 --- a/widgets/grid/org.eclipse.nebula.jface.gridviewer/src/org/eclipse/nebula/jface/gridviewer/GridViewerRow.java +++ /dev/null @@ -1,244 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * rmcamara@us.ibm.com - initial API and implementation - * Tom Schindl - various significant contributions - * bug fix in: 191216 - *******************************************************************************/ - -package org.eclipse.nebula.jface.gridviewer; - -import org.eclipse.jface.viewers.TreePath; -import org.eclipse.jface.viewers.ViewerRow; -import org.eclipse.nebula.widgets.grid.GridItem; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Widget; - -/** - * GridViewerRow is the concrete implementation of the part that represents items in a - * Grid. - */ -public class GridViewerRow extends ViewerRow -{ - private GridItem item; - - /** - * Create a new instance of the receiver. - * - * @param item GridItem source. - */ - GridViewerRow(GridItem item) - { - this.item = item; - } - - /** {@inheritDoc} */ - public Rectangle getBounds(int columnIndex) - { - if( columnIndex == Integer.MAX_VALUE ) { - //TODO Provide implementation for GridItem - return null; - } else { - if( ! item.getParent().getColumn(columnIndex).isVisible() ) { - return new Rectangle(0,0,0,0); - } else { - return item.getBounds(columnIndex); - } - - } - } - - /** {@inheritDoc} */ - public Rectangle getBounds() - { - // TODO This is not correct. Update once item returns the correct information. - return item.getBounds(0); - } - - - /** {@inheritDoc} */ - public int getColumnCount() - { - return item.getParent().getColumnCount(); - } - - /** {@inheritDoc} */ - public Color getBackground(int columnIndex) - { - if( columnIndex == Integer.MAX_VALUE ) { - //TODO Provide implementation for GridItem - return null; - } else { - return item.getBackground(columnIndex); - } - } - - /** {@inheritDoc} */ - public Font getFont(int columnIndex) - { - if( columnIndex == Integer.MAX_VALUE ) { - //TODO Provide implementation for GridItem - return null; - } else { - return item.getFont(columnIndex); - } - } - - /** {@inheritDoc} */ - public Color getForeground(int columnIndex) - { - if( columnIndex == Integer.MAX_VALUE ) { - //TODO Provide implementation for GridItem - return null; - } else { - return item.getForeground(columnIndex); - } - } - - /** {@inheritDoc} */ - public Image getImage(int columnIndex) - { - if( columnIndex == Integer.MAX_VALUE ) { - //TODO Provide implementation for GridItem - return null; - } else { - return item.getImage(columnIndex); - } - - } - - /** {@inheritDoc} */ - public String getText(int columnIndex) - { - if( columnIndex == Integer.MAX_VALUE ) { - return item.getHeaderText(); - } else { - return item.getText(columnIndex); - } - - } - - /** {@inheritDoc} */ - public void setBackground(int columnIndex, Color color) - { - if( columnIndex == Integer.MAX_VALUE ) { - //TODO Provide implementation for GridItem - } else { - item.setBackground(columnIndex, color); - } - } - - /** {@inheritDoc} */ - public void setFont(int columnIndex, Font font) - { - if( columnIndex == Integer.MAX_VALUE ) { - //TODO Provide implementation for GridItem - } else { - item.setFont(columnIndex, font); - } - } - - /** {@inheritDoc} */ - public void setForeground(int columnIndex, Color color) - { - if( columnIndex == Integer.MAX_VALUE ) { - //TODO Provide implementation for GridItem - } else { - item.setForeground(columnIndex, color); - } - } - - /** {@inheritDoc} */ - public void setImage(int columnIndex, Image image) - { - if( columnIndex == Integer.MAX_VALUE ) { - //TODO Provide implementation for GridItem - } else { - item.setImage(columnIndex, image); - } - - } - - /** {@inheritDoc} */ - public void setText(int columnIndex, String text) - { - if( columnIndex == Integer.MAX_VALUE ) { - item.setHeaderText(text); - } else { - item.setText(columnIndex, text == null ? "" : text); //$NON-NLS-1$ - } - } - - /** {@inheritDoc} */ - public Control getControl() - { - return item.getParent(); - } - - public ViewerRow getNeighbor(int direction, boolean sameLevel) { - if( direction == ViewerRow.ABOVE ) { - return getRowAbove(); - } else if( direction == ViewerRow.BELOW ) { - return getRowBelow(); - } else { - throw new IllegalArgumentException("Illegal value of direction argument."); //$NON-NLS-1$ - } - } - - - private ViewerRow getRowAbove() { - int index = item.getParent().indexOf(item) - 1; - - if( index >= 0 ) { - return new GridViewerRow(item.getParent().getItem(index)); - } - - return null; - } - - private ViewerRow getRowBelow() { - int index = item.getParent().indexOf(item) + 1; - - if( index < item.getParent().getItemCount() ) { - GridItem tmp = item.getParent().getItem(index); - if( tmp != null ) { - return new GridViewerRow(tmp); - } - } - - return null; - } - - public TreePath getTreePath() { - return new TreePath(new Object[] {item.getData()}); - } - - public Object clone() { - return new GridViewerRow(item); - } - - public Object getElement() { - return item.getData(); - } - - void setItem(GridItem item) { - this.item = item; - } - - public Widget getItem() - { - return item; - } -}