file_name
stringlengths
6
86
file_path
stringlengths
45
249
content
stringlengths
47
6.26M
file_size
int64
47
6.26M
language
stringclasses
1 value
extension
stringclasses
1 value
repo_name
stringclasses
767 values
repo_stars
int64
8
14.4k
repo_forks
int64
0
1.17k
repo_open_issues
int64
0
788
repo_created_at
stringclasses
767 values
repo_pushed_at
stringclasses
767 values
ColumnHideCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/hideshow/command/ColumnHideCommandHandler.java
package net.sourceforge.nattable.hideshow.command; import static java.util.Arrays.asList; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.hideshow.ColumnHideShowLayer; public class ColumnHideCommandHandler extends AbstractLayerCommandHandler<ColumnHideCommand> { private final ColumnHideShowLayer columnHideShowLayer; public ColumnHideCommandHandler(ColumnHideShowLayer columnHideShowLayer) { this.columnHideShowLayer = columnHideShowLayer; } public Class<ColumnHideCommand> getCommandClass() { return ColumnHideCommand.class; } @Override protected boolean doCommand(ColumnHideCommand command) { columnHideShowLayer.hideColumnPositions(asList(command.getColumnPosition())); return true; } }
767
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MultiColumnShowCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/hideshow/command/MultiColumnShowCommandHandler.java
package net.sourceforge.nattable.hideshow.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.hideshow.ColumnHideShowLayer; public class MultiColumnShowCommandHandler extends AbstractLayerCommandHandler<MultiColumnShowCommand> { private final ColumnHideShowLayer columnHideShowLayer; public MultiColumnShowCommandHandler(ColumnHideShowLayer columnHideShowLayer) { this.columnHideShowLayer = columnHideShowLayer; } public Class<MultiColumnShowCommand> getCommandClass() { return MultiColumnShowCommand.class; } @Override protected boolean doCommand(MultiColumnShowCommand command) { int[] columnIndexes = command.getColumnIndexes(); columnHideShowLayer.showColumnIndexes(columnIndexes); return true; } }
787
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ShowAllColumnsCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/hideshow/command/ShowAllColumnsCommandHandler.java
package net.sourceforge.nattable.hideshow.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.hideshow.ColumnHideShowLayer; public class ShowAllColumnsCommandHandler extends AbstractLayerCommandHandler<ShowAllColumnsCommand> { private final ColumnHideShowLayer columnHideShowLayer; public ShowAllColumnsCommandHandler(ColumnHideShowLayer columnHideShowLayer) { this.columnHideShowLayer = columnHideShowLayer; } public Class<ShowAllColumnsCommand> getCommandClass() { return ShowAllColumnsCommand.class; } @Override protected boolean doCommand(ShowAllColumnsCommand command) { columnHideShowLayer.showAllColumns(); return true; } }
713
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ShowAllColumnsCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/hideshow/command/ShowAllColumnsCommand.java
package net.sourceforge.nattable.hideshow.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; public class ShowAllColumnsCommand extends AbstractContextFreeCommand { }
201
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MultiColumnHideCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/hideshow/command/MultiColumnHideCommand.java
package net.sourceforge.nattable.hideshow.command; import net.sourceforge.nattable.command.AbstractMultiColumnCommand; import net.sourceforge.nattable.layer.ILayer; public class MultiColumnHideCommand extends AbstractMultiColumnCommand { public MultiColumnHideCommand(ILayer layer, int columnPosition) { this(layer, new int[] { columnPosition }); } public MultiColumnHideCommand(ILayer layer, int[] columnPositions) { super(layer, columnPositions); } protected MultiColumnHideCommand(MultiColumnHideCommand command) { super(command); } public MultiColumnHideCommand cloneCommand() { return new MultiColumnHideCommand(this); } }
676
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ShowColumnPositionsEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/hideshow/event/ShowColumnPositionsEvent.java
package net.sourceforge.nattable.hideshow.event; import java.util.ArrayList; import java.util.Collection; import net.sourceforge.nattable.coordinate.PositionUtil; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.layer.event.ColumnStructuralChangeEvent; import net.sourceforge.nattable.layer.event.StructuralDiff; import net.sourceforge.nattable.layer.event.StructuralDiff.DiffTypeEnum; public class ShowColumnPositionsEvent extends ColumnStructuralChangeEvent { public ShowColumnPositionsEvent(IUniqueIndexLayer layer, Collection<Integer> columnPositions) { super(layer, PositionUtil.getRanges(columnPositions)); } // Copy constructor public ShowColumnPositionsEvent(ShowColumnPositionsEvent event) { super(event); } public Collection<StructuralDiff> getColumnDiffs() { Collection<StructuralDiff> columnDiffs = new ArrayList<StructuralDiff>(); int offset = 0; for (Range range : getColumnPositionRanges()) { columnDiffs.add(new StructuralDiff(DiffTypeEnum.ADD, new Range(range.start - offset, range.start - offset), range)); offset += range.size(); } return columnDiffs; } public ShowColumnPositionsEvent cloneEvent() { return new ShowColumnPositionsEvent(this); } @Override public boolean convertToLocal(ILayer localLayer) { super.convertToLocal(localLayer); return true; } }
1,514
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
HideColumnPositionsEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/hideshow/event/HideColumnPositionsEvent.java
package net.sourceforge.nattable.hideshow.event; import java.util.ArrayList; import java.util.Collection; import net.sourceforge.nattable.coordinate.PositionUtil; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.event.ColumnStructuralChangeEvent; import net.sourceforge.nattable.layer.event.StructuralDiff; import net.sourceforge.nattable.layer.event.StructuralDiff.DiffTypeEnum; public class HideColumnPositionsEvent extends ColumnStructuralChangeEvent { public HideColumnPositionsEvent(ILayer layer, Collection<Integer> columnPositions) { super(layer, PositionUtil.getRanges(columnPositions)); } // Copy constructor protected HideColumnPositionsEvent(HideColumnPositionsEvent event) { super(event); } public HideColumnPositionsEvent cloneEvent() { return new HideColumnPositionsEvent(this); } public Collection<StructuralDiff> getColumnDiffs() { Collection<StructuralDiff> columnDiffs = new ArrayList<StructuralDiff>(); for (Range range : getColumnPositionRanges()) { StructuralDiff diff = new StructuralDiff(DiffTypeEnum.DELETE, range, new Range(range.start, range.start)); columnDiffs.add(diff); } return columnDiffs; } @Override public boolean convertToLocal(ILayer localLayer) { super.convertToLocal(localLayer); return true; } }
1,411
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MaxCellBoundsHelper.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/MaxCellBoundsHelper.java
package net.sourceforge.nattable.resize; import net.sourceforge.nattable.config.CellConfigAttributes; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.config.IConfiguration; import net.sourceforge.nattable.grid.command.AutoResizeColumnCommandHandler; import net.sourceforge.nattable.grid.command.AutoResizeRowCommandHandler; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.cell.LayerCell; import net.sourceforge.nattable.painter.cell.ICellPainter; import org.eclipse.swt.graphics.GC; /** * Does the calculations needed for auto resizing feature * Helper class for {@link AutoResizeColumnCommandHandler} and {@link AutoResizeRowCommandHandler} */ public class MaxCellBoundsHelper { /** * @return Preferred widths for columns. Preferred width is the minimum width * required to horizontally fit all the contents of the column (including header) */ public static int[] getPreferedColumnWidths(IConfigRegistry configRegistry, GC gc, ILayer layer, int[]columnPositions) { int[] columnWidths = new int[columnPositions.length]; for (int i = 0; i < columnPositions.length; i++) { columnWidths[i] = getPreferredColumnWidth(layer, columnPositions[i], configRegistry, gc); } return columnWidths; } /** * Calculates the minimum width (in pixels) required to display the complete * contents of the cells in a column. Takes into account the font settings * and display type conversion. */ public static int getPreferredColumnWidth(ILayer layer, int columnPosition, IConfigRegistry configRegistry, GC gc) { ICellPainter painter; int maxWidth = 0; LayerCell cell; for (int rowPosition = 0; rowPosition < layer.getRowCount(); rowPosition++) { cell = layer.getCellByPosition(columnPosition, rowPosition); if (cell != null) { painter = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_PAINTER, cell.getDisplayMode(), cell.getConfigLabels().getLabels()); if (painter != null) { int preferedWidth = painter.getPreferredWidth(cell, gc, configRegistry); maxWidth = (preferedWidth > maxWidth) ? preferedWidth : maxWidth; } } } return maxWidth; } /** * @see MaxCellBoundsHelper#getPreferedColumnWidths(IConfiguration, GC, ILayer, int[]) */ public static int[] getPreferedRowHeights(IConfigRegistry configRegistry, GC gc, ILayer layer, int[]rows) { int[] rowHeights = new int[rows.length]; for (int i = 0; i < rows.length; i++) { rowHeights[i] = getPreferredRowHeight(layer, rows[i], configRegistry, gc); } return rowHeights; } public static int getPreferredRowHeight(ILayer layer, int rowPosition, IConfigRegistry configRegistry, GC gc) { int maxHeight = 0; ICellPainter painter; LayerCell cell; for (int columnPosition = 0; columnPosition < layer.getColumnCount(); columnPosition++) { cell = layer.getCellByPosition(columnPosition, rowPosition); if (cell != null) { painter = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_PAINTER, cell.getDisplayMode(), cell.getConfigLabels().getLabels()); if (painter != null) { int preferedHeight = painter.getPreferredHeight(cell, gc, configRegistry); maxHeight = (preferedHeight > maxHeight) ? preferedHeight : maxHeight; } } } return maxHeight; } /** * Traverse the two arrays and return the greater element in each index position. */ public static int[] greater(int[] array1, int[] array2) { int resultSize = (array1.length < array2.length) ? array1.length : array2.length; int[] result = new int[resultSize]; for(int i=0; i<resultSize; i++){ result[i] = (array1[i] > array2[i]) ? array1[i] : array2[i]; } return result; } }
3,845
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AutoResizeColumnAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/action/AutoResizeColumnAction.java
package net.sourceforge.nattable.resize.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand; import net.sourceforge.nattable.ui.action.IMouseAction; import net.sourceforge.nattable.ui.util.CellEdgeDetectUtil; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; public class AutoResizeColumnAction implements IMouseAction { private GC gc; public void run(NatTable natTable, MouseEvent event) { if (gc == null) { gc = new GC(natTable); natTable.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { gc.dispose(); } }); } Point clickPoint = new Point(event.x, event.y); int column = CellEdgeDetectUtil.getColumnPositionToResize(natTable, clickPoint); InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(natTable, column, natTable.getConfigRegistry(), gc); natTable.doCommand(command); } }
1,186
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowResizeCursorAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/action/RowResizeCursorAction.java
package net.sourceforge.nattable.resize.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.ui.action.IMouseAction; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.widgets.Display; public class RowResizeCursorAction implements IMouseAction { private Cursor rowResizeCursor; public void run(NatTable natTable, MouseEvent event) { if (rowResizeCursor == null) { rowResizeCursor = new Cursor(Display.getDefault(), SWT.CURSOR_SIZENS); natTable.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { rowResizeCursor.dispose(); } }); } natTable.setCursor(rowResizeCursor); } }
902
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AutoResizeRowAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/action/AutoResizeRowAction.java
package net.sourceforge.nattable.resize.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.resize.command.InitializeAutoResizeRowsCommand; import net.sourceforge.nattable.ui.action.IMouseAction; import net.sourceforge.nattable.ui.util.CellEdgeDetectUtil; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; public class AutoResizeRowAction implements IMouseAction { private GC gc; public void run(NatTable natTable, MouseEvent event) { if (gc == null) { gc = new GC(natTable); natTable.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { gc.dispose(); } }); } Point clickPoint = new Point(event.x, event.y); int row = CellEdgeDetectUtil.getRowPositionToResize(natTable, clickPoint); InitializeAutoResizeRowsCommand command = new InitializeAutoResizeRowsCommand(natTable, row, natTable.getConfigRegistry(), gc); natTable.doCommand(command); } }
1,166
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnResizeCursorAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/action/ColumnResizeCursorAction.java
package net.sourceforge.nattable.resize.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.ui.action.IMouseAction; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.widgets.Display; public class ColumnResizeCursorAction implements IMouseAction { private Cursor columnResizeCursor; public void run(NatTable natTable, MouseEvent event) { if (columnResizeCursor == null) { columnResizeCursor = new Cursor(Display.getDefault(), SWT.CURSOR_SIZEWE); natTable.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { columnResizeCursor.dispose(); } }); } natTable.setCursor(columnResizeCursor); } }
916
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultRowResizeBindings.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/config/DefaultRowResizeBindings.java
package net.sourceforge.nattable.resize.config; import net.sourceforge.nattable.config.AbstractUiBindingConfiguration; import net.sourceforge.nattable.resize.action.AutoResizeRowAction; import net.sourceforge.nattable.resize.action.RowResizeCursorAction; import net.sourceforge.nattable.resize.event.RowResizeEventMatcher; import net.sourceforge.nattable.resize.mode.RowResizeDragMode; import net.sourceforge.nattable.ui.action.ClearCursorAction; import net.sourceforge.nattable.ui.action.NoOpMouseAction; import net.sourceforge.nattable.ui.binding.UiBindingRegistry; import net.sourceforge.nattable.ui.matcher.MouseEventMatcher; import org.eclipse.swt.SWT; public class DefaultRowResizeBindings extends AbstractUiBindingConfiguration { public void configureUiBindings(UiBindingRegistry uiBindingRegistry) { // Mouse move - Show resize cursor uiBindingRegistry.registerFirstMouseMoveBinding(new RowResizeEventMatcher(SWT.NONE, 0), new RowResizeCursorAction()); uiBindingRegistry.registerMouseMoveBinding(new MouseEventMatcher(), new ClearCursorAction()); // Row resize uiBindingRegistry.registerFirstMouseDragMode(new RowResizeEventMatcher(SWT.NONE, 1), new RowResizeDragMode()); uiBindingRegistry.registerDoubleClickBinding(new RowResizeEventMatcher(SWT.NONE, 1), new AutoResizeRowAction()); uiBindingRegistry.registerSingleClickBinding(new RowResizeEventMatcher(SWT.NONE, 1), new NoOpMouseAction()); } }
1,461
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultColumnResizeBindings.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/config/DefaultColumnResizeBindings.java
package net.sourceforge.nattable.resize.config; import net.sourceforge.nattable.config.AbstractUiBindingConfiguration; import net.sourceforge.nattable.resize.action.AutoResizeColumnAction; import net.sourceforge.nattable.resize.action.ColumnResizeCursorAction; import net.sourceforge.nattable.resize.event.ColumnResizeEventMatcher; import net.sourceforge.nattable.resize.mode.ColumnResizeDragMode; import net.sourceforge.nattable.ui.action.ClearCursorAction; import net.sourceforge.nattable.ui.action.NoOpMouseAction; import net.sourceforge.nattable.ui.binding.UiBindingRegistry; import net.sourceforge.nattable.ui.matcher.MouseEventMatcher; import org.eclipse.swt.SWT; public class DefaultColumnResizeBindings extends AbstractUiBindingConfiguration { public void configureUiBindings(UiBindingRegistry uiBindingRegistry) { // Mouse move - Show resize cursor uiBindingRegistry.registerFirstMouseMoveBinding(new ColumnResizeEventMatcher(SWT.NONE, 0), new ColumnResizeCursorAction()); uiBindingRegistry.registerMouseMoveBinding(new MouseEventMatcher(), new ClearCursorAction()); // Column resize uiBindingRegistry.registerFirstMouseDragMode(new ColumnResizeEventMatcher(SWT.NONE, 1), new ColumnResizeDragMode()); uiBindingRegistry.registerDoubleClickBinding(new ColumnResizeEventMatcher(SWT.NONE, 1), new AutoResizeColumnAction()); uiBindingRegistry.registerSingleClickBinding(new ColumnResizeEventMatcher(SWT.NONE, 1), new NoOpMouseAction()); } }
1,502
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MultiColumnResizeCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/MultiColumnResizeCommandHandler.java
package net.sourceforge.nattable.resize.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.layer.DataLayer; public class MultiColumnResizeCommandHandler extends AbstractLayerCommandHandler<MultiColumnResizeCommand> { private final DataLayer dataLayer; public MultiColumnResizeCommandHandler(DataLayer dataLayer) { this.dataLayer = dataLayer; } public Class<MultiColumnResizeCommand> getCommandClass() { return MultiColumnResizeCommand.class; } @Override protected boolean doCommand(MultiColumnResizeCommand command) { for (int columnPosition : command.getColumnPositions()) { dataLayer.setColumnWidthByPosition(columnPosition, command.getColumnWidth(columnPosition)); } return true; } }
775
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnResizeCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/ColumnResizeCommandHandler.java
package net.sourceforge.nattable.resize.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.layer.DataLayer; public class ColumnResizeCommandHandler extends AbstractLayerCommandHandler<ColumnResizeCommand> { private final DataLayer dataLayer; public ColumnResizeCommandHandler(DataLayer dataLayer) { this.dataLayer = dataLayer; } public Class<ColumnResizeCommand> getCommandClass() { return ColumnResizeCommand.class; } @Override protected boolean doCommand(ColumnResizeCommand command) { final int newColumnWidth = command.getNewColumnWidth(); dataLayer.setColumnWidthByPosition(command.getColumnPosition(), newColumnWidth); return true; } }
727
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnResizeCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/ColumnResizeCommand.java
package net.sourceforge.nattable.resize.command; import net.sourceforge.nattable.command.AbstractColumnCommand; import net.sourceforge.nattable.layer.ILayer; /** * Event indicating that a column has been resized. */ public class ColumnResizeCommand extends AbstractColumnCommand { private int newColumnWidth; public ColumnResizeCommand(ILayer layer, int columnPosition, int newWidth) { super (layer, columnPosition); this.newColumnWidth = newWidth; } protected ColumnResizeCommand(ColumnResizeCommand command) { super(command); this.newColumnWidth = command.newColumnWidth; } public int getNewColumnWidth() { return newColumnWidth; } public ColumnResizeCommand cloneCommand() { return new ColumnResizeCommand(this); } }
845
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
InitializeAutoResizeRowsCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/InitializeAutoResizeRowsCommand.java
package net.sourceforge.nattable.resize.command; import net.sourceforge.nattable.command.AbstractRowCommand; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.graphics.GC; /** * @see InitializeAutoResizeColumnsCommand */ public class InitializeAutoResizeRowsCommand extends AbstractRowCommand { private final IConfigRegistry configRegistry; private final GC gc; private final ILayer sourceLayer; private int[] selectedRowPositions = new int[0]; public InitializeAutoResizeRowsCommand(ILayer layer, int rowPosition, IConfigRegistry configRegistry, GC gc) { super(layer, rowPosition); this.configRegistry = configRegistry; this.gc = gc; this.sourceLayer = layer; } protected InitializeAutoResizeRowsCommand(InitializeAutoResizeRowsCommand command) { super(command); this.configRegistry = command.configRegistry; this.gc = command.gc; this.sourceLayer = command.sourceLayer; } public ILayerCommand cloneCommand() { return new InitializeAutoResizeRowsCommand(this); } // Accessors public GC getGC() { return gc; } public IConfigRegistry getConfigRegistry() { return configRegistry; } public ILayer getSourceLayer() { return sourceLayer; } public void setSelectedRowPositions(int[] selectedRowPositions) { this.selectedRowPositions = selectedRowPositions; } public int[] getRowPositions() { return selectedRowPositions; } }
1,572
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MultiRowResizeCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/MultiRowResizeCommand.java
package net.sourceforge.nattable.resize.command; import java.util.HashMap; import java.util.Map; import net.sourceforge.nattable.command.AbstractMultiRowCommand; import net.sourceforge.nattable.command.LayerCommandUtil; import net.sourceforge.nattable.coordinate.RowPositionCoordinate; import net.sourceforge.nattable.layer.ILayer; public class MultiRowResizeCommand extends AbstractMultiRowCommand { private int commonRowHeight = -1; protected Map<RowPositionCoordinate, Integer> rowPositionToHeight = new HashMap<RowPositionCoordinate, Integer>(); /** * All rows are being resized to the same height e.g. during a drag resize */ public MultiRowResizeCommand(ILayer layer, int[] rowPositions, int commonRowHeight) { super(layer, rowPositions); this.commonRowHeight = commonRowHeight; } /** * Each row is being resized to a different size e.g. during auto resize */ public MultiRowResizeCommand(ILayer layer, int[] rowPositions, int[] rowHeights) { super(layer, rowPositions); for (int i = 0; i < rowPositions.length; i++) { rowPositionToHeight.put(new RowPositionCoordinate(layer, rowPositions[i]), Integer.valueOf(rowHeights[i])); } } protected MultiRowResizeCommand(MultiRowResizeCommand command) { super(command); this.commonRowHeight = command.commonRowHeight; this.rowPositionToHeight = new HashMap<RowPositionCoordinate, Integer>(command.rowPositionToHeight); } public int getCommonRowHeight() { return commonRowHeight; } public int getRowHeight(int rowPosition) { for (RowPositionCoordinate rowPositionCoordinate : rowPositionToHeight.keySet()) { if (rowPositionCoordinate.getRowPosition() == rowPosition) { return rowPositionToHeight.get(rowPositionCoordinate).intValue(); } } return commonRowHeight; } @Override public boolean convertToTargetLayer(ILayer targetLayer) { Map<RowPositionCoordinate, Integer> newRowPositionToHeight = new HashMap<RowPositionCoordinate, Integer>(); for (RowPositionCoordinate rowPositionCoordinate : rowPositionToHeight.keySet()) { RowPositionCoordinate convertedRowPositionCoordinate = LayerCommandUtil.convertRowPositionToTargetContext(rowPositionCoordinate, targetLayer); if (convertedRowPositionCoordinate != null) { newRowPositionToHeight.put(convertedRowPositionCoordinate, rowPositionToHeight.get(rowPositionCoordinate)); } } rowPositionToHeight = newRowPositionToHeight; return super.convertToTargetLayer(targetLayer); } public MultiRowResizeCommand cloneCommand() { return new MultiRowResizeCommand(this); } }
2,644
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowResizeCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/RowResizeCommandHandler.java
package net.sourceforge.nattable.resize.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.layer.DataLayer; public class RowResizeCommandHandler extends AbstractLayerCommandHandler<RowResizeCommand> { private final DataLayer dataLayer; public RowResizeCommandHandler(DataLayer dataLayer) { this.dataLayer = dataLayer; } public Class<RowResizeCommand> getCommandClass() { return RowResizeCommand.class; } @Override protected boolean doCommand(RowResizeCommand command) { final int rowPosition = command.getRowPosition(); final int newRowHeight = command.getNewHeight(); dataLayer.setRowHeightByPosition(rowPosition, newRowHeight); return true; } }
734
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AutoResizeRowsCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/AutoResizeRowsCommand.java
package net.sourceforge.nattable.resize.command; import net.sourceforge.nattable.command.AbstractMultiRowCommand; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.config.IConfigRegistry; import org.eclipse.swt.graphics.GC; /** * @see AutoResizeColumnsCommand */ public class AutoResizeRowsCommand extends AbstractMultiRowCommand { private final IConfigRegistry configRegistry; private final GC gc; public AutoResizeRowsCommand(InitializeAutoResizeRowsCommand initCommand) { super(initCommand.getSourceLayer(), initCommand.getRowPositions()); this.configRegistry = initCommand.getConfigRegistry(); this.gc = initCommand.getGC(); } protected AutoResizeRowsCommand(AutoResizeRowsCommand command) { super(command); this.configRegistry = command.configRegistry; this.gc = command.gc; } public ILayerCommand cloneCommand() { return new AutoResizeRowsCommand(this); } // Accessors public GC getGC() { return gc; } public IConfigRegistry getConfigRegistry() { return configRegistry; } }
1,103
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
InitializeAutoResizeColumnsCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/InitializeAutoResizeColumnsCommand.java
package net.sourceforge.nattable.resize.command; import net.sourceforge.nattable.command.AbstractColumnCommand; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.grid.layer.GridLayer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.selection.SelectionLayer; import org.eclipse.swt.graphics.GC; /** * This command triggers the AutoResizeColumms command. It collects the selected * columns from the {@link SelectionLayer} and fires the * {@link AutoResizeColumnsCommand} on the {@link GridLayer} */ public class InitializeAutoResizeColumnsCommand extends AbstractColumnCommand { private final IConfigRegistry configRegistry; private final GC gc; private final ILayer sourceLayer; private int[] selectedColumnPositions = new int[0]; public InitializeAutoResizeColumnsCommand(ILayer layer, int columnPosition, IConfigRegistry configRegistry, GC gc) { super(layer, columnPosition); this.configRegistry = configRegistry; this.gc = gc; this.sourceLayer = layer; } protected InitializeAutoResizeColumnsCommand(InitializeAutoResizeColumnsCommand command) { super(command); this.configRegistry = command.configRegistry; this.gc = command.gc; this.sourceLayer = command.sourceLayer; } public ILayerCommand cloneCommand() { return new InitializeAutoResizeColumnsCommand(this); } // Accessors public GC getGC() { return gc; } public IConfigRegistry getConfigRegistry() { return configRegistry; } public ILayer getSourceLayer() { return sourceLayer; } public void setSelectedColumnPositions(int[] selectedColumnPositions) { this.selectedColumnPositions = selectedColumnPositions; } public int[] getColumnPositions() { return selectedColumnPositions; } }
1,892
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MultiColumnResizeCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/MultiColumnResizeCommand.java
package net.sourceforge.nattable.resize.command; import java.util.HashMap; import java.util.Map; import net.sourceforge.nattable.command.AbstractMultiColumnCommand; import net.sourceforge.nattable.command.LayerCommandUtil; import net.sourceforge.nattable.coordinate.ColumnPositionCoordinate; import net.sourceforge.nattable.layer.ILayer; public class MultiColumnResizeCommand extends AbstractMultiColumnCommand { private int commonColumnWidth = -1; protected Map<ColumnPositionCoordinate, Integer> colPositionToWidth = new HashMap<ColumnPositionCoordinate, Integer>(); /** * All columns are being resized to the same size e.g. during a drag resize */ public MultiColumnResizeCommand(ILayer layer, int[] columnPositions, int commonColumnWidth) { super(layer, columnPositions); this.commonColumnWidth = commonColumnWidth; } /** * Each column is being resized to a different size e.g. during auto resize */ public MultiColumnResizeCommand(ILayer layer, int[] columnPositions, int[] columnWidths) { super(layer, columnPositions); for (int i = 0; i < columnPositions.length; i++) { colPositionToWidth.put(new ColumnPositionCoordinate(layer, columnPositions[i]), Integer.valueOf(columnWidths[i])); } } protected MultiColumnResizeCommand(MultiColumnResizeCommand command) { super(command); this.commonColumnWidth = command.commonColumnWidth; this.colPositionToWidth = new HashMap<ColumnPositionCoordinate, Integer>(command.colPositionToWidth); } public int getCommonColumnWidth() { return commonColumnWidth; } public int getColumnWidth(int columnPosition) { for (ColumnPositionCoordinate columnPositionCoordinate : colPositionToWidth.keySet()) { if (columnPositionCoordinate.getColumnPosition() == columnPosition) { return colPositionToWidth.get(columnPositionCoordinate).intValue(); } } return commonColumnWidth; } /** * Convert the column positions to the target layer. * Ensure that the width associated with the column is now associated with the * converted column position. */ @Override public boolean convertToTargetLayer(ILayer targetLayer) { Map<ColumnPositionCoordinate, Integer> newColPositionToWidth = new HashMap<ColumnPositionCoordinate, Integer>(); for (ColumnPositionCoordinate columnPositionCoordinate : colPositionToWidth.keySet()) { ColumnPositionCoordinate convertedColumnPositionCoordinate = LayerCommandUtil.convertColumnPositionToTargetContext(columnPositionCoordinate, targetLayer); if (convertedColumnPositionCoordinate != null) { newColPositionToWidth.put(convertedColumnPositionCoordinate, colPositionToWidth.get(columnPositionCoordinate)); } } colPositionToWidth = newColPositionToWidth; return super.convertToTargetLayer(targetLayer); } public MultiColumnResizeCommand cloneCommand() { return new MultiColumnResizeCommand(this); } }
2,949
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AutoResizeColumnsCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/AutoResizeColumnsCommand.java
package net.sourceforge.nattable.resize.command; import net.sourceforge.nattable.command.AbstractMultiColumnCommand; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.config.IConfigRegistry; import org.eclipse.swt.graphics.GC; /** * Command indicating that all selected columns have to be auto resized i.e made * wide enough to just fit the widest cell. This should also take the column * header into account * * Note: The {@link InitializeAutoResizeColumnsCommand} has to be fired first * when autoresizing columns. */ public class AutoResizeColumnsCommand extends AbstractMultiColumnCommand { private final IConfigRegistry configRegistry; private final GC gc; public AutoResizeColumnsCommand(InitializeAutoResizeColumnsCommand initCommand) { super(initCommand.getSourceLayer(), initCommand.getColumnPositions()); this.configRegistry = initCommand.getConfigRegistry(); this.gc = initCommand.getGC(); } protected AutoResizeColumnsCommand(AutoResizeColumnsCommand command) { super(command); this.configRegistry = command.configRegistry; this.gc = command.gc; } public ILayerCommand cloneCommand() { return new AutoResizeColumnsCommand(this); } // Accessors public GC getGC() { return gc; } public IConfigRegistry getConfigRegistry() { return configRegistry; } }
1,397
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowResizeCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/RowResizeCommand.java
package net.sourceforge.nattable.resize.command; import net.sourceforge.nattable.command.AbstractRowCommand; import net.sourceforge.nattable.layer.ILayer; /** * Event indicating that a row has been resized. */ public class RowResizeCommand extends AbstractRowCommand { private int newHeight; public RowResizeCommand(ILayer layer, int rowPosition, int newHeight) { super(layer, rowPosition); this.newHeight = newHeight; } protected RowResizeCommand(RowResizeCommand command) { super(command); this.newHeight = command.newHeight; } public int getNewHeight() { return newHeight; } public RowResizeCommand cloneCommand() { return new RowResizeCommand(this); } }
794
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MultiRowResizeCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/command/MultiRowResizeCommandHandler.java
package net.sourceforge.nattable.resize.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.layer.DataLayer; public class MultiRowResizeCommandHandler extends AbstractLayerCommandHandler<MultiRowResizeCommand> { private final DataLayer dataLayer; public MultiRowResizeCommandHandler(DataLayer dataLayer) { this.dataLayer = dataLayer; } public Class<MultiRowResizeCommand> getCommandClass() { return MultiRowResizeCommand.class; } @Override protected boolean doCommand(MultiRowResizeCommand command) { for (int rowPosition : command.getRowPositions()) { dataLayer.setRowHeightByPosition(rowPosition, command.getRowHeight(rowPosition)); } return true; } }
741
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnResizeDragMode.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/mode/ColumnResizeDragMode.java
package net.sourceforge.nattable.resize.mode; import java.util.HashSet; import java.util.Set; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.painter.IOverlayPainter; import net.sourceforge.nattable.resize.command.ColumnResizeCommand; import net.sourceforge.nattable.ui.action.IDragMode; import net.sourceforge.nattable.ui.util.CellEdgeDetectUtil; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; /** * Drag mode that will implement the column resizing process. */ public class ColumnResizeDragMode implements IDragMode { private static final int DEFAULT_COLUMN_WIDTH_MINIMUM = 25; private int columnPositionToResize; private int originalColumnWidth; private int startX; private int currentX; private int lastX = -1; private int gridColumnStartX; private final IOverlayPainter overlayPainter = new ColumnResizeOverlayPainter(); public void mouseDown(NatTable natTable, MouseEvent event) { natTable.forceFocus(); columnPositionToResize = CellEdgeDetectUtil.getColumnPositionToResize(natTable, new Point(event.x, event.y)); if (columnPositionToResize >= 0) { gridColumnStartX = natTable.getStartXOfColumnPosition(columnPositionToResize); originalColumnWidth = natTable.getColumnWidthByPosition(columnPositionToResize); startX = event.x; natTable.addOverlayPainter(overlayPainter); } } public void mouseMove(NatTable natTable, MouseEvent event) { if (event.x > natTable.getWidth()) { return; } this.currentX = event.x; if (currentX < gridColumnStartX + getColumnWidthMinimum()) { currentX = gridColumnStartX + getColumnWidthMinimum(); } else { int overlayExtent = ColumnResizeOverlayPainter.COLUMN_RESIZE_OVERLAY_WIDTH / 2; Set<Integer> columnsToRepaint = new HashSet<Integer>(); columnsToRepaint.add(Integer.valueOf(natTable.getColumnPositionByX(currentX - overlayExtent))); columnsToRepaint.add(Integer.valueOf(natTable.getColumnPositionByX(currentX + overlayExtent))); if (lastX >= 0) { columnsToRepaint.add(Integer.valueOf(natTable.getColumnPositionByX(lastX - overlayExtent))); columnsToRepaint.add(Integer.valueOf(natTable.getColumnPositionByX(lastX + overlayExtent))); } for (Integer columnToRepaint : columnsToRepaint) { natTable.repaintColumn(columnToRepaint.intValue()); } lastX = currentX; } } public void mouseUp(NatTable natTable, MouseEvent event) { natTable.removeOverlayPainter(overlayPainter); updateColumnWidth(natTable, event); } private void updateColumnWidth(ILayer natLayer, MouseEvent e) { int dragWidth = e.x - startX; int newColumnWidth = originalColumnWidth + dragWidth; if (newColumnWidth < getColumnWidthMinimum()) newColumnWidth = getColumnWidthMinimum(); natLayer.doCommand(new ColumnResizeCommand(natLayer, columnPositionToResize, newColumnWidth)); } // XXX: This method must ask the layer what it's minimum width is! private int getColumnWidthMinimum() { return DEFAULT_COLUMN_WIDTH_MINIMUM; } private class ColumnResizeOverlayPainter implements IOverlayPainter { static final int COLUMN_RESIZE_OVERLAY_WIDTH = 2; public void paintOverlay(GC gc, ILayer layer) { Color originalBackgroundColor = gc.getBackground(); gc.setBackground(GUIHelper.COLOR_DARK_GRAY); gc.fillRectangle(currentX - (COLUMN_RESIZE_OVERLAY_WIDTH / 2), 0, COLUMN_RESIZE_OVERLAY_WIDTH, layer.getHeight()); gc.setBackground(originalBackgroundColor); } } }
3,860
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowResizeDragMode.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/mode/RowResizeDragMode.java
package net.sourceforge.nattable.resize.mode; import java.util.HashSet; import java.util.Set; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.painter.IOverlayPainter; import net.sourceforge.nattable.resize.command.RowResizeCommand; import net.sourceforge.nattable.ui.action.IDragMode; import net.sourceforge.nattable.ui.util.CellEdgeDetectUtil; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; /** * Drag mode that will implement the row resizing process. */ public class RowResizeDragMode implements IDragMode { private static final int DEFAULT_ROW_HEIGHT_MINIMUM = 18; private int gridRowPositionToResize; private int originalRowHeight; private int startY; private int currentY; private int lastY = -1; private int gridRowStartY; private IOverlayPainter overlayPainter = new RowResizeOverlayPainter(); public void mouseDown(NatTable natTable, MouseEvent event) { natTable.forceFocus(); gridRowPositionToResize = CellEdgeDetectUtil.getRowPositionToResize(natTable, new Point(event.x, event.y)); if (gridRowPositionToResize > 0) { gridRowStartY = natTable.getStartYOfRowPosition(gridRowPositionToResize); originalRowHeight = natTable.getRowHeightByPosition(gridRowPositionToResize); startY = event.y; natTable.addOverlayPainter(overlayPainter); } } public void mouseMove(NatTable natTable, MouseEvent event) { if (event.y > natTable.getHeight()) { return; } currentY = event.y; if (currentY < gridRowStartY + getRowHeightMinimum()) { currentY = gridRowStartY + getRowHeightMinimum(); } else { int overlayExtent = RowResizeOverlayPainter.ROW_RESIZE_OVERLAY_HEIGHT / 2; Set<Integer> rowsToRepaint = new HashSet<Integer>(); rowsToRepaint.add(Integer.valueOf(natTable.getRowPositionByY(currentY - overlayExtent))); rowsToRepaint.add(Integer.valueOf(natTable.getRowPositionByY(currentY + overlayExtent))); if (lastY >= 0) { rowsToRepaint.add(Integer.valueOf(natTable.getRowPositionByY(lastY - overlayExtent))); rowsToRepaint.add(Integer.valueOf(natTable.getRowPositionByY(lastY + overlayExtent))); } for (Integer rowToRepaint : rowsToRepaint) { natTable.repaintRow(rowToRepaint.intValue()); } lastY = currentY; } } public void mouseUp(NatTable natTable, MouseEvent event) { natTable.removeOverlayPainter(overlayPainter); updateRowHeight(natTable, event); } private void updateRowHeight(ILayer natLayer, MouseEvent e) { int dragHeight = e.y - startY; int newRowHeight = originalRowHeight + dragHeight; if (newRowHeight < getRowHeightMinimum()) newRowHeight = getRowHeightMinimum(); natLayer.doCommand(new RowResizeCommand(natLayer, gridRowPositionToResize, newRowHeight)); } // XXX: should ask the layer for its minimum row height public int getRowHeightMinimum() { return DEFAULT_ROW_HEIGHT_MINIMUM; } private class RowResizeOverlayPainter implements IOverlayPainter { static final int ROW_RESIZE_OVERLAY_HEIGHT = 2; public void paintOverlay(GC gc, ILayer layer) { Color originalBackgroundColor = gc.getBackground(); gc.setBackground(GUIHelper.COLOR_DARK_GRAY); gc.fillRectangle(0, currentY - (ROW_RESIZE_OVERLAY_HEIGHT / 2), layer.getWidth(), ROW_RESIZE_OVERLAY_HEIGHT); gc.setBackground(originalBackgroundColor); } } }
3,763
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnResizeEventMatcher.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/event/ColumnResizeEventMatcher.java
package net.sourceforge.nattable.resize.event; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.grid.GridRegion; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.ui.matcher.MouseEventMatcher; import net.sourceforge.nattable.ui.util.CellEdgeDetectUtil; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Point; public class ColumnResizeEventMatcher extends MouseEventMatcher { public ColumnResizeEventMatcher(int stateMask, int button) { super(stateMask, GridRegion.COLUMN_HEADER, button); } @Override public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) { return super.matches(natTable, event, regionLabels) && isColumnResizable(natTable, event); } private boolean isColumnResizable(ILayer natLayer, MouseEvent event) { int columnPosition = CellEdgeDetectUtil.getColumnPositionToResize(natLayer, new Point(event.x, event.y)); if (columnPosition < 0) { return false; } else { return natLayer.isColumnPositionResizable(columnPosition); } } }
1,177
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowResizeEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/event/RowResizeEvent.java
package net.sourceforge.nattable.resize.event; import java.util.ArrayList; import java.util.Collection; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.event.RowStructuralChangeEvent; import net.sourceforge.nattable.layer.event.StructuralDiff; import net.sourceforge.nattable.layer.event.StructuralDiff.DiffTypeEnum; public class RowResizeEvent extends RowStructuralChangeEvent { public RowResizeEvent(ILayer layer, int rowPosition) { super(layer, new Range(rowPosition, rowPosition + 1)); } public RowResizeEvent(ILayer layer, Range rowPositionRange) { super(layer, rowPositionRange); } protected RowResizeEvent(RowResizeEvent event) { super(event); } public RowResizeEvent cloneEvent() { return new RowResizeEvent(this); } public Collection<StructuralDiff> getRowDiffs() { Collection<StructuralDiff> rowDiffs = new ArrayList<StructuralDiff>(); for (Range range : getRowPositionRanges()) { new StructuralDiff(DiffTypeEnum.CHANGE, range, range); } return rowDiffs; } }
1,144
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowResizeEventMatcher.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/event/RowResizeEventMatcher.java
package net.sourceforge.nattable.resize.event; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.grid.GridRegion; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.ui.matcher.MouseEventMatcher; import net.sourceforge.nattable.ui.util.CellEdgeDetectUtil; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Point; public class RowResizeEventMatcher extends MouseEventMatcher { public RowResizeEventMatcher(int stateMask, int button) { super(stateMask, GridRegion.ROW_HEADER, button); } @Override public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) { return super.matches(natTable, event, regionLabels) && indexIsResizable(natTable, event); } private boolean indexIsResizable(ILayer natLayer, MouseEvent event) { int rowPosition = CellEdgeDetectUtil.getRowPositionToResize(natLayer, new Point(event.x, event.y)); if (rowPosition < 0) { return false; } else { return natLayer.isRowPositionResizable(rowPosition); } } }
1,139
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnResizeEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/resize/event/ColumnResizeEvent.java
package net.sourceforge.nattable.resize.event; import java.util.ArrayList; import java.util.Collection; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.event.ColumnStructuralChangeEvent; import net.sourceforge.nattable.layer.event.StructuralDiff; import net.sourceforge.nattable.layer.event.StructuralDiff.DiffTypeEnum; public class ColumnResizeEvent extends ColumnStructuralChangeEvent { public ColumnResizeEvent(ILayer layer, int columnPosition) { super(layer, new Range(columnPosition, columnPosition + 1)); } protected ColumnResizeEvent(ColumnResizeEvent event) { super(event); } public ColumnResizeEvent cloneEvent() { return new ColumnResizeEvent(this); } public Collection<StructuralDiff> getColumnDiffs() { Collection<StructuralDiff> rowDiffs = new ArrayList<StructuralDiff>(); for (Range range : getColumnPositionRanges()) { rowDiffs.add(new StructuralDiff(DiffTypeEnum.CHANGE, range, range)); } return rowDiffs; } }
1,091
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
IColumnGroupModelListener.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/IColumnGroupModelListener.java
package net.sourceforge.nattable.group; public interface IColumnGroupModelListener { public void columnGroupModelChanged(); }
138
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupExpandCollapseLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/ColumnGroupExpandCollapseLayer.java
package net.sourceforge.nattable.group; import java.util.Collection; import java.util.HashSet; import net.sourceforge.nattable.group.command.ColumnGroupExpandCollapseCommandHandler; import net.sourceforge.nattable.hideshow.AbstractColumnHideShowLayer; import net.sourceforge.nattable.layer.IUniqueIndexLayer; /** * Tracks the Expand/Collapse of a Column Group header * NOTE: Only relevant when Column Grouping is enabled. */ public class ColumnGroupExpandCollapseLayer extends AbstractColumnHideShowLayer implements IColumnGroupModelListener { private final ColumnGroupModel model; public ColumnGroupExpandCollapseLayer(IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) { super(underlyingLayer); this.model = model; model.registerColumnGroupModelListner(this); registerCommandHandler(new ColumnGroupExpandCollapseCommandHandler(this)); } public ColumnGroupModel getModel() { return model; } // Expand/collapse @Override public boolean isColumnIndexHidden(int columnIndex) { IUniqueIndexLayer underlyingLayer = (IUniqueIndexLayer) getUnderlyingLayer(); return ColumnGroupUtils.isColumnIndexHiddenInUnderLyingLayer(columnIndex, this, underlyingLayer) || (model.isCollapsed(columnIndex) && !ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(columnIndex, this, underlyingLayer, model)); } @Override public Collection<Integer> getHiddenColumnIndexes() { Collection<Integer> hiddenColumnIndexes = new HashSet<Integer>(); IUniqueIndexLayer underlyingLayer = (IUniqueIndexLayer) getUnderlyingLayer(); int underlyingColumnCount = underlyingLayer.getColumnCount(); for (int i = 0; i < underlyingColumnCount; i++) { int colIndex = underlyingLayer.getColumnIndexByPosition(i); if (model.isCollapsed(colIndex)) { if (!ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(colIndex, this, underlyingLayer, model)) { hiddenColumnIndexes.add(Integer.valueOf(colIndex)); } } } return hiddenColumnIndexes; } // IColumnGroupModelListener public void columnGroupModelChanged() { invalidateCache(); } }
2,141
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupModel.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/ColumnGroupModel.java
package net.sourceforge.nattable.group; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Properties; import java.util.StringTokenizer; import net.sourceforge.nattable.persistence.IPersistable; import net.sourceforge.nattable.util.ObjectUtils; /** * Tracks: * Columns (by index) in a column Group. Does not keep the column indexes in any defined order. * Expand/collapse state of the Group. * Name of the Column Group (CG) */ public class ColumnGroupModel implements IPersistable { private static final String PERSISTENCE_KEY_COLUMN_GROUPS = ".columnGroups"; /** Column group header name to column indexes */ private final LinkedHashMap<String, ColumnGroup> nameToColumnGroup = new LinkedHashMap<String, ColumnGroup>(); private final LinkedHashMap<Integer, String> indexToColumnGroupName = new LinkedHashMap<Integer, String>(); private final Collection<IColumnGroupModelListener> listeners = new HashSet<IColumnGroupModelListener>(); public void registerColumnGroupModelListner(IColumnGroupModelListener listener) { listeners.add(listener); } public void notifyListeners() { for (IColumnGroupModelListener listener : listeners) { listener.columnGroupModelChanged(); } } public void saveState(String prefix, Properties properties) { StringBuilder strBuilder = new StringBuilder(); for (String columnGroupName : nameToColumnGroup.keySet()) { strBuilder.append(columnGroupName); strBuilder.append('='); ColumnGroup columnGroup = nameToColumnGroup.get(columnGroupName); strBuilder.append(columnGroup.collapsed ? "collapsed" : "expanded"); strBuilder.append(':'); strBuilder.append(columnGroup.unbreakable ? "unbreakable" : "breakable"); strBuilder.append(':'); for (Integer member : columnGroup.members) { strBuilder.append(member); strBuilder.append(','); } strBuilder.append('|'); } properties.setProperty(prefix + PERSISTENCE_KEY_COLUMN_GROUPS, strBuilder.toString()); } public void loadState(String prefix, Properties properties) { String property = properties.getProperty(prefix + PERSISTENCE_KEY_COLUMN_GROUPS); if (property != null) { clear(); StringTokenizer columnGroupTokenizer = new StringTokenizer(property, "|"); while (columnGroupTokenizer.hasMoreTokens()) { String columnGroupToken = columnGroupTokenizer.nextToken(); int separatorIndex = columnGroupToken.indexOf('='); // Column group name String columnGroupName = columnGroupToken.substring(0, separatorIndex); ColumnGroup columnGroup = new ColumnGroup(columnGroupName); nameToColumnGroup.put(columnGroupName, columnGroup); String[] columnGroupProperties = columnGroupToken.substring(separatorIndex + 1).split(":"); // Expanded/collapsed String state = columnGroupProperties[0]; if ("collapsed".equals(state)) { columnGroup.collapsed = true; } else if ("expanded".equals(state)) { columnGroup.collapsed = false; } else { throw new IllegalArgumentException(state + " not one of 'expanded' or 'collapsed'"); } // breakable / unbreakable state = columnGroupProperties[1]; if ("breakable".equals(state)) { columnGroup.unbreakable = false; } else if ("unbreakable".equals(state)) { columnGroup.unbreakable = true; } else { throw new IllegalArgumentException(state + " not one of 'breakable' or 'unbreakable'"); } // Indexes String indexes = columnGroupProperties[2]; StringTokenizer indexTokenizer = new StringTokenizer(indexes, ","); while (indexTokenizer.hasMoreTokens()) { Integer index = Integer.valueOf(indexTokenizer.nextToken()); columnGroup.members.add(index); indexToColumnGroupName.put(index, columnGroupName); } } } } /** * Creates the column group if one does not exist with the given name * and adds the column indexes to it. * @see ColumnGroupModel#insertColumnIndexes(String, int...); */ public void addColumnsIndexesToGroup(String colGroupName, int... bodyColumnIndexs) { if (nameToColumnGroup.get(colGroupName) == null) { ColumnGroup group = new ColumnGroup(colGroupName); nameToColumnGroup.put(colGroupName, group); } insertColumnIndexes(colGroupName, bodyColumnIndexs); notifyListeners(); } /** * This method will add column index(s) to an existing group * @param colGroupName to add the indexes to * @param columnIndexToInsert * @return FALSE if: * The column group is frozen * Index is already s part of a column group */ public boolean insertColumnIndexes(String colGroupName, int... columnIndexesToInsert) { LinkedList<Integer> members = new LinkedList<Integer>(); LinkedHashMap<Integer, String> indexToColumnGroupName = new LinkedHashMap<Integer, String>(); ColumnGroup columnGroup = nameToColumnGroup.get(colGroupName); if (columnGroup.unbreakable) { return false; } // Check if any of the indexes belong to existing groups for (int columnIndexToInsert : columnIndexesToInsert) { final Integer index = Integer.valueOf(columnIndexToInsert); if (isPartOfAGroup(columnIndexToInsert)) { return false; } members.add(index); indexToColumnGroupName.put(index, colGroupName); } this.indexToColumnGroupName.putAll(indexToColumnGroupName); columnGroup.members.addAll(members); notifyListeners(); return true; } // Getters /* * Do not expose private ColumnGroup class */ private ColumnGroup getColumnGroupForIndex(int bodyColumnIndex) { Integer key = Integer.valueOf(bodyColumnIndex); if (indexToColumnGroupName.containsKey(key)) { return nameToColumnGroup.get(indexToColumnGroupName.get(key)); } return null; } public String getColumnGroupNameForIndex(int bodyColumnIndex) { if (isPartOfAGroup(bodyColumnIndex)) { return getColumnGroupForIndex(bodyColumnIndex).name; } return null; } /** * @return Unmodifiable list of other column indexes in the same group as this index */ public List<Integer> getColumnIndexesInGroup(int bodyColumnIndex) { ColumnGroup group = getColumnGroupForIndex(bodyColumnIndex); if(group == null) { return Collections.emptyList(); } return Collections.unmodifiableList(group.members); } /** * @return all the indexes which belong to groups */ public List<Integer> getAllIndexesInGroups() { List<Integer> indexes = new LinkedList<Integer>(); for (ColumnGroup columnGroup : nameToColumnGroup.values()) { indexes.addAll(columnGroup.members); } return indexes; } public boolean isPartOfAGroup(int bodyColumnIndex){ return indexToColumnGroupName.containsKey(Integer.valueOf(bodyColumnIndex)); } public void clear() { nameToColumnGroup.clear(); indexToColumnGroupName.clear(); } /** * @return Number of column Groups in the model. */ public int size() { return nameToColumnGroup.size(); } /** * Number of columns in the Group which the bodyColumnIndex belongs to. */ public int sizeOfGroup(int bodyColumnIndex) { return getColumnIndexesInGroup(bodyColumnIndex).size(); } /** * @return TRUE if no column groups exist */ public boolean isEmpty() { return nameToColumnGroup.size() == 0; } /** * @return TRUE if the column group this index belongs to is collapsed */ public boolean isCollapsed(int bodyColumnIndex) { if (isPartOfAGroup(bodyColumnIndex)) { return getColumnGroupForIndex(bodyColumnIndex).collapsed; } return false; } public boolean isCollapsed(String columnGroupName) { boolean collpased = false; if (nameToColumnGroup.containsKey(columnGroupName)) { collpased = nameToColumnGroup.get(columnGroupName).collapsed; } return collpased; } /** * @return TRUE if a group by this name exists */ public boolean isAGroup(String cellValue) { return nameToColumnGroup.containsKey(cellValue); } /** * @return Total number of columns hidden for all the collapsed columns. * The first column is visible for each collapsed column. */ public int getCollapsedColumnCount() { int count = 0; for (String groupName : nameToColumnGroup.keySet()) { ColumnGroup columnGroup = nameToColumnGroup.get(groupName); if (columnGroup.collapsed) { count = count + columnGroup.getMemberCount() - 1; } } return count; } protected void collapse(int bodyColumnIndex) { if (isPartOfAGroup(bodyColumnIndex)) { getColumnGroupForIndex(bodyColumnIndex).collapsed = true; } notifyListeners(); } protected void expand(int bodyColumnIndex) { if (isPartOfAGroup(bodyColumnIndex)) { getColumnGroupForIndex(bodyColumnIndex).collapsed = false; } notifyListeners(); } /** * @return TRUE if index successfully removed from its group. */ public boolean removeColumnFromGroup(int bodyColumnIndex) { if (isPartOfAGroup(bodyColumnIndex) && !isPartOfAnUnbreakableGroup(bodyColumnIndex)) { ColumnGroup group = getColumnGroupForIndex(bodyColumnIndex); removeColumn(bodyColumnIndex, group); notifyListeners(); return true; } return false; } private void removeColumn(int bodyColumnIndex, ColumnGroup group) { final LinkedList<Integer> members = group.members; members.remove(Integer.valueOf(bodyColumnIndex)); indexToColumnGroupName.remove(Integer.valueOf(bodyColumnIndex)); if (members.size() == 0) { nameToColumnGroup.remove(group.name); } notifyListeners(); } /** * @param columnIndex * @return The position of the index within the column group */ public int getColumnGroupPositionFromIndex(int bodyColumnIndex) { if (isPartOfAGroup(bodyColumnIndex)) { ColumnGroup columnGroup = getColumnGroupForIndex(bodyColumnIndex); return columnGroup.members.indexOf(Integer.valueOf(bodyColumnIndex)); } return -1; } /** * Toggle the expand/collapse state of the Column Group */ public ColumnGroup toggleColumnGroupExpandCollapse(int bodyColumnIndex) { if (isPartOfAGroup(bodyColumnIndex)) { ColumnGroup columnGroup = getColumnGroupForIndex(bodyColumnIndex); columnGroup.collapsed = !columnGroup.collapsed; notifyListeners(); return columnGroup; } return null; } // Unbreakable Groups /** * If a group is marked as unbreakable, the composition of the group cannot be changed. * Columns cannot be added or removed from the group. * Columns may be reorder within the group. * @return TRUE if the operation was successful. * @see NTBL 393 */ public boolean setGroupUnBreakable(int bodyColumnIndex) { if (isPartOfAGroup(bodyColumnIndex)) { getColumnGroupForIndex(bodyColumnIndex).unbreakable = true; return true; } return false; } public boolean isPartOfAnUnbreakableGroup(int bodyColumnIndex) { if (isPartOfAGroup(bodyColumnIndex)) { return getColumnGroupForIndex(bodyColumnIndex).unbreakable; } return false; } // *** Column Group *** public class ColumnGroup { /** Body column indexes */ private final LinkedList<Integer> members = new LinkedList<Integer>(); final String name; boolean collapsed = false; public boolean unbreakable = false; ColumnGroup(String groupName) { this.name = groupName; } int getMemberCount(){ return members.size(); } public List<Integer> getMembers() { return members; } @Override public String toString() { return "Column Group:\n\t name: " + name + "\n\t collapsed: " + collapsed + "\n\t unbreakable: " + unbreakable + "\n\t members: " + ObjectUtils.toString(members) + "\n"; } } @Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("Column Group Model:\n"); for (String groupName : nameToColumnGroup.keySet()) { buffer.append(nameToColumnGroup.get(groupName)); } return buffer.toString(); } }
12,228
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupHeaderLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/ColumnGroupHeaderLayer.java
package net.sourceforge.nattable.group; import java.util.List; import java.util.Properties; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.grid.GridRegion; import net.sourceforge.nattable.group.command.ColumnGroupsCommandHandler; import net.sourceforge.nattable.group.config.DefaultColumnGroupHeaderLayerConfiguration; import net.sourceforge.nattable.layer.AbstractLayerTransform; import net.sourceforge.nattable.layer.DataLayer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.layer.SizeConfig; import net.sourceforge.nattable.layer.cell.LayerCell; import net.sourceforge.nattable.layer.event.ColumnStructuralRefreshEvent; import net.sourceforge.nattable.painter.layer.CellLayerPainter; import net.sourceforge.nattable.painter.layer.ILayerPainter; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.style.DisplayMode; /** * Adds the Column grouping functionality to the column headers.<br/> * Also persists the state of the column groups when {@link NatTable#saveState()} is invoked.<br/> * <br/> * Internally uses the {@link ColumnGroupModel} to track the column groups.<br/> * @see ColumnGroupGridExample */ public class ColumnGroupHeaderLayer extends AbstractLayerTransform { private final SizeConfig rowHeightConfig = new SizeConfig(DataLayer.DEFAULT_ROW_HEIGHT); private final ColumnGroupModel model; private final ILayer columnHeaderLayer; private final ILayerPainter layerPainter = new CellLayerPainter(); public ColumnGroupHeaderLayer(ILayer columnHeaderLayer, SelectionLayer selectionLayer, ColumnGroupModel columnGroupModel) { this(columnHeaderLayer, selectionLayer, columnGroupModel, true); } public ColumnGroupHeaderLayer(ILayer columnHeaderLayer, SelectionLayer selectionLayer, ColumnGroupModel columnGroupModel, boolean useDefaultConfiguration) { super(columnHeaderLayer); this.columnHeaderLayer = columnHeaderLayer; this.model = columnGroupModel; registerCommandHandler(new ColumnGroupsCommandHandler(model, selectionLayer, this)); if (useDefaultConfiguration) { addConfiguration(new DefaultColumnGroupHeaderLayerConfiguration(columnGroupModel)); } } // Persistence @Override public void saveState(String prefix, Properties properties) { super.saveState(prefix, properties); model.saveState(prefix, properties); } @Override public void loadState(String prefix, Properties properties) { super.loadState(prefix, properties); model.loadState(prefix, properties); fireLayerEvent(new ColumnStructuralRefreshEvent(this)); } // Configuration @Override public ILayerPainter getLayerPainter() { return layerPainter; } // Vertical features // Rows @Override public int getRowCount() { return columnHeaderLayer.getRowCount() + 1; } @Override public int getPreferredRowCount() { return columnHeaderLayer.getPreferredRowCount() + 1; } @Override public int getRowIndexByPosition(int rowPosition) { if (rowPosition == 0) { return rowPosition; } else { return columnHeaderLayer.getRowIndexByPosition(rowPosition - 1); } } // Height @Override public int getHeight() { return rowHeightConfig.getAggregateSize(1) + columnHeaderLayer.getHeight(); } @Override public int getPreferredHeight() { return rowHeightConfig.getAggregateSize(1) + columnHeaderLayer.getPreferredHeight(); } @Override public int getRowHeightByPosition(int rowPosition) { if (rowPosition == 0) { return rowHeightConfig.getSize(rowPosition); } else { return columnHeaderLayer.getRowHeightByPosition(rowPosition - 1); } } public void setRowHeight(int rowHeight) { this.rowHeightConfig.setSize(0, rowHeight); } // Row resize @Override public boolean isRowPositionResizable(int rowPosition) { if (rowPosition == 0) { return rowHeightConfig.isPositionResizable(rowPosition); } else { return columnHeaderLayer.isRowPositionResizable(rowPosition - 1); } } // Y @Override public int getRowPositionByY(int y) { int row0Height = getRowHeightByPosition(0); if (y < row0Height) { return 0; } else { return 1 + columnHeaderLayer.getRowPositionByY(y - row0Height); } } @Override public int getStartYOfRowPosition(int rowPosition) { if (rowPosition == 0) { return rowHeightConfig.getAggregateSize(rowPosition); } else { return getRowHeightByPosition(0) + columnHeaderLayer.getStartYOfRowPosition(rowPosition - 1); } } // Cell features /** * If a cell belongs to a column group: * column position - set to the start position of the group * span - set to the width/size of the column group * * NOTE: gc.setClip() is used in the CompositeLayerPainter to ensure that partially visible * Column group header cells are rendered properly. */ @Override public LayerCell getCellByPosition(int columnPosition, int rowPosition) { int bodyColumnIndex = getColumnIndexByPosition(columnPosition); // Column group header cell if (model.isPartOfAGroup(bodyColumnIndex)) { if (rowPosition == 0) { return new LayerCell( this, getStartPositionOfGroup(columnPosition), rowPosition, columnPosition, rowPosition, getColumnSpan(columnPosition), 1 ); } else { return new LayerCell(this, columnPosition, rowPosition); } } else { // render column header w/ rowspan = 2 LayerCell cell = columnHeaderLayer.getCellByPosition(columnPosition, 0); if (cell != null) { cell.updateLayer(this); cell.updateRowSpan(2); } return cell; } } /** * Calculates the span of a cell in a Column Group. * Takes into account collapsing and hidden columns in the group. * * @param selectionLayerColumnPosition of any column belonging to the group */ protected int getColumnSpan(int columnPosition) { int columnIndex = getColumnIndexByPosition(columnPosition); if (model.isCollapsed(columnIndex)) { return 1; } else { int startPositionOfGroup = getStartPositionOfGroup(columnPosition); int sizeOfGroup = model.sizeOfGroup(columnIndex); int endPositionOfGroup = startPositionOfGroup + sizeOfGroup; List<Integer> columnIndexesInGroup = model.getColumnIndexesInGroup(columnIndex); for (int i = startPositionOfGroup; i < endPositionOfGroup; i++) { int index = getColumnIndexByPosition(i); if (!columnIndexesInGroup.contains(Integer.valueOf(index))) { sizeOfGroup--; } } return sizeOfGroup; } } /** * Figures out the start position of the group. * * @param selectionLayerColumnPosition of any column belonging to the group * @return first position of the column group */ private int getStartPositionOfGroup(int columnPosition) { int bodyColumnIndex = getColumnIndexByPosition(columnPosition); int leastPossibleStartPositionOfGroup = columnPosition - model.sizeOfGroup(bodyColumnIndex); int i = 0; for (i = leastPossibleStartPositionOfGroup; i < columnPosition; i++) { if (ColumnGroupUtils.isInTheSameGroup(getColumnIndexByPosition(i), bodyColumnIndex, model)) { break; } } return i; } @Override public String getDisplayModeByPosition(int columnPosition, int rowPosition) { int columnIndex = getColumnIndexByPosition(columnPosition); if (rowPosition == 0 && model.isPartOfAGroup(columnIndex)) { return DisplayMode.NORMAL; } else { return columnHeaderLayer.getDisplayModeByPosition(columnPosition, rowPosition); } } @Override public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) { int columnIndex = getColumnIndexByPosition(columnPosition); if (rowPosition == 0 && model.isPartOfAGroup(columnIndex)) { return new LabelStack(GridRegion.COLUMN_GROUP_HEADER); } else { return columnHeaderLayer.getConfigLabelsByPosition(columnPosition, rowPosition); } } @Override public Object getDataValueByPosition(int columnPosition, int rowPosition) { int columnIndex = getColumnIndexByPosition(columnPosition); if (rowPosition == 0 && model.isPartOfAGroup(columnIndex)) { return model.getColumnGroupNameForIndex(columnIndex); } else { return columnHeaderLayer.getDataValueByPosition(columnPosition, 0); } } @Override public LabelStack getRegionLabelsByXY(int x, int y) { int columnIndex = getColumnIndexByPosition(getColumnPositionByX(x)); if (model.isPartOfAGroup(columnIndex) && y < getRowHeightByPosition(0)) { return new LabelStack(GridRegion.COLUMN_GROUP_HEADER); } else { return columnHeaderLayer.getRegionLabelsByXY(x, y - getRowHeightByPosition(0)); } } // ColumnGroupModel delegates public void addColumnsIndexesToGroup(String colGroupName, int... colIndexes) { model.addColumnsIndexesToGroup(colGroupName, colIndexes); } public void collapseColumnGroupByIndex(int columnIndex) { model.collapse(columnIndex); } public void clearAllGroups(){ model.clear(); } /** * @see ColumnGroupModel#setGroupUnBreakable(int) */ public void setGroupUnbreakable(int columnIndex){ model.setGroupUnBreakable(columnIndex); } public void setGroupAsCollapsed(int i) { model.collapse(i); } }
9,428
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupReorderLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/ColumnGroupReorderLayer.java
package net.sourceforge.nattable.group; import java.util.ArrayList; import java.util.Collections; import java.util.List; import net.sourceforge.nattable.group.command.GroupColumnReorderCommandHandler; import net.sourceforge.nattable.group.command.GroupMultiColumnReorderCommandHandler; import net.sourceforge.nattable.group.command.ReorderColumnGroupCommandHandler; import net.sourceforge.nattable.group.command.ReorderColumnsAndGroupsCommandHandler; import net.sourceforge.nattable.layer.AbstractLayerTransform; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand; /** * Adds functionality allowing the reordering of the the Column groups. */ public class ColumnGroupReorderLayer extends AbstractLayerTransform implements IUniqueIndexLayer { private IUniqueIndexLayer underlyingLayer; private final ColumnGroupModel model; public ColumnGroupReorderLayer(IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) { setUnderlyingLayer(underlyingLayer); this.underlyingLayer = underlyingLayer; this.model = model; registerCommandHandler(new ReorderColumnGroupCommandHandler(this)); registerCommandHandler(new ReorderColumnsAndGroupsCommandHandler(this)); registerCommandHandler(new GroupColumnReorderCommandHandler(this)); registerCommandHandler(new GroupMultiColumnReorderCommandHandler(this)); } public boolean reorderColumnGroup(int fromColumnPosition, int toColumnPosition) { int fromColumnIndex = underlyingLayer.getColumnIndexByPosition(fromColumnPosition); List<Integer> fromColumnPositions = getColumnGroupPositions(fromColumnIndex); return underlyingLayer.doCommand(new MultiColumnReorderCommand(this, fromColumnPositions, toColumnPosition)); } public ColumnGroupModel getModel() { return model; } @Override public ILayer getUnderlyingLayer() { return super.getUnderlyingLayer(); } // Horizontal features // Columns public int getColumnPositionByIndex(int columnIndex) { return underlyingLayer.getColumnPositionByIndex(columnIndex); } // Vertical features // Rows public int getRowPositionByIndex(int rowIndex) { return underlyingLayer.getRowPositionByIndex(rowIndex); } // Column Groups /** * @return the column positions for all the columns in this group */ public List<Integer> getColumnGroupPositions(int fromColumnIndex) { List<Integer> fromColumnIndexes = model.getColumnIndexesInGroup(fromColumnIndex); List<Integer> fromColumnPositions = new ArrayList<Integer>(); for (Integer columnIndex : fromColumnIndexes) { fromColumnPositions.add( Integer.valueOf(underlyingLayer.getColumnPositionByIndex(columnIndex.intValue()))); } //These positions are actually consecutive but the Column Group does not know about the order Collections.sort(fromColumnPositions); return fromColumnPositions; } }
3,037
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupUtils.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/ColumnGroupUtils.java
package net.sourceforge.nattable.group; import java.util.ArrayList; import java.util.Collections; import java.util.List; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; public class ColumnGroupUtils { public static MoveDirectionEnum getMoveDirection(int fromColumnPosition, int toColumnPosition) { if (fromColumnPosition > toColumnPosition){ return MoveDirectionEnum.LEFT; } else if(fromColumnPosition < toColumnPosition){ return MoveDirectionEnum.RIGHT; } else { return MoveDirectionEnum.NONE; } } public static boolean isInTheSameGroup(int fromColumnIndex, int toColumnIndex, ColumnGroupModel model) { String fromColumnGroupName = model.getColumnGroupNameForIndex(fromColumnIndex); String toColumnGroupName = model.getColumnGroupNameForIndex(toColumnIndex); return fromColumnGroupName != null && toColumnGroupName != null && fromColumnGroupName.equals(toColumnGroupName); } public static boolean isFirstVisibleColumnIndexInGroup(int columnIndex, ILayer layer, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model){ if (isColumnIndexHiddenInUnderLyingLayer(columnIndex, layer, underlyingLayer)) { return false; } int columnPosition = underlyingLayer.getColumnPositionByIndex(columnIndex); List<Integer> columnIndexesInGroup = model.getColumnIndexesInGroup(columnIndex); List<Integer> previousVisibleColumnIndexes = new ArrayList<Integer>(); //All other indexes in the column group which are visible and //are positioned before me for (Integer currentIndex : columnIndexesInGroup) { int currentPosition = underlyingLayer.getColumnPositionByIndex(currentIndex.intValue()); if(!isColumnIndexHiddenInUnderLyingLayer(currentIndex.intValue(), layer, underlyingLayer) && currentPosition < columnPosition){ previousVisibleColumnIndexes.add(currentIndex); } } return previousVisibleColumnIndexes.isEmpty(); } public static boolean isLastVisibleColumnIndexInGroup(int columnIndex, ILayer layer, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) { if (isColumnIndexHiddenInUnderLyingLayer(columnIndex, layer, underlyingLayer)) { return false; } List<Integer> visibleIndexesToTheRight = getVisibleIndexesToTheRight(columnIndex, layer, underlyingLayer, model); return visibleIndexesToTheRight.size() == 1 && visibleIndexesToTheRight.get(0).intValue() == columnIndex; } /** * Inclusive of the columnIndex passed as the parameter. */ public static List<Integer> getVisibleIndexesToTheRight(int columnIndex, ILayer layer, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model){ if(model.isCollapsed(columnIndex)){ return Collections.emptyList(); } List<Integer> columnIndexesInGroup = model.getColumnIndexesInGroup(columnIndex); int columnPosition = underlyingLayer.getColumnPositionByIndex(columnIndex); List<Integer> visibleColumnIndexesOnRight = new ArrayList<Integer>(); for (Integer currentIndex : columnIndexesInGroup) { int currentPosition = underlyingLayer.getColumnPositionByIndex(currentIndex.intValue()); if(!isColumnIndexHiddenInUnderLyingLayer(currentIndex.intValue(), layer, underlyingLayer) && currentPosition >= columnPosition){ visibleColumnIndexesOnRight.add(currentIndex); } } return visibleColumnIndexesOnRight; } public static boolean isColumnIndexHiddenInUnderLyingLayer(int columnIndex, ILayer layer, IUniqueIndexLayer underlyingLayer) { return underlyingLayer.getColumnPositionByIndex(columnIndex) == -1; } public static boolean isColumnPositionHiddenInUnderLyingLayer(int columnPosition, ILayer layer, IUniqueIndexLayer underlyingLayer) { if (columnPosition < underlyingLayer.getColumnCount() && columnPosition >= 0) { int columnIndex = underlyingLayer.getColumnIndexByPosition(columnPosition); return isColumnIndexHiddenInUnderLyingLayer(columnIndex, layer, underlyingLayer); } return true; } /** * @see ColumnGroupUtilsTest * @return TRUE if the given column is the <i>right</i> most column in a group */ public static boolean isRightEdgeOfAColumnGroup(ILayer natLayer, int columnPosition, int columnIndex, ColumnGroupModel model) { int nextColumnPosition = columnPosition + 1; if (nextColumnPosition < natLayer.getColumnCount()) { int nextColumnIndex = natLayer.getColumnIndexByPosition(nextColumnPosition); if ((model.isPartOfAGroup(columnIndex) && !model.isPartOfAGroup(nextColumnIndex))) { return true; } if ((model.isPartOfAGroup(columnIndex) && model.isPartOfAGroup(nextColumnIndex)) && !ColumnGroupUtils.isInTheSameGroup(columnIndex, nextColumnIndex, model)) { return true; } } return false; } /** * @see ColumnGroupUtilsTest * @return TRUE if the given column is the <i>left</i> most column in a group */ public static boolean isLeftEdgeOfAColumnGroup(ILayer natLayer, int columnPosition, int columnIndex, ColumnGroupModel model) { int previousColumnPosition = columnPosition - 1; // First column && in a group if(columnPosition == 0 && model.isPartOfAGroup(columnIndex)){ return true; } if (previousColumnPosition >= 0) { int previousColumnIndex = natLayer.getColumnIndexByPosition(previousColumnPosition); if ((model.isPartOfAGroup(columnIndex) && !model.isPartOfAGroup(previousColumnIndex))) { return true; } if ((model.isPartOfAGroup(columnIndex) && model.isPartOfAGroup(previousColumnIndex)) && !ColumnGroupUtils.isInTheSameGroup(columnIndex, previousColumnIndex, model)) { return true; } } return false; } /** * @return TRUE if there is a column group boundary between startX and endX */ public static boolean isBetweenTwoGroups(ILayer natLayer, int startX, int endX, ColumnGroupModel model) { return !ColumnGroupUtils.isInTheSameGroup( natLayer.getColumnIndexByPosition(natLayer.getColumnPositionByX(startX)), natLayer.getColumnIndexByPosition(natLayer.getColumnPositionByX(endX)), model); } }
6,225
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnHeaderReorderDragMode.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/action/ColumnHeaderReorderDragMode.java
package net.sourceforge.nattable.group.action; import net.sourceforge.nattable.group.ColumnGroupModel; import net.sourceforge.nattable.group.ColumnGroupUtils; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.reorder.action.ColumnReorderDragMode; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.events.MouseEvent; /** * Extends the regular column drag functionality to work with Column groups.<br/> * It does the following checks:<br/> * <ol> * <li>Checks that the destination is not part of a Unbreakable column group</li> * <li>Checks if the destination is between two adjoining column groups</li> * </ol> */ public class ColumnHeaderReorderDragMode extends ColumnReorderDragMode { private final ColumnGroupModel model; private MouseEvent event; public ColumnHeaderReorderDragMode(ColumnGroupModel model) { this.model = model; } public boolean isValidTargetColumnPosition(ILayer natLayer, int fromGridColumnPosition, int toGridColumnPosition) { int toColumnIndex = natLayer.getColumnIndexByPosition(toGridColumnPosition); int fromColumnIndex = natLayer.getColumnIndexByPosition(fromGridColumnPosition); // Allow moving within the unbreakable group if (model.isPartOfAnUnbreakableGroup(fromColumnIndex)){ return ColumnGroupUtils.isInTheSameGroup(fromColumnIndex, toColumnIndex, model); } boolean betweenTwoGroups = false; if (event != null) { int minX = event.x - GUIHelper.DEFAULT_RESIZE_HANDLE_SIZE; int maxX = event.x + GUIHelper.DEFAULT_RESIZE_HANDLE_SIZE; betweenTwoGroups = ColumnGroupUtils.isBetweenTwoGroups(natLayer, minX, maxX, model); } return (!model.isPartOfAnUnbreakableGroup(toColumnIndex)) || betweenTwoGroups; } @Override public boolean isValidTargetColumnPosition(ILayer natLayer, int fromGridColumnPosition, int toGridColumnPosition, MouseEvent event) { this.event = event; toGridColumnPosition = natLayer.getColumnPositionByX(event.x); return isValidTargetColumnPosition(natLayer, fromGridColumnPosition, toGridColumnPosition); } }
2,121
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
UngroupColumnsAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/action/UngroupColumnsAction.java
package net.sourceforge.nattable.group.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.group.command.UngroupColumnCommand; import net.sourceforge.nattable.ui.action.IKeyAction; import org.eclipse.swt.events.KeyEvent; public class UngroupColumnsAction implements IKeyAction { public void run(NatTable natTable, KeyEvent event) { natTable.doCommand(new UngroupColumnCommand()); } }
434
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupHeaderReorderDragMode.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/action/ColumnGroupHeaderReorderDragMode.java
package net.sourceforge.nattable.group.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.group.ColumnGroupModel; import net.sourceforge.nattable.group.ColumnGroupUtils; import net.sourceforge.nattable.group.command.ReorderColumnGroupCommand; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.reorder.action.ColumnReorderDragMode; import net.sourceforge.nattable.ui.action.IDragMode; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.events.MouseEvent; /** * Default {@link IDragMode} invoked for 'left click + drag' on the column group header.<br/> * * It overrides the isValidTargetColumnPosition() to calculate if a destination position is valid * for the column group to be reordered to.<br/> * * Example, a column group cannot only be reordered to be inside another column group. * @see ColumnGroupHeaderReorderDragModeTest */ public class ColumnGroupHeaderReorderDragMode extends ColumnReorderDragMode { private final ColumnGroupModel model; private MouseEvent event; public ColumnGroupHeaderReorderDragMode(ColumnGroupModel model) { this.model = model; } @Override protected boolean isValidTargetColumnPosition(ILayer natLayer, int fromGridColumnPosition, int toGridColumnPosition, MouseEvent event) { this.event = event; toGridColumnPosition = natLayer.getColumnPositionByX(event.x); return isValidTargetColumnPosition(natLayer, fromGridColumnPosition, toGridColumnPosition); } /** * Work off the event coordinates since the drag {@link ColumnReorderDragMode} adjusts the * 'to' column positions (for on screen semantics) */ protected boolean isValidTargetColumnPosition(ILayer natLayer, int fromGridColumnPosition, int toGridColumnPosition) { int toColumnIndex = natLayer.getColumnIndexByPosition(toGridColumnPosition); boolean betweenGroups = false; if(event != null){ int minX = event.x - GUIHelper.DEFAULT_RESIZE_HANDLE_SIZE; int maxX = event.x + GUIHelper.DEFAULT_RESIZE_HANDLE_SIZE; betweenGroups = ColumnGroupUtils.isBetweenTwoGroups(natLayer, minX, maxX, model); } return (!model.isPartOfAGroup(toColumnIndex)) || betweenGroups; } /** * Fire a {@link ReorderColumnGroupCommand} for the column group */ @Override protected void fireMoveCommand(NatTable natTable) { natTable.doCommand(new ReorderColumnGroupCommand(natTable, dragFromGridColumnPosition, dragToGridColumnPosition)); } }
2,515
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupExpandCollapseAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/action/ColumnGroupExpandCollapseAction.java
package net.sourceforge.nattable.group.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.group.command.ColumnGroupExpandCollapseCommand; import net.sourceforge.nattable.ui.action.IMouseAction; import org.eclipse.swt.events.MouseEvent; public class ColumnGroupExpandCollapseAction implements IMouseAction{ public void run(NatTable natTable, MouseEvent event) { ColumnGroupExpandCollapseCommand command = new ColumnGroupExpandCollapseCommand(natTable, natTable.getColumnPositionByX(event.x)); natTable.doCommand(command); } }
583
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CreateColumnGroupAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/action/CreateColumnGroupAction.java
package net.sourceforge.nattable.group.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.group.command.OpenCreateColumnGroupDialog; import net.sourceforge.nattable.ui.action.IKeyAction; import org.eclipse.swt.events.KeyEvent; public class CreateColumnGroupAction implements IKeyAction { private OpenCreateColumnGroupDialog dialogCommand; public void run(NatTable natTable, KeyEvent event) { if (dialogCommand == null) { // Create dialog dialogCommand = new OpenCreateColumnGroupDialog(natTable.getShell()); } natTable.doCommand(dialogCommand); } }
622
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultColumnGroupHeaderLayerConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/config/DefaultColumnGroupHeaderLayerConfiguration.java
package net.sourceforge.nattable.group.config; import net.sourceforge.nattable.config.CellConfigAttributes; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.config.IConfiguration; import net.sourceforge.nattable.grid.GridRegion; import net.sourceforge.nattable.group.ColumnGroupModel; import net.sourceforge.nattable.group.action.ColumnGroupExpandCollapseAction; import net.sourceforge.nattable.group.action.ColumnGroupHeaderReorderDragMode; import net.sourceforge.nattable.group.action.ColumnHeaderReorderDragMode; import net.sourceforge.nattable.group.action.CreateColumnGroupAction; import net.sourceforge.nattable.group.action.UngroupColumnsAction; import net.sourceforge.nattable.group.painter.ColumnGroupHeaderTextPainter; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.painter.cell.decorator.BeveledBorderDecorator; import net.sourceforge.nattable.style.DisplayMode; import net.sourceforge.nattable.ui.binding.UiBindingRegistry; import net.sourceforge.nattable.ui.matcher.KeyEventMatcher; import net.sourceforge.nattable.ui.matcher.MouseEventMatcher; import org.eclipse.swt.SWT; public class DefaultColumnGroupHeaderLayerConfiguration implements IConfiguration { private final ColumnGroupModel columnGroupModel; public DefaultColumnGroupHeaderLayerConfiguration(final ColumnGroupModel columnGroupModel) { this.columnGroupModel = columnGroupModel; } public void configureLayer(ILayer layer) { // No op } public void configureRegistry(IConfigRegistry configRegistry) { configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_PAINTER, new BeveledBorderDecorator(new ColumnGroupHeaderTextPainter(columnGroupModel)), DisplayMode.NORMAL, GridRegion.COLUMN_GROUP_HEADER ); } public void configureUiBindings(UiBindingRegistry uiBindingRegistry) { // Column Group Header is a part of the Group Header. // Register the 'column group header matcher' first so that it gets // picked up before the more general 'column header matcher'. uiBindingRegistry.registerMouseDragMode( MouseEventMatcher.columnGroupHeaderLeftClick(SWT.NONE), new ColumnGroupHeaderReorderDragMode(columnGroupModel)); uiBindingRegistry.registerMouseDragMode( MouseEventMatcher.columnHeaderLeftClick(SWT.NONE), new ColumnHeaderReorderDragMode(columnGroupModel)); uiBindingRegistry.registerDoubleClickBinding( MouseEventMatcher.columnGroupHeaderLeftClick(SWT.NONE), new ColumnGroupExpandCollapseAction()); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CTRL, 'g'), new CreateColumnGroupAction()); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CTRL, 'u'), new UngroupColumnsAction()); } }
2,860
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CreateColumnGroupDialog.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/gui/CreateColumnGroupDialog.java
package net.sourceforge.nattable.group.gui; import net.sourceforge.nattable.group.command.CreateColumnGroupCommand; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class CreateColumnGroupDialog extends Dialog { private Button createButton; private Text groupNameText; private ILayer contextLayer; private CreateColumnGroupDialog(Shell parentShell) { super(parentShell); setShellStyle(SWT.CLOSE | SWT.BORDER | SWT.TITLE | SWT.APPLICATION_MODAL); setBlockOnOpen(false); } public static CreateColumnGroupDialog createColumnGroupDialog(Shell shell) { return new CreateColumnGroupDialog(shell); } public void setContextLayer(ILayer layer) { this.contextLayer = layer; } @Override public void create() { super.create(); getShell().setText("Create Column Group"); } @Override protected Control createContents(final Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1,false)); GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); GridDataFactory.fillDefaults().minSize(200, 100).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(createInputPanel(composite)); Composite buttonPanel = createButtonSection(composite); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BOTTOM).grab(true, true).applyTo(buttonPanel); return composite; } private Composite createButtonSection(Composite composite) { Composite panel = new Composite(composite, SWT.NONE); GridLayout layout= new GridLayout(1,false); panel.setLayout(layout); Label spacer = new Label(panel, SWT.LEFT); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(spacer); createButton = createButton(panel, IDialogConstants.CLIENT_ID, "&Group", false); GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.BOTTOM).grab(false, false).hint(52, SWT.DEFAULT).applyTo(createButton); createButton.setEnabled(false); getShell().setDefaultButton(createButton); createButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doColumnGrouping(); } }); Button closeButton = createButton(panel, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.BOTTOM).grab(false, false).hint(52, SWT.DEFAULT).applyTo(closeButton); return panel; } private Composite createInputPanel(final Composite composite) { final Composite row = new Composite(composite, SWT.NONE); row.setLayout(new GridLayout(2,false)); final Label createLabel = new Label(row, SWT.NONE); createLabel.setText("G&roup Name:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(createLabel); groupNameText = new Text(row, SWT.SINGLE | SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(groupNameText); groupNameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { createButton.setEnabled(groupNameText.getText().length() > 0); } }); groupNameText.addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent e) { if (createButton.isEnabled()) { doColumnGrouping(); } } }); return row; } public void terminateDialog() { close(); } @Override public boolean close() { return super.close(); } private void doColumnGrouping() { BusyIndicator.showWhile(super.getShell().getDisplay(), new Runnable() { public void run() { final CreateColumnGroupCommand command = new CreateColumnGroupCommand(groupNameText.getText()); try { contextLayer.doCommand(command); } finally { terminateDialog(); } } }); } }
4,599
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CreateColumnGroupCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/CreateColumnGroupCommand.java
package net.sourceforge.nattable.group.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; public class CreateColumnGroupCommand extends AbstractContextFreeCommand implements IColumnGroupCommand { private final String columnGroupName; public CreateColumnGroupCommand(String columnGroupName) { this.columnGroupName = columnGroupName; } public String getColumnGroupName() { return columnGroupName; } }
461
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
GroupColumnReorderCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/GroupColumnReorderCommandHandler.java
package net.sourceforge.nattable.group.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.group.ColumnGroupModel; import net.sourceforge.nattable.group.ColumnGroupReorderLayer; import net.sourceforge.nattable.group.ColumnGroupUtils; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.reorder.command.ColumnReorderCommand; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; /** * Handles updating of the Column Group Model when a column belonging to * a group is reordered. The actual reordering of the column is delegated to the lower layers. */ public class GroupColumnReorderCommandHandler extends AbstractLayerCommandHandler<ColumnReorderCommand> { private final ColumnGroupReorderLayer columnGroupReorderLayer; private final ColumnGroupModel model; public GroupColumnReorderCommandHandler(ColumnGroupReorderLayer columnGroupReorderLayer) { this.columnGroupReorderLayer = columnGroupReorderLayer; this.model = columnGroupReorderLayer.getModel(); } public Class<ColumnReorderCommand> getCommandClass() { return ColumnReorderCommand.class; } @Override protected boolean doCommand(ColumnReorderCommand command) { int fromColumnPosition = command.getFromColumnPosition(); int toColumnPosition = command.getToColumnPosition(); if (fromColumnPosition == -1 || toColumnPosition == -1) { System.err.println("Invalid reorder positions, fromPosition: " + fromColumnPosition + ", toPosition: " + toColumnPosition); } ILayer underlyingLayer = columnGroupReorderLayer.getUnderlyingLayer(); int fromColumnIndex = underlyingLayer.getColumnIndexByPosition(fromColumnPosition); int toColumnIndex = underlyingLayer.getColumnIndexByPosition(toColumnPosition); MoveDirectionEnum moveDirection = ColumnGroupUtils.getMoveDirection(fromColumnPosition, toColumnPosition); String leftEdgeGroupName = null; String rightEdgeGroupName = null; if (MoveDirectionEnum.RIGHT == moveDirection) { rightEdgeGroupName = movedToLeftEdgeOfAGroup(toColumnPosition, toColumnIndex); } if (MoveDirectionEnum.LEFT == moveDirection) { leftEdgeGroupName = movedToRightEdgeOfAGroup(toColumnPosition, toColumnIndex); } if(updateModel(fromColumnIndex, toColumnIndex, leftEdgeGroupName, rightEdgeGroupName)){ return underlyingLayer.doCommand(command); }else{ return false; } } private boolean updateModel(int fromColumnIndex, int toColumnIndex, String leftEdgeGroupName, String rightEdgeGroupName) { // If moved to the RIGHT edge of a group - remove from group if (rightEdgeGroupName != null) { return (model.isPartOfAGroup(fromColumnIndex)) ? model.removeColumnFromGroup(fromColumnIndex) : true; } // If moved to the LEFT edge of a column group - include in the group if (leftEdgeGroupName != null) { boolean removed = true; if (model.isPartOfAGroup(fromColumnIndex)){ removed = model.removeColumnFromGroup(fromColumnIndex); } return removed && model.insertColumnIndexes(leftEdgeGroupName, fromColumnIndex); } // Move column INTO a group if (model.isPartOfAGroup(toColumnIndex) && !model.isPartOfAGroup(fromColumnIndex)) { String groupName = model.getColumnGroupNameForIndex(toColumnIndex); return model.insertColumnIndexes(groupName, fromColumnIndex); } // Move column OUT of a group if (model.isPartOfAGroup(fromColumnIndex) && !model.isPartOfAGroup(toColumnIndex)) { return model.removeColumnFromGroup(fromColumnIndex); } // Move column BETWEEN groups if (model.isPartOfAGroup(toColumnIndex) && model.isPartOfAGroup(fromColumnIndex)) { String toGroupName = model.getColumnGroupNameForIndex(toColumnIndex); String fromGroupName = model.getColumnGroupNameForIndex(fromColumnIndex); if (fromGroupName.equals(toGroupName)) { return true; } else { return model.removeColumnFromGroup(fromColumnIndex) && model.insertColumnIndexes(toGroupName, fromColumnIndex); } } return true; } private String movedToRightEdgeOfAGroup(int dropColumnPosition, int dropColumnIndex){ if(ColumnGroupUtils.isRightEdgeOfAColumnGroup(columnGroupReorderLayer, dropColumnPosition, dropColumnIndex, model)){ return model.getColumnGroupNameForIndex(dropColumnIndex); } return null; } private String movedToLeftEdgeOfAGroup(int dropColumnPosition, int dropColumnIndex){ if(ColumnGroupUtils.isLeftEdgeOfAColumnGroup(columnGroupReorderLayer, dropColumnPosition, dropColumnIndex, model)){ return model.getColumnGroupNameForIndex(dropColumnIndex); } return null; } }
4,595
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ReorderColumnGroupCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/ReorderColumnGroupCommandHandler.java
package net.sourceforge.nattable.group.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.group.ColumnGroupReorderLayer; public class ReorderColumnGroupCommandHandler extends AbstractLayerCommandHandler<ReorderColumnGroupCommand> { private final ColumnGroupReorderLayer columnGroupReorderLayer; public ReorderColumnGroupCommandHandler(ColumnGroupReorderLayer columnGroupReorderLayer) { this.columnGroupReorderLayer = columnGroupReorderLayer; } public Class<ReorderColumnGroupCommand> getCommandClass() { return ReorderColumnGroupCommand.class; } @Override protected boolean doCommand(ReorderColumnGroupCommand command) { int fromColumnPosition = command.getFromColumnPosition(); int toColumnPosition = command.getToColumnPosition(); return columnGroupReorderLayer.reorderColumnGroup(fromColumnPosition, toColumnPosition); } }
914
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ReorderColumnGroupCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/ReorderColumnGroupCommand.java
package net.sourceforge.nattable.group.command; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.reorder.command.ColumnReorderCommand; public class ReorderColumnGroupCommand extends ColumnReorderCommand { public ReorderColumnGroupCommand(ILayer layer, int fromColumnPosition, int toColumnPosition) { super(layer, fromColumnPosition, toColumnPosition); } public ReorderColumnGroupCommand(ReorderColumnGroupCommand command) { super(command); } @Override public ReorderColumnGroupCommand cloneCommand() { return new ReorderColumnGroupCommand(this); } }
619
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupExpandCollapseCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/ColumnGroupExpandCollapseCommand.java
package net.sourceforge.nattable.group.command; import net.sourceforge.nattable.command.AbstractColumnCommand; import net.sourceforge.nattable.layer.ILayer; public class ColumnGroupExpandCollapseCommand extends AbstractColumnCommand { public ColumnGroupExpandCollapseCommand(ILayer layer, int columnPosition) { super(layer, columnPosition); } protected ColumnGroupExpandCollapseCommand(ColumnGroupExpandCollapseCommand command) { super(command); } public ColumnGroupExpandCollapseCommand cloneCommand() { return new ColumnGroupExpandCollapseCommand(this); } }
600
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupExpandCollapseCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/ColumnGroupExpandCollapseCommandHandler.java
package net.sourceforge.nattable.group.command; import java.util.ArrayList; import java.util.List; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.group.ColumnGroupExpandCollapseLayer; import net.sourceforge.nattable.group.ColumnGroupModel; import net.sourceforge.nattable.group.ColumnGroupModel.ColumnGroup; import net.sourceforge.nattable.hideshow.event.HideColumnPositionsEvent; import net.sourceforge.nattable.hideshow.event.ShowColumnPositionsEvent; import net.sourceforge.nattable.layer.event.ILayerEvent; public class ColumnGroupExpandCollapseCommandHandler extends AbstractLayerCommandHandler<ColumnGroupExpandCollapseCommand> { private final ColumnGroupExpandCollapseLayer columnGroupExpandCollapseLayer; public ColumnGroupExpandCollapseCommandHandler(ColumnGroupExpandCollapseLayer columnGroupExpandCollapseLayer) { this.columnGroupExpandCollapseLayer = columnGroupExpandCollapseLayer; } public Class<ColumnGroupExpandCollapseCommand> getCommandClass() { return ColumnGroupExpandCollapseCommand.class; } @Override protected boolean doCommand(ColumnGroupExpandCollapseCommand command) { int columnIndex = columnGroupExpandCollapseLayer.getColumnIndexByPosition(command.getColumnPosition()); ColumnGroupModel model = columnGroupExpandCollapseLayer.getModel(); boolean wasCollapsed = model.isCollapsed(columnIndex); ColumnGroup columnGroup = model.toggleColumnGroupExpandCollapse(columnIndex); List<Integer> columnPositions = new ArrayList<Integer>(columnGroup.getMembers()); columnPositions.remove(0); ILayerEvent event; if (wasCollapsed) { event = new ShowColumnPositionsEvent(columnGroupExpandCollapseLayer, columnPositions); } else { event = new HideColumnPositionsEvent(columnGroupExpandCollapseLayer, columnPositions); } columnGroupExpandCollapseLayer.fireLayerEvent(event); return true; } }
1,921
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
OpenCreateColumnGroupDialog.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/OpenCreateColumnGroupDialog.java
package net.sourceforge.nattable.group.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; import net.sourceforge.nattable.group.gui.CreateColumnGroupDialog; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; public class OpenCreateColumnGroupDialog extends AbstractContextFreeCommand implements IColumnGroupCommand { private final CreateColumnGroupDialog dialog; private final MessageBox messageBox; public OpenCreateColumnGroupDialog(Shell parentShell) { this.dialog = CreateColumnGroupDialog.createColumnGroupDialog(parentShell); messageBox = new MessageBox(parentShell, SWT.INHERIT_DEFAULT | SWT.ICON_ERROR | SWT.OK); } public CreateColumnGroupDialog getDialog() { return dialog; } public void openDialog(ILayer contextLayer) { dialog.setContextLayer(contextLayer); dialog.open(); } public void openErrorBox(String errMessage) { messageBox.setText("Error Message"); messageBox.setMessage(errMessage); messageBox.open(); } }
1,133
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupsCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/ColumnGroupsCommandHandler.java
package net.sourceforge.nattable.group.command; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.group.ColumnGroupHeaderLayer; import net.sourceforge.nattable.group.ColumnGroupModel; import net.sourceforge.nattable.group.ColumnGroupUtils; import net.sourceforge.nattable.group.event.GroupColumnsEvent; import net.sourceforge.nattable.group.event.UngroupColumnsEvent; import net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand; import net.sourceforge.nattable.selection.SelectionLayer; public class ColumnGroupsCommandHandler extends AbstractLayerCommandHandler<IColumnGroupCommand> { private final ColumnGroupModel model; private final SelectionLayer selectionLayer; private final ColumnGroupHeaderLayer contextLayer; private Map<Integer, Integer> columnIndexesToPositionsMap; public ColumnGroupsCommandHandler(ColumnGroupModel model, SelectionLayer selectionLayer, ColumnGroupHeaderLayer contextLayer) { this.model = model; this.selectionLayer = selectionLayer; this.contextLayer = contextLayer; } public boolean doCommand(IColumnGroupCommand command) { if (command instanceof CreateColumnGroupCommand) { if (columnIndexesToPositionsMap.size() > 0) { handleGroupColumnsCommand(((CreateColumnGroupCommand)command).getColumnGroupName()); columnIndexesToPositionsMap.clear(); return true; } } else if (command instanceof OpenCreateColumnGroupDialog) { OpenCreateColumnGroupDialog openDialogCommand = (OpenCreateColumnGroupDialog)command; loadSelectedColumnsIndexesWithPositions(); if (selectionLayer.getFullySelectedColumnPositions().length > 0 && columnIndexesToPositionsMap.size() > 0) { openDialogCommand.openDialog(contextLayer); } else { openDialogCommand.openErrorBox("Please select non-grouped columns prior to creating a group."); } return true; } else if (command instanceof UngroupColumnCommand) { handleUngroupCommand(); return true; } return false; } public Class<IColumnGroupCommand> getCommandClass() { return IColumnGroupCommand.class; } protected void loadSelectedColumnsIndexesWithPositions() { columnIndexesToPositionsMap = new LinkedHashMap<Integer, Integer>(); int[] fullySelectedColumns = selectionLayer.getFullySelectedColumnPositions(); if (fullySelectedColumns.length > 0) { for (int index = 0; index < fullySelectedColumns.length; index++) { final int columnPosition = fullySelectedColumns[index]; int columnIndex = selectionLayer.getColumnIndexByPosition(columnPosition); if (model.isPartOfAGroup(columnIndex)){ columnIndexesToPositionsMap.clear(); break; } columnIndexesToPositionsMap.put(Integer.valueOf(columnIndex), Integer.valueOf(columnPosition)); } } } public void handleGroupColumnsCommand(String columnGroupName) { try { List<Integer> selectedPositions = new ArrayList<Integer>(); int[] fullySelectedColumns = new int[columnIndexesToPositionsMap.size()]; int count = 0; for (Integer columnIndex : columnIndexesToPositionsMap.keySet()) { fullySelectedColumns[count++] = columnIndex.intValue(); selectedPositions.add(columnIndexesToPositionsMap.get(columnIndex)); } model.addColumnsIndexesToGroup(columnGroupName, fullySelectedColumns); selectionLayer.doCommand(new MultiColumnReorderCommand(selectionLayer, selectedPositions, selectedPositions.get(0).intValue())); selectionLayer.clear(); } catch (Throwable t) { } contextLayer.fireLayerEvent(new GroupColumnsEvent(contextLayer)); } public void handleUngroupCommand() { // Grab fully selected column positions int[] fullySelectedColumns = selectionLayer.getFullySelectedColumnPositions(); Map<String, Integer> toColumnPositions = new HashMap<String, Integer>(); if (fullySelectedColumns.length > 0) { // Pick the ones which belong to a group and remove them from the group for (int index = 0; index < fullySelectedColumns.length; index++) { final int columnPosition = fullySelectedColumns[index]; int columnIndex = selectionLayer.getColumnIndexByPosition(columnPosition); if (model.isPartOfAGroup(columnIndex) && !model.isPartOfAnUnbreakableGroup(columnIndex)){ handleRemovalFromGroup(toColumnPositions, columnIndex); } } // The groups which were affected should be reordered to the start position, this should group all columns together Collection<Integer> values = toColumnPositions.values(); final Iterator<Integer> toColumnPositionsIterator = values.iterator(); while(toColumnPositionsIterator.hasNext()) { Integer toColumnPosition = toColumnPositionsIterator.next(); selectionLayer.doCommand(new ReorderColumnGroupCommand(selectionLayer, toColumnPosition.intValue(), toColumnPosition.intValue())); } selectionLayer.clear(); } contextLayer.fireLayerEvent(new UngroupColumnsEvent(contextLayer)); } private void handleRemovalFromGroup(Map<String, Integer> toColumnPositions, int columnIndex) { final String columnGroupName = model.getColumnGroupNameForIndex(columnIndex); final List<Integer> columnIndexesInGroup = model.getColumnIndexesInGroup(columnIndex); final int columnGroupSize = columnIndexesInGroup.size(); if (!toColumnPositions.containsKey(columnGroupName)) { for (int colGroupIndex : columnIndexesInGroup) { if (ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(colGroupIndex, contextLayer, selectionLayer, model)) { int toPosition = selectionLayer.getColumnPositionByIndex(colGroupIndex); if (colGroupIndex == columnIndex) { if (columnGroupSize == 1) { break; } else { toPosition++; } } toColumnPositions.put(columnGroupName, Integer.valueOf(toPosition)); break; } } } else { if (columnGroupSize - 1 <= 0) { toColumnPositions.remove(columnGroupName); } } model.removeColumnFromGroup(columnIndex); } }
6,274
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ReorderColumnsAndGroupsCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/ReorderColumnsAndGroupsCommand.java
package net.sourceforge.nattable.group.command; import java.util.List; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand; /** * Reorder single multiple columns and column groups in one shot. * - Needed by the column chooser */ public class ReorderColumnsAndGroupsCommand extends MultiColumnReorderCommand { /** * If any of the fromColumnPositions contain a group * - the group will be moved. */ public ReorderColumnsAndGroupsCommand(ILayer layer, List<Integer> fromColumnPositions, int toColumnPositions) { super(layer, fromColumnPositions, toColumnPositions); } }
683
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ReorderColumnsAndGroupsCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/ReorderColumnsAndGroupsCommandHandler.java
package net.sourceforge.nattable.group.command; import java.util.ArrayList; import java.util.List; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.group.ColumnGroupModel; import net.sourceforge.nattable.group.ColumnGroupReorderLayer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand; public class ReorderColumnsAndGroupsCommandHandler extends AbstractLayerCommandHandler<ReorderColumnsAndGroupsCommand> { private final ColumnGroupReorderLayer columnGroupReorderLayer; public ReorderColumnsAndGroupsCommandHandler(ColumnGroupReorderLayer columnGroupReorderLayer) { this.columnGroupReorderLayer = columnGroupReorderLayer; } public Class<ReorderColumnsAndGroupsCommand> getCommandClass() { return ReorderColumnsAndGroupsCommand.class; } /** * Check if any column belongs to a group. If yes, add all columns in that group. * Assumes that the 'toLocation' is not inside another group */ @Override protected boolean doCommand(ReorderColumnsAndGroupsCommand command) { final ILayer underlyingLayer = columnGroupReorderLayer.getUnderlyingLayer(); List<String> groupsProcessed = new ArrayList<String>(); List<Integer> fromColumnPositions = command.getFromColumnPositions(); List<Integer> fromColumnPositionsWithGroupColumns = new ArrayList<Integer>(); for (Integer fromColumnPosition : fromColumnPositions) { int fromColumnIndex = underlyingLayer.getColumnIndexByPosition(fromColumnPosition.intValue()); ColumnGroupModel model = columnGroupReorderLayer.getModel(); if (model.isPartOfAGroup(fromColumnIndex)) { String groupName = model.getColumnGroupNameForIndex(fromColumnIndex); if (!groupsProcessed.contains(groupName)) { groupsProcessed.add(groupName); fromColumnPositionsWithGroupColumns.addAll(columnGroupReorderLayer.getColumnGroupPositions(fromColumnIndex)); } } else { fromColumnPositionsWithGroupColumns.add(fromColumnPosition); } } return underlyingLayer.doCommand(new MultiColumnReorderCommand(columnGroupReorderLayer, fromColumnPositionsWithGroupColumns, command.getToColumnPosition())); } }
2,215
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
IColumnGroupCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/IColumnGroupCommand.java
package net.sourceforge.nattable.group.command; import net.sourceforge.nattable.command.ILayerCommand; /** * Marker interface for all column group related commands * */ public interface IColumnGroupCommand extends ILayerCommand { }
252
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
UngroupColumnCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/UngroupColumnCommand.java
package net.sourceforge.nattable.group.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; public class UngroupColumnCommand extends AbstractContextFreeCommand implements IColumnGroupCommand { }
228
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
GroupMultiColumnReorderCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/command/GroupMultiColumnReorderCommandHandler.java
package net.sourceforge.nattable.group.command; import java.util.List; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.group.ColumnGroupModel; import net.sourceforge.nattable.group.ColumnGroupReorderLayer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand; public class GroupMultiColumnReorderCommandHandler extends AbstractLayerCommandHandler<MultiColumnReorderCommand> { private final ColumnGroupReorderLayer columnGroupReorderLayer; public GroupMultiColumnReorderCommandHandler(ColumnGroupReorderLayer columnGroupReorderLayer) { this.columnGroupReorderLayer = columnGroupReorderLayer; } public Class<MultiColumnReorderCommand> getCommandClass() { return MultiColumnReorderCommand.class; } @Override protected boolean doCommand(MultiColumnReorderCommand command) { int toColumnPosition = command.getToColumnPosition(); ILayer underlyingLayer = columnGroupReorderLayer.getUnderlyingLayer(); int toColumnIndex = underlyingLayer.getColumnIndexByPosition(toColumnPosition); List<Integer> fromColumnPositions = command.getFromColumnPositions(); ColumnGroupModel model = columnGroupReorderLayer.getModel(); if (updateModel(underlyingLayer, toColumnIndex, fromColumnPositions, model)) { return underlyingLayer.doCommand(command); } else { return false; } } private boolean updateModel(ILayer underlyingLayer, int toColumnIndex, List<Integer> fromColumnPositions, ColumnGroupModel model) { // Moving INTO a group if (model.isPartOfAGroup(toColumnIndex)) { String toGroupName = model.getColumnGroupNameForIndex(toColumnIndex); if (model.isPartOfAnUnbreakableGroup(toColumnIndex)) { return false; } for (Integer fromColumnPosition : fromColumnPositions) { int fromColumnIndex = underlyingLayer.getColumnIndexByPosition(fromColumnPosition.intValue()); // If 'from' index not already present in the 'to' group if (!toGroupName.equals(model.getColumnGroupNameForIndex(fromColumnIndex))) { model.removeColumnFromGroup(fromColumnIndex); model.addColumnsIndexesToGroup(toGroupName, fromColumnIndex); } } return true; } // Moving OUT OF a group if (!model.isPartOfAGroup(toColumnIndex)) { for (Integer fromColumnPosition : fromColumnPositions) { // Remove from model - if present int fromColumnIndex = underlyingLayer.getColumnIndexByPosition(fromColumnPosition.intValue()); if (model.isPartOfAGroup(fromColumnIndex) && !model.removeColumnFromGroup(fromColumnIndex)) { return false; } } return true; } return true; } }
2,690
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupHeaderTextPainter.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/painter/ColumnGroupHeaderTextPainter.java
package net.sourceforge.nattable.group.painter; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.group.ColumnGroupModel; import net.sourceforge.nattable.layer.cell.LayerCell; import net.sourceforge.nattable.painter.cell.CellPainterWrapper; import net.sourceforge.nattable.painter.cell.ICellPainter; import net.sourceforge.nattable.painter.cell.ImagePainter; import net.sourceforge.nattable.painter.cell.TextPainter; import net.sourceforge.nattable.painter.cell.decorator.CellPainterDecorator; import net.sourceforge.nattable.ui.util.CellEdgeEnum; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; public class ColumnGroupHeaderTextPainter extends CellPainterWrapper { /** Needed to query column group cell expand/collapse state */ private final ColumnGroupModel columnGroupModel; public ColumnGroupHeaderTextPainter(ColumnGroupModel columnGroupModel) { this.columnGroupModel = columnGroupModel; setWrappedPainter(new CellPainterDecorator( new TextPainter(), CellEdgeEnum.RIGHT, new ExpandCollapseImagePainter())); } /** * @param columnGroupModel Column group model used by the grid * @param interiorPainter for painting the text portion * @param imagePainter for painting the icon image on the right */ public ColumnGroupHeaderTextPainter(ColumnGroupModel columnGroupModel, ICellPainter interiorPainter) { this.columnGroupModel = columnGroupModel; setWrappedPainter(new CellPainterDecorator(interiorPainter, CellEdgeEnum.RIGHT, new ExpandCollapseImagePainter())); } /** * Preferred width is used during auto resize. * Column groups do not participate in auto resize, since auto resizing is * done by the column width. Hence, always return 0 */ @Override public int getPreferredWidth(LayerCell cell, GC gc, IConfigRegistry configRegistry) { return 0; } public class ExpandCollapseImagePainter extends ImagePainter { final Image rightImg = GUIHelper.getImage("right"); final Image leftImg = GUIHelper.getImage("left"); public ExpandCollapseImagePainter() { super(null, false); } @Override protected Image getImage(LayerCell cell, IConfigRegistry configRegistry) { String cellValue = cell.getDataValue().toString(); if (columnGroupModel.isAGroup(cellValue)) { return columnGroupModel.isCollapsed(cellValue) ? rightImg : leftImg; } else { return null; } } } }
2,527
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
GroupColumnsEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/event/GroupColumnsEvent.java
package net.sourceforge.nattable.group.event; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.event.VisualRefreshEvent; public class GroupColumnsEvent extends VisualRefreshEvent { public GroupColumnsEvent(ILayer layer) { super(layer); } protected GroupColumnsEvent(GroupColumnsEvent event) { super(event); } public GroupColumnsEvent cloneEvent() { return new GroupColumnsEvent(this); } }
463
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
UngroupColumnsEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/group/event/UngroupColumnsEvent.java
package net.sourceforge.nattable.group.event; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.event.VisualRefreshEvent; public class UngroupColumnsEvent extends VisualRefreshEvent { public UngroupColumnsEvent(ILayer layer) { super(layer); } protected UngroupColumnsEvent(UngroupColumnsEvent event) { super(event); } public UngroupColumnsEvent cloneEvent() { return new UngroupColumnsEvent(this); } }
475
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectionLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/SelectionLayer.java
package net.sourceforge.nattable.selection; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Set; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.coordinate.PositionCoordinate; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.copy.command.CopyDataCommandHandler; import net.sourceforge.nattable.edit.command.EditSelectionCommandHandler; import net.sourceforge.nattable.grid.command.InitializeAutoResizeColumnsCommandHandler; import net.sourceforge.nattable.grid.command.InitializeAutoResizeRowsCommandHandler; import net.sourceforge.nattable.hideshow.command.ColumnHideCommand; import net.sourceforge.nattable.hideshow.command.MultiColumnHideCommand; import net.sourceforge.nattable.layer.AbstractLayerTransform; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.painter.layer.ILayerPainter; import net.sourceforge.nattable.resize.command.ColumnResizeCommand; import net.sourceforge.nattable.resize.command.MultiColumnResizeCommand; import net.sourceforge.nattable.resize.command.MultiRowResizeCommand; import net.sourceforge.nattable.resize.command.RowResizeCommand; import net.sourceforge.nattable.search.command.SearchGridCellsCommandHandler; import net.sourceforge.nattable.selection.command.ClearAllSelectionsCommand; import net.sourceforge.nattable.selection.command.SelectAllCommand; import net.sourceforge.nattable.selection.config.DefaultSelectionLayerConfiguration; import net.sourceforge.nattable.selection.event.CellSelectionEvent; import net.sourceforge.nattable.selection.event.SelectionLayerStructuralChangeEventHandler; import net.sourceforge.nattable.style.DisplayMode; import net.sourceforge.nattable.style.SelectionStyleLabels; import org.eclipse.swt.graphics.Rectangle; /** * Enables selection of column, rows, cells etc. on the table. * Also responds to UI bindings by changing the current selection. * Internally it uses the {@link ISelectionModel} to track the selection state.<br/> * * @see DefaultSelectionLayerConfiguration * @see MoveDirectionEnum */ public class SelectionLayer extends AbstractLayerTransform implements IUniqueIndexLayer { public static final int MOVE_ALL = -1; private static final int NO_SELECTION = -1; public enum MoveDirectionEnum { UP, DOWN, LEFT, RIGHT, NONE; } protected ISelectionModel selectionModel; protected IUniqueIndexLayer underlyingLayer; protected final PositionCoordinate lastSelectedCell; protected final PositionCoordinate selectionAnchor; protected Rectangle lastSelectedRegion; private final SelectRowCommandHandler selectRowCommandHandler; private final SelectCellCommandHandler selectCellCommandHandler; private final SelectColumnCommandHandler selectColumnCommandHandler; public SelectionLayer(IUniqueIndexLayer underlyingLayer) { this(underlyingLayer, new SelectionModel(), true); } public SelectionLayer(IUniqueIndexLayer underlyingLayer, boolean useDefaultConfiguration) { this(underlyingLayer, new SelectionModel(), useDefaultConfiguration); } public SelectionLayer(IUniqueIndexLayer underlyingLayer, ISelectionModel selectionModel, boolean useDefaultConfiguration) { super(underlyingLayer); this.underlyingLayer = underlyingLayer; setLayerPainter(new SelectionLayerPainter()); this.selectionModel = selectionModel; lastSelectedCell = new PositionCoordinate(this, NO_SELECTION, NO_SELECTION); selectionAnchor = new PositionCoordinate(this, NO_SELECTION, NO_SELECTION); selectRowCommandHandler = new SelectRowCommandHandler(this); selectCellCommandHandler = new SelectCellCommandHandler(this); selectColumnCommandHandler = new SelectColumnCommandHandler(this); registerCommandHandlers(); registerEventHandler(new SelectionLayerStructuralChangeEventHandler(this, selectionModel)); if (useDefaultConfiguration) { addConfiguration(new DefaultSelectionLayerConfiguration()); } } public void setSelectionModel(ISelectionModel selectionModel) { this.selectionModel = selectionModel; } @Override public ILayerPainter getLayerPainter() { return layerPainter; } public int getColumnPositionByIndex(int columnIndex) { return underlyingLayer.getColumnPositionByIndex(columnIndex); } // Column features public boolean hasColumnSelection() { return lastSelectedCell.columnPosition != NO_SELECTION; } public boolean isColumnPositionSelected(int columnPosition) { return selectionModel.isColumnPositionSelected(columnPosition); } public int[] getSelectedColumns() { return selectionModel.getSelectedColumns(); } public int[] getFullySelectedColumnPositions(){ return selectionModel.getFullySelectedColumns(getRowCount()); } public int[] getFullySelectedColumns() { return selectionModel.getFullySelectedColumns(getRowCount()); } public boolean isColumnFullySelected(int columnPosition) { return selectionModel.isColumnFullySelected(columnPosition, getRowCount()); } public void selectColumn(int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask){ selectColumnCommandHandler.selectColumn(columnPosition, rowPosition, withShiftMask, withControlMask); } // Cell features public boolean isCellPositionSelected(int columnPosition, int rowPosition) { return selectionModel.isCellPositionSelected(columnPosition, rowPosition); } public void setSelectedCell(int columnPosition, int rowPosition) { selectCell(columnPosition, rowPosition, false, false); } /** * When extending a selected area we need to start adding cells from the last selected cell. * If we are not extending a selection we need to move from the selection <i>anchor</i>. */ protected PositionCoordinate getCellPositionToMoveFrom(boolean withShiftMask, boolean withControlMask) { return (!withShiftMask && !withControlMask) ? getSelectionAnchor() : getLastSelectedCellPosition(); } public PositionCoordinate[] getSelectedCells() { int[] selectedColumnPositions = getSelectedColumns(); Set<Range> selectedRowPositions = getSelectedRows(); List<PositionCoordinate> selectedCells = new LinkedList<PositionCoordinate>(); for (int columnPositionIndex = 0; columnPositionIndex < selectedColumnPositions.length; columnPositionIndex++) { final int columnPosition = selectedColumnPositions[columnPositionIndex]; for (Range rowIndexRange : selectedRowPositions) { for (int rowPositionIndex = rowIndexRange.start; rowPositionIndex < rowIndexRange.end; rowPositionIndex++) { if (selectionModel.isCellPositionSelected(columnPosition, rowPositionIndex)) { selectedCells.add(new PositionCoordinate(this, columnPosition, rowPositionIndex)); } } } } return selectedCells.toArray(new PositionCoordinate[0]); } /** * Calculates the selected cells - taking into account Shift and Ctrl key presses. */ public void selectCell(int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask) { selectCellCommandHandler.selectCell(columnPosition, rowPosition, withShiftMask, withControlMask); } public PositionCoordinate getSelectionAnchor() { return selectionAnchor; } public PositionCoordinate getLastSelectedCellPosition() { if (lastSelectedCell.columnPosition != NO_SELECTION && lastSelectedCell.rowPosition != NO_SELECTION) { return lastSelectedCell; } else { return null; } } protected void setLastSelectedCell(int columnPosition, int rowPosition) { lastSelectedCell.columnPosition = columnPosition; lastSelectedCell.rowPosition = rowPosition; } // Row features public boolean hasRowSelection() { return lastSelectedCell.rowPosition != NO_SELECTION; } public boolean isRowPositionSelected(int rowPosition) { return selectionModel.isRowPositionSelected(rowPosition); } public boolean isRowFullySelected(int rowPosition) { return selectionModel.isRowFullySelected(rowPosition, getColumnCount()); } public Set<Range> getSelectedRows() { return selectionModel.getSelectedRows(); } public int[] getFullySelectedRowPositions() { return selectionModel.getFullySelectedRows(getColumnCount()); } protected ISelectionModel getSelectionModel() { return selectionModel; } public int getSelectedRowCount() { return selectionModel.getSelectedRowCount(); } public void selectRow(int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask) { selectRowCommandHandler.selectRows(columnPosition, Arrays.asList(Integer.valueOf(rowPosition)), withShiftMask, withControlMask); } // Clear features public void clear() { selectionModel.clearSelection(); lastSelectedCell.columnPosition = -1; lastSelectedCell.rowPosition = -1; lastSelectedRegion = new Rectangle(0,0,0,0); selectionAnchor.columnPosition = -1; selectionAnchor.rowPosition = -1; } protected void clearSelection(int columnPosition, int rowPosition) { selectionModel.removeSelection(columnPosition, rowPosition); } protected void clearSelection(Rectangle selection) { selectionModel.removeSelection(selection); } protected void addSelection(Rectangle selection) { if (selection != lastSelectedRegion) { selectionAnchor.columnPosition = lastSelectedCell.columnPosition; selectionAnchor.rowPosition = lastSelectedCell.rowPosition; lastSelectedRegion = selection; } selectionModel.addSelection(selection); } public void selectAll() { Rectangle selection = new Rectangle(0, 0, getColumnCount(), getRowCount()); addSelection(selection); fireCellSelectionEvent(lastSelectedCell.columnPosition, lastSelectedCell.rowPosition, false, false, false); } // ILayer methods public int getRowPositionByIndex(int rowIndex) { return underlyingLayer.getRowPositionByIndex(rowIndex); } @Override public String getDisplayModeByPosition(int columnPosition, int rowPosition) { if (isCellPositionSelected(columnPosition, rowPosition)) { return DisplayMode.SELECT; } else { return super.getDisplayModeByPosition(columnPosition, rowPosition); } } @Override public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) { LabelStack labelStack = super.getConfigLabelsByPosition(columnPosition, rowPosition); if (selectionAnchor.columnPosition == columnPosition && selectionAnchor.rowPosition == rowPosition) { labelStack.addLabel(SelectionStyleLabels.SELECTION_ANCHOR_STYLE); } return labelStack; } // Command handling private void registerCommandHandlers() { // Command handlers also registered by the DefaultSelectionLayerConfiguration registerCommandHandler(selectCellCommandHandler); registerCommandHandler(selectRowCommandHandler); registerCommandHandler(selectColumnCommandHandler); registerCommandHandler(new EditSelectionCommandHandler(this)); registerCommandHandler(new InitializeAutoResizeColumnsCommandHandler(this)); registerCommandHandler(new InitializeAutoResizeRowsCommandHandler(this)); registerCommandHandler(new CopyDataCommandHandler(this)); registerCommandHandler(new SearchGridCellsCommandHandler(this)); } @Override public boolean doCommand(ILayerCommand command) { if (command instanceof SelectAllCommand && command.convertToTargetLayer(this)) { selectAll(); return true; } else if (command instanceof ClearAllSelectionsCommand && command.convertToTargetLayer(this)) { clear(); return true; } else if (command instanceof MultiColumnHideCommand && command.convertToTargetLayer(this)) { return hideMultipleColumnPositions((MultiColumnHideCommand)command); } else if (command instanceof ColumnHideCommand && command.convertToTargetLayer(this)) { return hideColumnPosition((ColumnHideCommand)command); } else if (command instanceof ColumnResizeCommand && command.convertToTargetLayer(this)) { return handleColumnResizeCommand((ColumnResizeCommand) command); } else if (command instanceof RowResizeCommand && command.convertToTargetLayer(this)) { return handleRowResizeCommand((RowResizeCommand) command); } return super.doCommand(command); } /** * Any selected columns will be hidden. A column is considered selected even if a cell is selected. */ protected boolean hideMultipleColumnPositions(MultiColumnHideCommand command) { for (int columnPosition : command.getColumnPositions()) { if (isColumnFullySelected(columnPosition)) { Rectangle selection = new Rectangle(columnPosition, 0, 1, getRowCount()); clearSelection(selection); } } return super.doCommand(command); } protected boolean hideColumnPosition(ColumnHideCommand command) { if (isColumnFullySelected(command.getColumnPosition())) { return super.doCommand(new MultiColumnHideCommand(this, getFullySelectedColumnPositions())); } else { return super.doCommand(command); } } /** * This method will check to see if the column to resize is part of the selection model, if it is, it will create a * new MultiResizeColumnCommand and pass it. * @param command */ protected boolean handleColumnResizeCommand(ColumnResizeCommand command) { if (isColumnFullySelected(command.getColumnPosition())) { return super.doCommand(new MultiColumnResizeCommand(this, selectionModel.getFullySelectedColumns(getRowCount()), command.getNewColumnWidth())); } else { return super.doCommand(command); } } protected boolean handleRowResizeCommand(RowResizeCommand command) { if (isRowFullySelected(command.getRowPosition())) { return super.doCommand(new MultiRowResizeCommand(this, selectionModel.getFullySelectedRows(getColumnCount()), command.getNewHeight())); } else { return super.doCommand(command); } } protected void selectRegion(int startColumnPosition, int startRowPosition, int regionWidth, int regionHeight) { if (lastSelectedRegion == null) { lastSelectedRegion = new Rectangle(startColumnPosition, startRowPosition, regionWidth, regionHeight); } else { lastSelectedRegion.x = startColumnPosition; lastSelectedRegion.y = startRowPosition; lastSelectedRegion.width = regionWidth; lastSelectedRegion.height = regionHeight; } selectionModel.addSelection(lastSelectedRegion); } public void moveSelectionAnchor(int startColumnPositionInRegion, int startRowPosition) { selectionAnchor.columnPosition = startColumnPositionInRegion; selectionAnchor.rowPosition = startRowPosition; } public void fireCellSelectionEvent(int columnPosition, int rowPosition, boolean forcingEntireCellIntoViewport, boolean withShiftMask, boolean withControlMask) { final CellSelectionEvent selectionEvent = new CellSelectionEvent(this, columnPosition, rowPosition, forcingEntireCellIntoViewport, withShiftMask, withControlMask); fireLayerEvent(selectionEvent); } }
15,189
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectionModel.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/SelectionModel.java
package net.sourceforge.nattable.selection; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.TreeSet; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.util.ObjectUtils; import org.apache.commons.lang.ArrayUtils; import org.eclipse.swt.graphics.Rectangle; /** * Tracks the selections made in the table. All selections are tracked in terms of * Rectangles. * * For example if the table has 10 rows and column 2 is selected, the * Rectangle tracked is (0, 2, 10, 1) * * Coordinates are in <i>Selection Layer positions</i> * * @see SelectionLayer */ public class SelectionModel implements ISelectionModel { private final List<Rectangle> selections; private final ReadWriteLock selectionsLock; public SelectionModel() { selections = new LinkedList<Rectangle>(); selectionsLock = new ReentrantReadWriteLock(); } public boolean isCellPositionSelected(int columnPosition, int rowPosition) { selectionsLock.readLock().lock(); try { for (Rectangle r : selections) { if (r.contains(columnPosition, rowPosition)) return true; } } finally { selectionsLock.readLock().unlock(); } return false; } public boolean isRowPositionSelected(int rowPosition) { selectionsLock.readLock().lock(); try { for (Range rowRange : getSelectedRows()) { if (rowRange.contains(rowPosition)) { return true; } } } finally { selectionsLock.readLock().unlock(); } return false; } /** * @see #isColumnFullySelected(int, int) */ public boolean isRowFullySelected(int rowPosition, int rowWidth) { selectionsLock.readLock().lock(); try { // Aggregate all rectangles in the row which are in the selection model List<Rectangle> selectedRectanglesInRow = new ArrayList<Rectangle>(); // If X is same add up the width of the selected area for (Rectangle r : selections) { // Row is within the bounds of the selcted rectangle if (rowPosition >= r.y && rowPosition < r.y + r.height) { selectedRectanglesInRow.add(new Rectangle(r.x, rowPosition, r.width, 1)); } } if (selectedRectanglesInRow.isEmpty()) { return false; } sortByX(selectedRectanglesInRow); Rectangle finalRectangle = new Rectangle(selectedRectanglesInRow.get(0).x, rowPosition, 0, 0); // Ensure that selections in the row are contiguous and cover the entire row for (int i = 0; i < selectedRectanglesInRow.size(); i++) { Rectangle rectangle = selectedRectanglesInRow.get(i); if(contains(finalRectangle, rectangle)){ continue; } if (i > 0) { Rectangle previousRect = selectedRectanglesInRow.get(i - 1); if (rectangle.union(previousRect).width > (rectangle.width + previousRect.width)) { // Rectangles not contiguous return false; } } // Union will resolve any overlaping area finalRectangle = finalRectangle.union(rectangle); } return finalRectangle.width == rowWidth; } finally { selectionsLock.readLock().unlock(); } } /** * @return TRUE if <i>rectangle</i> is completely contained inside <i>containerRectangle</i> */ protected boolean contains(Rectangle containerRectangle, Rectangle rectangle) { Rectangle union = containerRectangle.union(rectangle); return union.equals(containerRectangle); } /** * Is a cell in this column selected ? */ public boolean isColumnPositionSelected(int columnPosition) { selectionsLock.readLock().lock(); try { for (int column : getSelectedColumns()) { if (column == columnPosition) { return true; } } } finally { selectionsLock.readLock().unlock(); } return false; } /** * Are all cells in this column selected ? * Different selection rectangles might aggregate to cover the entire column. * We need to take into account any overlapping selections or any selection rectangles * contained within each other. * * @see the related tests for a better understanding. */ public boolean isColumnFullySelected(int columnPosition, int fullySelectedColumnRowCount) { selectionsLock.readLock().lock(); try { // Aggregate all rectangles in the column which are in the selection model List<Rectangle> selectedRectanglesInColumn = new ArrayList<Rectangle>(); // If X is same add up the height of the selected area for (Rectangle r : selections) { // Column is within the bounds of the selcted rectangle if (columnPosition >= r.x && columnPosition < r.x + r.width) { selectedRectanglesInColumn.add(new Rectangle(columnPosition, r.y, 1, r.height)); } } if (selectedRectanglesInColumn.isEmpty()) { return false; } sortByY(selectedRectanglesInColumn); Rectangle finalRectangle = new Rectangle(columnPosition, selectedRectanglesInColumn.get(0).y, 0, 0); // Ensure that selections in the column are contiguous and cover the entire column for (int i = 0; i < selectedRectanglesInColumn.size(); i++) { Rectangle rectangle = selectedRectanglesInColumn.get(i); if(contains(finalRectangle, rectangle)){ continue; } if (i > 0) { Rectangle previousRect = selectedRectanglesInColumn.get(i - 1); if (rectangle.union(previousRect).height > (rectangle.height + previousRect.height)) { // Rectangles not contiguous return false; } } // Union will resolve any overlaping area finalRectangle = finalRectangle.union(rectangle); } return finalRectangle.height == fullySelectedColumnRowCount; } finally { selectionsLock.readLock().unlock(); } } protected void sortByX(List<Rectangle> selectionRectanglesInRow) { Collections.sort(selectionRectanglesInRow, new Comparator<Rectangle>(){ public int compare(Rectangle rectangle1, Rectangle rectangle2) { return new Integer(rectangle1.x).compareTo(new Integer(rectangle2.x)) ; } }); } protected void sortByY(List<Rectangle> selectionRectanglesInColumn) { Collections.sort(selectionRectanglesInColumn, new Comparator<Rectangle>(){ public int compare(Rectangle rectangle1, Rectangle rectangle2) { return new Integer(rectangle1.y).compareTo(new Integer(rectangle2.y)) ; } }); } public void addSelection(int columnPosition, int rowPosition) { addSelectionIntoList(new Rectangle(columnPosition, rowPosition, 1, 1)); } public void addSelection(final Rectangle range) { if (range != null) { addSelectionIntoList(range); } } private void addSelectionIntoList(Rectangle selection) { selectionsLock.writeLock().lock(); try { ArrayList<Rectangle> itemsToRemove = null; for (Rectangle r : selections) { if (selection.intersects(r)) { if (r.equals(selection)) { break; } Rectangle intersection = selection.intersection(r); if (intersection.equals(r)) { // r is a subset of intersection if (itemsToRemove == null) itemsToRemove = new ArrayList<Rectangle>(); itemsToRemove.add(r); } else if (intersection.equals(selection)) { // selection is a subset of r break; } } } if (itemsToRemove != null) { selections.removeAll(itemsToRemove); } selections.add(selection); } finally { selectionsLock.writeLock().unlock(); } } public void clearSelection() { selectionsLock.writeLock().lock(); try { selections.clear(); } finally { selectionsLock.writeLock().unlock(); } } public void removeSelection(Rectangle removedSelection) { List<Rectangle> removedItems = new LinkedList<Rectangle>(); List<Rectangle> addedItems = new LinkedList<Rectangle>(); selectionsLock.readLock().lock(); try { for (Rectangle r : selections) { if (r.intersects(removedSelection)) { Rectangle intersection = removedSelection.intersection(r); removedItems.add(r); Rectangle topSelection = getTopSelection(intersection, r); if (topSelection != null) { addedItems.add(topSelection); } Rectangle rightSelection = getRightSelection(intersection, r); if (rightSelection != null) addedItems.add(rightSelection); Rectangle leftSelection = getLeftSelection(intersection, r); if (leftSelection != null) addedItems.add(leftSelection); Rectangle bottomSelection = getBottomSelection(intersection, r); if (bottomSelection != null) addedItems.add(bottomSelection); } } } finally { selectionsLock.readLock().unlock(); } if (removedItems.size() > 0) { selectionsLock.writeLock().lock(); try { selections.removeAll(removedItems); } finally { selectionsLock.writeLock().unlock(); } removedItems.clear(); } if (addedItems.size() > 0) { selectionsLock.writeLock().lock(); try { selections.addAll(addedItems); } finally { selectionsLock.writeLock().unlock(); } addedItems.clear(); } } private Rectangle getLeftSelection(Rectangle intersection, Rectangle selection) { if (intersection.x > selection.x) { Rectangle leftSelection = new Rectangle(selection.x, selection.y, intersection.x - selection.x, selection.height); return leftSelection; } return null; } private Rectangle getRightSelection(Rectangle intersection, Rectangle selection) { int newX = intersection.x + intersection.width; if (newX < selection.x + selection.width) { Rectangle rightSelection = new Rectangle(newX, selection.y, selection.x + selection.width - newX, selection.height); return rightSelection; } return null; } private Rectangle getTopSelection(Rectangle intersection, Rectangle selectoin) { if (intersection.y > selectoin.y) { Rectangle topSelection = new Rectangle(selectoin.x, selectoin.y, selectoin.width, intersection.y - selectoin.y); return topSelection; } return null; } private Rectangle getBottomSelection(Rectangle intersection, Rectangle selection) { int newY = intersection.y + intersection.height; if (newY < selection.y + selection.height) { Rectangle bottomSelection = new Rectangle(selection.x, newY, selection.width, selection.y + selection.height - newY); return bottomSelection; } return null; } public void removeSelection(int columnPosition, int rowPosition) { removeSelection(new Rectangle(columnPosition, rowPosition, 1, 1)); } public boolean isEmpty() { selectionsLock.readLock().lock(); try { return selections.isEmpty(); } finally { selectionsLock.readLock().unlock(); } } /** * @return all selected rows in the model */ public Set<Range> getSelectedRows() { Set<Range> selectedRowsRange = new HashSet<Range>(); selectionsLock.readLock().lock(); try { for (Rectangle r : selections) { selectedRowsRange.add(new Range(r.y, r.y + r.height)); } } finally { selectionsLock.readLock().unlock(); } ArrayList<Range> ranges = new ArrayList<Range>(selectedRowsRange); Range.sortByStart(ranges); List<Range> uniqueRanges = new ArrayList<Range>(); // Adjust for overlaps - between consecutive selections for(int i=0; i<ranges.size(); i++){ if(i>0){ Range previousRange = ranges.get(i-1); Range currrentRange = ranges.get(i); if(previousRange.overlap(currrentRange)){ int largerRangeEnd = (previousRange.end > currrentRange.end) ? previousRange.end : currrentRange.end; uniqueRanges.get(uniqueRanges.size()-1).end = largerRangeEnd; ranges.get(i).end = largerRangeEnd; }else{ uniqueRanges.add(ranges.get(i)); } } else { uniqueRanges.add(ranges.get(i)); } } return new HashSet<Range>(uniqueRanges); } public int getSelectedRowCount(){ Set<Range> selectedRows = getSelectedRows(); int count = 0; for (Range range : selectedRows) { count += range.end - range.start; } return count; } public int[] getFullySelectedRows(int rowWidth) { final Set<Range> selectedRows = getSelectedRows(); int[] fullySelectedRows = new int[getSelectedRowCount()]; int index = 0; for (Range rowRange : selectedRows) { for (int i = rowRange.start; i < rowRange.end; i++) { if (isRowFullySelected(i, rowWidth)) { fullySelectedRows[index++] = i; } } } return index > 0 ? ArrayUtils.subarray(fullySelectedRows, 0, index) : new int[0]; } public int[] getSelectedColumns() { TreeSet<Integer> selectedColumns = new TreeSet<Integer>(); selectionsLock.readLock().lock(); try { for (Rectangle r : selections) { int startColumn = r.x; int numColumns = r.width; // Change from row < startRow to row < startRow+numRows for (int column = startColumn; column < startColumn + numColumns; column++) { selectedColumns.add(Integer.valueOf(column)); } } } finally { selectionsLock.readLock().unlock(); } // Convert to array return ObjectUtils.asIntArray(selectedColumns); } /** * Get the positions of all fully selected columns. * @param fullySelectedColumnRowCount the number of rows in a fully selected column * @return */ public int[] getFullySelectedColumns(int fullySelectedColumnRowCount) { final int[] selectedColumns = getSelectedColumns(); int[] columnsToHide = new int[selectedColumns.length]; int index = 0; for (int columnPosition : selectedColumns) { if (isColumnFullySelected(columnPosition, fullySelectedColumnRowCount)) { columnsToHide[index++] = columnPosition; } } return index > 0 ? ArrayUtils.subarray(columnsToHide, 0, index) : new int[0]; } // Object methods @Override public String toString() { selectionsLock.readLock().lock(); try { return selections.toString(); } finally { selectionsLock.readLock().unlock(); } } public List<Rectangle> getSelections() { return selections; } }
14,448
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectionUtils.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/SelectionUtils.java
package net.sourceforge.nattable.selection; public class SelectionUtils { public static boolean noShiftOrControl(boolean withShiftMask, boolean withControlMask) { return !withShiftMask && !withControlMask; } public static boolean bothShiftAndControl(boolean withShiftMask, boolean withControlMask) { return withShiftMask && withControlMask; } public static boolean isControlOnly(boolean withShiftMask, boolean withControlMask) { return !withShiftMask && withControlMask; } public static boolean isShiftOnly(boolean withShiftMask, boolean withControlMask) { return withShiftMask && !withControlMask; } }
646
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ISelectionModel.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/ISelectionModel.java
package net.sourceforge.nattable.selection; import java.util.List; import java.util.Set; import net.sourceforge.nattable.coordinate.Range; import org.eclipse.swt.graphics.Rectangle; /** * Tracks the selections made in the table. */ public interface ISelectionModel { public boolean isCellPositionSelected(int columnPosition, int rowPosition); public boolean isRowPositionSelected(int rowPosition); /** * @see #isColumnFullySelected(int, int) */ public boolean isRowFullySelected(int rowPosition, int rowWidth); /** * Is a cell in this column selected ? */ public boolean isColumnPositionSelected(int columnPosition); /** * Are all cells in this column selected ? * Different selection rectangles might aggregate to cover the entire column. * We need to take into account any overlapping selections or any selection rectangles * contained within each other. * * @see the related tests for a better understanding. */ public boolean isColumnFullySelected(int columnPosition, int fullySelectedColumnRowCount); public void addSelection(int columnPosition, int rowPosition); public void addSelection(final Rectangle range); public void clearSelection(); public void removeSelection(Rectangle removedSelection); public void removeSelection(int columnPosition, int rowPosition); public boolean isEmpty(); /** * @return all selected rows in the model */ public Set<Range> getSelectedRows(); public int getSelectedRowCount(); public int[] getFullySelectedRows(int rowWidth); public int[] getSelectedColumns(); /** * Get the positions of all fully selected columns. * @param fullySelectedColumnRowCount the number of rows in a fully selected column * @return */ public int[] getFullySelectedColumns(int fullySelectedColumnRowCount); public List<Rectangle> getSelections(); }
1,919
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectRowCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/SelectRowCommandHandler.java
package net.sourceforge.nattable.selection; import static net.sourceforge.nattable.selection.SelectionUtils.bothShiftAndControl; import static net.sourceforge.nattable.selection.SelectionUtils.isControlOnly; import static net.sourceforge.nattable.selection.SelectionUtils.isShiftOnly; import static net.sourceforge.nattable.selection.SelectionUtils.noShiftOrControl; import java.util.Collection; import java.util.HashSet; import java.util.Set; import net.sourceforge.nattable.command.ILayerCommandHandler; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.selection.command.SelectRowsCommand; import net.sourceforge.nattable.selection.event.RowSelectionEvent; import org.eclipse.swt.graphics.Rectangle; public class SelectRowCommandHandler implements ILayerCommandHandler<SelectRowsCommand> { private final SelectionLayer selectionLayer; public SelectRowCommandHandler(SelectionLayer selectionLayer) { this.selectionLayer = selectionLayer; } public boolean doCommand(ILayer targetLayer, SelectRowsCommand command) { if (command.convertToTargetLayer(selectionLayer)) { selectRows(command.getColumnPosition(), command.getRowPositions(), command.isWithShiftMask(), command.isWithControlMask()); return true; } return false; } protected void selectRows(int columnPosition, Collection<Integer> rowPositions, boolean withShiftMask, boolean withControlMask) { Set<Range> changedRowRanges = new HashSet<Range>(); for (int rowPosition : rowPositions) { changedRowRanges.addAll(internalSelectRow(columnPosition, rowPosition, withShiftMask, withControlMask)); } Set<Integer> changedRows = new HashSet<Integer>(); for (Range range : changedRowRanges) { for (int i = range.start; i < range.end; i++) { changedRows.add(Integer.valueOf(i)); } } selectionLayer.fireLayerEvent(new RowSelectionEvent(selectionLayer, changedRows)); } private Set<Range> internalSelectRow(int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask) { Set<Range> changedRowRanges = new HashSet<Range>(); if (noShiftOrControl(withShiftMask, withControlMask)) { changedRowRanges.addAll(selectionLayer.getSelectedRows()); selectionLayer.clear(); selectionLayer.selectCell(0, rowPosition, withShiftMask, withControlMask); selectionLayer.selectRegion(0, rowPosition, selectionLayer.getColumnCount(), 1); selectionLayer.moveSelectionAnchor(columnPosition, rowPosition); changedRowRanges.add(new Range(rowPosition, rowPosition + 1)); } else if (bothShiftAndControl(withShiftMask, withControlMask)) { changedRowRanges.add(selectRowWithShiftKey(rowPosition)); } else if (isShiftOnly(withShiftMask, withControlMask)) { changedRowRanges.add(selectRowWithShiftKey(rowPosition)); } else if (isControlOnly(withShiftMask, withControlMask)) { changedRowRanges.add(selectRowWithCtrlKey(columnPosition, rowPosition)); } selectionLayer.lastSelectedCell.columnPosition = selectionLayer.getColumnCount() - 1; selectionLayer.lastSelectedCell.rowPosition = rowPosition; return changedRowRanges; } private Range selectRowWithCtrlKey(int columnPosition, int rowPosition) { Rectangle selectedRowRectangle = new Rectangle(0, rowPosition, selectionLayer.getColumnCount(), 1); if (selectionLayer.isRowFullySelected(rowPosition)) { selectionLayer.clearSelection(selectedRowRectangle); if (selectionLayer.lastSelectedRegion != null && selectionLayer.lastSelectedRegion.equals(selectedRowRectangle)) { selectionLayer.lastSelectedRegion = null; } } else { // Preserve last selected region if (selectionLayer.lastSelectedRegion != null) { selectionLayer.selectionModel.addSelection( new Rectangle(selectionLayer.lastSelectedRegion.x, selectionLayer.lastSelectedRegion.y, selectionLayer.lastSelectedRegion.width, selectionLayer.lastSelectedRegion.height)); } selectionLayer.selectRegion(0, rowPosition, selectionLayer.getColumnCount(), 1); selectionLayer.moveSelectionAnchor(columnPosition, rowPosition); } return new Range(rowPosition, rowPosition + 1); } private Range selectRowWithShiftKey(int rowPosition) { int numOfRowsToIncludeInRegion = 1; int startRowPosition = rowPosition; if (selectionLayer.lastSelectedRegion != null) { numOfRowsToIncludeInRegion = Math.abs(selectionLayer.selectionAnchor.rowPosition - rowPosition) + 1; if (startRowPosition < selectionLayer.selectionAnchor.rowPosition) { // Selecting above startRowPosition = rowPosition; } else { // Selecting below startRowPosition = selectionLayer.selectionAnchor.rowPosition; } } selectionLayer.selectRegion(0, startRowPosition, selectionLayer.getColumnCount(), numOfRowsToIncludeInRegion); return new Range(startRowPosition, startRowPosition + numOfRowsToIncludeInRegion); } public Class<SelectRowsCommand> getCommandClass() { return SelectRowsCommand.class; } }
5,134
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MoveCellSelectionCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/MoveCellSelectionCommandHandler.java
package net.sourceforge.nattable.selection; import net.sourceforge.nattable.coordinate.PositionCoordinate; import net.sourceforge.nattable.selection.command.MoveSelectionCommand; /** * Specifies the semantics of moving the selection in the table, based on selecting the adjoining cell(s). */ public class MoveCellSelectionCommandHandler extends MoveSelectionCommandHandler<MoveSelectionCommand> { protected int newSelectedColumnPosition; protected int newSelectedRowPosition; protected PositionCoordinate lastSelectedCell; public MoveCellSelectionCommandHandler(SelectionLayer selectionLayer) { super(selectionLayer); } @Override protected void moveLastSelectedLeft(int stepSize, boolean withShiftMask, boolean withControlMask) { if (selectionLayer.hasColumnSelection()) { lastSelectedCell = selectionLayer.getCellPositionToMoveFrom(withShiftMask, withControlMask); int newSelectedRowPosition = lastSelectedCell.rowPosition; newSelectedColumnPosition = (stepSize >= 0) ? (lastSelectedCell.columnPosition - stepSize) : 0; if (newSelectedColumnPosition < 0) { newSelectedColumnPosition = 0; } if(stepSize == SelectionLayer.MOVE_ALL && !withShiftMask){ selectionLayer.clear(); } selectionLayer.selectCell(newSelectedColumnPosition, newSelectedRowPosition, withShiftMask, withControlMask); selectionLayer.fireCellSelectionEvent(lastSelectedCell.columnPosition, lastSelectedCell.rowPosition, false, withShiftMask, withControlMask); } } @Override protected void moveLastSelectedRight(int stepSize, boolean withShiftMask, boolean withControlMask) { if (selectionLayer.hasColumnSelection()) { lastSelectedCell = selectionLayer.getCellPositionToMoveFrom(withShiftMask, withControlMask); int newSelectedRowPosition = lastSelectedCell.rowPosition; newSelectedColumnPosition = (stepSize >= 0) ? (lastSelectedCell.columnPosition + stepSize) : selectionLayer.getColumnCount() - 1; if (newSelectedColumnPosition >= selectionLayer.getColumnCount()) { newSelectedColumnPosition = selectionLayer.getColumnCount() - 1; } if(stepSize == SelectionLayer.MOVE_ALL && !withShiftMask){ selectionLayer.clear(); } selectionLayer.selectCell(newSelectedColumnPosition, newSelectedRowPosition, withShiftMask, withControlMask); selectionLayer.fireCellSelectionEvent(lastSelectedCell.columnPosition, lastSelectedCell.rowPosition, false, withShiftMask, withControlMask); } } @Override protected void moveLastSelectedUp(int stepSize, boolean withShiftMask, boolean withControlMask) { if (selectionLayer.hasRowSelection()) { lastSelectedCell = selectionLayer.getCellPositionToMoveFrom(withShiftMask, withControlMask); newSelectedRowPosition = stepSize >= 0 ? lastSelectedCell.rowPosition - stepSize : 0; if (newSelectedRowPosition < 0) { newSelectedRowPosition = 0; } selectionLayer.selectCell(lastSelectedCell.columnPosition, newSelectedRowPosition, withShiftMask, withControlMask); selectionLayer.fireCellSelectionEvent(lastSelectedCell.columnPosition, lastSelectedCell.rowPosition, false, withShiftMask, withControlMask); } } @Override protected void moveLastSelectedDown(int stepSize, boolean withShiftMask, boolean withControlMask) { if (selectionLayer.hasRowSelection()) { lastSelectedCell = selectionLayer.getCellPositionToMoveFrom(withShiftMask, withControlMask); newSelectedRowPosition = stepSize >= 0 ? lastSelectedCell.rowPosition + stepSize : selectionLayer.getRowCount() - 1; if (newSelectedRowPosition >= selectionLayer.getRowCount()) { newSelectedRowPosition = selectionLayer.getRowCount() - 1; } selectionLayer.selectCell(lastSelectedCell.columnPosition, newSelectedRowPosition, withShiftMask, withControlMask); selectionLayer.fireCellSelectionEvent(lastSelectedCell.columnPosition, lastSelectedCell.rowPosition, false, withShiftMask, withControlMask); } } public Class<MoveSelectionCommand> getCommandClass() { return MoveSelectionCommand.class; } }
4,112
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowSelectionPreserver.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/RowSelectionPreserver.java
package net.sourceforge.nattable.selection; import java.util.ArrayList; import java.util.List; import net.sourceforge.nattable.data.IRowDataProvider; import net.sourceforge.nattable.layer.event.ILayerEventHandler; import net.sourceforge.nattable.layer.event.IVisualChangeEvent; import net.sourceforge.nattable.layer.event.RowStructuralChangeEvent; import net.sourceforge.nattable.layer.event.RowStructuralRefreshEvent; import net.sourceforge.nattable.sort.event.SortColumnEvent; import net.sourceforge.nattable.util.ObjectUtils; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; /** * Preserves the selected row when the underlying data changes or column is sorted.<br/> * * <b>Example:</b> * Data 'A' is the 1st row. An update comes in and data 'A' moves to the 5th row. * This class clears current selection and selects row 5. * * @param <T> Type of row object beans in the underlying data source * @deprecated Use SelectionLayer.setSelectionModel(new RowSelectionModel(...)) instead */ public class RowSelectionPreserver<T> implements ILayerEventHandler<IVisualChangeEvent> { private final SelectionLayer selectionLayer; private final RowSelectionProvider<T> selectionProvider; private final IRowDataProvider<T> rowDataProvider; /** Track the selected objects */ private List<T> selectedRowObjects = new ArrayList<T>(); public RowSelectionPreserver(SelectionLayer selectionLayer, IRowDataProvider<T> rowDataProvider) { this.selectionLayer = selectionLayer; this.rowDataProvider = rowDataProvider; selectionProvider = new RowSelectionProvider<T>(selectionLayer, rowDataProvider, true); selectionProvider.addSelectionChangedListener(new ISelectionChangedListener() { @SuppressWarnings("unchecked") public void selectionChanged(SelectionChangedEvent event) { selectedRowObjects = ((StructuredSelection) event.getSelection()).toList(); } }); } /** * Checks if all the previously selected objects are available in the data provider. * Previously selected object might have been deleted from the list. */ private List<T> getValidSelections() { List<T> newSelection = new ArrayList<T>(); for (T rowObj : selectedRowObjects) { int index = rowDataProvider.indexOfRowObject(rowObj); if (index != -1){ newSelection.add(rowObj); } } return newSelection; } /** * On a change in the underlying data: * <ol> * <li>Clears the selection * <li>Re-select the row objects selected earlier. * </ol> */ public void handleLayerEvent(IVisualChangeEvent event) { if(ObjectUtils.isEmpty(selectedRowObjects)){ return; } if (event instanceof RowStructuralRefreshEvent || event instanceof RowStructuralChangeEvent || event instanceof SortColumnEvent) { selectionLayer.clear(); selectionProvider.setSelection(new StructuredSelection(getValidSelections())); } } public Class<IVisualChangeEvent> getLayerEventClass() { return IVisualChangeEvent.class; } }
3,164
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectionLayerPainter.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/SelectionLayerPainter.java
package net.sourceforge.nattable.selection; import java.util.HashMap; import java.util.Map; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.coordinate.PositionCoordinate; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.cell.LayerCell; import net.sourceforge.nattable.painter.layer.GridLineCellLayerPainter; import net.sourceforge.nattable.style.DisplayMode; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Rectangle; public class SelectionLayerPainter extends GridLineCellLayerPainter { private int columnPositionOffset; private int rowPositionOffset; private Map<PositionCoordinate, LayerCell> cells; @Override public void paintLayer(ILayer natLayer, GC gc, int xOffset, int yOffset, Rectangle pixelRectangle, IConfigRegistry configRegistry) { Rectangle positionRectangle = getPositionRectangleFromPixelRectangle(natLayer, pixelRectangle); columnPositionOffset = positionRectangle.x; rowPositionOffset = positionRectangle.y; cells = new HashMap<PositionCoordinate, LayerCell>(); super.paintLayer(natLayer, gc, xOffset, yOffset, pixelRectangle, configRegistry); // Save gc settings int originalLineStyle = gc.getLineStyle(); Color originalForeground = gc.getForeground(); // Apply border settings gc.setLineStyle(SWT.LINE_CUSTOM); gc.setLineDash(new int[] { 1, 1 }); gc.setForeground(GUIHelper.COLOR_BLACK); // Draw horizontal borders boolean selectedMode = false; for (int columnPosition = columnPositionOffset; columnPosition < columnPositionOffset + positionRectangle.width; columnPosition++) { LayerCell cell = null; for (int rowPosition = rowPositionOffset; rowPosition < rowPositionOffset + positionRectangle.height; rowPosition++) { cell = cells.get(new PositionCoordinate(natLayer, columnPosition, rowPosition)); if (cell != null) { if (selectedMode != isSelected(cell)) { selectedMode = !selectedMode; Rectangle cellBounds = cell.getBounds(); // Draw top edge gc.drawLine( cellBounds.x - 1, cellBounds.y - 1, cellBounds.x + cellBounds.width - 1, cellBounds.y - 1 ); } } } if (selectedMode && cell != null) { // If last cell is selected, draw its bottom edge Rectangle cellBounds = cell.getBounds(); gc.drawLine( cellBounds.x - 1, cellBounds.y + cellBounds.height - 1, cellBounds.x + cellBounds.width - 1, cellBounds.y + cellBounds.height - 1 ); } selectedMode = false; } // Draw vertical borders for (int rowPosition = rowPositionOffset; rowPosition < rowPositionOffset + positionRectangle.height; rowPosition++) { LayerCell cell = null; for (int columnPosition = columnPositionOffset; columnPosition < columnPositionOffset + positionRectangle.width; columnPosition++) { cell = cells.get(new PositionCoordinate(natLayer, columnPosition, rowPosition)); if (cell != null) { if (selectedMode != isSelected(cell)) { selectedMode = !selectedMode; Rectangle cellBounds = cell.getBounds(); // Draw left edge gc.drawLine( cellBounds.x - 1, cellBounds.y - 1, cellBounds.x - 1, cellBounds.y + cellBounds.height - 1 ); } } } if (selectedMode && cell != null) { // If last cell is selected, draw its right edge Rectangle cellBounds = cell.getBounds(); gc.drawLine( cellBounds.x + cellBounds.width - 1, cellBounds.y - 1, cellBounds.x + cellBounds.width - 1, cellBounds.y + cellBounds.height - 1 ); } selectedMode = false; } // Restore original gc settings gc.setLineStyle(originalLineStyle); gc.setForeground(originalForeground); } @Override protected void paintCell(LayerCell cell, GC gc, IConfigRegistry configRegistry) { for (int columnPosition = cell.getColumnPosition(); columnPosition < cell.getColumnPosition() + cell.getColumnSpan(); columnPosition++) { for (int rowPosition = cell.getRowPosition(); rowPosition < cell.getRowPosition() + cell.getRowSpan(); rowPosition++) { cells.put(new PositionCoordinate(cell.getLayer(), columnPosition, rowPosition), cell); } } super.paintCell(cell, gc, configRegistry); } private boolean isSelected(LayerCell cell) { return cell.getDisplayMode() == DisplayMode.SELECT; } }
4,521
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectColumnCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/SelectColumnCommandHandler.java
package net.sourceforge.nattable.selection; import static net.sourceforge.nattable.selection.SelectionUtils.bothShiftAndControl; import static net.sourceforge.nattable.selection.SelectionUtils.isControlOnly; import static net.sourceforge.nattable.selection.SelectionUtils.isShiftOnly; import static net.sourceforge.nattable.selection.SelectionUtils.noShiftOrControl; import org.eclipse.swt.graphics.Rectangle; import net.sourceforge.nattable.command.ILayerCommandHandler; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.selection.command.SelectColumnCommand; import net.sourceforge.nattable.selection.event.ColumnSelectionEvent; public class SelectColumnCommandHandler implements ILayerCommandHandler<SelectColumnCommand> { private final SelectionLayer selectionLayer; public SelectColumnCommandHandler(SelectionLayer selectionLayer) { this.selectionLayer = selectionLayer; } public boolean doCommand(ILayer targetLayer, SelectColumnCommand command) { if (command.convertToTargetLayer(selectionLayer)) { selectColumn(command.getColumnPosition(), command.getRowPosition(), command.isWithShiftMask(), command.isWithControlMask()); return true; } return false; } protected void selectColumn(int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask) { if (noShiftOrControl(withShiftMask, withControlMask)) { selectionLayer.clear(); selectionLayer.selectCell(columnPosition, 0, false, false); selectionLayer.selectRegion(columnPosition, 0, 1, selectionLayer.getRowCount()); selectionLayer.moveSelectionAnchor(columnPosition, rowPosition); } else if (bothShiftAndControl(withShiftMask, withControlMask)) { selectColumnWithShiftKey(columnPosition); } else if (isShiftOnly(withShiftMask, withControlMask)) { selectColumnWithShiftKey(columnPosition); } else if (isControlOnly(withShiftMask, withControlMask)) { selectColumnWithCtrlKey(columnPosition, rowPosition); } // Set last selected column position to the recently clicked column selectionLayer.lastSelectedCell.columnPosition = columnPosition; selectionLayer.lastSelectedCell.rowPosition = selectionLayer.getRowCount() - 1; selectionLayer.fireLayerEvent(new ColumnSelectionEvent(selectionLayer, columnPosition)); } private void selectColumnWithCtrlKey(int columnPosition, int rowPosition) { Rectangle selectedColumnRectangle = new Rectangle(columnPosition, 0, 1, selectionLayer.getRowCount()); if (selectionLayer.isColumnFullySelected(columnPosition)) { selectionLayer.clearSelection(selectedColumnRectangle); if(selectionLayer.lastSelectedRegion != null && selectionLayer.lastSelectedRegion.equals(selectedColumnRectangle)){ selectionLayer.lastSelectedRegion = null; } }else{ if(selectionLayer.lastSelectedRegion != null){ selectionLayer.selectionModel.addSelection( new Rectangle(selectionLayer.lastSelectedRegion.x, selectionLayer.lastSelectedRegion.y, selectionLayer.lastSelectedRegion.width, selectionLayer.lastSelectedRegion.height)); } selectionLayer.selectRegion(columnPosition, 0, 1, selectionLayer.getRowCount()); selectionLayer.moveSelectionAnchor(columnPosition, rowPosition); } } private void selectColumnWithShiftKey(int columnPosition) { int numOfColumnsToIncludeInRegion = 1; int startColumnPosition = columnPosition; if (selectionLayer.lastSelectedRegion != null) { // Negative when we move left, but we are only concerned with the num. of columns numOfColumnsToIncludeInRegion = Math.abs(selectionLayer.selectionAnchor.columnPosition - columnPosition) + 1; // Select to the Left if (columnPosition < selectionLayer.selectionAnchor.columnPosition) { startColumnPosition = columnPosition; } else { startColumnPosition = selectionLayer.selectionAnchor.columnPosition; } } selectionLayer.selectRegion(startColumnPosition, 0, numOfColumnsToIncludeInRegion, selectionLayer.getRowCount()); } public Class<SelectColumnCommand> getCommandClass() { return SelectColumnCommand.class; } }
4,196
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
Selectable.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/Selectable.java
package net.sourceforge.nattable.selection; import net.sourceforge.nattable.coordinate.PositionCoordinate; import net.sourceforge.nattable.layer.ILayer; /** * Indicates an {@link ILayer} that supports the selection of individual cells. Classes should implement this interface * if they need to customize selection logic. */ public interface Selectable { /** * Determine if a cell at a given position is selected. * * @param p cell to query * @return <code>true</code> if the given cell is selected */ public boolean isSelected(PositionCoordinate p); }
613
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowSelectionProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/RowSelectionProvider.java
package net.sourceforge.nattable.selection; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.data.IRowDataProvider; import net.sourceforge.nattable.layer.ILayerListener; import net.sourceforge.nattable.layer.event.ILayerEvent; import net.sourceforge.nattable.selection.command.SelectRowsCommand; import net.sourceforge.nattable.selection.event.ISelectionEvent; import net.sourceforge.nattable.util.ObjectUtils; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; public class RowSelectionProvider<T> implements ISelectionProvider, ILayerListener { private SelectionLayer selectionLayer; private final IRowDataProvider<T> rowDataProvider; private final boolean fullySelectedRowsOnly; private Set<ISelectionChangedListener> listeners = new HashSet<ISelectionChangedListener>(); public RowSelectionProvider(SelectionLayer selectionLayer, IRowDataProvider<T> rowDataProvider) { this(selectionLayer, rowDataProvider, true); } public RowSelectionProvider(SelectionLayer selectionLayer, IRowDataProvider<T> rowDataProvider, boolean fullySelectedRowsOnly) { this.selectionLayer = selectionLayer; this.rowDataProvider = rowDataProvider; this.fullySelectedRowsOnly = fullySelectedRowsOnly; selectionLayer.addLayerListener(this); } public void addSelectionChangedListener(ISelectionChangedListener listener) { listeners.add(listener); } public ISelection getSelection() { return populateRowSelection(selectionLayer, rowDataProvider, fullySelectedRowsOnly); } public void removeSelectionChangedListener(ISelectionChangedListener listener) { listeners.remove(listener); } @SuppressWarnings("unchecked") public void setSelection(ISelection selection) { if (selectionLayer != null && selection instanceof IStructuredSelection) { selectionLayer.clear(); List<T> rowObjects = ((IStructuredSelection) selection).toList(); Set<Integer> rowPositions = new HashSet<Integer>(); for (T rowObject : rowObjects) { int rowIndex = rowDataProvider.indexOfRowObject(rowObject); int rowPosition = selectionLayer.getRowPositionByIndex(rowIndex); rowPositions.add(Integer.valueOf(rowPosition)); } selectionLayer.doCommand(new SelectRowsCommand(selectionLayer, 0, ObjectUtils.asIntArray(rowPositions), false, true)); } } public void handleLayerEvent(ILayerEvent event) { if (event instanceof ISelectionEvent) { if (fullySelectedRowsOnly && selectionLayer.getFullySelectedRowPositions().length == 0) { return; } ISelection selection = getSelection(); for (ISelectionChangedListener listener : listeners) { listener.selectionChanged(new SelectionChangedEvent(this, selection)); } } } @SuppressWarnings("unchecked") static StructuredSelection populateRowSelection(SelectionLayer selectionLayer, IRowDataProvider rowDataProvider, boolean fullySelectedRowsOnly) { List rows = new ArrayList(); if (selectionLayer != null) { if (fullySelectedRowsOnly) { for (int rowPosition : selectionLayer.getFullySelectedRowPositions()) { addToSelection(rows, rowPosition, selectionLayer, rowDataProvider); } } else { Set<Range> rowRanges = selectionLayer.getSelectedRows(); for (Range rowRange : rowRanges) { for (int rowPosition = rowRange.start; rowPosition < rowRange.end; rowPosition++) { addToSelection(rows, rowPosition, selectionLayer, rowDataProvider); } } } } return new StructuredSelection(rows); } @SuppressWarnings("unchecked") private static void addToSelection(List<Object> rows, int rowPosition, SelectionLayer selectionLayer, IRowDataProvider rowDataProvider) { int rowIndex = selectionLayer.getRowIndexByPosition(rowPosition); Object rowObject = rowDataProvider.getRowObject(rowIndex); rows.add(rowObject); } }
4,287
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ScrollSelectionCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/ScrollSelectionCommandHandler.java
package net.sourceforge.nattable.selection; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.selection.command.ScrollSelectionCommand; import net.sourceforge.nattable.viewport.ViewportLayer; public class ScrollSelectionCommandHandler extends AbstractLayerCommandHandler<ScrollSelectionCommand> { private final ViewportLayer viewportLayer; public ScrollSelectionCommandHandler(ViewportLayer viewportLayer) { this.viewportLayer = viewportLayer; } public Class<ScrollSelectionCommand> getCommandClass() { return ScrollSelectionCommand.class; } @Override protected boolean doCommand(ScrollSelectionCommand command) { viewportLayer.scrollVerticallyByAPage(command); return true; } }
754
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MoveRowSelectionCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/MoveRowSelectionCommandHandler.java
package net.sourceforge.nattable.selection; import net.sourceforge.nattable.coordinate.PositionCoordinate; /** * Preserves the basic semantics of the cell selection. <br/> * Additionally it selects the entire row when a cell in the row is selected.<br/> */ public class MoveRowSelectionCommandHandler extends MoveCellSelectionCommandHandler { public MoveRowSelectionCommandHandler(SelectionLayer selectionLayer) { super(selectionLayer); } @Override protected void moveLastSelectedLeft(int stepSize, boolean withShiftMask, boolean withControlMask) { super.moveLastSelectedLeft(stepSize, withShiftMask, withControlMask); selectionLayer.selectRow(newSelectedColumnPosition, lastSelectedCell.rowPosition, withShiftMask, withControlMask); } @Override protected void moveLastSelectedRight(int stepSize, boolean withShiftMask, boolean withControlMask) { super.moveLastSelectedRight(stepSize, withShiftMask, withControlMask); selectionLayer.selectRow(lastSelectedCell.columnPosition, lastSelectedCell.rowPosition, withShiftMask, withControlMask); } @Override protected void moveLastSelectedUp(int stepSize, boolean withShiftMask, boolean withControlMask) { if (selectionLayer.hasRowSelection()) { PositionCoordinate lastSelectedCell = selectionLayer.getCellPositionToMoveFrom(withShiftMask, withControlMask); int newSelectedRowPosition = stepSize >= 0 ? lastSelectedCell.rowPosition - stepSize : 0; if (newSelectedRowPosition < 0) { newSelectedRowPosition = 0; } selectionLayer.selectRow(lastSelectedCell.columnPosition, newSelectedRowPosition, withShiftMask, withControlMask); } } @Override protected void moveLastSelectedDown(int stepSize, boolean withShiftMask, boolean withControlMask) { if (selectionLayer.hasRowSelection()) { PositionCoordinate lastSelectedCell = selectionLayer.getCellPositionToMoveFrom(withShiftMask, withControlMask); int newSelectedRowPosition = stepSize >= 0 ? lastSelectedCell.rowPosition + stepSize : selectionLayer.getRowCount() - 1; if (newSelectedRowPosition >= selectionLayer.getRowCount()) { newSelectedRowPosition = selectionLayer.getRowCount() - 1; } selectionLayer.selectRow(lastSelectedCell.columnPosition, newSelectedRowPosition, withShiftMask, withControlMask); } } }
2,333
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MoveSelectionCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/MoveSelectionCommandHandler.java
package net.sourceforge.nattable.selection; import net.sourceforge.nattable.command.ILayerCommandHandler; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.selection.command.MoveSelectionCommand; /** * Abstraction of the selection behavior during navigation in the grid.<br/> * Implementations of this class specify what to select when the selection moves<br/> * by responding to the {@link MoveSelectionCommand}.<br/> * * @param <T> an instance of the {@link MoveSelectionCommand} * @see MoveCellSelectionCommandHandler * @see MoveRowSelectionCommandHandler */ public abstract class MoveSelectionCommandHandler<T extends MoveSelectionCommand> implements ILayerCommandHandler<T> { protected final SelectionLayer selectionLayer; public MoveSelectionCommandHandler(SelectionLayer selectionLayer) { this.selectionLayer = selectionLayer; } public boolean doCommand(ILayer targetLayer, T command) { if (command.convertToTargetLayer(selectionLayer)) { moveSelection(command.getDirection(), command.getStepSize(), command.isShiftMask(), command.isControlMask()); return true; } return false; } protected void moveSelection(MoveDirectionEnum moveDirection, int stepSize, boolean withShiftMask, boolean withControlMask) { switch (moveDirection) { case UP: moveLastSelectedUp(stepSize, withShiftMask, withControlMask); break; case DOWN: moveLastSelectedDown(stepSize, withShiftMask, withControlMask); break; case LEFT: moveLastSelectedLeft(stepSize, withShiftMask, withControlMask); break; case RIGHT: moveLastSelectedRight(stepSize, withShiftMask, withControlMask); break; default: break; } } protected abstract void moveLastSelectedRight(int stepSize, boolean withShiftMask, boolean withControlMask); protected abstract void moveLastSelectedLeft(int stepSize, boolean withShiftMask, boolean withControlMask); protected abstract void moveLastSelectedUp(int stepSize, boolean withShiftMask, boolean withControlMask); protected abstract void moveLastSelectedDown(int stepSize, boolean withShiftMask, boolean withControlMask); }
2,260
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowSelectionModel.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/RowSelectionModel.java
package net.sourceforge.nattable.selection; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.data.IRowDataProvider; import net.sourceforge.nattable.data.IRowIdAccessor; import org.eclipse.swt.graphics.Rectangle; public class RowSelectionModel<R> implements ISelectionModel { private final SelectionLayer selectionLayer; private final IRowDataProvider<R> rowDataProvider; private final IRowIdAccessor<R> rowIdAccessor; private Map<Serializable, R> selectedRows; private Rectangle lastSelectedRange; // *live* reference to last range parameter used in addSelection(range) private Set<Serializable> lastSelectedRowIds; private final ReadWriteLock selectionsLock; public RowSelectionModel(SelectionLayer selectionLayer, IRowDataProvider<R> rowDataProvider, IRowIdAccessor<R> rowIdAccessor) { this.selectionLayer = selectionLayer; this.rowDataProvider = rowDataProvider; this.rowIdAccessor = rowIdAccessor; selectedRows = new HashMap<Serializable, R>(); selectionsLock = new ReentrantReadWriteLock(); } public void clearSelection() { selectionsLock.writeLock().lock(); try { selectedRows.clear(); } finally { selectionsLock.writeLock().unlock(); } } public boolean isColumnPositionSelected(int columnPosition) { selectionsLock.readLock().lock(); try { return !selectedRows.isEmpty(); } finally { selectionsLock.readLock().unlock(); } } public int[] getSelectedColumns() { if (!isEmpty()) { selectionsLock.readLock().lock(); int columnCount; try { columnCount = selectionLayer.getColumnCount(); } finally { selectionsLock.readLock().unlock(); } int[] columns = new int[columnCount]; for (int i = 0; i < columnCount; i++) { columns[i] = i; } return columns; } return new int[] {}; } public void addSelection(int columnPosition, int rowPosition) { selectionsLock.writeLock().lock(); try { R rowObject = getRowObjectByPosition(rowPosition); if (rowObject != null) { Serializable rowId = rowIdAccessor.getRowId(rowObject); selectedRows.put(rowId, rowObject); } } finally { selectionsLock.writeLock().unlock(); } } public void addSelection(Rectangle range) { selectionsLock.writeLock().lock(); try { if (range == lastSelectedRange) { // Unselect all previously selected rowIds if (lastSelectedRowIds != null) { for (Serializable rowId : lastSelectedRowIds) { selectedRows.remove(rowId); } } } Map<Serializable, R> rowsToSelect = new HashMap<Serializable, R>(); for (int rowPosition = range.y; rowPosition < range.y + range.height; rowPosition++) { R rowObject = getRowObjectByPosition(rowPosition); if (rowObject != null) { Serializable rowId = rowIdAccessor.getRowId(rowObject); rowsToSelect.put(rowId, rowObject); } } selectedRows.putAll(rowsToSelect); if (range == lastSelectedRange) { lastSelectedRowIds = rowsToSelect.keySet(); } else { lastSelectedRowIds = null; } lastSelectedRange = range; } finally { selectionsLock.writeLock().unlock(); } } public int[] getFullySelectedColumns(int fullySelectedColumnRowCount) { selectionsLock.readLock().lock(); try { if (isColumnFullySelected(0, fullySelectedColumnRowCount)) { return getSelectedColumns(); } } finally { selectionsLock.readLock().unlock(); } return new int[] {}; } public int[] getFullySelectedRows(int rowWidth) { selectionsLock.readLock().lock(); try { int selectedRowCount = selectedRows.size(); int[] selectedRowPositions = new int[selectedRowCount]; int i = 0; for (Serializable rowId : selectedRows.keySet()) { selectedRowPositions[i] = getRowPositionById(rowId); i++; } return selectedRowPositions; } finally { selectionsLock.readLock().unlock(); } } public int getSelectedRowCount() { selectionsLock.readLock().lock(); try { return selectedRows.size(); } finally { selectionsLock.readLock().unlock(); } } public Set<Range> getSelectedRows() { Set<Range> selectedRowRanges = new HashSet<Range>(); selectionsLock.readLock().lock(); try { for (Serializable rowId : selectedRows.keySet()) { int rowPosition = getRowPositionById(rowId); selectedRowRanges.add(new Range(rowPosition, rowPosition + 1)); } } finally { selectionsLock.readLock().unlock(); } return selectedRowRanges; } public List<Rectangle> getSelections() { List<Rectangle> selectionRectangles = new ArrayList<Rectangle>(); selectionsLock.readLock().lock(); try { int width = selectionLayer.getColumnCount(); for (Serializable rowId : selectedRows.keySet()) { int rowPosition = getRowPositionById(rowId); selectionRectangles.add(new Rectangle(0, rowPosition, width, 1)); } } finally { selectionsLock.readLock().unlock(); } return selectionRectangles; } public boolean isCellPositionSelected(int columnPosition, int rowPosition) { return isRowPositionSelected(rowPosition); } public boolean isColumnFullySelected(int columnPosition, int fullySelectedColumnRowCount) { selectionsLock.readLock().lock(); try { return selectedRows.size() == fullySelectedColumnRowCount; } finally { selectionsLock.readLock().unlock(); } } public boolean isEmpty() { selectionsLock.readLock().lock(); try { return selectedRows.isEmpty(); } finally { selectionsLock.readLock().unlock(); } } public boolean isRowFullySelected(int rowPosition, int rowWidth) { return isRowPositionSelected(rowPosition); } public boolean isRowPositionSelected(int rowPosition) { selectionsLock.readLock().lock(); try { Serializable rowId = getRowIdByPosition(rowPosition); return selectedRows.containsKey(rowId); } finally { selectionsLock.readLock().unlock(); } } public void removeSelection(Rectangle removedSelection) { selectionsLock.writeLock().lock(); try { for (int rowPosition = removedSelection.y; rowPosition < removedSelection.y + removedSelection.height; rowPosition++) { removeSelection(0, rowPosition); } } finally { selectionsLock.writeLock().unlock(); } } public void removeSelection(int columnPosition, int rowPosition) { selectionsLock.writeLock().lock(); try { Serializable rowId = getRowIdByPosition(rowPosition); selectedRows.remove(rowId); } finally { selectionsLock.writeLock().unlock(); } } private Serializable getRowIdByPosition(int rowPosition) { R rowObject = getRowObjectByPosition(rowPosition); if (rowObject != null) { Serializable rowId = rowIdAccessor.getRowId(rowObject); return rowId; } return null; } private R getRowObjectByPosition(int rowPosition) { selectionsLock.readLock().lock(); try { int rowIndex = selectionLayer.getRowIndexByPosition(rowPosition); if (rowIndex >= 0) { try { R rowObject = rowDataProvider.getRowObject(rowIndex); return rowObject; } catch (Exception e) { // row index is invalid for the data provider } } } finally { selectionsLock.readLock().unlock(); } return null; } private int getRowPositionById(Serializable rowId) { selectionsLock.readLock().lock(); try { R rowObject = selectedRows.get(rowId); int rowIndex = rowDataProvider.indexOfRowObject(rowObject); int rowPosition = selectionLayer.getRowPositionByIndex(rowIndex); return rowPosition; } finally { selectionsLock.readLock().unlock(); } } }
8,164
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectCellCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/SelectCellCommandHandler.java
package net.sourceforge.nattable.selection; import static net.sourceforge.nattable.selection.SelectionUtils.isControlOnly; import net.sourceforge.nattable.command.ILayerCommandHandler; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.selection.command.SelectCellCommand; import org.eclipse.swt.graphics.Rectangle; public class SelectCellCommandHandler implements ILayerCommandHandler<SelectCellCommand> { private final SelectionLayer selectionLayer; public SelectCellCommandHandler(SelectionLayer selectionLayer) { this.selectionLayer = selectionLayer; } public boolean doCommand(ILayer targetLayer, SelectCellCommand command) { if (command.convertToTargetLayer(selectionLayer)) { toggleCell(command.getColumnPosition(), command.getRowPosition(), command.isShiftMask(), command.isControlMask(), command.isForcingEntireCellIntoViewport()); selectionLayer.fireCellSelectionEvent(command.getColumnPosition(), command.getRowPosition(), command.isForcingEntireCellIntoViewport(), command.isShiftMask(), command.isControlMask()); return true; } return false; } /** * Toggles the selection state of the given row and column. * @return <code>false</code> if the cell was unselected. */ protected void toggleCell(int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask, boolean forcingEntireCellIntoViewport) { boolean selectCell = true; if (isControlOnly(withShiftMask, withControlMask)) { if (selectionLayer.isCellPositionSelected(columnPosition, rowPosition)) { selectionLayer.clearSelection(columnPosition, rowPosition); selectCell = false; } } if (selectCell) { selectCell(columnPosition, rowPosition, withShiftMask, withControlMask); } } /** * Selects a cell, optionally clearing current selection */ public void selectCell(int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask) { if (!withShiftMask && !withControlMask) { selectionLayer.clear(); } selectionLayer.setLastSelectedCell(columnPosition, rowPosition); // Shift pressed + row selected if (withShiftMask && selectionLayer.lastSelectedRegion != null && selectionLayer.hasRowSelection()) { selectionLayer.lastSelectedRegion.height = Math.abs(selectionLayer.selectionAnchor.rowPosition - rowPosition) + 1; selectionLayer.lastSelectedRegion.y = Math.min(selectionLayer.selectionAnchor.rowPosition, rowPosition); selectionLayer.lastSelectedRegion.width = Math.abs(selectionLayer.selectionAnchor.columnPosition - columnPosition) + 1; selectionLayer.lastSelectedRegion.x = Math.min(selectionLayer.selectionAnchor.columnPosition, columnPosition); selectionLayer.addSelection(selectionLayer.lastSelectedRegion); } else { selectionLayer.lastSelectedRegion = null; Rectangle selection = null; selection = new Rectangle(selectionLayer.lastSelectedCell.columnPosition, selectionLayer.lastSelectedCell.rowPosition, 1, 1); selectionLayer.addSelection(selection); } } public Class<SelectCellCommand> getCommandClass() { return SelectCellCommand.class; } }
3,190
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CellSelectionDragMode.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/CellSelectionDragMode.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.command.SelectCellCommand; import net.sourceforge.nattable.ui.action.IDragMode; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Point; /** * Fires commands to select a range of cells when the mouse is dragged in the viewport. */ public class CellSelectionDragMode implements IDragMode { private boolean shiftMask; private boolean controlMask; private Point lastDragInCellPosition = null; public void mouseDown(NatTable natTable, MouseEvent event) { natTable.forceFocus(); shiftMask = ((event.stateMask & SWT.SHIFT) == SWT.SHIFT); controlMask = ((event.stateMask & SWT.CONTROL) == SWT.CONTROL); fireSelectionCommand(natTable, natTable.getColumnPositionByX(event.x), natTable.getRowPositionByY(event.y), shiftMask, controlMask); } public void mouseMove(NatTable natTable, MouseEvent event) { if (event.x > natTable.getWidth()) { return; } int selectedColumnPosition = natTable.getColumnPositionByX(event.x); int selectedRowPosition = natTable.getRowPositionByY(event.y); if (selectedColumnPosition > -1 && selectedRowPosition > -1) { Point dragInCellPosition = new Point(selectedColumnPosition, selectedRowPosition); if(lastDragInCellPosition == null || !dragInCellPosition.equals(lastDragInCellPosition)){ lastDragInCellPosition = dragInCellPosition; fireSelectionCommand(natTable, selectedColumnPosition, selectedRowPosition, true, false); } } } public void fireSelectionCommand(NatTable natTable, int columnPosition, int rowPosition, boolean shiftMask, boolean controlMask) { natTable.doCommand(new SelectCellCommand(natTable, columnPosition, rowPosition, shiftMask, controlMask)); } public void mouseUp(NatTable natTable, MouseEvent event) { endDrag(); } private void endDrag(){ lastDragInCellPosition = null; } }
2,036
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
PageDownAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/PageDownAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.selection.command.ScrollSelectionCommand; import org.eclipse.swt.events.KeyEvent; public class PageDownAction extends AbstractKeySelectAction { public PageDownAction() { super(MoveDirectionEnum.DOWN); } public void run(NatTable natTable, KeyEvent event) { super.run(natTable, event); natTable.doCommand(new ScrollSelectionCommand(MoveDirectionEnum.DOWN, isShiftMask(), isControlMask())); } }
629
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MoveToFirstRowAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/MoveToFirstRowAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.selection.command.MoveSelectionCommand; import org.eclipse.swt.events.KeyEvent; public class MoveToFirstRowAction extends AbstractKeySelectAction { public MoveToFirstRowAction() { super(MoveDirectionEnum.UP, false, false); } @Override public void run(NatTable natTable, KeyEvent event) { super.run(natTable, event); natTable.doCommand(new MoveSelectionCommand(MoveDirectionEnum.UP, SelectionLayer.MOVE_ALL, isShiftMask(), isControlMask())); } }
743
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractKeySelectAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/AbstractKeySelectAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.ui.action.IKeyAction; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; public abstract class AbstractKeySelectAction implements IKeyAction { private boolean shiftMask = false; private boolean controlMask = false; private boolean isStateMaskSpecified = false; private final MoveDirectionEnum direction; public AbstractKeySelectAction(MoveDirectionEnum direction) { this.direction = direction; } public AbstractKeySelectAction(MoveDirectionEnum direction, boolean shiftMask, boolean ctrlMask) { this.direction = direction; this.shiftMask = shiftMask; this.controlMask = ctrlMask; this.isStateMaskSpecified = true; } public void run(NatTable natTable, KeyEvent event) { if (!isStateMaskSpecified) { this.shiftMask = (event.stateMask & SWT.SHIFT) != 0; this.controlMask = (event.stateMask & SWT.CTRL) != 0; } } protected boolean isShiftMask() { return shiftMask; } protected boolean isControlMask() { return controlMask; } public void setShiftMask(boolean shiftMask) { this.shiftMask = shiftMask; } public void setControlMask(boolean controlMask) { this.controlMask = controlMask; } public MoveDirectionEnum getDirection() { return direction; } }
1,481
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectRowAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/SelectRowAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.command.SelectRowsCommand; import org.eclipse.swt.events.MouseEvent; /** * Action executed when the user selects any row in the grid. */ public class SelectRowAction extends AbstractMouseSelectionAction { @Override public void run(NatTable natTable, MouseEvent event) { super.run(natTable, event); natTable.doCommand(new SelectRowsCommand(natTable, getGridColumnPosition(), getGridRowPosition(), isWithShiftMask(), isWithControlMask())); } }
625
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
PageUpAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/PageUpAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.selection.command.ScrollSelectionCommand; import org.eclipse.swt.events.KeyEvent; public class PageUpAction extends AbstractKeySelectAction { public PageUpAction() { super(MoveDirectionEnum.UP); } public void run(NatTable natTable, KeyEvent event) { super.run(natTable, event); natTable.doCommand(new ScrollSelectionCommand(MoveDirectionEnum.UP, isShiftMask(), isControlMask())); } }
621
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MoveToFirstColumnAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/MoveToFirstColumnAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.selection.command.MoveSelectionCommand; import org.eclipse.swt.events.KeyEvent; public class MoveToFirstColumnAction extends AbstractKeySelectAction { public MoveToFirstColumnAction() { super(MoveDirectionEnum.LEFT); } public void run(NatTable natTable, KeyEvent event) { super.run(natTable, event); natTable.doCommand(new MoveSelectionCommand(MoveDirectionEnum.LEFT, SelectionLayer.MOVE_ALL, isShiftMask(), isControlMask())); } }
727
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MoveToLastRowAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/MoveToLastRowAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.selection.command.MoveSelectionCommand; import org.eclipse.swt.events.KeyEvent; public class MoveToLastRowAction extends AbstractKeySelectAction { public MoveToLastRowAction() { super(MoveDirectionEnum.DOWN, false, false); } @Override public void run(NatTable natTable, KeyEvent event) { super.run(natTable, event); natTable.doCommand(new MoveSelectionCommand(MoveDirectionEnum.DOWN, SelectionLayer.MOVE_ALL, isShiftMask(), isControlMask())); } }
745
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectCellAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/SelectCellAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.command.SelectCellCommand; import org.eclipse.swt.events.MouseEvent; /** * Action executed when the user selects any cell in the grid. */ public class SelectCellAction extends AbstractMouseSelectionAction { @Override public void run(NatTable natTable, MouseEvent event) { super.run(natTable, event); natTable.doCommand(new SelectCellCommand(natTable, getGridColumnPosition(), getGridRowPosition(), isWithShiftMask(), isWithControlMask())); } }
627
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowSelectionDragMode.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/RowSelectionDragMode.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.command.SelectRowsCommand; import net.sourceforge.nattable.selection.config.RowOnlySelectionBindings; /** * Selects the entire row when the mouse is dragged on the body. * <i>Multiple</i> rows are selected as the user drags. * * @see RowOnlySelectionBindings */ public class RowSelectionDragMode extends CellSelectionDragMode { @Override public void fireSelectionCommand(NatTable natTable, int columnPosition, int rowPosition, boolean shiftMask, boolean controlMask) { natTable.doCommand(new SelectRowsCommand(natTable, columnPosition, rowPosition, shiftMask, controlMask)); } }
746
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MoveSelectionAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/MoveSelectionAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.selection.command.MoveSelectionCommand; import org.eclipse.swt.events.KeyEvent; public class MoveSelectionAction extends AbstractKeySelectAction { public MoveSelectionAction(MoveDirectionEnum direction) { super(direction); } public MoveSelectionAction(MoveDirectionEnum direction, boolean shiftMask, boolean ctrlMask) { super(direction, shiftMask, ctrlMask); } @Override public void run(NatTable natTable, KeyEvent event) { super.run(natTable, event); natTable.doCommand(new MoveSelectionCommand(getDirection(), 1, isShiftMask(), isControlMask())); } }
801
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractMouseSelectionAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/AbstractMouseSelectionAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.ui.action.IMouseAction; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseEvent; public class AbstractMouseSelectionAction implements IMouseAction { private boolean withShiftMask; private boolean withControlMask; private int gridColumnPosition; private int gridRowPosition; public void run(NatTable natTable, MouseEvent event) { withShiftMask = (event.stateMask & SWT.SHIFT) != 0; withControlMask = (event.stateMask & SWT.CTRL) != 0; gridColumnPosition = natTable.getColumnPositionByX(event.x); gridRowPosition = natTable.getRowPositionByY(event.y); natTable.forceFocus(); } public boolean isWithShiftMask() { return withShiftMask; } public boolean isWithControlMask() { return withControlMask; } public int getGridColumnPosition() { return gridColumnPosition; } public int getGridRowPosition() { return gridRowPosition; } }
1,076
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MoveToLastColumnAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/MoveToLastColumnAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.selection.command.MoveSelectionCommand; import org.eclipse.swt.events.KeyEvent; public class MoveToLastColumnAction extends AbstractKeySelectAction { public MoveToLastColumnAction() { super(MoveDirectionEnum.RIGHT); } public void run(NatTable natTable, KeyEvent event) { super.run(natTable, event); natTable.doCommand(new MoveSelectionCommand(MoveDirectionEnum.RIGHT, SelectionLayer.MOVE_ALL, isShiftMask(), isControlMask())); } }
727
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectAllAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/SelectAllAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.command.SelectAllCommand; import net.sourceforge.nattable.ui.action.IKeyAction; import org.eclipse.swt.events.KeyEvent; public class SelectAllAction implements IKeyAction { public void run(NatTable natTable, KeyEvent event) { natTable.doCommand(new SelectAllCommand()); } }
434
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SingleRowSelectionDragMode.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/SingleRowSelectionDragMode.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.command.ClearAllSelectionsCommand; import net.sourceforge.nattable.selection.config.RowOnlySelectionBindings; import net.sourceforge.nattable.ui.action.IDragMode; import org.eclipse.swt.events.MouseEvent; /** * Selects the entire row when the mouse is dragged on the body. Only a * <i>single</i> row is selected at a given time. This is the row the mouse is * over. * * @see RowOnlySelectionBindings */ public class SingleRowSelectionDragMode extends RowSelectionDragMode implements IDragMode { @Override public void mouseMove(NatTable natTable, MouseEvent event) { natTable.doCommand(new ClearAllSelectionsCommand()); if (event.x > natTable.getWidth()) { return; } int selectedColumnPosition = natTable.getColumnPositionByX(event.x); int selectedRowPosition = natTable.getRowPositionByY(event.y); if (selectedColumnPosition > -1 && selectedRowPosition > -1) { fireSelectionCommand(natTable, selectedColumnPosition, selectedRowPosition, false, false); } } }
1,183
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ToggleSelectCellAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/action/ToggleSelectCellAction.java
package net.sourceforge.nattable.selection.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.selection.command.SelectCellCommand; import net.sourceforge.nattable.ui.action.IMouseAction; import org.eclipse.swt.events.MouseEvent; /** * NOTE - work in progress - NTBL-252 */ public class ToggleSelectCellAction implements IMouseAction { private boolean withControlMask; private boolean withShiftMask; public ToggleSelectCellAction(boolean withShiftMask, boolean withControlMask) { this.withShiftMask = withShiftMask; this.withControlMask = withControlMask; } public void run(NatTable natTable, MouseEvent event) { new SelectCellCommand( natTable, natTable.getColumnPositionByX(event.x), natTable.getRowPositionByY(event.y), withShiftMask, withControlMask); } }
864
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowOnlySelectionBindings.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/config/RowOnlySelectionBindings.java
package net.sourceforge.nattable.selection.config; import net.sourceforge.nattable.selection.action.RowSelectionDragMode; import net.sourceforge.nattable.selection.action.SelectRowAction; import net.sourceforge.nattable.ui.action.IDragMode; import net.sourceforge.nattable.ui.action.IMouseAction; import net.sourceforge.nattable.ui.binding.UiBindingRegistry; import net.sourceforge.nattable.ui.matcher.MouseEventMatcher; import org.eclipse.swt.SWT; public class RowOnlySelectionBindings extends DefaultSelectionBindings { @Override protected void configureBodyMouseClickBindings(UiBindingRegistry uiBindingRegistry) { IMouseAction action = new SelectRowAction(); uiBindingRegistry.registerFirstSingleClickBinding(MouseEventMatcher.bodyLeftClick(SWT.NONE), action); uiBindingRegistry.registerFirstSingleClickBinding(MouseEventMatcher.bodyLeftClick(SWT.SHIFT), action); uiBindingRegistry.registerFirstSingleClickBinding(MouseEventMatcher.bodyLeftClick(SWT.CTRL), action); uiBindingRegistry.registerFirstSingleClickBinding(MouseEventMatcher.bodyLeftClick(SWT.SHIFT | SWT.CONTROL), action); } @Override protected void configureBodyMouseDragMode(UiBindingRegistry uiBindingRegistry) { IDragMode dragMode = new RowSelectionDragMode(); uiBindingRegistry.registerFirstMouseDragMode(MouseEventMatcher.bodyLeftClick(SWT.NONE), dragMode); uiBindingRegistry.registerFirstMouseDragMode(MouseEventMatcher.bodyLeftClick(SWT.SHIFT), dragMode); uiBindingRegistry.registerFirstMouseDragMode(MouseEventMatcher.bodyLeftClick(SWT.CONTROL), dragMode); uiBindingRegistry.registerFirstMouseDragMode(MouseEventMatcher.bodyLeftClick(SWT.SHIFT | SWT.CONTROL), dragMode); } }
1,710
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultSelectionBindings.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/config/DefaultSelectionBindings.java
package net.sourceforge.nattable.selection.config; import net.sourceforge.nattable.config.AbstractUiBindingConfiguration; import net.sourceforge.nattable.copy.action.CopyDataAction; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.selection.action.CellSelectionDragMode; import net.sourceforge.nattable.selection.action.MoveSelectionAction; import net.sourceforge.nattable.selection.action.MoveToFirstColumnAction; import net.sourceforge.nattable.selection.action.MoveToFirstRowAction; import net.sourceforge.nattable.selection.action.MoveToLastColumnAction; import net.sourceforge.nattable.selection.action.MoveToLastRowAction; import net.sourceforge.nattable.selection.action.PageDownAction; import net.sourceforge.nattable.selection.action.PageUpAction; import net.sourceforge.nattable.selection.action.SelectAllAction; import net.sourceforge.nattable.selection.action.SelectCellAction; import net.sourceforge.nattable.ui.action.IKeyAction; import net.sourceforge.nattable.ui.action.IMouseAction; import net.sourceforge.nattable.ui.binding.UiBindingRegistry; import net.sourceforge.nattable.ui.matcher.KeyEventMatcher; import net.sourceforge.nattable.ui.matcher.MouseEventMatcher; import net.sourceforge.nattable.viewport.action.ViewportSelectColumnAction; import net.sourceforge.nattable.viewport.action.ViewportSelectRowAction; import org.eclipse.swt.SWT; public class DefaultSelectionBindings extends AbstractUiBindingConfiguration { public void configureUiBindings(UiBindingRegistry uiBindingRegistry) { // Move up configureMoveUpBindings(uiBindingRegistry, new MoveSelectionAction(MoveDirectionEnum.UP)); // Move down configureMoveDownBindings(uiBindingRegistry, new MoveSelectionAction(MoveDirectionEnum.DOWN)); // Move left configureMoveLeftBindings(uiBindingRegistry, new MoveSelectionAction(MoveDirectionEnum.LEFT)); // Move right configureMoveRightBindings(uiBindingRegistry, new MoveSelectionAction(MoveDirectionEnum.RIGHT)); // Page Up configurePageUpButtonBindings(uiBindingRegistry, new PageUpAction()); // Page down configurePageDownButtonBindings(uiBindingRegistry, new PageDownAction()); // Home - Move to first column configureHomeButtonBindings(uiBindingRegistry, new MoveToFirstColumnAction()); // End - Move to last column configureEndButtonBindings(uiBindingRegistry, new MoveToLastColumnAction()); // Select all uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, 'a'), new SelectAllAction()); // Copy uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, 'c'), new CopyDataAction()); // Mouse bindings - select Cell configureBodyMouseClickBindings(uiBindingRegistry); // Mouse bindings - select columns configureColumnHeaderMouseClickBindings(uiBindingRegistry); // Mouse bindings - select rows configureRowHeaderMouseClickBindings(uiBindingRegistry); // Mouse bindings - Drag configureBodyMouseDragMode(uiBindingRegistry); } // *** pg. up, pg. down, home, end keys selection bindings *** protected void configureEndButtonBindings(UiBindingRegistry uiBindingRegistry, IKeyAction action) { uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.END), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT, SWT.END), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, SWT.END), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT | SWT.CONTROL, SWT.END), action); } protected void configureHomeButtonBindings(UiBindingRegistry uiBindingRegistry, IKeyAction action) { uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.HOME), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT, SWT.HOME), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, SWT.HOME), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT | SWT.CONTROL, SWT.HOME), action); } protected void configurePageDownButtonBindings(UiBindingRegistry uiBindingRegistry, IKeyAction action) { uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.PAGE_DOWN), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT, SWT.PAGE_DOWN), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, SWT.PAGE_DOWN), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT | SWT.CONTROL, SWT.PAGE_DOWN), action); } protected void configurePageUpButtonBindings(UiBindingRegistry uiBindingRegistry, PageUpAction action) { uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.PAGE_UP), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT, SWT.PAGE_UP), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, SWT.PAGE_UP), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT | SWT.CONTROL, SWT.PAGE_UP), action); } // *** Arrow keys selection bindings *** protected void configureMoveRightBindings(UiBindingRegistry uiBindingRegistry, IKeyAction action) { uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.ARROW_RIGHT), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT, SWT.ARROW_RIGHT), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, SWT.ARROW_RIGHT), new MoveToLastColumnAction()); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT | SWT.CONTROL, SWT.ARROW_RIGHT), new MoveToLastColumnAction()); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.TAB), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, SWT.TAB), action); } protected void configureMoveLeftBindings(UiBindingRegistry uiBindingRegistry, IKeyAction action) { uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.ARROW_LEFT), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT, SWT.ARROW_LEFT), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, SWT.ARROW_LEFT), new MoveToFirstColumnAction()); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT | SWT.CONTROL, SWT.ARROW_LEFT), new MoveToFirstColumnAction()); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT, SWT.TAB), new MoveSelectionAction(MoveDirectionEnum.LEFT, false, false)); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT | SWT.CONTROL, SWT.TAB), action); } protected void configureMoveDownBindings(UiBindingRegistry uiBindingRegistry, IKeyAction action) { uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.ARROW_DOWN), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT, SWT.ARROW_DOWN), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, SWT.ARROW_DOWN), new MoveToLastRowAction()); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT | SWT.CONTROL, SWT.ARROW_DOWN), new MoveToLastRowAction()); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.CR), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, SWT.CR), action); } protected void configureMoveUpBindings(UiBindingRegistry uiBindingRegistry, IKeyAction action) { uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.ARROW_UP), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT, SWT.ARROW_UP), action); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CONTROL, SWT.ARROW_UP), new MoveToFirstRowAction()); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT | SWT.CONTROL, SWT.ARROW_UP), new MoveToFirstRowAction()); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT, SWT.CR), new MoveSelectionAction(MoveDirectionEnum.UP, false, false)); uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.SHIFT | SWT.CONTROL, SWT.CR), action); } // *** Mouse bindings *** protected void configureBodyMouseClickBindings(UiBindingRegistry uiBindingRegistry) { IMouseAction action = new SelectCellAction(); uiBindingRegistry.registerFirstSingleClickBinding(MouseEventMatcher.bodyLeftClick(SWT.NONE), action); uiBindingRegistry.registerFirstSingleClickBinding(MouseEventMatcher.bodyLeftClick(SWT.SHIFT), action); uiBindingRegistry.registerFirstSingleClickBinding(MouseEventMatcher.bodyLeftClick(SWT.CTRL), action); uiBindingRegistry.registerFirstSingleClickBinding(MouseEventMatcher.bodyLeftClick(SWT.SHIFT | SWT.CONTROL), action); } protected void configureColumnHeaderMouseClickBindings(UiBindingRegistry uiBindingRegistry) { uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.columnHeaderLeftClick(SWT.NONE), new ViewportSelectColumnAction(false, false)); uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.columnHeaderLeftClick(SWT.SHIFT), new ViewportSelectColumnAction(true, false)); uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.columnHeaderLeftClick(SWT.CONTROL), new ViewportSelectColumnAction(false, true)); uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.columnHeaderLeftClick(SWT.SHIFT | SWT.CONTROL), new ViewportSelectColumnAction(true, true)); } protected void configureRowHeaderMouseClickBindings(UiBindingRegistry uiBindingRegistry) { uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.rowHeaderLeftClick(SWT.NONE), new ViewportSelectRowAction(false, false)); uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.rowHeaderLeftClick(SWT.SHIFT), new ViewportSelectRowAction(true, false)); uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.rowHeaderLeftClick(SWT.CONTROL), new ViewportSelectRowAction(false, true)); uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.rowHeaderLeftClick(SWT.SHIFT | SWT.CONTROL), new ViewportSelectRowAction(true, true)); } protected void configureBodyMouseDragMode(UiBindingRegistry uiBindingRegistry) { CellSelectionDragMode dragMode = new CellSelectionDragMode(); uiBindingRegistry.registerMouseDragMode(MouseEventMatcher.bodyLeftClick(SWT.NONE), dragMode); uiBindingRegistry.registerMouseDragMode(MouseEventMatcher.bodyLeftClick(SWT.SHIFT), dragMode); uiBindingRegistry.registerMouseDragMode(MouseEventMatcher.bodyLeftClick(SWT.CONTROL), dragMode); uiBindingRegistry.registerMouseDragMode(MouseEventMatcher.bodyLeftClick(SWT.SHIFT | SWT.CONTROL), dragMode); } }
10,805
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowOnlySelectionConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/config/RowOnlySelectionConfiguration.java
package net.sourceforge.nattable.selection.config; import net.sourceforge.nattable.config.AbstractLayerConfiguration; import net.sourceforge.nattable.layer.event.ILayerEventHandler; import net.sourceforge.nattable.selection.MoveRowSelectionCommandHandler; import net.sourceforge.nattable.selection.SelectionLayer; /** * Configure the move selection behavior so that we always move by a row.<br/> * Add {@link ILayerEventHandler} to preserve row selection.<br/> * * @see DefaultMoveSelectionConfiguration */ public class RowOnlySelectionConfiguration<T> extends AbstractLayerConfiguration<SelectionLayer> { @Override public void configureTypedLayer(SelectionLayer layer) { layer.registerCommandHandler(new MoveRowSelectionCommandHandler(layer)); } }
783
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultMoveSelectionConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/config/DefaultMoveSelectionConfiguration.java
package net.sourceforge.nattable.selection.config; import net.sourceforge.nattable.config.AbstractLayerConfiguration; import net.sourceforge.nattable.selection.MoveCellSelectionCommandHandler; import net.sourceforge.nattable.selection.MoveRowSelectionCommandHandler; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.selection.command.MoveSelectionCommand; /** * Configure the behavior when the selection is moved. Example: by using arrow keys.<br/> * This default configuration moves by cell.<br/> * * {@link MoveSelectionCommand} are fired by the {@link DefaultSelectionBindings}.<br/> * An suitable handler can be plugged in to handle the move commands as required.<br/> * * @see MoveRowSelectionCommandHandler */ public class DefaultMoveSelectionConfiguration extends AbstractLayerConfiguration<SelectionLayer>{ @Override public void configureTypedLayer(SelectionLayer layer) { layer.registerCommandHandler(new MoveCellSelectionCommandHandler(layer)); } }
1,044
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultSelectionStyleConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/config/DefaultSelectionStyleConfiguration.java
package net.sourceforge.nattable.selection.config; import net.sourceforge.nattable.config.AbstractRegistryConfiguration; import net.sourceforge.nattable.config.CellConfigAttributes; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.grid.GridRegion; import net.sourceforge.nattable.style.BorderStyle; import net.sourceforge.nattable.style.CellStyleAttributes; import net.sourceforge.nattable.style.DisplayMode; import net.sourceforge.nattable.style.SelectionStyleLabels; import net.sourceforge.nattable.style.Style; import net.sourceforge.nattable.style.BorderStyle.LineStyleEnum; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; /** * Sets up rendering style used for selected areas and the selection anchor. */ public class DefaultSelectionStyleConfiguration extends AbstractRegistryConfiguration { // Selection style public Font selectionFont = GUIHelper.getFont(new FontData("Verdana", 8, SWT.BOLD | SWT.ITALIC)); public Color selectionBgColor = GUIHelper.COLOR_TITLE_INACTIVE_BACKGROUND; public Color selectionFgColor = GUIHelper.COLOR_BLACK; // Anchor style public Color anchorBorderColor = GUIHelper.COLOR_DARK_GRAY; public BorderStyle anchorBorderStyle = new BorderStyle(1, anchorBorderColor, LineStyleEnum.SOLID); public Color anchorBgColor = GUIHelper.COLOR_GRAY; public Color anchorFgColor = GUIHelper.COLOR_WHITE; // Selected headers style public Color selectedHeaderBgColor = GUIHelper.COLOR_GRAY; public Color selectedHeaderFgColor = GUIHelper.COLOR_WHITE; public Font selectedHeaderFont = GUIHelper.getFont(new FontData("Verdana", 10, SWT.BOLD)); public BorderStyle selectedHeaderBorderStyle = new BorderStyle(-1, selectedHeaderFgColor, LineStyleEnum.SOLID); public void configureRegistry(IConfigRegistry configRegistry) { configureSelectionStyle(configRegistry); configureSelectionAnchorStyle(configRegistry); configureHeaderHasSelectionStyle(configRegistry); configureHeaderFullySelectedStyle(configRegistry); } protected void configureSelectionStyle(IConfigRegistry configRegistry) { Style cellStyle = new Style(); cellStyle.setAttributeValue(CellStyleAttributes.FONT, selectionFont); cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, selectionBgColor); cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, selectionFgColor); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT); } protected void configureSelectionAnchorStyle(IConfigRegistry configRegistry) { // Selection anchor style for normal display mode Style cellStyle = new Style(); cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, anchorBorderStyle); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, SelectionStyleLabels.SELECTION_ANCHOR_STYLE); // Selection anchor style for select display mode cellStyle = new Style(); cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, anchorBgColor); cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, anchorFgColor); cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, anchorBorderStyle); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_STYLE); } protected void configureHeaderHasSelectionStyle(IConfigRegistry configRegistry) { Style cellStyle = new Style(); cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, selectedHeaderFgColor); cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, selectedHeaderBgColor); cellStyle.setAttributeValue(CellStyleAttributes.FONT, selectedHeaderFont); cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, selectedHeaderBorderStyle); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT, GridRegion.COLUMN_HEADER); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT, GridRegion.CORNER); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT, GridRegion.ROW_HEADER); } protected void configureHeaderFullySelectedStyle(IConfigRegistry configRegistry) { // Header fully selected Style cellStyle = new Style() {{ setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.COLOR_WIDGET_NORMAL_SHADOW); }}; configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT, SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT, SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE); } }
5,014
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultSelectionLayerConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/config/DefaultSelectionLayerConfiguration.java
package net.sourceforge.nattable.selection.config; import net.sourceforge.nattable.config.AggregateConfiguration; import net.sourceforge.nattable.search.config.DefaultSearchBindings; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.tickupdate.config.DefaultTickUpdateConfiguration; /** * Sets up default styling and UI bindings. Override the methods in here to * customize behavior. Added by the {@link SelectionLayer} */ public class DefaultSelectionLayerConfiguration extends AggregateConfiguration { public DefaultSelectionLayerConfiguration() { addSelectionStyleConfig(); addSelectionUIBindings(); addSearchUIBindings(); addTickUpdateConfig(); addMoveSelectionConfig(); } protected void addSelectionStyleConfig() { addConfiguration(new DefaultSelectionStyleConfiguration()); } protected void addSelectionUIBindings() { addConfiguration(new DefaultSelectionBindings()); } protected void addSearchUIBindings() { addConfiguration(new DefaultSearchBindings()); } protected void addTickUpdateConfig() { addConfiguration(new DefaultTickUpdateConfiguration()); } protected void addMoveSelectionConfig() { addConfiguration(new DefaultMoveSelectionConfiguration()); } }
1,290
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
MoveSelectionCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/command/MoveSelectionCommand.java
package net.sourceforge.nattable.selection.command; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; public class MoveSelectionCommand extends AbstractSelectionCommand { private final MoveDirectionEnum direction; private final int stepSize; public MoveSelectionCommand(MoveDirectionEnum direction, boolean shiftMask, boolean controlMask) { this(direction, 0, shiftMask, controlMask); } public MoveSelectionCommand(MoveDirectionEnum direction, int stepSize, boolean shiftMask, boolean controlMask) { super(shiftMask, controlMask); this.direction = direction; this.stepSize = stepSize; } public MoveDirectionEnum getDirection() { return direction; } public int getStepSize() { return stepSize; } }
783
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z