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
ClearAllSelectionsCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/command/ClearAllSelectionsCommand.java
package net.sourceforge.nattable.selection.command; public class ClearAllSelectionsCommand extends AbstractSelectionCommand { public ClearAllSelectionsCommand() { super(false, false); } }
204
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectRowsCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/command/SelectRowsCommand.java
package net.sourceforge.nattable.selection.command; import net.sourceforge.nattable.command.AbstractMultiRowCommand; import net.sourceforge.nattable.command.LayerCommandUtil; import net.sourceforge.nattable.coordinate.ColumnPositionCoordinate; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.util.ArrayUtil; public class SelectRowsCommand extends AbstractMultiRowCommand { private ColumnPositionCoordinate columnPositionCoordinate; private final boolean withShiftMask; private final boolean withControlMask; public SelectRowsCommand(ILayer layer, int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask) { this(layer, columnPosition, ArrayUtil.asIntArray(rowPosition), withShiftMask, withControlMask); } public SelectRowsCommand(ILayer layer, int columnPosition, int[] rowPositions, boolean withShiftMask, boolean withControlMask) { super(layer, rowPositions); this.columnPositionCoordinate = new ColumnPositionCoordinate(layer, columnPosition); this.withControlMask = withControlMask; this.withShiftMask = withShiftMask; } protected SelectRowsCommand(SelectRowsCommand command) { super(command); this.columnPositionCoordinate = command.columnPositionCoordinate; this.withShiftMask = command.withShiftMask; this.withControlMask = command.withControlMask; } @Override public boolean convertToTargetLayer(ILayer targetLayer) { super.convertToTargetLayer(targetLayer); this.columnPositionCoordinate = LayerCommandUtil.convertColumnPositionToTargetContext(columnPositionCoordinate, targetLayer); return columnPositionCoordinate != null && columnPositionCoordinate.getColumnPosition() >= 0; } public int getColumnPosition() { return columnPositionCoordinate.getColumnPosition(); } public boolean isWithShiftMask() { return withShiftMask; } public boolean isWithControlMask() { return withControlMask; } public SelectRowsCommand cloneCommand() { return new SelectRowsCommand(this); } }
2,056
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractSelectionCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/command/AbstractSelectionCommand.java
package net.sourceforge.nattable.selection.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; public abstract class AbstractSelectionCommand extends AbstractContextFreeCommand { private boolean shiftMask; private boolean controlMask; public AbstractSelectionCommand(boolean shiftMask, boolean controlMask) { this.shiftMask = shiftMask; this.controlMask = controlMask; } public boolean isShiftMask() { return shiftMask; } public boolean isControlMask() { return controlMask; } }
554
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectCellCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/command/SelectCellCommand.java
package net.sourceforge.nattable.selection.command; import net.sourceforge.nattable.command.AbstractPositionCommand; import net.sourceforge.nattable.layer.ILayer; /** * Event indicating that the user has selected a specific cell in the data grid. This command should be used for * implementing all selection handling by layers. * * <strong>Note that this command takes a Grid PositionCoordinate describing a cell on the screen on which the user has * clicked. Do not pass it anything else or you will introduce very subtle and very difficult to debug bugs into the * code and then we will have to pay you a visit on one random Sunday morning when you least expect it.<strong> */ public class SelectCellCommand extends AbstractPositionCommand { private boolean shiftMask; private boolean controlMask; private boolean forcingEntireCellIntoViewport = false; public SelectCellCommand(ILayer layer, int columnPosition, int rowPosition, boolean shiftMask, boolean controlMask) { super(layer, columnPosition, rowPosition); this.shiftMask = shiftMask; this.controlMask = controlMask; } protected SelectCellCommand(SelectCellCommand command) { super(command); this.shiftMask = command.shiftMask; this.controlMask = command.controlMask; this.forcingEntireCellIntoViewport = command.forcingEntireCellIntoViewport; } public boolean isShiftMask() { return shiftMask; } public boolean isControlMask() { return controlMask; } public boolean isForcingEntireCellIntoViewport() { return forcingEntireCellIntoViewport; } public void setForcingEntireCellIntoViewport(boolean forcingEntireCellIntoViewport) { this.forcingEntireCellIntoViewport = forcingEntireCellIntoViewport; } public SelectCellCommand cloneCommand() { return new SelectCellCommand(this); } }
1,962
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ScrollSelectionCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/command/ScrollSelectionCommand.java
package net.sourceforge.nattable.selection.command; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; public class ScrollSelectionCommand extends MoveSelectionCommand { public ScrollSelectionCommand(MoveDirectionEnum direction, boolean shiftMask, boolean controlMask) { super(direction, shiftMask, controlMask); } }
362
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectAllCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/command/SelectAllCommand.java
package net.sourceforge.nattable.selection.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; public class SelectAllCommand extends AbstractContextFreeCommand { }
197
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectColumnCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/command/SelectColumnCommand.java
package net.sourceforge.nattable.selection.command; import net.sourceforge.nattable.command.AbstractPositionCommand; import net.sourceforge.nattable.layer.ILayer; public class SelectColumnCommand extends AbstractPositionCommand { private final boolean withShiftMask; private final boolean withControlMask; public SelectColumnCommand(ILayer layer, int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask) { super(layer, columnPosition, rowPosition); this.withShiftMask = withShiftMask; this.withControlMask = withControlMask; } protected SelectColumnCommand(SelectColumnCommand command) { super(command); this.withShiftMask = command.withShiftMask; this.withControlMask = command.withControlMask; } public boolean isWithShiftMask() { return withShiftMask; } public boolean isWithControlMask() { return withControlMask; } public SelectColumnCommand cloneCommand() { return new SelectColumnCommand(this); } }
1,013
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CellSelectionEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/event/CellSelectionEvent.java
package net.sourceforge.nattable.selection.event; import net.sourceforge.nattable.layer.event.CellVisualChangeEvent; import net.sourceforge.nattable.selection.SelectionLayer; public class CellSelectionEvent extends CellVisualChangeEvent implements ISelectionEvent { private final SelectionLayer selectionLayer; private boolean forcingEntireCellIntoViewport = false; // The state of the keys when the event was raised private boolean withShiftMask = false; private boolean withControlMask = false; public CellSelectionEvent(SelectionLayer selectionLayer, int columnPosition, int rowPosition, boolean forcingEntireCellIntoViewport, boolean withShiftMask, boolean withControlMask) { super(selectionLayer, columnPosition, rowPosition); this.selectionLayer = selectionLayer; this.forcingEntireCellIntoViewport = forcingEntireCellIntoViewport; this.withControlMask = withControlMask; this.withShiftMask = withShiftMask; } // Copy constructor protected CellSelectionEvent(CellSelectionEvent event) { super(event); this.selectionLayer = event.selectionLayer; this.forcingEntireCellIntoViewport = event.forcingEntireCellIntoViewport; this.withControlMask = event.withControlMask; this.withShiftMask = event.withShiftMask; } public SelectionLayer getSelectionLayer() { return selectionLayer; } public boolean isForcingEntireCellIntoViewport() { return forcingEntireCellIntoViewport; } @Override public CellSelectionEvent cloneEvent() { return new CellSelectionEvent(this); } public boolean isWithShiftMask() { return withShiftMask; } public boolean isWithControlMask() { return withControlMask; } }
1,707
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ISelectionEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/event/ISelectionEvent.java
package net.sourceforge.nattable.selection.event; import net.sourceforge.nattable.selection.SelectionLayer; /** * Marker interface for selection events. */ public interface ISelectionEvent { public SelectionLayer getSelectionLayer(); }
256
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnSelectionEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/event/ColumnSelectionEvent.java
package net.sourceforge.nattable.selection.event; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.event.ColumnVisualChangeEvent; import net.sourceforge.nattable.selection.SelectionLayer; public class ColumnSelectionEvent extends ColumnVisualChangeEvent implements ISelectionEvent { private final SelectionLayer selectionLayer; public ColumnSelectionEvent(SelectionLayer selectionLayer, int columnPosition) { super(selectionLayer, new Range(columnPosition, columnPosition + 1)); this.selectionLayer = selectionLayer; } protected ColumnSelectionEvent(ColumnSelectionEvent event) { super(event); this.selectionLayer = event.selectionLayer; } public SelectionLayer getSelectionLayer() { return selectionLayer; } public ColumnSelectionEvent cloneEvent() { return new ColumnSelectionEvent(this); } }
897
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectionLayerStructuralChangeEventHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/event/SelectionLayerStructuralChangeEventHandler.java
package net.sourceforge.nattable.selection.event; import java.util.Collection; import java.util.Set; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.event.ILayerEventHandler; import net.sourceforge.nattable.layer.event.IStructuralChangeEvent; import net.sourceforge.nattable.selection.ISelectionModel; import net.sourceforge.nattable.selection.SelectionLayer; import org.eclipse.swt.graphics.Rectangle; public class SelectionLayerStructuralChangeEventHandler implements ILayerEventHandler<IStructuralChangeEvent> { private ISelectionModel selectionModel; private final SelectionLayer selectionLayer; public SelectionLayerStructuralChangeEventHandler(SelectionLayer selectionLayer, ISelectionModel selectionModel) { this.selectionLayer = selectionLayer; this.selectionModel = selectionModel; } public Class<IStructuralChangeEvent> getLayerEventClass() { return IStructuralChangeEvent.class; } public void handleLayerEvent(IStructuralChangeEvent event) { if (event.isHorizontalStructureChanged()) { // TODO handle column deletion } if (event.isVerticalStructureChanged()) { Collection<Rectangle> rectangles = event.getChangedPositionRectangles(); for (Rectangle rectangle : rectangles) { if(selectedRowModified(rectangle.y)) { selectionLayer.clear(); } } } } private boolean selectedRowModified(int rowPosition){ Set<Range> selectedRows = selectionModel.getSelectedRows(); for (Range rowRange : selectedRows) { if (rowRange.contains(rowPosition)){ return true; } } return false; } }
1,656
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowSelectionEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/selection/event/RowSelectionEvent.java
package net.sourceforge.nattable.selection.event; import java.util.Collection; import net.sourceforge.nattable.coordinate.PositionUtil; import net.sourceforge.nattable.layer.event.RowVisualChangeEvent; import net.sourceforge.nattable.selection.SelectionLayer; public class RowSelectionEvent extends RowVisualChangeEvent implements ISelectionEvent { private final SelectionLayer selectionLayer; public RowSelectionEvent(SelectionLayer selectionLayer, Collection<Integer> rowPositions) { super(selectionLayer, PositionUtil.getRanges(rowPositions)); this.selectionLayer = selectionLayer; } // Copy constructor protected RowSelectionEvent(RowSelectionEvent event) { super(event); this.selectionLayer = event.selectionLayer; } public SelectionLayer getSelectionLayer() { return selectionLayer; } public RowSelectionEvent cloneEvent() { return new RowSelectionEvent(this); } }
936
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
GridRegion.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/GridRegion.java
package net.sourceforge.nattable.grid; /** * A region is simply an area on the Grid. * Diving the table/grid into regions makes it easier to manage areas with similar behavior. * * For example all the cells in the column header are painted differently * and can respond to sorting actions. */ public interface GridRegion { public static final String CORNER = "CORNER"; public static final String COLUMN_HEADER = "COLUMN_HEADER"; public static final String COLUMN_GROUP_HEADER = "COLUMN_GROUP_HEADER"; public static final String ROW_HEADER = "ROW_HEADER"; public static final String BODY = "BODY"; public static final String DATAGRID = "DATAGRID"; public static final String FILTER_ROW = "FILTER_ROW"; }
737
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DummySpanningBodyDataProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/data/DummySpanningBodyDataProvider.java
package net.sourceforge.nattable.grid.data; import net.sourceforge.nattable.data.ISpanningDataProvider; import net.sourceforge.nattable.layer.cell.DataCell; public class DummySpanningBodyDataProvider extends DummyBodyDataProvider implements ISpanningDataProvider { private static final int BLOCK_SIZE = 4; private static final int CELL_SPAN = 2; public DummySpanningBodyDataProvider(int columnCount, int rowCount) { super(columnCount, rowCount); } public DataCell getCellByPosition(int columnPosition, int rowPosition) { int columnBlock = columnPosition / BLOCK_SIZE; int rowBlock = rowPosition / BLOCK_SIZE; boolean isSpanned = isEven(columnBlock + rowBlock) && (columnPosition % BLOCK_SIZE) < CELL_SPAN && (rowPosition % BLOCK_SIZE) < CELL_SPAN; int columnSpan = isSpanned ? CELL_SPAN : 1; int rowSpan = isSpanned ? CELL_SPAN : 1; int cellColumnPosition = columnPosition; int cellRowPosition = rowPosition; if (isSpanned) { cellColumnPosition -= columnPosition % BLOCK_SIZE; cellRowPosition -= rowPosition % BLOCK_SIZE; } return new DataCell(cellColumnPosition, cellRowPosition, columnSpan, rowSpan); } private boolean isEven(int i) { return i % 2 == 0; } }
1,262
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultSummaryRowHeaderDataProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/data/DefaultSummaryRowHeaderDataProvider.java
package net.sourceforge.nattable.grid.data; import net.sourceforge.nattable.data.IDataProvider; import net.sourceforge.nattable.grid.layer.RowHeaderLayer; import net.sourceforge.nattable.summaryrow.SummaryRowLayer; /** * {@link IDataProvider} to use for the {@link RowHeaderLayer} if the {@link SummaryRowLayer} is present in the body layer stack. <br/> * This adds an extra row to the row header for displaying the summary row. */ public class DefaultSummaryRowHeaderDataProvider extends DefaultRowHeaderDataProvider implements IDataProvider { public static final String DEFAULT_SUMMARY_ROW_LABEL = "Summary"; private final String summaryRowLabel; public DefaultSummaryRowHeaderDataProvider(IDataProvider bodyDataProvider) { this(bodyDataProvider, DEFAULT_SUMMARY_ROW_LABEL); } /** * @param summaryRowLabel label to display in the row header for the Summary Row */ public DefaultSummaryRowHeaderDataProvider(IDataProvider bodyDataProvider, String summaryRowLabel) { super(bodyDataProvider); this.summaryRowLabel = summaryRowLabel; } public int getRowCount() { return super.getRowCount() + 1; } @Override public Object getDataValue(int columnIndex, int rowIndex) { if (rowIndex == super.getRowCount()){ return summaryRowLabel; } return super.getDataValue(columnIndex, rowIndex); } }
1,365
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DummyColumnHeaderDataProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/data/DummyColumnHeaderDataProvider.java
package net.sourceforge.nattable.grid.data; import net.sourceforge.nattable.data.IDataProvider; public class DummyColumnHeaderDataProvider implements IDataProvider { private final IDataProvider bodyDataProvider; public DummyColumnHeaderDataProvider(IDataProvider bodyDataProvider) { this.bodyDataProvider = bodyDataProvider; } public int getColumnCount() { return bodyDataProvider.getColumnCount(); } public int getRowCount() { return 1; } public Object getDataValue(int columnIndex, int rowIndex) { return "Column " + (columnIndex + 1); } public void setDataValue(int columnIndex, int rowIndex, Object newValue) { throw new UnsupportedOperationException(); } }
724
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultCornerDataProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/data/DefaultCornerDataProvider.java
package net.sourceforge.nattable.grid.data; import net.sourceforge.nattable.data.IDataProvider; public class DefaultCornerDataProvider implements IDataProvider { private final IDataProvider columnHeaderDataProvider; private final IDataProvider rowHeaderDataProvider; public DefaultCornerDataProvider(IDataProvider columnHeaderDataProvider, IDataProvider rowHeaderDataProvider) { this.columnHeaderDataProvider = columnHeaderDataProvider; this.rowHeaderDataProvider = rowHeaderDataProvider; } public int getColumnCount() { return rowHeaderDataProvider.getColumnCount(); } public int getRowCount() { return columnHeaderDataProvider.getRowCount(); } public Object getDataValue(int columnIndex, int rowIndex) { return null; } public void setDataValue(int columnIndex, int rowIndex, Object newValue) { throw new UnsupportedOperationException(); } }
910
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultBodyDataProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/data/DefaultBodyDataProvider.java
package net.sourceforge.nattable.grid.data; import java.util.List; import net.sourceforge.nattable.data.ListDataProvider; import net.sourceforge.nattable.data.ReflectiveColumnPropertyAccessor; public class DefaultBodyDataProvider<T> extends ListDataProvider<T> { public DefaultBodyDataProvider(List<T> rowData, String[] propertyNames) { super(rowData, new ReflectiveColumnPropertyAccessor<T>(propertyNames)); } }
437
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DummyBodyDataProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/data/DummyBodyDataProvider.java
package net.sourceforge.nattable.grid.data; import java.util.HashMap; import java.util.Map; import org.eclipse.swt.graphics.Point; import net.sourceforge.nattable.data.IDataProvider; public class DummyBodyDataProvider implements IDataProvider { private final int columnCount; private final int rowCount; private Map<Point, Object> values = new HashMap<Point, Object>(); public DummyBodyDataProvider(int columnCount, int rowCount) { this.columnCount = columnCount; this.rowCount = rowCount; } public int getColumnCount() { return columnCount; } public int getRowCount() { return rowCount; } public Object getDataValue(int columnIndex, int rowIndex) { Point point = new Point(columnIndex, rowIndex); if (values.containsKey(point)) { return values.get(point); } else { return "Col: " + (columnIndex + 1) + ", Row: " + (rowIndex + 1); } } public void setDataValue(int columnIndex, int rowIndex, Object newValue) { values.put(new Point(columnIndex, rowIndex), newValue); } }
1,068
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultRowHeaderDataProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/data/DefaultRowHeaderDataProvider.java
package net.sourceforge.nattable.grid.data; import net.sourceforge.nattable.data.IDataProvider; public class DefaultRowHeaderDataProvider implements IDataProvider { protected final IDataProvider bodyDataProvider; public DefaultRowHeaderDataProvider(IDataProvider bodyDataProvider) { this.bodyDataProvider = bodyDataProvider; } public int getColumnCount() { return 1; } public int getRowCount() { return bodyDataProvider.getRowCount(); } public Object getDataValue(int columnIndex, int rowIndex) { return Integer.valueOf(rowIndex + 1); } public void setDataValue(int columnIndex, int rowIndex, Object newValue) { throw new UnsupportedOperationException(); } }
721
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultColumnHeaderDataProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/data/DefaultColumnHeaderDataProvider.java
package net.sourceforge.nattable.grid.data; import java.util.Map; import net.sourceforge.nattable.data.IDataProvider; public class DefaultColumnHeaderDataProvider implements IDataProvider { private final String[] propertyNames; private Map<String, String> propertyToLabelMap; public DefaultColumnHeaderDataProvider(final String[] columnLabels) { propertyNames = columnLabels; } public DefaultColumnHeaderDataProvider(final String[] propertyNames, Map<String, String> propertyToLabelMap) { this.propertyNames = propertyNames; this.propertyToLabelMap = propertyToLabelMap; } public String getColumnHeaderLabel(int columnIndex) { String propertyName = propertyNames[columnIndex]; if (propertyToLabelMap != null) { String label = propertyToLabelMap.get(propertyName); if (label != null) { return label; } } return propertyName; } public int getColumnCount() { return propertyNames.length; } public int getRowCount() { return 1; } /** * This class does not support multiple rows in the column header layer. */ public Object getDataValue(int columnIndex, int rowIndex) { return getColumnHeaderLabel(columnIndex); } public void setDataValue(int columnIndex, int rowIndex, Object newValue) { throw new UnsupportedOperationException(); } }
1,352
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AlternatingRowConfigLabelAccumulator.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/cell/AlternatingRowConfigLabelAccumulator.java
package net.sourceforge.nattable.grid.cell; import net.sourceforge.nattable.grid.GridRegion; import net.sourceforge.nattable.grid.layer.config.DefaultRowStyleConfiguration; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.layer.cell.IConfigLabelAccumulator; /** * Applies 'odd'/'even' labels to all the rows. These labels are * the used to apply color to alternate rows. * * @see DefaultRowStyleConfiguration */ public class AlternatingRowConfigLabelAccumulator implements IConfigLabelAccumulator { public static final String ODD_ROW_CONFIG_TYPE = "ODD_" + GridRegion.BODY; public static final String EVEN_ROW_CONFIG_TYPE = "EVEN_" + GridRegion.BODY; public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) { configLabels.addLabel((rowPosition % 2 == 0 ? EVEN_ROW_CONFIG_TYPE : ODD_ROW_CONFIG_TYPE)); } }
918
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnHeaderLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/ColumnHeaderLayer.java
package net.sourceforge.nattable.grid.layer; import net.sourceforge.nattable.columnRename.DisplayColumnRenameDialogCommandHandler; import net.sourceforge.nattable.columnRename.RenameColumnHeaderCommandHandler; import net.sourceforge.nattable.columnRename.RenameColumnHelper; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.layer.LayerUtil; import net.sourceforge.nattable.layer.config.DefaultColumnHeaderLayerConfiguration; 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; import net.sourceforge.nattable.style.SelectionStyleLabels; /** * Responsible for rendering, event handling etc on the column headers. */ public class ColumnHeaderLayer extends DimensionallyDependentLayer { private final SelectionLayer selectionLayer; private final ILayerPainter layerPainter = new CellLayerPainter(); private final RenameColumnHelper renameColumnHelper; /** * @param baseLayer data provider for the column header layer * @param horizontalLayerDependency typically the body layer * @param selectionLayer required to respond to selection events */ public ColumnHeaderLayer(IUniqueIndexLayer baseLayer, ILayer horizontalLayerDependency, SelectionLayer selectionLayer) { this(baseLayer, horizontalLayerDependency, selectionLayer, true); } public ColumnHeaderLayer(IUniqueIndexLayer baseLayer, ILayer horizontalLayerDependency, SelectionLayer selectionLayer, boolean useDefaultConfiguration) { super(baseLayer, horizontalLayerDependency, baseLayer); this.selectionLayer = selectionLayer; this.renameColumnHelper = new RenameColumnHelper(this); registerPersistable(renameColumnHelper); selectionLayer.addLayerListener(new ColumnHeaderSelectionListener(this)); registerCommandHandler(new RenameColumnHeaderCommandHandler(this)); registerCommandHandler(new DisplayColumnRenameDialogCommandHandler(this)); if (useDefaultConfiguration) { addConfiguration(new DefaultColumnHeaderLayerConfiguration()); } } @Override public String getDisplayModeByPosition(int columnPosition, int rowPosition) { int selectionLayerColumnPosition = LayerUtil.convertColumnPosition(this, columnPosition, selectionLayer); if (selectionLayer.isColumnPositionSelected(selectionLayerColumnPosition)) { return DisplayMode.SELECT; } else { return super.getDisplayModeByPosition(columnPosition, rowPosition); } } @Override public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) { LabelStack labelStack = super.getConfigLabelsByPosition(columnPosition, rowPosition); final int selectionLayerColumnPosition = LayerUtil.convertColumnPosition(this, columnPosition, selectionLayer); if (selectionLayer.isColumnFullySelected(selectionLayerColumnPosition)) { labelStack.addLabel(SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE); } return labelStack; } public SelectionLayer getSelectionLayer() { return selectionLayer; } @Override public ILayerPainter getLayerPainter() { return layerPainter; } @Override public Object getDataValueByPosition(int columnPosition, int rowPosition) { int columnIndex = getColumnIndexByPosition(columnPosition); if (isColumnRenamed(columnIndex)) { return getRenamedColumnLabelByIndex(columnIndex); } return super.getDataValueByPosition(columnPosition, rowPosition); } // Column header renaming /** * @return column header as defined by the data source */ public String getOriginalColumnLabel(int columnPosition) { return super.getDataValueByPosition(columnPosition, 0).toString(); } /** * @return renamed column header if the column has been renamed, NULL otherwise */ public String getRenamedColumnLabel(int columnPosition) { int index = getColumnIndexByPosition(columnPosition); return getRenamedColumnLabelByIndex(index); } /** * @return renamed column header if the column has been renamed, NULL otherwise */ public String getRenamedColumnLabelByIndex(int columnIndex) { return renameColumnHelper.getRenamedColumnLabel(columnIndex); } /** * @return TRUE if the column at the given index has been given a custom name by the user. */ public boolean isColumnRenamed(int columnIndex) { return renameColumnHelper.isColumnRenamed(columnIndex); } public boolean renameColumnPosition(int columnPosition, String customColumnName) { return renameColumnHelper.renameColumnPosition(columnPosition, customColumnName); } }
4,820
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultRowHeaderDataLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/DefaultRowHeaderDataLayer.java
package net.sourceforge.nattable.grid.layer; import net.sourceforge.nattable.data.IDataProvider; import net.sourceforge.nattable.layer.DataLayer; public class DefaultRowHeaderDataLayer extends DataLayer { public DefaultRowHeaderDataLayer(IDataProvider rowHeaderDataProvider) { super(rowHeaderDataProvider, 40, 40); } }
340
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnHeaderSelectionListener.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/ColumnHeaderSelectionListener.java
package net.sourceforge.nattable.grid.layer; import net.sourceforge.nattable.grid.layer.event.ColumnHeaderSelectionEvent; import net.sourceforge.nattable.layer.ILayerListener; import net.sourceforge.nattable.layer.event.ILayerEvent; import net.sourceforge.nattable.selection.event.ColumnSelectionEvent; /** * Marks the ColumnHeader as selected in response to a {@link ColumnSelectionEvent} */ public class ColumnHeaderSelectionListener implements ILayerListener { private ColumnHeaderLayer columnHeaderLayer; public ColumnHeaderSelectionListener(ColumnHeaderLayer columnHeaderLayer) { this.columnHeaderLayer = columnHeaderLayer; } public void handleLayerEvent(ILayerEvent event) { if (event instanceof ColumnSelectionEvent) { ColumnSelectionEvent selectionEvent = (ColumnSelectionEvent) event; ColumnHeaderSelectionEvent colHeaderSelectionEvent = new ColumnHeaderSelectionEvent(columnHeaderLayer, selectionEvent.getColumnPositionRanges()); columnHeaderLayer.fireLayerEvent(colHeaderSelectionEvent); } } }
1,060
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
GridLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/GridLayer.java
package net.sourceforge.nattable.grid.layer; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.export.excel.command.ExportToExcelCommandHandler; import net.sourceforge.nattable.grid.GridRegion; import net.sourceforge.nattable.grid.command.AutoResizeColumnCommandHandler; import net.sourceforge.nattable.grid.command.AutoResizeRowCommandHandler; import net.sourceforge.nattable.grid.layer.config.DefaultGridLayerConfiguration; import net.sourceforge.nattable.layer.CompositeLayer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.print.command.PrintCommandHandler; import net.sourceforge.nattable.selection.command.SelectCellCommand; /** * Top level layer. It is composed of the smaller child layers: RowHeader, * ColumnHeader, Corner and Body It does not have its own coordinate system * unlike the other layers. It simply delegates most functions to its child * layers. */ public class GridLayer extends CompositeLayer { public GridLayer(ILayer bodyLayer, ILayer columnHeaderLayer, ILayer rowHeaderLayer, ILayer cornerLayer) { this(bodyLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer, true); } public GridLayer(ILayer bodyLayer, ILayer columnHeaderLayer, ILayer rowHeaderLayer, ILayer cornerLayer, boolean useDefaultConfiguration) { super(2, 2); setBodyLayer(bodyLayer); setColumnHeaderLayer(columnHeaderLayer); setRowHeaderLayer(rowHeaderLayer); setCornerLayer(cornerLayer); init(useDefaultConfiguration); } protected GridLayer(boolean useDefaultConfiguration) { super(2, 2); init(useDefaultConfiguration); } protected void init(boolean useDefaultConfiguration) { registerCommandHandlers(); if (useDefaultConfiguration) { addConfiguration(new DefaultGridLayerConfiguration(this)); } } protected void registerCommandHandlers() { registerCommandHandler(new PrintCommandHandler(this)); registerCommandHandler(new ExportToExcelCommandHandler(this)); registerCommandHandler(new AutoResizeColumnCommandHandler(this)); registerCommandHandler(new AutoResizeRowCommandHandler(this)); } /** * How the GridLayer processes commands is very important. <strong>Do not * change this unless you know what you are doing and understand the full * ramifications of your change. Otherwise your grid will not behave * correctly!</strong> * * The Body is always given the first chance to process a command. There are * two reasons for this: (1) most commands (80%) are destined for the body * anyways so it's faster to check there first (2) the other layers all * transitively depend on the body so it's not wise to ask them to do stuff * until after the body has done it. This is especially true of grid * initialization where the body must be initialized before any of its * dependent layers. * * Because of this, if you want to intercept well-known commands to * implement custom behavior (for example, you want to intercept the * {@link SelectCellCommand}) then <strong>you must inject your special * layer into the body. </strong> An injected column or row header will * never see the command because it will be consumed first by the body. In * practice, it's a good idea to implement all your command-handling logic * in the body. **/ @Override protected boolean doCommandOnChildLayers(ILayerCommand command) { if (doCommandOnChildLayer(command, getBodyLayer())) { return true; } else if (doCommandOnChildLayer(command, getColumnHeaderLayer())) { return true; } else if (doCommandOnChildLayer(command, getRowHeaderLayer())) { return true; } else { return doCommandOnChildLayer(command, getCornerLayer()); } } private boolean doCommandOnChildLayer(ILayerCommand command, ILayer childLayer) { ILayerCommand childCommand = command.cloneCommand(); return childLayer.doCommand(childCommand); } // Sub-layer accessors public ILayer getCornerLayer() { return getChildLayerByLayoutCoordinate(0, 0); } public void setCornerLayer(ILayer cornerLayer) { setChildLayer(GridRegion.CORNER, cornerLayer, 0, 0); } public ILayer getColumnHeaderLayer() { return getChildLayerByLayoutCoordinate(1, 0); } public void setColumnHeaderLayer(ILayer columnHeaderLayer) { setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 1, 0); } public ILayer getRowHeaderLayer() { return getChildLayerByLayoutCoordinate(0, 1); } public void setRowHeaderLayer(ILayer rowHeaderLayer) { setChildLayer(GridRegion.ROW_HEADER, rowHeaderLayer, 0, 1); } public ILayer getBodyLayer() { return getChildLayerByLayoutCoordinate(1, 1); } public void setBodyLayer(ILayer bodyLayer) { setChildLayer(GridRegion.BODY, bodyLayer, 1, 1); } @Override public String toString() { return getClass().getSimpleName() + "[corner=" + getCornerLayer() + " columnHeader=" + getColumnHeaderLayer() + " rowHeader=" + getRowHeaderLayer() + " bodyLayer=" + getBodyLayer() + "]"; } }
5,121
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultColumnHeaderDataLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/DefaultColumnHeaderDataLayer.java
package net.sourceforge.nattable.grid.layer; import net.sourceforge.nattable.data.IDataProvider; import net.sourceforge.nattable.layer.DataLayer; public class DefaultColumnHeaderDataLayer extends DataLayer { public DefaultColumnHeaderDataLayer(IDataProvider columnHeaderDataProvider) { super(columnHeaderDataProvider, 100, 20); } }
353
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CornerLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/CornerLayer.java
package net.sourceforge.nattable.grid.layer; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.cell.LayerCell; import net.sourceforge.nattable.painter.layer.CellLayerPainter; import net.sourceforge.nattable.painter.layer.ILayerPainter; public class CornerLayer extends DimensionallyDependentLayer { private ILayerPainter layerPainter = new CellLayerPainter(); public CornerLayer(IUniqueIndexLayer baseLayer, ILayer horizontalLayerDependency, ILayer verticalLayerDependency) { super(baseLayer, horizontalLayerDependency, verticalLayerDependency); } @Override public ILayerPainter getLayerPainter() { return layerPainter; } @Override public LayerCell getCellByPosition(int columnPosition, int rowPosition) { return new LayerCell(this, 0, 0, columnPosition, rowPosition, getHorizontalLayerDependency().getColumnCount(), getVerticalLayerDependency().getRowCount()); } }
1,009
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DimensionallyDependentLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/DimensionallyDependentLayer.java
package net.sourceforge.nattable.grid.layer; import java.util.Collection; import java.util.HashSet; import java.util.Properties; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.config.ConfigRegistry; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.AbstractLayer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.ILayerListener; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.layer.LayerUtil; import net.sourceforge.nattable.layer.event.ILayerEvent; import net.sourceforge.nattable.layer.event.IStructuralChangeEvent; import net.sourceforge.nattable.painter.layer.ILayerPainter; import net.sourceforge.nattable.ui.binding.UiBindingRegistry; import net.sourceforge.nattable.util.IClientAreaProvider; /** * <p> * A DimensionallyDependentLayer is a layer whose horizontal and vertical dimensions are dependent on the horizontal and * vertical dimensions of other layers. A DimensionallyDependentLayer takes three constructor parameters: the horizontal * layer that the DimensionallyDependentLayer's horizontal dimension is linked to, the vertical layer that the * DimensionallyDependentLayer is linked to, and a base layer to which all non-dimensionally related ILayer method calls * will be delegated to (e.g. command, event methods) * </p> * <p> * Prime examples of dimensionally dependent layers are the column header and row header layers. For example, the column * header layer's horizontal dimension is linked to the body layer's horizontal dimension. This means that whatever * columns are shown in the body area will also be shown in the column header area, and vice versa. Note that the column * header layer maintains its own vertical dimension, however, so it's vertical layer dependency would be a separate * data layer. The same is true for the row header layer, only with the vertical instead of the horizontal dimension. * The constructors for the column header and row header layers would therefore look something like this: * </p> * <pre> * ILayer columnHeaderLayer = new DimensionallyDependentLayer(columnHeaderRowDataLayer, bodyLayer, columnHeaderRowDataLayer); * ILayer rowHeaderLayer = new DimensionallyDependentLayer(rowHeaderColumnDataLayer, bodyLayer, rowHeaderColumnDataLayer); * </pre> */ public class DimensionallyDependentLayer extends AbstractLayer { private final IUniqueIndexLayer baseLayer; private ILayer horizontalLayerDependency; private ILayer verticalLayerDependency; private IClientAreaProvider clientAreaProvider; public DimensionallyDependentLayer(IUniqueIndexLayer baseLayer, ILayer horizontalLayerDependency, ILayer verticalLayerDependency) { this.baseLayer = baseLayer; this.horizontalLayerDependency = horizontalLayerDependency; this.verticalLayerDependency = verticalLayerDependency; baseLayer.addLayerListener(this); horizontalLayerDependency.addLayerListener(new ILayerListener() { public void handleLayerEvent(ILayerEvent event) { if (event instanceof IStructuralChangeEvent) { // TODO refresh horizontal structure } } }); verticalLayerDependency.addLayerListener(new ILayerListener() { public void handleLayerEvent(ILayerEvent event) { if (event instanceof IStructuralChangeEvent) { // TODO refresh vertical structure } } }); } // Persistence @Override public void saveState(String prefix, Properties properties) { super.saveState(prefix, properties); baseLayer.saveState(prefix, properties); } @Override public void loadState(String prefix, Properties properties) { super.loadState(prefix, properties); baseLayer.loadState(prefix, properties); } // Configuration @Override public void configure(ConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry) { baseLayer.configure(configRegistry, uiBindingRegistry); super.configure(configRegistry, uiBindingRegistry); } // Dependent layer accessors public void setHorizontalLayerDependency(ILayer horizontalLayerDependency) { this.horizontalLayerDependency = horizontalLayerDependency; } public void setVerticalLayerDependency(ILayer verticalLayerDependency) { this.verticalLayerDependency = verticalLayerDependency; } public ILayer getHorizontalLayerDependency() { return horizontalLayerDependency; } public ILayer getVerticalLayerDependency() { return verticalLayerDependency; } public IUniqueIndexLayer getBaseLayer() { return baseLayer; } // Commands @Override public boolean doCommand(ILayerCommand command) { // Invoke command handler(s) on the Dimensionally dependent layer ILayerCommand clonedCommand = command.cloneCommand(); if (super.doCommand(command)) { return true; } clonedCommand = command.cloneCommand(); if (horizontalLayerDependency.doCommand(clonedCommand)) { return true; } clonedCommand = command.cloneCommand(); if (verticalLayerDependency.doCommand(clonedCommand)) { return true; } return baseLayer.doCommand(command); } // Events @Override public ILayerPainter getLayerPainter() { return baseLayer.getLayerPainter(); } // Horizontal features // Columns public int getColumnCount() { return horizontalLayerDependency.getColumnCount(); } public int getPreferredColumnCount() { return horizontalLayerDependency.getPreferredColumnCount(); } public int getColumnIndexByPosition(int columnPosition) { return horizontalLayerDependency.getColumnIndexByPosition(columnPosition); } public int localToUnderlyingColumnPosition(int localColumnPosition) { return horizontalLayerDependency.localToUnderlyingColumnPosition(localColumnPosition); } public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) { return horizontalLayerDependency.underlyingToLocalColumnPosition(sourceUnderlyingLayer, underlyingColumnPosition); } public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) { return horizontalLayerDependency.underlyingToLocalColumnPositions(sourceUnderlyingLayer, underlyingColumnPositionRanges); } // Width public int getWidth() { return horizontalLayerDependency.getWidth(); } public int getPreferredWidth() { return horizontalLayerDependency.getPreferredWidth(); } public int getColumnWidthByPosition(int columnPosition) { return horizontalLayerDependency.getColumnWidthByPosition(columnPosition); } // Column resize public boolean isColumnPositionResizable(int columnPosition) { return horizontalLayerDependency.isColumnPositionResizable(columnPosition); } // X public int getColumnPositionByX(int x) { return horizontalLayerDependency.getColumnPositionByX(x); } public int getStartXOfColumnPosition(int columnPosition) { return horizontalLayerDependency.getStartXOfColumnPosition(columnPosition); } // Underlying public Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition) { Collection<ILayer> underlyingLayers = new HashSet<ILayer>(); underlyingLayers.add(baseLayer); return underlyingLayers; } // Vertical features // Rows public int getRowCount() { return verticalLayerDependency.getRowCount(); } public int getPreferredRowCount() { return verticalLayerDependency.getPreferredRowCount(); } public int getRowIndexByPosition(int rowPosition) { return verticalLayerDependency.getRowIndexByPosition(rowPosition); } public int localToUnderlyingRowPosition(int localRowPosition) { return verticalLayerDependency.localToUnderlyingRowPosition(localRowPosition); } public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition) { return verticalLayerDependency.underlyingToLocalRowPosition(sourceUnderlyingLayer, underlyingRowPosition); } public Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges) { return verticalLayerDependency.underlyingToLocalRowPositions(sourceUnderlyingLayer, underlyingRowPositionRanges); } // Height public int getHeight() { return verticalLayerDependency.getHeight(); } public int getPreferredHeight() { return verticalLayerDependency.getPreferredHeight(); } public int getRowHeightByPosition(int rowPosition) { return verticalLayerDependency.getRowHeightByPosition(rowPosition); } // Row resize public boolean isRowPositionResizable(int rowPosition) { return verticalLayerDependency.isRowPositionResizable(rowPosition); } // Y public int getRowPositionByY(int y) { return verticalLayerDependency.getRowPositionByY(y); } public int getStartYOfRowPosition(int rowPosition) { return verticalLayerDependency.getStartYOfRowPosition(rowPosition); } // Underlying public Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition) { Collection<ILayer> underlyingLayers = new HashSet<ILayer>(); underlyingLayers.add(baseLayer); return underlyingLayers; } // Cell features @Override public String getDisplayModeByPosition(int columnPosition, int rowPosition) { int baseColumnPosition = LayerUtil.convertColumnPosition(this, columnPosition, baseLayer); int baseRowPosition = LayerUtil.convertRowPosition(this, rowPosition, baseLayer); return baseLayer.getDisplayModeByPosition(baseColumnPosition, baseRowPosition); } @Override public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) { int baseColumnPosition = LayerUtil.convertColumnPosition(this, columnPosition, baseLayer); int baseRowPosition = LayerUtil.convertRowPosition(this, rowPosition, baseLayer); return baseLayer.getConfigLabelsByPosition(baseColumnPosition, baseRowPosition); } public Object getDataValueByPosition(int columnPosition, int rowPosition) { int baseColumnPosition = LayerUtil.convertColumnPosition(this, columnPosition, baseLayer); int baseRowPosition = LayerUtil.convertRowPosition(this, rowPosition, baseLayer); return baseLayer.getDataValueByPosition(baseColumnPosition, baseRowPosition); } // IRegionResolver @Override public LabelStack getRegionLabelsByXY(int x, int y) { return baseLayer.getRegionLabelsByXY(x, y); } @Override public IClientAreaProvider getClientAreaProvider() { return clientAreaProvider; } @Override public void setClientAreaProvider(IClientAreaProvider clientAreaProvider) { this.clientAreaProvider = clientAreaProvider; } public ILayer getUnderlyingLayerByPosition(int columnPosition, int rowPosition) { return baseLayer; } }
11,002
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultGridLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/DefaultGridLayer.java
package net.sourceforge.nattable.grid.layer; import java.util.List; import java.util.Map; import net.sourceforge.nattable.data.IDataProvider; import net.sourceforge.nattable.grid.data.DefaultBodyDataProvider; import net.sourceforge.nattable.grid.data.DefaultColumnHeaderDataProvider; import net.sourceforge.nattable.grid.data.DefaultCornerDataProvider; import net.sourceforge.nattable.grid.data.DefaultRowHeaderDataProvider; import net.sourceforge.nattable.layer.DataLayer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.layer.stack.DefaultBodyLayerStack; import net.sourceforge.nattable.selection.SelectionLayer; public class DefaultGridLayer extends GridLayer { protected IUniqueIndexLayer bodyDataLayer; protected IUniqueIndexLayer columnHeaderDataLayer; protected IUniqueIndexLayer rowHeaderDataLayer; protected IUniqueIndexLayer cornerDataLayer; public <T> DefaultGridLayer(List<T> rowData, String[] propertyNames, Map<String, String> propertyToLabelMap) { this(rowData, propertyNames, propertyToLabelMap, true); } public <T> DefaultGridLayer(List<T> rowData, String[] propertyNames, Map<String, String> propertyToLabelMap, boolean useDefaultConfiguration) { super(useDefaultConfiguration); init(rowData, propertyNames, propertyToLabelMap); } public DefaultGridLayer(IDataProvider bodyDataProvider, IDataProvider columnHeaderDataProvider) { this(bodyDataProvider, columnHeaderDataProvider, true); } public DefaultGridLayer(IDataProvider bodyDataProvider, IDataProvider columnHeaderDataProvider, boolean useDefaultConfiguration) { super(useDefaultConfiguration); init(bodyDataProvider, columnHeaderDataProvider); } public DefaultGridLayer(IDataProvider bodyDataProvider, IDataProvider columnHeaderDataProvider, IDataProvider rowHeaderDataProvider) { this(bodyDataProvider, columnHeaderDataProvider, rowHeaderDataProvider, true); } public DefaultGridLayer(IDataProvider bodyDataProvider, IDataProvider columnHeaderDataProvider, IDataProvider rowHeaderDataProvider, boolean useDefaultConfiguration) { super(useDefaultConfiguration); init(bodyDataProvider, columnHeaderDataProvider, rowHeaderDataProvider); } public DefaultGridLayer(IDataProvider bodyDataProvider, IDataProvider columnHeaderDataProvider, IDataProvider rowHeaderDataProvider, IDataProvider cornerDataProvider) { this(bodyDataProvider, columnHeaderDataProvider, rowHeaderDataProvider, cornerDataProvider, true); } public DefaultGridLayer(IDataProvider bodyDataProvider, IDataProvider columnHeaderDataProvider, IDataProvider rowHeaderDataProvider, IDataProvider cornerDataProvider, boolean useDefaultConfiguration) { super(useDefaultConfiguration); init(bodyDataProvider, columnHeaderDataProvider, rowHeaderDataProvider, cornerDataProvider); } public DefaultGridLayer(IUniqueIndexLayer bodyDataLayer, IUniqueIndexLayer columnHeaderDataLayer, IUniqueIndexLayer rowHeaderDataLayer, IUniqueIndexLayer cornerDataLayer) { this(bodyDataLayer, columnHeaderDataLayer, rowHeaderDataLayer, cornerDataLayer, true); } public DefaultGridLayer(IUniqueIndexLayer bodyDataLayer, IUniqueIndexLayer columnHeaderDataLayer, IUniqueIndexLayer rowHeaderDataLayer, IUniqueIndexLayer cornerDataLayer, boolean useDefaultConfiguration) { super(useDefaultConfiguration); init(bodyDataLayer, columnHeaderDataLayer, rowHeaderDataLayer, cornerDataLayer); } protected DefaultGridLayer(boolean useDefaultConfiguration) { super(useDefaultConfiguration); } protected <T> void init(List<T> rowData, String[] propertyNames, Map<String, String> propertyToLabelMap) { init(new DefaultBodyDataProvider<T>(rowData, propertyNames), new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap)); } protected void init(IDataProvider bodyDataProvider, IDataProvider columnHeaderDataProvider) { init(bodyDataProvider, columnHeaderDataProvider, new DefaultRowHeaderDataProvider(bodyDataProvider)); } protected void init(IDataProvider bodyDataProvider, IDataProvider columnHeaderDataProvider, IDataProvider rowHeaderDataProvider) { init(bodyDataProvider, columnHeaderDataProvider, rowHeaderDataProvider, new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)); } protected void init(IDataProvider bodyDataProvider, IDataProvider columnHeaderDataProvider, IDataProvider rowHeaderDataProvider, IDataProvider cornerDataProvider) { init(new DataLayer(bodyDataProvider), new DefaultColumnHeaderDataLayer(columnHeaderDataProvider), new DefaultRowHeaderDataLayer(rowHeaderDataProvider), new DataLayer(cornerDataProvider)); } protected void init(IUniqueIndexLayer bodyDataLayer, IUniqueIndexLayer columnHeaderDataLayer, IUniqueIndexLayer rowHeaderDataLayer, IUniqueIndexLayer cornerDataLayer) { // Body this.bodyDataLayer = bodyDataLayer; DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(bodyDataLayer); SelectionLayer selectionLayer = bodyLayer.getSelectionLayer(); // Column header this.columnHeaderDataLayer = columnHeaderDataLayer; ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayer, selectionLayer); // Row header this.rowHeaderDataLayer = rowHeaderDataLayer; ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayer, selectionLayer); // Corner this.cornerDataLayer = cornerDataLayer; ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, columnHeaderLayer); setBodyLayer(bodyLayer); setColumnHeaderLayer(columnHeaderLayer); setRowHeaderLayer(rowHeaderLayer); setCornerLayer(cornerLayer); } public IUniqueIndexLayer getBodyDataLayer() { return bodyDataLayer; } @Override public DefaultBodyLayerStack getBodyLayer() { return (DefaultBodyLayerStack) super.getBodyLayer(); } public IUniqueIndexLayer getColumnHeaderDataLayer() { return columnHeaderDataLayer; } @Override public ColumnHeaderLayer getColumnHeaderLayer() { return (ColumnHeaderLayer) super.getColumnHeaderLayer(); } public IUniqueIndexLayer getRowHeaderDataLayer() { return rowHeaderDataLayer; } @Override public RowHeaderLayer getRowHeaderLayer() { return (RowHeaderLayer) super.getRowHeaderLayer(); } public IUniqueIndexLayer getCornerDataLayer() { return cornerDataLayer; } @Override public CornerLayer getCornerLayer() { return (CornerLayer) super.getCornerLayer(); } }
6,607
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowHeaderLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/RowHeaderLayer.java
package net.sourceforge.nattable.grid.layer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.layer.LayerUtil; import net.sourceforge.nattable.layer.config.DefaultRowHeaderLayerConfiguration; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.style.DisplayMode; import net.sourceforge.nattable.style.SelectionStyleLabels; public class RowHeaderLayer extends DimensionallyDependentLayer { private final SelectionLayer selectionLayer; public RowHeaderLayer(IUniqueIndexLayer baseLayer, ILayer verticalLayerDependency, SelectionLayer selectionLayer) { this(baseLayer, verticalLayerDependency, selectionLayer, true); } public RowHeaderLayer(IUniqueIndexLayer baseLayer, ILayer verticalLayerDependency, SelectionLayer selectionLayer, boolean useDefaultConfiguration) { super(baseLayer, baseLayer, verticalLayerDependency); this.selectionLayer = selectionLayer; if (useDefaultConfiguration) { addConfiguration(new DefaultRowHeaderLayerConfiguration()); } } @Override public String getDisplayModeByPosition(int columnPosition, int rowPosition) { int selectionLayerRowPosition = LayerUtil.convertRowPosition(this, rowPosition, selectionLayer); if (selectionLayer.isRowPositionSelected(selectionLayerRowPosition)) { return DisplayMode.SELECT; } else { return super.getDisplayModeByPosition(columnPosition, rowPosition); } } @Override public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) { LabelStack labelStack = super.getConfigLabelsByPosition(columnPosition, rowPosition); final int selectionLayerRowPosition = LayerUtil.convertRowPosition(this, rowPosition, selectionLayer); if (selectionLayer.isRowFullySelected(selectionLayerRowPosition)) { labelStack.addLabel(SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE); } return labelStack; } }
2,056
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultGridLayerConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/config/DefaultGridLayerConfiguration.java
package net.sourceforge.nattable.grid.layer.config; import net.sourceforge.nattable.config.AggregateConfiguration; import net.sourceforge.nattable.edit.config.DefaultEditBindings; import net.sourceforge.nattable.edit.config.DefaultEditConfiguration; import net.sourceforge.nattable.export.excel.config.DefaultExportToExcelBindings; import net.sourceforge.nattable.grid.GridRegion; import net.sourceforge.nattable.grid.cell.AlternatingRowConfigLabelAccumulator; import net.sourceforge.nattable.grid.layer.GridLayer; import net.sourceforge.nattable.print.config.DefaultPrintBindings; /** * Sets up features handled at the grid level. Added by {@link GridLayer} */ public class DefaultGridLayerConfiguration extends AggregateConfiguration { public DefaultGridLayerConfiguration(GridLayer gridLayer) { addAlternateRowColoringConfig(gridLayer); addEditingHandlerConfig(); addEditingUIConfig(); addPrintUIBindings(); addExcelExportUIBindings(); } protected void addExcelExportUIBindings() { addConfiguration(new DefaultExportToExcelBindings()); } protected void addPrintUIBindings() { addConfiguration(new DefaultPrintBindings()); } protected void addEditingUIConfig() { addConfiguration(new DefaultEditBindings()); } protected void addEditingHandlerConfig() { addConfiguration(new DefaultEditConfiguration()); } protected void addAlternateRowColoringConfig(GridLayer gridLayer) { addConfiguration(new DefaultRowStyleConfiguration()); gridLayer.setConfigLabelAccumulatorForRegion(GridRegion.BODY, new AlternatingRowConfigLabelAccumulator()); } }
1,585
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultRowStyleConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/config/DefaultRowStyleConfiguration.java
package net.sourceforge.nattable.grid.layer.config; import net.sourceforge.nattable.config.AbstractRegistryConfiguration; import net.sourceforge.nattable.config.CellConfigAttributes; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.grid.cell.AlternatingRowConfigLabelAccumulator; import net.sourceforge.nattable.style.CellStyleAttributes; import net.sourceforge.nattable.style.DisplayMode; import net.sourceforge.nattable.style.Style; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.graphics.Color; /** * Sets up alternate row coloring. Applied by {@link DefaultGridLayerConfiguration} */ public class DefaultRowStyleConfiguration extends AbstractRegistryConfiguration { public Color evenRowBgColor = GUIHelper.COLOR_WIDGET_BACKGROUND; public Color oddRowBgColor = GUIHelper.COLOR_WHITE; public void configureRegistry(IConfigRegistry configRegistry) { configureOddRowStyle(configRegistry); configureEvenRowStyle(configRegistry); } protected void configureOddRowStyle(IConfigRegistry configRegistry) { Style cellStyle = new Style(); cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, oddRowBgColor); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE); } protected void configureEvenRowStyle(IConfigRegistry configRegistry) { Style cellStyle = new Style(); cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, evenRowBgColor); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE); } }
1,727
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnHeaderSelectionEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/layer/event/ColumnHeaderSelectionEvent.java
package net.sourceforge.nattable.grid.layer.event; import java.util.Arrays; import java.util.Collection; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.event.ColumnVisualChangeEvent; public class ColumnHeaderSelectionEvent extends ColumnVisualChangeEvent { public ColumnHeaderSelectionEvent(ILayer layer, int columnPosition) { this(layer, new Range(columnPosition, columnPosition + 1)); } public ColumnHeaderSelectionEvent(ILayer layer, Range...columnPositionRanges) { this(layer, Arrays.asList(columnPositionRanges)); } public ColumnHeaderSelectionEvent(ILayer layer, Collection<Range> columnPositionRanges) { super(layer, columnPositionRanges); } protected ColumnHeaderSelectionEvent(ColumnHeaderSelectionEvent event) { super(event); } public ColumnHeaderSelectionEvent cloneEvent() { return new ColumnHeaderSelectionEvent(this); } }
987
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AutoResizeColumnCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/command/AutoResizeColumnCommandHandler.java
package net.sourceforge.nattable.grid.command; import net.sourceforge.nattable.command.ILayerCommandHandler; import net.sourceforge.nattable.grid.layer.GridLayer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.print.command.TurnViewportOffCommand; import net.sourceforge.nattable.print.command.TurnViewportOnCommand; import net.sourceforge.nattable.resize.MaxCellBoundsHelper; import net.sourceforge.nattable.resize.command.AutoResizeColumnsCommand; import net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand; import net.sourceforge.nattable.resize.command.MultiColumnResizeCommand; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.util.ObjectUtils; /** * This command is triggered by the {@link InitializeAutoResizeColumnsCommand}. * The selected columns picked from the {@link SelectionLayer} by the above command. * This handler runs as a second step. This <i>must</i> run at the {@link GridLayer} level * since we need to pick up all the region labels which are applied at the grid level. * * Additionally running at the grid layer level ensures that we include cells from the * headers in the width calculations. */ public class AutoResizeColumnCommandHandler implements ILayerCommandHandler<AutoResizeColumnsCommand> { private final GridLayer gridLayer; public AutoResizeColumnCommandHandler(GridLayer gridLayer) { this.gridLayer = gridLayer; } public Class<AutoResizeColumnsCommand> getCommandClass() { return AutoResizeColumnsCommand.class; } public boolean doCommand(ILayer targetLayer, AutoResizeColumnsCommand command) { // Need to resize selected columns even if they are outside the viewport targetLayer.doCommand(new TurnViewportOffCommand()); int[] columnPositions = ObjectUtils.asIntArray(command.getColumnPositions()); int[] gridColumnPositions = convertFromSelectionToGrid(columnPositions); int[] gridColumnWidths = MaxCellBoundsHelper.getPreferedColumnWidths( command.getConfigRegistry(), command.getGC(), gridLayer, gridColumnPositions); gridLayer.doCommand(new MultiColumnResizeCommand(gridLayer, gridColumnPositions, gridColumnWidths)); targetLayer.doCommand(new TurnViewportOnCommand()); return true; } private int[] convertFromSelectionToGrid(int[] columnPositions) { int[] gridColumnPositions = new int[columnPositions.length]; for (int i = 0; i < columnPositions.length; i++) { // Since the viewport is turned off - body layer can be used as the underlying layer gridColumnPositions[i] = gridLayer.underlyingToLocalColumnPosition(gridLayer.getBodyLayer(), columnPositions[i]); } return gridColumnPositions; } }
2,992
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
InitializeAutoResizeColumnsCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/command/InitializeAutoResizeColumnsCommandHandler.java
package net.sourceforge.nattable.grid.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.resize.command.AutoResizeColumnsCommand; import net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand; import net.sourceforge.nattable.selection.SelectionLayer; public class InitializeAutoResizeColumnsCommandHandler extends AbstractLayerCommandHandler<InitializeAutoResizeColumnsCommand> { private SelectionLayer selectionLayer; public InitializeAutoResizeColumnsCommandHandler(SelectionLayer selectionLayer) { super(); this.selectionLayer = selectionLayer; } public Class<InitializeAutoResizeColumnsCommand> getCommandClass() { return InitializeAutoResizeColumnsCommand.class; } @Override protected boolean doCommand(InitializeAutoResizeColumnsCommand initCommand) { int columnPosition = initCommand.getColumnPosition(); if (selectionLayer.isColumnFullySelected(columnPosition)) { initCommand.setSelectedColumnPositions(selectionLayer.getFullySelectedColumnPositions()); } else { initCommand.setSelectedColumnPositions(new int[] { columnPosition }); } // Fire command carrying the selected columns initCommand.getSourceLayer().doCommand(new AutoResizeColumnsCommand(initCommand)); return true; } }
1,345
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ClientAreaResizeCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/command/ClientAreaResizeCommand.java
package net.sourceforge.nattable.grid.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; import org.eclipse.swt.widgets.Scrollable; /** * Command that gives the layers access to ClientArea and the Scrollable */ public class ClientAreaResizeCommand extends AbstractContextFreeCommand { private Scrollable scrollable; public ClientAreaResizeCommand(Scrollable scrollable) { super(); this.scrollable = scrollable; } public Scrollable getScrollable() { return scrollable; } }
539
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
InitializeGridCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/command/InitializeGridCommand.java
package net.sourceforge.nattable.grid.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; import org.eclipse.swt.widgets.Composite; /** * Command that is propagated when NatTable starts up. This gives every layer a * chance to initialize itself and compute its structural caches. */ public class InitializeGridCommand extends AbstractContextFreeCommand { private final Composite tableComposite; public InitializeGridCommand(Composite tableComposite) { this.tableComposite = tableComposite; } public Composite getTableComposite() { return tableComposite; } }
625
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
InitializeAutoResizeRowsCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/command/InitializeAutoResizeRowsCommandHandler.java
package net.sourceforge.nattable.grid.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.resize.command.AutoResizeRowsCommand; import net.sourceforge.nattable.resize.command.InitializeAutoResizeRowsCommand; import net.sourceforge.nattable.selection.SelectionLayer; public class InitializeAutoResizeRowsCommandHandler extends AbstractLayerCommandHandler<InitializeAutoResizeRowsCommand> { private SelectionLayer selectionLayer; public InitializeAutoResizeRowsCommandHandler(SelectionLayer selectionLayer) { super(); this.selectionLayer = selectionLayer; } public Class<InitializeAutoResizeRowsCommand> getCommandClass() { return InitializeAutoResizeRowsCommand.class; } @Override protected boolean doCommand(InitializeAutoResizeRowsCommand initCommand) { int rowPosition = initCommand.getRowPosition(); if (selectionLayer.isRowFullySelected(rowPosition)) { initCommand.setSelectedRowPositions(selectionLayer.getFullySelectedRowPositions()); } else { initCommand.setSelectedRowPositions(new int[] { rowPosition }); } // Fire command carrying the selected columns initCommand.getSourceLayer().doCommand(new AutoResizeRowsCommand(initCommand)); return true; } }
1,298
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AutoResizeRowCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/grid/command/AutoResizeRowCommandHandler.java
package net.sourceforge.nattable.grid.command; import net.sourceforge.nattable.command.ILayerCommandHandler; import net.sourceforge.nattable.grid.layer.GridLayer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.print.command.TurnViewportOffCommand; import net.sourceforge.nattable.print.command.TurnViewportOnCommand; import net.sourceforge.nattable.resize.MaxCellBoundsHelper; import net.sourceforge.nattable.resize.command.AutoResizeRowsCommand; import net.sourceforge.nattable.resize.command.MultiRowResizeCommand; import net.sourceforge.nattable.util.ObjectUtils; /** * @see AutoResizeColumnCommandHandler */ public class AutoResizeRowCommandHandler implements ILayerCommandHandler<AutoResizeRowsCommand> { private final GridLayer gridLayer; public AutoResizeRowCommandHandler(GridLayer gridLayer) { this.gridLayer = gridLayer; } public Class<AutoResizeRowsCommand> getCommandClass() { return AutoResizeRowsCommand.class; } public boolean doCommand(ILayer targetLayer, AutoResizeRowsCommand command) { // Need to resize selected rows even if they are outside the viewport targetLayer.doCommand(new TurnViewportOffCommand()); int[] rowPositions = ObjectUtils.asIntArray(command.getRowPositions()); int[] gridRowPositions = convertFromSelectionToGrid(rowPositions); int[] gridRowHeights = MaxCellBoundsHelper.getPreferedRowHeights( command.getConfigRegistry(), command.getGC(), gridLayer, gridRowPositions); gridLayer.doCommand(new MultiRowResizeCommand(gridLayer, gridRowPositions, gridRowHeights)); targetLayer.doCommand(new TurnViewportOnCommand()); return true; } private int[] convertFromSelectionToGrid(int[] rowPositions) { int[] gridRowPositions = new int[rowPositions.length]; for (int i = 0; i < rowPositions.length; i++) { // Since the viewport is turned off - body layer can be used as the underlying layer gridRowPositions[i] = gridLayer.underlyingToLocalRowPosition(gridLayer.getBodyLayer(), rowPositions[i]); } return gridRowPositions; } }
2,316
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
IDisplayModeOrdering.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/IDisplayModeOrdering.java
package net.sourceforge.nattable.style; import java.util.List; public interface IDisplayModeOrdering { public List<String> getDisplayModeOrdering(String targetDisplayMode); }
190
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CellStyleAttributes.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/CellStyleAttributes.java
package net.sourceforge.nattable.style; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; public interface CellStyleAttributes { public static final ConfigAttribute<Color> BACKGROUND_COLOR = new ConfigAttribute<Color>(); public static final ConfigAttribute<Color> FOREGROUND_COLOR = new ConfigAttribute<Color>(); public static final ConfigAttribute<HorizontalAlignmentEnum> HORIZONTAL_ALIGNMENT = new ConfigAttribute<HorizontalAlignmentEnum>(); public static final ConfigAttribute<VerticalAlignmentEnum> VERTICAL_ALIGNMENT = new ConfigAttribute<VerticalAlignmentEnum>(); public static final ConfigAttribute<Font> FONT = new ConfigAttribute<Font>(); public static final ConfigAttribute<Image> IMAGE = new ConfigAttribute<Image>(); public static final ConfigAttribute<BorderStyle> BORDER_STYLE = new ConfigAttribute<BorderStyle>(); }
987
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CellStyleProxy.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/CellStyleProxy.java
package net.sourceforge.nattable.style; import java.util.List; import net.sourceforge.nattable.config.CellConfigAttributes; import net.sourceforge.nattable.config.IConfigRegistry; public class CellStyleProxy extends StyleProxy { public CellStyleProxy(IConfigRegistry configRegistry, String targetDisplayMode, List<String> configLabels) { super(CellConfigAttributes.CELL_STYLE, configRegistry, targetDisplayMode, configLabels); } public <T> void setAttributeValue(ConfigAttribute<T> styleAttribute, T value) { throw new UnsupportedOperationException("Not implmented yet"); } }
590
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SelectionStyleLabels.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/SelectionStyleLabels.java
package net.sourceforge.nattable.style; import net.sourceforge.nattable.grid.GridRegion; public interface SelectionStyleLabels { public static final String SELECTION_ANCHOR_STYLE = "selectionAnchor"; public static final String COLUMN_FULLY_SELECTED_STYLE = GridRegion.COLUMN_HEADER + "_FULL"; public static final String ROW_FULLY_SELECTED_STYLE = GridRegion.ROW_HEADER + "_FULL"; }
425
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
HorizontalAlignmentEnum.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/HorizontalAlignmentEnum.java
package net.sourceforge.nattable.style; import org.eclipse.swt.SWT; public enum HorizontalAlignmentEnum { LEFT, CENTER, RIGHT; public static int getSWTStyle(IStyle cellStyle) { HorizontalAlignmentEnum horizontalAlignment = cellStyle.getAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT); if (horizontalAlignment == null) { return SWT.NONE; } switch (horizontalAlignment) { case CENTER: return SWT.CENTER; case LEFT: return SWT.LEFT; case RIGHT: return SWT.RIGHT; default: return SWT.NONE; } } }
578
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
VerticalAlignmentEnum.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/VerticalAlignmentEnum.java
package net.sourceforge.nattable.style; public enum VerticalAlignmentEnum { TOP, MIDDLE, BOTTOM; }
111
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultDisplayModeOrdering.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/DefaultDisplayModeOrdering.java
package net.sourceforge.nattable.style; import java.util.Arrays; import java.util.Collections; import java.util.List; public class DefaultDisplayModeOrdering implements IDisplayModeOrdering { private static final List<String> NORMAL_ORDERING = Arrays.asList(DisplayMode.NORMAL); private static final List<String> SELECT_ORDERING = Arrays.asList(DisplayMode.SELECT, DisplayMode.NORMAL); private static final List<String> EDIT_ORDERING = Arrays.asList(DisplayMode.EDIT, DisplayMode.NORMAL); private static final List<String> EMPTY_ORDERING = Collections.emptyList(); /** * @see DefaultDisplayModeOrderingTest */ public List<String> getDisplayModeOrdering(String targetDisplayMode) { if (DisplayMode.NORMAL.equals(targetDisplayMode)) { return NORMAL_ORDERING; } else if (DisplayMode.SELECT.equals(targetDisplayMode)) { return SELECT_ORDERING; } else if (DisplayMode.EDIT.equals(targetDisplayMode)) { return EDIT_ORDERING; } else { return EMPTY_ORDERING; } } }
1,032
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
BorderStyle.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/BorderStyle.java
package net.sourceforge.nattable.style; import net.sourceforge.nattable.persistence.ColorPersistor; import net.sourceforge.nattable.util.GUIHelper; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; /** * This class defines the visual attributes of a Border. */ public class BorderStyle { private int thickness = 1; private Color color = GUIHelper.COLOR_BLACK; private LineStyleEnum lineStyle = LineStyleEnum.SOLID; public enum LineStyleEnum { SOLID, DASHED, DOTTED, DASHDOT, DASHDOTDOT; public static int toSWT(LineStyleEnum line) { if (line == null) throw new IllegalArgumentException("null"); if (line.equals(SOLID)) return SWT.LINE_SOLID; else if (line.equals(DASHED)) return SWT.LINE_DASH; else if (line.equals(DOTTED)) return SWT.LINE_DOT; else if (line.equals(DASHDOT)) return SWT.LINE_DASHDOT; else if (line.equals(DASHDOTDOT)) return SWT.LINE_DASHDOTDOT; else return SWT.LINE_SOLID; } } public BorderStyle() {} public BorderStyle(int thickness, Color color, LineStyleEnum lineStyle) { this.thickness = thickness; this.color = color; this.lineStyle = lineStyle; } /** * Reconstruct this instance from the persisted String. * @see BorderStyle#toString() */ public BorderStyle(String string) { String[] tokens = string.split("\\|"); this.thickness = Integer.parseInt(tokens[0]); this.color = ColorPersistor.asColor(tokens[1]); this.lineStyle = LineStyleEnum.valueOf(tokens[2]); } public int getThickness() { return thickness; } public Color getColor() { return color; } public LineStyleEnum getLineStyle() { return lineStyle; } public void setThickness(int thickness) { this.thickness = thickness; } public void setColor(Color color) { this.color = color; } public void setLineStyle(LineStyleEnum lineStyle) { this.lineStyle = lineStyle; } @Override public boolean equals(Object obj) { if (obj instanceof BorderStyle == false) { return false; } if (this == obj) { return true; } BorderStyle that = (BorderStyle) obj; return new EqualsBuilder() .append(this.thickness, that.thickness) .append(this.color, that.color) .append(this.lineStyle.name(), that.lineStyle.name()) .isEquals(); } @Override public int hashCode() { return new HashCodeBuilder(87, 19) .append(thickness) .append(color) .append(lineStyle.name()) .toHashCode(); } /** * @return a human readable representation of the border style. * This is suitable for constructing an equivalent instance using the BorderStyle(String) constructor */ @Override public String toString() { return thickness + "|" + ColorPersistor.asString(color) + "|" + lineStyle; } }
3,207
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
StyleProxy.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/StyleProxy.java
package net.sourceforge.nattable.style; import java.util.List; import net.sourceforge.nattable.config.IConfigRegistry; public abstract class StyleProxy implements IStyle { private final ConfigAttribute<IStyle> styleConfigAttribute; private final IConfigRegistry configRegistry; private final String targetDisplayMode; private final List<String> configLabels; public StyleProxy(ConfigAttribute<IStyle> styleConfigAttribute, IConfigRegistry configRegistry, String targetDisplayMode, List<String> configLabels) { this.styleConfigAttribute = styleConfigAttribute; this.configRegistry = configRegistry; this.targetDisplayMode = targetDisplayMode; this.configLabels = configLabels; } public <T> T getAttributeValue(ConfigAttribute<T> styleAttribute) { T styleAttributeValue = null; IDisplayModeOrdering displayModeOrdering = configRegistry.getDisplayModeOrdering(); for (String displayMode : displayModeOrdering.getDisplayModeOrdering(targetDisplayMode)) { for (String configLabel : configLabels) { IStyle cellStyle = configRegistry.getSpecificConfigAttribute(styleConfigAttribute, displayMode, configLabel); if (cellStyle != null) { styleAttributeValue = cellStyle.getAttributeValue(styleAttribute); if (styleAttributeValue != null) { return styleAttributeValue; } } } // default IStyle cellStyle = configRegistry.getConfigAttribute(styleConfigAttribute, displayMode); if (cellStyle != null) { styleAttributeValue = cellStyle.getAttributeValue(styleAttribute); if (styleAttributeValue != null) { return styleAttributeValue; } } } return null; } }
1,700
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
Style.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/Style.java
package net.sourceforge.nattable.style; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Map.Entry; public class Style implements IStyle { private final Map<ConfigAttribute<?>, Object> styleAttributeValueMap = new HashMap<ConfigAttribute<?>, Object>(); @SuppressWarnings("unchecked") public <T> T getAttributeValue(ConfigAttribute<T> styleAttribute) { return (T) styleAttributeValueMap.get(styleAttribute); } public <T> void setAttributeValue(ConfigAttribute<T> styleAttribute, T value) { styleAttributeValueMap.put(styleAttribute, value); } @Override public String toString() { StringBuilder resultBuilder = new StringBuilder(); resultBuilder.append(this.getClass().getSimpleName() + ": "); Set<Entry<ConfigAttribute<?>, Object>> entrySet = styleAttributeValueMap.entrySet(); for (Entry<ConfigAttribute<?>, Object> entry : entrySet) { resultBuilder.append(entry.getKey() + ": " + entry.getValue() + "\n"); } return resultBuilder.toString(); } }
1,057
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DisplayMode.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/DisplayMode.java
package net.sourceforge.nattable.style; /** * The various modes the table can be under. * <ol> * <li>During normal display a cell is in NORMAL mode.</li> * <li>If the contents of the cell are being edited, its in EDIT mode.</li> * <li>If a cell has been selected, its in SELECT mode.</li> * </ol> * <br/> * These modes are used to bind different settings to different modes.<br/> * For example, a different style can be registered for a cell * when it is in SELECT mode. * */ public interface DisplayMode { public static final String NORMAL = "NORMAL"; public static final String SELECT = "SELECT"; public static final String EDIT = "EDIT"; }
693
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CellStyleUtil.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/CellStyleUtil.java
package net.sourceforge.nattable.style; import org.eclipse.swt.graphics.Rectangle; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.layer.cell.LayerCell; public class CellStyleUtil { public static IStyle getCellStyle(LayerCell cell, IConfigRegistry configRegistry) { return new CellStyleProxy(configRegistry, cell.getDisplayMode(), cell.getConfigLabels().getLabels()); } public static int getHorizontalAlignmentPadding(IStyle cellStyle, Rectangle rectangle, int contentWidth) { HorizontalAlignmentEnum horizontalAlignment = cellStyle.getAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT); return getHorizontalAlignmentPadding(horizontalAlignment, rectangle, contentWidth); } /** * Calculate padding needed at the left to align horizontally. Defaults to CENTER horizontal alignment. */ public static int getHorizontalAlignmentPadding(HorizontalAlignmentEnum horizontalAlignment, Rectangle rectangle, int contentWidth) { if (horizontalAlignment == null) { horizontalAlignment = HorizontalAlignmentEnum.CENTER; } int padding = 0; switch (horizontalAlignment) { case CENTER: padding = (rectangle.width - contentWidth) / 2; break; case RIGHT: padding = rectangle.width - contentWidth; break; } if (padding < 0) { padding = 0; } return padding; } public static int getVerticalAlignmentPadding(IStyle cellStyle, Rectangle rectangle, int contentHeight) { VerticalAlignmentEnum verticalAlignment = cellStyle.getAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT); return getVerticalAlignmentPadding(verticalAlignment, rectangle, contentHeight); } /** * Calculate padding needed at the top to align vertically. Defaults to MIDDLE vertical alignment. */ public static int getVerticalAlignmentPadding(VerticalAlignmentEnum verticalAlignment, Rectangle rectangle, int contentHeight) { if (verticalAlignment == null) { verticalAlignment = VerticalAlignmentEnum.MIDDLE; } int padding = 0; switch (verticalAlignment) { case MIDDLE: padding = (rectangle.height - contentHeight) / 2; break; case BOTTOM: padding = rectangle.height - contentHeight; break; } if (padding < 0) { padding = 0; } return padding; } }
2,277
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
IStyle.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/IStyle.java
package net.sourceforge.nattable.style; /** * Used to store attributes reflecting a (usually display) style. */ public interface IStyle { public <T> T getAttributeValue(ConfigAttribute<T> styleAttribute); public <T> void setAttributeValue(ConfigAttribute<T> styleAttribute, T value); }
305
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractStyleEditorDialog.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/AbstractStyleEditorDialog.java
package net.sourceforge.nattable.style.editor; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public abstract class AbstractStyleEditorDialog extends Dialog { private boolean cancelPressed = false; public AbstractStyleEditorDialog(Shell parent) { super(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); } /** * Create all widgets to be displayed in the editor */ protected abstract void initComponents(Shell shell); /** * Initialize and display the SWT shell. This is a blocking call. */ public void open() { Shell shell = new Shell(getParent(), getStyle()); shell.setImage(GUIHelper.getImage("preferences")); shell.setText(getText()); initComponents(shell); createButtons(shell); shell.pack(); shell.open(); Display display = shell.getDisplay(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } /** * Create OK, Reset and Cancel buttons */ protected void createButtons(final Shell shell) { Composite buttonPanel = new Composite(shell, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; gridLayout.marginLeft = 65; buttonPanel.setLayout(gridLayout); GridData gridLayoutData = new GridData(); gridLayoutData.horizontalAlignment = GridData.FILL_HORIZONTAL; buttonPanel.setLayoutData(gridLayoutData); Button okButton = new Button(buttonPanel, SWT.PUSH); okButton.setText("OK"); okButton.setLayoutData(new GridData(70, 25)); okButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doFormOK(shell); } }); Button clearButton = new Button(buttonPanel, SWT.PUSH); clearButton.setText("Clear"); clearButton.setToolTipText("Reset to original settings"); clearButton.setLayoutData(new GridData(80, 25)); clearButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doFormClear(shell); } }); Button cancelButton = new Button(buttonPanel, SWT.NONE); cancelButton.setText("Cancel"); cancelButton.setLayoutData(new GridData(80, 25)); cancelButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doFormCancel(shell); } }); shell.setDefaultButton(okButton); } /** * Respond to the OK button press. Read new state from the form. */ protected abstract void doFormOK(Shell shell); protected void doFormCancel(Shell shell) { cancelPressed = true; shell.dispose(); } protected void doFormClear(Shell shell) { shell.dispose(); } public boolean isCancelPressed(){ return cancelPressed; } }
3,195
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
BorderStyleEditorPanel.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/BorderStyleEditorPanel.java
package net.sourceforge.nattable.style.editor; import static org.eclipse.swt.SWT.CHECK; import static org.eclipse.swt.SWT.NONE; import net.sourceforge.nattable.style.BorderStyle; import net.sourceforge.nattable.style.BorderStyle.LineStyleEnum; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; /** * EditorPanel for editing a border style. */ public class BorderStyleEditorPanel extends AbstractEditorPanel<BorderStyle> { private BorderThicknessPicker thicknessPicker; private LineStylePicker lineStylePicker; private ColorPicker colorPicker; private Button noBordersCheckBox; @Override public String getEditorName() { return "Border Style"; } public BorderStyleEditorPanel(Composite parent, int style) { super(parent, style); initComponents(); } public void initComponents() { GridLayout gridLayout = new GridLayout(2, false); gridLayout.marginLeft = 10; setLayout(gridLayout); new Label(this, NONE).setText("No Border"); noBordersCheckBox = new Button(this, CHECK); noBordersCheckBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean noBorder = noBordersCheckBox.getSelection(); colorPicker.setEnabled(!noBorder); thicknessPicker.setEnabled(!noBorder); lineStylePicker.setEnabled(!noBorder); } }); new Label(this, NONE).setText("Color"); colorPicker = new ColorPicker(this, GUIHelper.COLOR_WIDGET_BORDER); new Label(this, NONE).setText("Line Style"); lineStylePicker = new LineStylePicker(this); new Label(this, NONE).setText("Thickness"); thicknessPicker = new BorderThicknessPicker(this); // By default, no border is selected and all controls are disabled noBordersCheckBox.setSelection(true); colorPicker.setEnabled(false); thicknessPicker.setEnabled(false); lineStylePicker.setEnabled(false); } private void disableEditing() { colorPicker.setEnabled(false); thicknessPicker.setEnabled(false); lineStylePicker.setEnabled(false); } public void edit(BorderStyle bstyle) throws Exception { if (bstyle != null) { noBordersCheckBox.setSelection(false); colorPicker.setSelectedColor(bstyle.getColor()); lineStylePicker.setSelectedLineStyle(bstyle.getLineStyle()); thicknessPicker.setSelectedThickness(bstyle.getThickness()); } else { noBordersCheckBox.setSelection(true); disableEditing(); } } public BorderStyle getNewValue() { if (!noBordersCheckBox.getSelection()) { Color borderColor = colorPicker.getSelectedColor(); LineStyleEnum lineStyle = lineStylePicker.getSelectedLineStyle(); int borderThickness = thicknessPicker.getSelectedThickness(); return new BorderStyle(borderThickness, borderColor, lineStyle); } return null; } }
3,540
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractEditorPanel.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/AbstractEditorPanel.java
package net.sourceforge.nattable.style.editor; import org.eclipse.swt.widgets.Composite; /** * SWT Panel to edit object of type T */ public abstract class AbstractEditorPanel<T> extends Composite { public AbstractEditorPanel(Composite parent, int style) { super(parent, style); } /** * Initialize UI widgets to match the initial state of T */ public abstract void edit(T t) throws Exception; /** * Get the new value of T with the user modifications */ public abstract T getNewValue(); /** * Use friendly name for this editor (used as tab labels). */ public abstract String getEditorName(); }
652
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColorPicker.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/ColorPicker.java
package net.sourceforge.nattable.style.editor; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.ColorDialog; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; /** * A button that displays a solid block of color and allows the user to pick a color. The user can double click on the * button in order to change the selected color which also changes the background color of the button. * */ public class ColorPicker extends CLabel { private Color selectedColor; private Image image; public ColorPicker(Composite parent, final Color originalColor) { super(parent, SWT.SHADOW_OUT); if (originalColor == null) throw new IllegalArgumentException("null"); this.selectedColor = originalColor; setImage(getColorImage(originalColor)); addMouseListener( new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { ColorDialog dialog = new ColorDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM)); dialog.setRGB(selectedColor.getRGB()); RGB selected = dialog.open(); if (selected != null) { update(selected); } } }); } private Image getColorImage(Color color){ Display display = Display.getCurrent(); image = new Image(display, new Rectangle(10, 10, 70, 20)); GC gc = new GC(image); gc.setBackground(color); gc.fillRectangle(image.getBounds()); gc.dispose(); return image; } private void update(RGB selected) { this.selectedColor = GUIHelper.getColor(selected); setImage(getColorImage(selectedColor)); } /** * @return the Color most recently selected by the user. <em>Note that it is the responsibility of the client to * dispose this resource</em> */ public Color getSelectedColor() { return selectedColor; } /** * Set the current selected color that will be displayed by the picker. <em>Note that this class is not responsible * for destroying the given Color object. It does not take ownership. Instead it will create its own internal * copy of the given Color resource.</em> * * @param backgroundColor */ public void setSelectedColor(Color backgroundColor) { if (backgroundColor == null) throw new IllegalArgumentException("null"); update(backgroundColor.getRGB()); } @Override public void dispose() { super.dispose(); image.dispose(); } }
3,185
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CellStyleEditorPanel.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/CellStyleEditorPanel.java
package net.sourceforge.nattable.style.editor; import net.sourceforge.nattable.style.CellStyleAttributes; import net.sourceforge.nattable.style.HorizontalAlignmentEnum; import net.sourceforge.nattable.style.Style; import net.sourceforge.nattable.style.VerticalAlignmentEnum; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; /** * EditorPanel for editing the core style attributes. */ public class CellStyleEditorPanel extends AbstractEditorPanel<Style> { private static final Color DEFAULT_FG_COLOR = GUIHelper.COLOR_BLACK; private static final Color DEFAULT_BG_COLOR = GUIHelper.COLOR_WHITE; private ColorPicker backgroundColorPicker; private ColorPicker foregroundColorPicker; private FontPicker fontPicker; private HorizontalAlignmentPicker horizontalAlignmentPicker; private VerticalAlignmentPicker verticalAlignmentPicker; public CellStyleEditorPanel(Composite parent, int style) { super(parent, style); initComponents(); } private void initComponents() { GridLayout gridLayout = new GridLayout(2, false); gridLayout.marginLeft = 10; setLayout(gridLayout); new Label(this, SWT.NONE).setText("Background Color"); backgroundColorPicker = new ColorPicker(this, DEFAULT_BG_COLOR); new Label(this, SWT.NONE).setText("Foreground Color"); foregroundColorPicker = new ColorPicker(this, DEFAULT_FG_COLOR); new Label(this, SWT.NONE).setText("Font"); fontPicker = new FontPicker(this, GUIHelper.DEFAULT_FONT); fontPicker.setLayoutData(new GridData(80, 20)); new Label(this, SWT.NONE).setText("Horizonatal Alignment"); horizontalAlignmentPicker = new HorizontalAlignmentPicker(this, HorizontalAlignmentEnum.CENTER); new Label(this, SWT.NONE).setText("Vertical Alignment"); verticalAlignmentPicker = new VerticalAlignmentPicker(this, VerticalAlignmentEnum.MIDDLE); } @Override public String getEditorName() { return "Basic Style"; } @Override public void edit(Style style) throws Exception { Color bgColor = style.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR); backgroundColorPicker.setSelectedColor(bgColor != null ? bgColor : GUIHelper.COLOR_WHITE); Color fgColor = style.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR); foregroundColorPicker.setSelectedColor(fgColor != null ? fgColor : GUIHelper.COLOR_BLACK); fontPicker.setFont(style.getAttributeValue(CellStyleAttributes.FONT)); HorizontalAlignmentEnum hAlign = style.getAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT); horizontalAlignmentPicker.setSelectedAlignment(hAlign != null ? hAlign : HorizontalAlignmentEnum.CENTER); VerticalAlignmentEnum vAlign = style.getAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT); verticalAlignmentPicker.setSelectedAlignment(vAlign != null ? vAlign : VerticalAlignmentEnum.MIDDLE); } @Override public Style getNewValue() { Style newStyle = new Style(); newStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, backgroundColorPicker.getSelectedColor()); newStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, foregroundColorPicker.getSelectedColor()); newStyle.setAttributeValue(CellStyleAttributes.FONT, fontPicker.getSelectedFont()); newStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, horizontalAlignmentPicker.getSelectedAlignment()); newStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, verticalAlignmentPicker.getSelectedAlignment()); return newStyle; } }
3,944
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SeparatorPanel.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/SeparatorPanel.java
package net.sourceforge.nattable.style.editor; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; /** * Adds a separator line and label to the parent panel. */ public class SeparatorPanel extends Composite { public SeparatorPanel(Composite parentPanel, String label) { super(parentPanel, SWT.NONE); initComponents(label); } public void initComponents(String label) { GridLayout gridLayout = new GridLayout(2, false); setLayout(gridLayout); GridData layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.horizontalAlignment = GridData.FILL; setLayoutData(layoutData); // Text label StyledText gridLinesLabel = new StyledText(this, SWT.NONE); gridLinesLabel.setEditable(false); Display display = Display.getDefault(); FontData data = display .getSystemFont().getFontData()[0]; Font font = new Font(display, data.getName(), data.getHeight(), SWT.BOLD); gridLinesLabel.setFont(font); gridLinesLabel.setBackground(Display.getCurrent().getSystemColor (SWT.COLOR_WIDGET_BACKGROUND)); gridLinesLabel.setText(label); // Separator line Label separator = new Label (this, SWT.SEPARATOR | SWT.HORIZONTAL); GridData separatorData = new GridData(); separatorData.grabExcessHorizontalSpace = true; separatorData.horizontalAlignment = GridData.FILL; separatorData.horizontalIndent = 5; separator.setLayoutData(separatorData); } }
1,766
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
GridStyleParameterObject.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/GridStyleParameterObject.java
package net.sourceforge.nattable.style.editor; import net.sourceforge.nattable.config.CellConfigAttributes; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.grid.cell.AlternatingRowConfigLabelAccumulator; import net.sourceforge.nattable.style.CellStyleAttributes; import net.sourceforge.nattable.style.DisplayMode; import net.sourceforge.nattable.style.IStyle; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; public class GridStyleParameterObject { public Font tableFont; public Color evenRowColor; public Color oddRowColor; public Color selectionColor; public IStyle evenRowStyle; public IStyle oddRowStyle; public IStyle selectionStyle; public IStyle tableStyle; private final IConfigRegistry configRegistry; public GridStyleParameterObject(IConfigRegistry configRegistry) { this.configRegistry = configRegistry; init(configRegistry); } private void init(IConfigRegistry configRegistry) { evenRowStyle = configRegistry.getConfigAttribute( CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE); evenRowColor = evenRowStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR); oddRowStyle = configRegistry.getConfigAttribute( CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE); oddRowColor = oddRowStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR); selectionStyle = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT); selectionColor = selectionStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR); tableStyle = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL); tableFont = tableStyle.getAttributeValue(CellStyleAttributes.FONT); } public IConfigRegistry getConfigRegistry() { return configRegistry; } }
2,025
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
HorizontalAlignmentPicker.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/HorizontalAlignmentPicker.java
package net.sourceforge.nattable.style.editor; import net.sourceforge.nattable.style.HorizontalAlignmentEnum; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; /** * Component that lets the user select an alignment. */ public class HorizontalAlignmentPicker extends Composite { private final Combo combo; public HorizontalAlignmentPicker(Composite parent, HorizontalAlignmentEnum alignment) { super(parent, SWT.NONE); setLayout(new RowLayout()); combo = new Combo(this, SWT.READ_ONLY | SWT.DROP_DOWN); combo.setItems(new String[] { "Center", "Left", "Right" }); update(alignment); } private void update(HorizontalAlignmentEnum alignment) { if (alignment.equals(HorizontalAlignmentEnum.CENTER)) combo.select(0); else if (alignment.equals(HorizontalAlignmentEnum.LEFT)) combo.select(1); else if (alignment.equals(HorizontalAlignmentEnum.RIGHT)) combo.select(2); else throw new IllegalArgumentException("bad alignment: " + alignment); } public HorizontalAlignmentEnum getSelectedAlignment() { int idx = combo.getSelectionIndex(); if (idx == 0) return HorizontalAlignmentEnum.CENTER; else if (idx == 1) return HorizontalAlignmentEnum.LEFT; else if (idx == 2) return HorizontalAlignmentEnum.RIGHT; else throw new IllegalStateException("shouldn't happen"); } public void setSelectedAlignment(HorizontalAlignmentEnum horizontalAlignment) { if (horizontalAlignment == null) throw new IllegalArgumentException("null"); update(horizontalAlignment); } }
1,868
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
BorderThicknessPicker.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/BorderThicknessPicker.java
package net.sourceforge.nattable.style.editor; import static org.eclipse.swt.SWT.NONE; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; /** * Control to select the thickness of a border. */ public class BorderThicknessPicker extends Composite { private Combo combo; public BorderThicknessPicker(Composite parent) { super(parent, NONE); setLayout(new RowLayout()); combo = new Combo(this, SWT.READ_ONLY | SWT.DROP_DOWN); combo.setItems(new String[] { "Thin", "Thick", "Very Thick" }); combo.select(0); } @Override public void setEnabled(boolean b) { combo.setEnabled(b); } public int getSelectedThickness() { int idx = combo.getSelectionIndex(); if (idx == 0) return 1; else if (idx == 1) return 3; else if (idx == 2) return 6; else throw new IllegalStateException("never happen"); } public void setSelectedThickness(int thickness) { if (thickness < 0) throw new IllegalArgumentException("negative number"); int idx = 0; if (thickness < 3) idx = 0; else if (thickness < 6) idx = 1; else if (thickness > 6) idx = 2; combo.select(idx); } }
1,379
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
VerticalAlignmentPicker.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/VerticalAlignmentPicker.java
package net.sourceforge.nattable.style.editor; import net.sourceforge.nattable.style.VerticalAlignmentEnum; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; /** * Component that lets the user select an alignment. */ public class VerticalAlignmentPicker extends Composite { private final Combo combo; public VerticalAlignmentPicker(Composite parent, VerticalAlignmentEnum alignment) { super(parent, SWT.NONE); setLayout(new RowLayout()); combo = new Combo(this, SWT.READ_ONLY | SWT.DROP_DOWN); combo.setItems(new String[] { "Top", "Middle", "Bottom" }); update(alignment); } private void update(VerticalAlignmentEnum alignment) { if (alignment.equals(VerticalAlignmentEnum.TOP)) combo.select(0); else if (alignment.equals(VerticalAlignmentEnum.MIDDLE)) combo.select(1); else if (alignment.equals(VerticalAlignmentEnum.BOTTOM)) combo.select(2); else throw new IllegalArgumentException("bad alignment: " + alignment); } public VerticalAlignmentEnum getSelectedAlignment() { int idx = combo.getSelectionIndex(); if (idx == 0) return VerticalAlignmentEnum.TOP; else if (idx == 1) return VerticalAlignmentEnum.MIDDLE; else if (idx == 2) return VerticalAlignmentEnum.BOTTOM; else throw new IllegalStateException("shouldn't happen"); } public void setSelectedAlignment(VerticalAlignmentEnum verticalAlignment) { if (verticalAlignment == null) throw new IllegalArgumentException("null"); update(verticalAlignment); } }
1,836
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
GridColorsEditorPanel.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/GridColorsEditorPanel.java
package net.sourceforge.nattable.style.editor; import net.sourceforge.nattable.config.IConfigRegistry; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; public class GridColorsEditorPanel extends AbstractEditorPanel<GridStyleParameterObject> { private FontPicker fontPicker; private ColorPicker evenRowColorPicker; private ColorPicker oddRowColorPicker; private ColorPicker selectionColorPicker; private IConfigRegistry configRegistry; public GridColorsEditorPanel(Composite parent, GridStyleParameterObject currentStyle) { super(parent, SWT.NONE); } @Override public String getEditorName() { return "Grid colors"; } @Override public GridStyleParameterObject getNewValue() { GridStyleParameterObject newStyle = new GridStyleParameterObject(configRegistry); newStyle.tableFont = fontPicker.getSelectedFont(); newStyle.evenRowColor = evenRowColorPicker.getSelectedColor(); newStyle.oddRowColor = oddRowColorPicker.getSelectedColor(); newStyle.selectionColor = selectionColorPicker.getSelectedColor(); return newStyle; } @Override public void edit(GridStyleParameterObject currentStyle) throws Exception { configRegistry = currentStyle.getConfigRegistry(); GridLayout layout = new GridLayout(2, false); layout.marginLeft = 10; setLayout(layout); new Label(this, SWT.NONE).setText("Font"); fontPicker = new FontPicker(this, currentStyle.tableFont); fontPicker.setLayoutData(new GridData(100, 22)); new Label(this, SWT.NONE).setText("Even row color"); evenRowColorPicker = new ColorPicker(this, currentStyle.evenRowColor); new Label(this, SWT.NONE).setText("Odd row color"); oddRowColorPicker = new ColorPicker(this, currentStyle.oddRowColor); new Label(this, SWT.NONE).setText("Selection Color"); selectionColorPicker = new ColorPicker(this, currentStyle.selectionColor); } }
2,082
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnStyleEditorDialog.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/ColumnStyleEditorDialog.java
package net.sourceforge.nattable.style.editor; import net.sourceforge.nattable.style.BorderStyle; import net.sourceforge.nattable.style.CellStyleAttributes; import net.sourceforge.nattable.style.Style; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.events.ShellAdapter; import org.eclipse.swt.events.ShellEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; public class ColumnStyleEditorDialog extends AbstractStyleEditorDialog { // Tabs in the dialog private CellStyleEditorPanel cellStyleEditorPanel; private BorderStyleEditorPanel borderStyleEditorPanel; // These are populated on OK button press protected Style newColumnCellStyle; protected BorderStyle newBorderStyle; private final Style columnStyle; public ColumnStyleEditorDialog(Shell parent, Style columnCellStyle) { super(parent); this.columnStyle = columnCellStyle; this.newColumnCellStyle = columnCellStyle; if (columnCellStyle != null) { this.newBorderStyle = columnStyle.getAttributeValue(CellStyleAttributes.BORDER_STYLE); } } @Override protected void initComponents(final Shell shell) { shell.setLayout(new GridLayout()); shell.setText("Customize style"); // Closing the window is the same as canceling the form shell.addShellListener(new ShellAdapter() { @Override public void shellClosed(ShellEvent e) { doFormCancel(shell); } }); // Tabs panel Composite tabPanel = new Composite(shell, SWT.NONE); tabPanel.setLayout(new GridLayout()); GridData fillGridData = new GridData(); fillGridData.grabExcessHorizontalSpace = true; fillGridData.horizontalAlignment = GridData.FILL; tabPanel.setLayoutData(fillGridData); CTabFolder tabFolder = new CTabFolder(tabPanel, SWT.BORDER); tabFolder.setLayout(new GridLayout()); tabFolder.setLayoutData(fillGridData); CTabItem columnTab = new CTabItem(tabFolder, SWT.NONE); columnTab.setText("Column"); columnTab.setImage(GUIHelper.getImage("column")); columnTab.setControl(createColumnPanel(tabFolder)); try { cellStyleEditorPanel.edit(columnStyle); borderStyleEditorPanel.edit(columnStyle.getAttributeValue(CellStyleAttributes.BORDER_STYLE)); } catch (Exception e) { e.printStackTrace(System.err); } } /* Grid level styling * private Composite createBlotterPanel(Composite parent) { Composite blotterPanel = new Composite(parent, SWT.NONE); GridLayout panelLayout = new GridLayout(); blotterPanel.setLayout(panelLayout); GridData panelLayoutData = new GridData(); panelLayoutData.grabExcessHorizontalSpace = true; panelLayoutData.grabExcessVerticalSpace = true; panelLayoutData.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING; panelLayoutData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; panelLayoutData.horizontalIndent = 20; blotterPanel.setLayoutData(panelLayoutData); new SeparatorPanel(blotterPanel, "Styling"); gridColorsEditorPanel = new GridColorsEditorPanel(blotterPanel, gridStyle); return blotterPanel; } */ private Composite createColumnPanel(Composite parent) { Composite columnPanel = new Composite(parent, SWT.NONE); columnPanel.setLayout(new GridLayout()); new SeparatorPanel(columnPanel, "Styling"); cellStyleEditorPanel = new CellStyleEditorPanel(columnPanel, SWT.NONE); new SeparatorPanel(columnPanel, "Border"); borderStyleEditorPanel = new BorderStyleEditorPanel(columnPanel, SWT.NONE); return columnPanel; } @Override protected void doFormOK(Shell shell) { newColumnCellStyle = cellStyleEditorPanel.getNewValue(); newBorderStyle = borderStyleEditorPanel.getNewValue(); shell.dispose(); } @Override protected void doFormClear(Shell shell) { this.newColumnCellStyle = null; shell.dispose(); } // Getters for the modified style public Style getNewColumCellStyle() { return newColumnCellStyle; } public BorderStyle getNewColumnBorderStyle() { return newBorderStyle; } }
4,283
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
FontPicker.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/FontPicker.java
package net.sourceforge.nattable.style.editor; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FontDialog; import org.eclipse.swt.widgets.Shell; /** * A button that displays a font name and allows the user to pick another font. */ public class FontPicker extends Button { private Font selectedFont; private FontData[] fontData = new FontData[1]; private Font displayFont; public FontPicker(final Composite parent, Font originalFont) { super(parent, SWT.NONE); if (originalFont == null) throw new IllegalArgumentException("null"); update(originalFont.getFontData()[0]); addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FontDialog dialog = new FontDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM)); dialog.setFontList(fontData); FontData selected = dialog.open(); if (selected != null) { update(selected); pack(true); } } }); } private void update(FontData data) { this.fontData[0] = data; this.selectedFont = GUIHelper.getFont(data); setText(data.getName() + ", " + data.getHeight() + "pt"); setFont(createDisplayFont(data)); setAlignment(SWT.CENTER); setToolTipText("Click to select font"); } private Font createDisplayFont(FontData data) { FontData resizedData = new FontData(data.getName(), 8, data.getStyle()); displayFont = GUIHelper.getFont(resizedData); return displayFont; } /** * @return Font selected by the user. <em>Note that it is the responsibility of the client to dispose of this * resource.</em> */ public Font getSelectedFont() { return selectedFont; } /** * Set the selected font. <em>Note that this class will not take ownership of the passed resource. Instead it will * create and manage its own internal copy.</em> */ public void setSelectedFont(Font font) { if (font == null) throw new IllegalArgumentException("null"); update(font.getFontData()[0]); } @Override protected void checkSubclass() { ; // do nothing } }
2,938
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
LineStylePicker.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/LineStylePicker.java
package net.sourceforge.nattable.style.editor; import static org.eclipse.swt.SWT.NONE; import net.sourceforge.nattable.style.BorderStyle.LineStyleEnum; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; /** * Component to select a {@link LineStyleEnum}. */ public class LineStylePicker extends Composite { private Combo combo; public LineStylePicker(Composite parent) { super(parent, NONE); setLayout(new RowLayout()); combo = new Combo(this, SWT.READ_ONLY | SWT.DROP_DOWN); combo.setItems(new String[] { "Solid", "Dashed", "Dotted", "Dashdot", "Dashdotdot" }); combo.select(0); } @Override public void setEnabled(boolean enabled) { combo.setEnabled(enabled); } public void setSelectedLineStyle(LineStyleEnum lineStyle) { int index = 0; if (lineStyle.equals(LineStyleEnum.SOLID)) index = 0; else if (lineStyle.equals(LineStyleEnum.DASHED)) index = 1; else if (lineStyle.equals(LineStyleEnum.DOTTED)) index = 2; else if (lineStyle.equals(LineStyleEnum.DASHDOT)) index = 3; else if (lineStyle.equals(LineStyleEnum.DASHDOTDOT)) index = 4; combo.select(index); } public LineStyleEnum getSelectedLineStyle() { int index = combo.getSelectionIndex(); if (index == 0) return LineStyleEnum.SOLID; else if (index == 1) return LineStyleEnum.DASHED; else if (index == 2) return LineStyleEnum.DOTTED; else if (index == 3) return LineStyleEnum.DASHDOT; else if (index == 4) return LineStyleEnum.DASHDOTDOT; else throw new IllegalStateException("never happen"); } }
1,841
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DisplayColumnStyleEditorCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/command/DisplayColumnStyleEditorCommand.java
package net.sourceforge.nattable.style.editor.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.layer.ILayer; public class DisplayColumnStyleEditorCommand extends AbstractContextFreeCommand { public final int columnPosition; public final int rowPosition; private final ILayer layer; private final IConfigRegistry configRegistry; public DisplayColumnStyleEditorCommand(ILayer natLayer, IConfigRegistry configRegistry, int columnPosition, int rowPosition) { this.layer = natLayer; this.configRegistry = configRegistry; this.columnPosition = columnPosition; this.rowPosition = rowPosition; } public ILayer getNattableLayer() { return layer; } public IConfigRegistry getConfigRegistry() { return configRegistry; } }
884
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DisplayColumnStyleEditorCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/style/editor/command/DisplayColumnStyleEditorCommandHandler.java
package net.sourceforge.nattable.style.editor.command; import static net.sourceforge.nattable.config.CellConfigAttributes.CELL_STYLE; import static net.sourceforge.nattable.style.DisplayMode.NORMAL; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.Set; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.cell.ColumnOverrideLabelAccumulator; import net.sourceforge.nattable.persistence.IPersistable; import net.sourceforge.nattable.persistence.StylePersistor; import net.sourceforge.nattable.style.CellStyleAttributes; import net.sourceforge.nattable.style.Style; import net.sourceforge.nattable.style.editor.ColumnStyleEditorDialog; import org.eclipse.swt.widgets.Display; /** * * 1. Captures a new style using the <code>StyleEditorDialog</code> * 2. Registers style from step 1 in the <code>ConfigRegistry</code> with a new label * 3. Applies the label from step 2 to all cells in the selected column * */ public class DisplayColumnStyleEditorCommandHandler extends AbstractLayerCommandHandler<DisplayColumnStyleEditorCommand> implements IPersistable { protected static final String PERSISTENCE_PREFIX = "userDefinedColumnStyle"; protected static final String USER_EDITED_STYLE_LABEL = "USER_EDITED_STYLE_FOR_INDEX_"; protected ColumnOverrideLabelAccumulator columnLabelAccumulator; protected ColumnStyleEditorDialog dialog; private final IConfigRegistry configRegistry; protected final Map<String, Style> stylesToPersist = new HashMap<String, Style>(); public DisplayColumnStyleEditorCommandHandler(ColumnOverrideLabelAccumulator labelAccumulator, IConfigRegistry configRegistry) { this.columnLabelAccumulator = labelAccumulator; this.configRegistry = configRegistry; } @Override public boolean doCommand(DisplayColumnStyleEditorCommand command) { ILayer nattableLayer = command.getNattableLayer(); int columnIndex = nattableLayer.getColumnIndexByPosition(command.columnPosition); // Column style Style slectedCellStyle = (Style) configRegistry.getConfigAttribute(CELL_STYLE, NORMAL, USER_EDITED_STYLE_LABEL + columnIndex); dialog = new ColumnStyleEditorDialog(Display.getCurrent().getActiveShell(), slectedCellStyle); dialog.open(); if(dialog.isCancelPressed()) { return true; } applySelectedStyleToColumn(command, columnIndex); return true; } public Class<DisplayColumnStyleEditorCommand> getCommandClass() { return DisplayColumnStyleEditorCommand.class; } protected void applySelectedStyleToColumn(DisplayColumnStyleEditorCommand command, int columnIndex) { // Read the edited styles Style newColumnCellStyle = dialog.getNewColumCellStyle(); if (newColumnCellStyle == null) { stylesToPersist.remove(getConfigLabel(columnIndex)); } else { newColumnCellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, dialog.getNewColumnBorderStyle()); stylesToPersist.put(getConfigLabel(columnIndex), newColumnCellStyle); } configRegistry.registerConfigAttribute(CELL_STYLE, newColumnCellStyle, NORMAL, getConfigLabel(columnIndex)); columnLabelAccumulator.registerColumnOverrides(columnIndex, getConfigLabel(columnIndex)); } protected String getConfigLabel(int columnIndex) { return USER_EDITED_STYLE_LABEL + columnIndex; } public void loadState(String prefix, Properties properties) { prefix = prefix + DOT + PERSISTENCE_PREFIX; Set<Object> keySet = properties.keySet(); for (Object key : keySet) { String keyString = (String) key; // Relevant Key if (keyString.contains(PERSISTENCE_PREFIX)) { int colIndex = parseColumnIndexFromKey(keyString); // Has the config label been processed if (!stylesToPersist.keySet().contains(getConfigLabel(colIndex))) { Style savedStyle = StylePersistor.loadStyle(prefix + DOT + getConfigLabel(colIndex), properties); configRegistry.registerConfigAttribute(CELL_STYLE, savedStyle, NORMAL, getConfigLabel(colIndex)); stylesToPersist.put(getConfigLabel(colIndex), savedStyle); } } } } protected int parseColumnIndexFromKey(String keyString) { int colLabelStartIndex = keyString.indexOf(USER_EDITED_STYLE_LABEL); String columnConfigLabel = keyString.substring(colLabelStartIndex, keyString.indexOf('.', colLabelStartIndex)); int lastUnderscoreInLabel = columnConfigLabel.lastIndexOf('_', colLabelStartIndex); return Integer.parseInt(columnConfigLabel.substring(lastUnderscoreInLabel + 1)); } public void saveState(String prefix, Properties properties) { prefix = prefix + DOT + PERSISTENCE_PREFIX; for (Map.Entry<String, Style> labelToStyle : stylesToPersist.entrySet()) { Style style = labelToStyle.getValue(); String label = labelToStyle.getKey(); StylePersistor.saveStyle(prefix + DOT + label, properties, style); } } }
5,077
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
BlinkLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/blink/BlinkLayer.java
package net.sourceforge.nattable.blink; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Timer; import java.util.TimerTask; import net.sourceforge.nattable.blink.command.BlinkTimerEnableCommandHandler; import net.sourceforge.nattable.blink.event.BlinkEvent; import net.sourceforge.nattable.config.ConfigRegistry; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.coordinate.IndexCoordinate; import net.sourceforge.nattable.data.IColumnPropertyResolver; import net.sourceforge.nattable.data.IDataProvider; import net.sourceforge.nattable.data.IRowDataProvider; import net.sourceforge.nattable.data.IRowIdAccessor; import net.sourceforge.nattable.layer.AbstractLayerTransform; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.layer.event.ILayerEvent; import net.sourceforge.nattable.layer.event.PropertyUpdateEvent; import net.sourceforge.nattable.style.DisplayMode; import org.eclipse.swt.widgets.Display; /** * Blinks cells when they are updated. * Returns blinking cell styles for the cells which have been updated. * * Every time its asked for config labels: * Checks the UpdateEventsCache for changes to the cell * If a cell is updated * The cell is tracked as 'blinking' and blinking config labels are returned * A TimerTask is started which will stop the blinking after the blink period is over * * @param <T> Type of the Bean in the backing {@linkplain IDataProvider} */ public class BlinkLayer<T> extends AbstractLayerTransform implements IUniqueIndexLayer { private final IUniqueIndexLayer dataLayer; private final IRowDataProvider<T> rowDataProvider; private final IConfigRegistry configRegistry; private final IRowIdAccessor<T> rowIdAccessor; private Timer stopBlinkTimer; protected boolean blinkingEnabled = true; /** Cache all the update events allowing the layer to track what got updated */ private final UpdateEventsCache<T> updateEventsCache; /** Duration of a single blink */ private int blinkDurationInMilis = 1000; /** Track the updates which are currently blinking */ Map<String, PropertyUpdateEvent<T>> blinkingUpdates = new HashMap<String, PropertyUpdateEvent<T>>(); /** Track the blinking TimerTasks which are currently running*/ Map<String, TimerTask> blinkingTasks = new HashMap<String, TimerTask>(); public BlinkLayer(IUniqueIndexLayer dataLayer, IRowDataProvider<T> listDataProvider, IRowIdAccessor<T> rowIdAccessor, IColumnPropertyResolver columnPropertyResolver, IConfigRegistry configRegistry) { super(dataLayer); this.dataLayer = dataLayer; this.rowDataProvider = listDataProvider; this.rowIdAccessor = rowIdAccessor; this.configRegistry = configRegistry; this.updateEventsCache = new UpdateEventsCache<T>(rowIdAccessor, columnPropertyResolver); registerCommandHandler(new BlinkTimerEnableCommandHandler(this)); } @Override public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) { if (!blinkingEnabled) { return getUnderlyingLayer().getConfigLabelsByPosition(columnPosition, rowPosition); } int rowIndex = getUnderlyingLayer().getRowIndexByPosition(rowPosition); int columnIndex = getUnderlyingLayer().getColumnIndexByPosition(columnPosition); String rowId = rowIdAccessor.getRowId(rowDataProvider.getRowObject(rowIndex)).toString(); String key = updateEventsCache.getKey(columnIndex, rowId); LabelStack underlyingLabelStack = getUnderlyingLayer().getConfigLabelsByPosition(columnPosition, rowPosition); IndexCoordinate coordinate = new IndexCoordinate(columnIndex, rowIndex); // Cell has been updated if (updateEventsCache.isUpdated(key)) { PropertyUpdateEvent<T> event = updateEventsCache.getEvent(key); // Old update in middle of a blink - cancel it if (blinkingUpdates.containsKey(key)) { blinkingTasks.get(key).cancel(); getStopBlinkTimer().purge(); blinkingTasks.remove(key); blinkingUpdates.remove(key); } LabelStack blinkingConfigTypes = resolveConfigTypes(event.getOldValue(), event.getNewValue(), coordinate, getUnderlyingLayer()); // start blinking cell if (blinkingConfigTypes != null) { TimerTask stopBlinkTask = getStopBlinkTask(key, this); blinkingUpdates.put(key, event); blinkingTasks.put(key, stopBlinkTask); updateEventsCache.remove(key); getStopBlinkTimer().schedule(stopBlinkTask, blinkDurationInMilis); return blinkingConfigTypes; } else { return new LabelStack(); } } // Previous blink timer is still running if (blinkingUpdates.containsKey(key)) { PropertyUpdateEvent<T> event = blinkingUpdates.get(key); return resolveConfigTypes(event.getOldValue(), event.getNewValue(), coordinate, getUnderlyingLayer()); } return underlyingLabelStack; } private IBlinkingCellResolver getBlinkingCellResolver(List<String> configTypes) { return configRegistry.getConfigAttribute(BlinkConfigAttributes.BLINK_RESOLVER, DisplayMode.NORMAL, configTypes); } /** * Find the {@link IBlinkingCellResolver} from the {@link ConfigRegistry}. * Use the above to find the config types associated with a blinking cell. */ public LabelStack resolveConfigTypes(Object oldValue, Object newValue, final IndexCoordinate coordinate, ILayer underlyingLayer) { // Acquire default config types for the coordinate. Use these to search for the associated resolver. LabelStack underlyingLabelStack = underlyingLayer.getConfigLabelsByPosition(coordinate.columnIndex, coordinate.rowIndex); IBlinkingCellResolver resolver = getBlinkingCellResolver(underlyingLabelStack.getLabels()); String[] blinkConfigTypes = null; if (resolver != null) { blinkConfigTypes = resolver.resolve(oldValue, newValue); } if(blinkConfigTypes != null && blinkConfigTypes.length > 0){ return new LabelStack(blinkConfigTypes); } return null; } /** * Stops the cell from blinking at the end of the blinking period. */ private TimerTask getStopBlinkTask(final String key, final ILayer layer) { return new TimerTask() { @Override public void run() { blinkingUpdates.remove(key); blinkingTasks.remove(key); if (blinkingTasks.isEmpty()) { stopBlinkTimer.cancel(); stopBlinkTimer = null; } Display.getDefault().asyncExec(new Runnable() { public void run() { fireLayerEvent(new BlinkEvent(layer)); } }); } }; } public Timer getStopBlinkTimer() { if (stopBlinkTimer == null) { stopBlinkTimer = new Timer("Stop Blink Task Timer"); } return stopBlinkTimer; } @SuppressWarnings("unchecked") @Override public void handleLayerEvent(ILayerEvent event) { if (event instanceof PropertyUpdateEvent) { updateEventsCache.put((PropertyUpdateEvent<T>) event); } super.handleLayerEvent(event); } public void setBlinkingEnabled(boolean enabled) { this.blinkingEnabled = enabled; } public int getColumnPositionByIndex(int columnIndex) { return dataLayer.getColumnPositionByIndex(columnIndex); } public int getRowPositionByIndex(int rowIndex) { return dataLayer.getRowPositionByIndex(rowIndex); } public void setBlinkDurationInMilis(int blinkDurationInMilis) { this.blinkDurationInMilis = blinkDurationInMilis; } }
7,579
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
UpdateEventsCache.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/blink/UpdateEventsCache.java
package net.sourceforge.nattable.blink; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import net.sourceforge.nattable.data.IColumnPropertyResolver; import net.sourceforge.nattable.data.IRowIdAccessor; import net.sourceforge.nattable.layer.event.PropertyUpdateEvent; /** * Cache for the update events coming in. * * This cache is used by the {@link BlinkLayer} to check if updates are * available for a cell (hence, does it need to blink). * * @param <T> Type of the Bean in the backing list. */ public class UpdateEventsCache<T> { /** Initial startup delay for the expired event removal task */ public static final int INITIAL_DELAY = 100; /** TTL for an event in the cache. The event is deleted when this expires */ public static final int TIME_TO_LIVE = 500; private final IRowIdAccessor<T> rowIdAccessor; private final IColumnPropertyResolver columnPropertyAccessor; private Map<String, TimeStampedEvent> updateEvents; private ScheduledExecutorService cleanupScheduler; public UpdateEventsCache(IRowIdAccessor<T> rowIdAccessor, IColumnPropertyResolver columnPropertyAccessor) { this.rowIdAccessor = rowIdAccessor; this.columnPropertyAccessor = columnPropertyAccessor; this.updateEvents = new HashMap<String, TimeStampedEvent>(); } /** * We are not interested in update events which are too old and need not be blinked. * This task cleans them up, by looking at the received time stamp. */ private Runnable getStaleUpdatesCleanupTask() { return new Runnable(){ public void run() { Map<String, TimeStampedEvent> recentEvents = new HashMap<String, TimeStampedEvent>(); Date recent = new Date(System.currentTimeMillis() - TIME_TO_LIVE); for (Map.Entry<String, TimeStampedEvent> entry : updateEvents.entrySet()) { if (entry.getValue().timeRecieved.after(recent)) { recentEvents.put(entry.getKey(), entry.getValue()); } } synchronized (updateEvents) { updateEvents = recentEvents; checkUpdateEvents(); } } }; } private void checkUpdateEvents() { if (updateEvents.isEmpty()) { cleanupScheduler.shutdownNow(); cleanupScheduler = null; } else { if (cleanupScheduler == null) { cleanupScheduler = Executors.newScheduledThreadPool(1); cleanupScheduler.scheduleAtFixedRate(getStaleUpdatesCleanupTask(), INITIAL_DELAY, TIME_TO_LIVE, TimeUnit.MILLISECONDS); } } } public void put(PropertyUpdateEvent<T> event) { String key = getKey(event); updateEvents.put(key, new TimeStampedEvent(event)); checkUpdateEvents(); } protected String getKey(PropertyUpdateEvent<T> event) { int columnIndex = columnPropertyAccessor.getColumnIndex(event.getPropertyName()); String rowId = rowIdAccessor.getRowId(event.getSourceBean()).toString(); return getKey(columnIndex, rowId); } public String getKey(int columnIndex, String rowId) { return columnIndex + "-" + rowId; } public PropertyUpdateEvent<T> getEvent(String key){ return updateEvents.get(key).event; } public int getCount() { return updateEvents.size(); } public boolean contains(int columnIndex, String rowId) { return updateEvents.containsKey(getKey(columnIndex, rowId)); } public boolean isUpdated(String key) { return updateEvents.containsKey(key); } public void clear() { updateEvents.clear(); checkUpdateEvents(); } public void remove(String key) { updateEvents.remove(key); checkUpdateEvents(); } /** * Class to keep track of the time when an event was received */ private class TimeStampedEvent { Date timeRecieved; PropertyUpdateEvent<T> event; public TimeStampedEvent(PropertyUpdateEvent<T> event) { this.event = event; this.timeRecieved = new Date(); } } }
4,002
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
BlinkConfigAttributes.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/blink/BlinkConfigAttributes.java
package net.sourceforge.nattable.blink; import net.sourceforge.nattable.style.ConfigAttribute; public class BlinkConfigAttributes { public static final ConfigAttribute<IBlinkingCellResolver> BLINK_RESOLVER = new ConfigAttribute<IBlinkingCellResolver>(); }
262
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
IBlinkingCellResolver.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/blink/IBlinkingCellResolver.java
package net.sourceforge.nattable.blink; /** * This interface is used to determine whether a change requires a blink. * This is a way to add thresholds to blinking. */ public interface IBlinkingCellResolver { /** * @param oldValue * @param newValue * @return Possibly the config type associated with the blinking style. */ public String[] resolve(Object oldValue, Object newValue); }
417
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
BlinkTimerEnableCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/blink/command/BlinkTimerEnableCommand.java
package net.sourceforge.nattable.blink.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; public class BlinkTimerEnableCommand extends AbstractContextFreeCommand { private boolean enableBlinkTimer; public BlinkTimerEnableCommand(boolean enableBlinkTimer) { this.enableBlinkTimer = enableBlinkTimer; } public boolean isEnableBlinkTimer() { return enableBlinkTimer; } public void setEnableBlinkTimer(boolean enableBlinkTimer) { this.enableBlinkTimer = enableBlinkTimer; } }
537
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
BlinkTimerEnableCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/blink/command/BlinkTimerEnableCommandHandler.java
package net.sourceforge.nattable.blink.command; import net.sourceforge.nattable.blink.BlinkLayer; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; public class BlinkTimerEnableCommandHandler extends AbstractLayerCommandHandler<BlinkTimerEnableCommand> { private final BlinkLayer<?> blinkLayer; public BlinkTimerEnableCommandHandler(BlinkLayer<?> blinkLayer) { this.blinkLayer = blinkLayer; } public Class<BlinkTimerEnableCommand> getCommandClass() { return BlinkTimerEnableCommand.class; } @Override protected boolean doCommand(BlinkTimerEnableCommand command) { blinkLayer.setBlinkingEnabled(command.isEnableBlinkTimer()); return true; } }
685
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
BlinkEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/blink/event/BlinkEvent.java
package net.sourceforge.nattable.blink.event; import java.util.Arrays; import java.util.Collection; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.event.ILayerEvent; import net.sourceforge.nattable.layer.event.IVisualChangeEvent; import org.eclipse.swt.graphics.Rectangle; public class BlinkEvent implements IVisualChangeEvent { private ILayer layer; public BlinkEvent(ILayer layer) { this.layer = layer; } public ILayerEvent cloneEvent() { return new BlinkEvent(this.layer); } public Collection<Rectangle> getChangedPositionRectangles() { return Arrays.asList(new Rectangle(0, 0, layer.getHeight(), layer.getWidth())); } public ILayer getLayer() { return layer; } public boolean convertToLocal(ILayer localLayer) { return true; } }
838
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ISerializer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/serializing/ISerializer.java
package net.sourceforge.nattable.serializing; public interface ISerializer { public void serialize(); }
111
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ObjectCloner.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/util/ObjectCloner.java
package net.sourceforge.nattable.util; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; /** * Public domain code from Dave Miller, JavaWorld.com */ public class ObjectCloner { /** * @return a deep copy of an object */ public static Object deepCopy(Object oldObj) { ObjectOutputStream oos = null; ObjectInputStream ois = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); // serialize and pass the object oos.writeObject(oldObj); oos.flush(); ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray()); ois = new ObjectInputStream(bin); // return the new object return ois.readObject(); } catch (Exception e) { e.printStackTrace(System.err); return null; } finally { try { oos.close(); ois.close(); } catch (IOException e) { e.printStackTrace(System.err); } } } }
1,077
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
GUIHelper.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/util/GUIHelper.java
package net.sourceforge.nattable.util; import java.net.URL; import java.util.concurrent.atomic.AtomicLong; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; public class GUIHelper { private static final String KEY_PREFIX = GUIHelper.class.getCanonicalName() + "."; // Color public static final Color COLOR_GRAY = Display.getDefault().getSystemColor(SWT.COLOR_GRAY); public static final Color COLOR_WHITE = Display.getDefault().getSystemColor(SWT.COLOR_WHITE); public static final Color COLOR_DARK_GRAY = Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); public static final Color COLOR_BLACK = Display.getDefault().getSystemColor(SWT.COLOR_BLACK); public static final Color COLOR_BLUE = Display.getDefault().getSystemColor(SWT.COLOR_BLUE); public static final Color COLOR_RED = Display.getDefault().getSystemColor(SWT.COLOR_RED); public static final Color COLOR_YELLOW = Display.getDefault().getSystemColor(SWT.COLOR_YELLOW); public static final Color COLOR_GREEN = Display.getDefault().getSystemColor(SWT.COLOR_GREEN); public static final Color COLOR_LIST_BACKGROUND = Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND); public static final Color COLOR_LIST_FOREGROUND = Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND); public static final Color COLOR_LIST_SELECTION = Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION); public static final Color COLOR_WIDGET_BACKGROUND = Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); public static final Color COLOR_WIDGET_FOREGROUND = Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND); public static final Color COLOR_TITLE_INACTIVE_BACKGROUND = Display.getDefault().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND); public static final Color COLOR_WIDGET_BORDER = Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BORDER); public static final Color COLOR_WIDGET_DARK_SHADOW = Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW); public static final Color COLOR_WIDGET_LIGHT_SHADOW = Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW); public static final Color COLOR_WIDGET_NORMAL_SHADOW = Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); public static final Color COLOR_WIDGET_HIGHLIGHT_SHADOW = Display.getDefault().getSystemColor( SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); public static Color getColor(RGB rgb) { return getColor(rgb.red, rgb.green, rgb.blue); } public static Color getColor(int red, int green, int blue) { String key = getColorKey(red, green, blue); if (JFaceResources.getColorRegistry().hasValueFor(key)) { return JFaceResources.getColorRegistry().get(key); } else { JFaceResources.getColorRegistry().put(key, new RGB(red, green, blue)); return getColor(key); } } public static Color getColor(String key) { return JFaceResources.getColorRegistry().get(key); } private static String getColorKey(int red, int green, int blue) { return KEY_PREFIX + "_COLOR_" + red + "_" + green + "_" + blue; } // Font public static final Font DEFAULT_FONT = Display.getDefault().getSystemFont(); public static final int DEFAULT_RESIZE_HANDLE_SIZE = 4; public static final int DEFAULT_MIN_DISPLAY_SIZE = 5; public static final int DEFAULT_ANTIALIAS = SWT.DEFAULT;; public static final int DEFAULT_TEXT_ANTIALIAS = SWT.DEFAULT;; public static Font getFont(FontData...fontDatas) { StringBuilder keyBuilder = new StringBuilder(); for (FontData fontData : fontDatas) { keyBuilder.append(fontData.toString()); } String key = keyBuilder.toString(); if (JFaceResources.getFontRegistry().hasValueFor(key)) { return JFaceResources.getFont(key); } else { JFaceResources.getFontRegistry().put(key, fontDatas); return JFaceResources.getFont(key); } } public static Font getFont(String key) { return JFaceResources.getFont(key); } // Image private static final String[] IMAGE_DIRS = new String[] { "net/sourceforge/nattable/images/", "" }; private static final String[] IMAGE_EXTENSIONS = new String[] { ".png", ".gif" }; public static Image getImage(String key) { Image image = JFaceResources.getImage(key); if (image == null) { URL imageUrl = getImageUrl(key); if (imageUrl != null) { ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(imageUrl); JFaceResources.getImageRegistry().put(key, imageDescriptor.createImage()); image = JFaceResources.getImage(key); } } return image; } private static URL getImageUrl(String imageName) { for (String dir : IMAGE_DIRS) { for (String ext : IMAGE_EXTENSIONS) { URL url = GUIHelper.class.getClassLoader().getResource(dir + imageName + ext); if (url != null) { return url; } } } return null; } // Sequence private static final AtomicLong atomicLong = new AtomicLong(0); public static String getSequenceNumber() { long id = atomicLong.addAndGet(1); return String.valueOf(id); } }
5,428
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ObjectUtils.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/util/ObjectUtils.java
package net.sourceforge.nattable.util; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Random; import java.util.TreeSet; public class ObjectUtils { /** * Transfers the iterator to an unmodifiable collection. * @return Contents of the Iterator<Cell> as a Collection. */ public static <T>Collection<T> asCollection(Iterator<T> iterator) { Collection<T> collection = new ArrayList<T>(); return addToCollection(iterator, collection); } public static <T> List<T> asList(Collection<T> collection) { return new ArrayList<T>(collection); } public static int[] asIntArray(Collection<Integer> collection) { int[] copy = new int[collection.size()]; int index = 0; for (Integer value : collection) { copy[index] = value.intValue(); index++; } return copy; } /** * Returns an unmodifiable ordered collection. * @param <T> * @param iterator * @return */ public static <T>Collection<T> asOrderedCollection(Iterator<T> iterator, Comparator<T> comparator) { Collection<T> collection = new TreeSet<T>(comparator); return addToCollection(iterator, collection); } private static <T> Collection<T> addToCollection(Iterator<T> iterator, Collection<T> collection) { while (iterator.hasNext()) { T object = iterator.next(); collection.add(object); } return Collections.unmodifiableCollection(collection); } public static <T>String toString(Collection<T> collection){ if (collection == null) { return "NULL"; } String out = "[ "; int count = 1; for (T object : collection) { if(object == null) continue; out = out + object.toString(); if(collection.size() != count){ out = out + ";\n"; } count++; } out = out + " ]"; return out; } public static <T>String toString(T[] array){ return toString(Arrays.asList(array)); } /** * @return TRUE is collection is null or contains no elements */ public static <T> boolean isEmpty(Collection<T> collection) { return collection == null || collection.size() == 0; } /** * @return TRUE if string == null || string.length() == 0 */ public static <T> boolean isEmpty(String string) { return string == null || string.length() == 0; } /** * @return TRUE if string != null && string.length() > 0 */ public static <T> boolean isNotEmpty(String string) { return string != null && string.length() > 0; } /** * @see ObjectUtils#isEmpty(Collection) */ public static <T> boolean isNotEmpty(Collection<T> collection) { return !isEmpty(collection); } /** * @return TRUE if object reference is null */ public static boolean isNull(Object object) { return object == null; } /** * @return TRUE if object reference is NOT null */ public static boolean isNotNull(Object object) { return object != null; } private static final Random RANDOM = new Random(); /** * @return a random Date */ public static Date getRandomDate() { return new Date(RANDOM.nextLong()); } /** * @return 4 digit random Integer number */ public static int getRandomNumber() { return RANDOM.nextInt(10000); } /** * @return random Integer number between 0 and parameter max */ public static int getRandomNumber(int max) { return RANDOM.nextInt(max); } public static <T> T getLastElement(List<T> list) { return list.get(list.size() - 1); } public static <T> T getFirstElement(List<T> list) { return list.get(0); } }
3,736
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
PersistenceUtils.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/util/PersistenceUtils.java
package net.sourceforge.nattable.util; import java.util.Map; import java.util.TreeMap; import java.util.Map.Entry; public class PersistenceUtils { /** * Parse the persisted property and create a TreeMap<Integer, String> from it.<br/> * Works in conjunction with the {@link PersistenceUtils#mapAsString(Map)}.<br/> * * @param property from the properties file. */ public static Map<Integer, String> parseString(Object property) { TreeMap<Integer, String> map = new TreeMap<Integer, String>(); if (property != null) { String value = (String) property; String[] renamedColumns = value.split("\\|"); for (String token : renamedColumns) { String[] split = token.split(":"); String index = split[0]; String label = split[1]; map.put(Integer.valueOf(index), label); } } return map; } /** * Convert the Map to a String suitable for persisting in the Properties file. * {@link PersistenceUtils#parseString(Object)} can be used to reconstruct this Map object from the String.<br/> */ public static String mapAsString(Map<Integer, String> map) { StringBuffer buffer = new StringBuffer(); for (Entry<Integer, String> entry : map.entrySet()) { buffer.append(entry.getKey() + ":" + entry.getValue() + "|"); } return buffer.toString(); } }
1,349
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ArrayUtil.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/util/ArrayUtil.java
package net.sourceforge.nattable.util; import java.util.ArrayList; import java.util.Collection; import java.util.List; public class ArrayUtil { public static final String[] STRING_TYPE_ARRAY = new String[] {}; public static final int[] INT_TYPE_ARRAY = new int[] {}; public static <T> List<T> asList(T[] array) { return new ArrayList<T>(ArrayUtil.asCollection(array)); } public static <T> Collection<T> asCollection(T[] array) { List<T> list = new ArrayList<T>(); for (int i = 0; i < array.length; i++) { list.add(array[i]); } return list; } public static int[] asIntArray(int... ints) { return ints; } public static List<Integer> asIntegerList(int... ints) { ArrayList<Integer> list = new ArrayList<Integer>(); for (Integer integer : ints) { list.add(integer); } return list; } public static boolean isEmpty(int[] array){ return (array == null) || (array.length == 0); } public static boolean isEmpty(String[] array){ return (array == null) || (array.length == 0); } public static boolean isNotEmpty(int[] array){ return !isEmpty(array); } public static boolean isNotEmpty(String[] array){ return !isEmpty(array); } public static int[] asIntArray(List<Integer> list) { int[] ints = new int[list.size()]; int i = 0; for (int fromSet : list) { ints[i] = fromSet; i++; } return ints; } }
1,431
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
Base64.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/util/Base64.java
/* * @(#)Base64.java 1.7 05/11/17 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package net.sourceforge.nattable.util; /** * Static methods for translating Base64 encoded strings to byte arrays * and vice-versa. * * @author Josh Bloch * @version 1.7, 11/17/05 * @see Preferences * @since 1.4 */ public class Base64 { /** * Translates the specified byte array into a Base64 string as per * Preferences.put(byte[]). */ public static String byteArrayToBase64(byte[] a) { return byteArrayToBase64(a, false); } /** * Translates the specified byte array into an "alternate representation" * Base64 string. This non-standard variant uses an alphabet that does * not contain the uppercase alphabetic characters, which makes it * suitable for use in situations where case-folding occurs. */ public static String byteArrayToAltBase64(byte[] a) { return byteArrayToBase64(a, true); } private static String byteArrayToBase64(byte[] a, boolean alternate) { int aLen = a.length; int numFullGroups = aLen/3; int numBytesInPartialGroup = aLen - 3*numFullGroups; int resultLen = 4*((aLen + 2)/3); StringBuffer result = new StringBuffer(resultLen); char[] intToAlpha = (alternate ? intToAltBase64 : intToBase64); // Translate all full groups from byte array elements to Base64 int inCursor = 0; for (int i=0; i<numFullGroups; i++) { int byte0 = a[inCursor++] & 0xff; int byte1 = a[inCursor++] & 0xff; int byte2 = a[inCursor++] & 0xff; result.append(intToAlpha[byte0 >> 2]); result.append(intToAlpha[(byte0 << 4)&0x3f | (byte1 >> 4)]); result.append(intToAlpha[(byte1 << 2)&0x3f | (byte2 >> 6)]); result.append(intToAlpha[byte2 & 0x3f]); } // Translate partial group if present if (numBytesInPartialGroup != 0) { int byte0 = a[inCursor++] & 0xff; result.append(intToAlpha[byte0 >> 2]); if (numBytesInPartialGroup == 1) { result.append(intToAlpha[(byte0 << 4) & 0x3f]); result.append("=="); } else { // assert numBytesInPartialGroup == 2; int byte1 = a[inCursor++] & 0xff; result.append(intToAlpha[(byte0 << 4)&0x3f | (byte1 >> 4)]); result.append(intToAlpha[(byte1 << 2)&0x3f]); result.append('='); } } // assert inCursor == a.length; // assert result.length() == resultLen; return result.toString(); } /** * This array is a lookup table that translates 6-bit positive integer * index values into their "Base64 Alphabet" equivalents as specified * in Table 1 of RFC 2045. */ private static final char intToBase64[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; /** * This array is a lookup table that translates 6-bit positive integer * index values into their "Alternate Base64 Alphabet" equivalents. * This is NOT the real Base64 Alphabet as per in Table 1 of RFC 2045. * This alternate alphabet does not use the capital letters. It is * designed for use in environments where "case folding" occurs. */ private static final char intToAltBase64[] = { '!', '"', '#', '$', '%', '&', '\'', '(', ')', ',', '-', '.', ':', ';', '<', '>', '@', '[', ']', '^', '`', '_', '{', '|', '}', '~', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '?' }; /** * Translates the specified Base64 string (as per Preferences.get(byte[])) * into a byte array. * * @throw IllegalArgumentException if <tt>s</tt> is not a valid Base64 * string. */ public static byte[] base64ToByteArray(String s) { return base64ToByteArray(s, false); } /** * Translates the specified "alternate representation" Base64 string * into a byte array. * * @throw IllegalArgumentException or ArrayOutOfBoundsException * if <tt>s</tt> is not a valid alternate representation * Base64 string. */ public static byte[] altBase64ToByteArray(String s) { return base64ToByteArray(s, true); } private static byte[] base64ToByteArray(String s, boolean alternate) { byte[] alphaToInt = (alternate ? altBase64ToInt : base64ToInt); int sLen = s.length(); int numGroups = sLen/4; if (4*numGroups != sLen) throw new IllegalArgumentException( "String length must be a multiple of four."); int missingBytesInLastGroup = 0; int numFullGroups = numGroups; if (sLen != 0) { if (s.charAt(sLen-1) == '=') { missingBytesInLastGroup++; numFullGroups--; } if (s.charAt(sLen-2) == '=') missingBytesInLastGroup++; } byte[] result = new byte[3*numGroups - missingBytesInLastGroup]; // Translate all full groups from base64 to byte array elements int inCursor = 0, outCursor = 0; for (int i=0; i<numFullGroups; i++) { int ch0 = base64toInt(s.charAt(inCursor++), alphaToInt); int ch1 = base64toInt(s.charAt(inCursor++), alphaToInt); int ch2 = base64toInt(s.charAt(inCursor++), alphaToInt); int ch3 = base64toInt(s.charAt(inCursor++), alphaToInt); result[outCursor++] = (byte) ((ch0 << 2) | (ch1 >> 4)); result[outCursor++] = (byte) ((ch1 << 4) | (ch2 >> 2)); result[outCursor++] = (byte) ((ch2 << 6) | ch3); } // Translate partial group, if present if (missingBytesInLastGroup != 0) { int ch0 = base64toInt(s.charAt(inCursor++), alphaToInt); int ch1 = base64toInt(s.charAt(inCursor++), alphaToInt); result[outCursor++] = (byte) ((ch0 << 2) | (ch1 >> 4)); if (missingBytesInLastGroup == 1) { int ch2 = base64toInt(s.charAt(inCursor++), alphaToInt); result[outCursor++] = (byte) ((ch1 << 4) | (ch2 >> 2)); } } // assert inCursor == s.length()-missingBytesInLastGroup; // assert outCursor == result.length; return result; } /** * Translates the specified character, which is assumed to be in the * "Base 64 Alphabet" into its equivalent 6-bit positive integer. * * @throw IllegalArgumentException or ArrayOutOfBoundsException if * c is not in the Base64 Alphabet. */ private static int base64toInt(char c, byte[] alphaToInt) { int result = alphaToInt[c]; if (result < 0) throw new IllegalArgumentException("Illegal character " + c); return result; } /** * This array is a lookup table that translates unicode characters * drawn from the "Base64 Alphabet" (as specified in Table 1 of RFC 2045) * into their 6-bit positive integer equivalents. Characters that * are not in the Base64 alphabet but fall within the bounds of the * array are translated to -1. */ private static final byte base64ToInt[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 }; /** * This array is the analogue of base64ToInt, but for the nonstandard * variant that avoids the use of uppercase alphabetic characters. */ private static final byte altBase64ToInt[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, -1, 62, 9, 10, 11, -1 , 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 12, 13, 14, -1, 15, 63, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, -1, 18, 19, 21, 20, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 22, 23, 24, 25 }; }
9,196
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
IClientAreaProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/util/IClientAreaProvider.java
package net.sourceforge.nattable.util; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.graphics.Rectangle; /** * Specifies the rectangular area available to an {@link ILayer}<br/> * Note: All layers get the client area from {@link NatTable} which implements this interface. * * @see ILayer#getClientAreaProvider() */ public interface IClientAreaProvider { IClientAreaProvider DEFAULT = new IClientAreaProvider() { public Rectangle getClientArea() { return new Rectangle(0, 0, 0, 0); } }; public Rectangle getClientArea(); }
632
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ConflationQueue.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/util/ConflationQueue.java
package net.sourceforge.nattable.util; public class ConflationQueue extends UpdateQueue { private static ConflationQueue queue = null; public ConflationQueue() { sleep = 300; } public static ConflationQueue getInstance() { if (queue == null) { queue = new ConflationQueue(); } return queue; } }
332
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
UpdateQueue.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/util/UpdateQueue.java
package net.sourceforge.nattable.util; import java.util.HashMap; import java.util.Map; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * GUI Update Event Queue */ public class UpdateQueue { private static final Log log = LogFactory.getLog(UpdateQueue.class); private ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); private Map<String, Runnable> runnableMap = new HashMap<String, Runnable>(); private Thread thread = null; private boolean stop = false; protected long sleep = 100; private static UpdateQueue queue = null; protected UpdateQueue() { // no-op } public static UpdateQueue getInstance() { if (queue == null) { queue = new UpdateQueue(); } return queue; } private Runnable runnable = new Runnable() { public void run() { try { while (!stop) { // Block thread and make sure that we are doing the // latest orders only lock.writeLock().lock(); Runnable[] runnables = runnableMap.values().toArray( new Runnable[runnableMap.size()]); runnableMap.clear(); lock.writeLock().unlock(); int len = runnables != null ? runnables.length : 0; for (int i = 0; i < len; i++) { try { runnables[i].run(); } catch (Exception e) { log.error(e); } } if (len > 0) { // Allow sleep try { Thread.sleep(sleep); } catch (Exception e) { log.error(e); } } else { // Sleep when nothing to do synchronized (thread) { try { thread.wait(); } catch (Exception e) { log.error(e); } } } } } catch (Exception e) { log.error(e); } } }; /** * Add a new runnable to a map along with a unique id<br> * The last update runnable of an id will be executed only. * * @param id * @param runnable */ public void addRunnable(String id, Runnable runnable) { try { // Block thread, ensure no one is going to update the vector lock.writeLock().lock(); try { runnableMap.put(id, runnable); } finally { lock.writeLock().unlock(); } runInThread(); } catch (Exception e) { log.error(e); } } // public void addRunnable(Runnable runnable) { // // Block thread, ensure no one is going to update the vector // lock.writeLock().lock(); // runnableList.add(runnable); // lock.writeLock().unlock(); // runInThread(); // } private void runInThread() { try { if (thread == null) { thread = new Thread(runnable, "GUI Display Delay Queue " + System.nanoTime()); thread.setDaemon(true); thread.start(); } else { synchronized (thread) { thread.notify(); } } } catch (Exception e) { log.error(e); } } public void stopThread() { try { if (thread != null) { stop = true; synchronized (thread) { thread.notify(); } } } catch (Exception e) { log.error(e); } } }
3,178
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultSummaryRowConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/summaryrow/DefaultSummaryRowConfiguration.java
package net.sourceforge.nattable.summaryrow; import net.sourceforge.nattable.config.AbstractRegistryConfiguration; import net.sourceforge.nattable.config.CellConfigAttributes; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.style.BorderStyle; import net.sourceforge.nattable.style.CellStyleAttributes; import net.sourceforge.nattable.style.DisplayMode; 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; public class DefaultSummaryRowConfiguration extends AbstractRegistryConfiguration { public BorderStyle summaryRowBorderStyle = new BorderStyle(0, GUIHelper.COLOR_BLACK, LineStyleEnum.DOTTED); public Color summaryRowFgColor = GUIHelper.COLOR_BLACK; public Color summaryRowBgColor = GUIHelper.COLOR_WHITE; public Font summaryRowFont = GUIHelper.getFont(new FontData("Verdana", 8, SWT.BOLD)); public void configureRegistry(IConfigRegistry configRegistry) { addSummaryRowStyleConfig(configRegistry); addSummaryProviderConfig(configRegistry); } protected void addSummaryRowStyleConfig(IConfigRegistry configRegistry) { Style cellStyle = new Style(); cellStyle.setAttributeValue(CellStyleAttributes.FONT, summaryRowFont); cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, summaryRowBgColor); cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, summaryRowFgColor); cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, summaryRowBorderStyle); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL); } protected void addSummaryProviderConfig(IConfigRegistry configRegistry) { configRegistry.registerConfigAttribute(SummaryRowConfigAttributes.SUMMARY_PROVIDER, ISummaryProvider.DEFAULT, DisplayMode.NORMAL, SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL); } }
2,164
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SummaryRowConfigAttributes.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/summaryrow/SummaryRowConfigAttributes.java
package net.sourceforge.nattable.summaryrow; import net.sourceforge.nattable.style.ConfigAttribute; public class SummaryRowConfigAttributes { public static final ConfigAttribute<ISummaryProvider> SUMMARY_PROVIDER = new ConfigAttribute<ISummaryProvider>(); }
272
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ISummaryProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/summaryrow/ISummaryProvider.java
package net.sourceforge.nattable.summaryrow; /** * Summarizes the values in a column.<br/> * Used by the {@link SummaryRowLayer} to calculate summary values. */ public interface ISummaryProvider { public static final Object DEFAULT_SUMMARY_VALUE = "..."; /** * @param columnIndex * for which the summary is required * @return the summary value for the column */ public Object summarize(int columnIndex); /** * Register this instance to indicate that a summary is not required.<br/> * Doing so avoids calls to the {@link ISummaryProvider} and is a performance tweak. */ public static final ISummaryProvider NONE = new ISummaryProvider() { public Object summarize(int columnIndex) { return null; } }; public static final ISummaryProvider DEFAULT = new ISummaryProvider() { public Object summarize(int columnIndex) { return DEFAULT_SUMMARY_VALUE; } }; }
939
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SummationSummaryProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/summaryrow/SummationSummaryProvider.java
package net.sourceforge.nattable.summaryrow; import net.sourceforge.nattable.data.IDataProvider; public class SummationSummaryProvider implements ISummaryProvider { private IDataProvider dataProvider; public SummationSummaryProvider(IDataProvider dataProvider) { this.dataProvider = dataProvider; } /** * @return sum of all the numbers in the column (as Floats). * DEFAULT_SUMMARY_VALUE for non-numeric columns */ public Object summarize(int columnIndex) { int rowCount = dataProvider.getRowCount(); float summaryValue = 0; for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { Object dataValue = dataProvider.getDataValue(columnIndex, rowIndex); if (!(dataValue instanceof Number)) { return DEFAULT_SUMMARY_VALUE; } summaryValue = summaryValue + Float.parseFloat(dataValue.toString()); } return summaryValue; } }
909
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SummaryRowLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/summaryrow/SummaryRowLayer.java
package net.sourceforge.nattable.summaryrow; import java.util.HashMap; import java.util.Map; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.layer.AbstractLayerTransform; import net.sourceforge.nattable.layer.DataLayer; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.layer.LayerUtil; import net.sourceforge.nattable.layer.cell.LayerCell; import net.sourceforge.nattable.layer.event.ILayerEvent; import net.sourceforge.nattable.layer.event.PropertyUpdateEvent; import net.sourceforge.nattable.layer.event.RowUpdateEvent; import net.sourceforge.nattable.layer.event.RowVisualChangeEvent; import net.sourceforge.nattable.resize.command.RowResizeCommand; import net.sourceforge.nattable.style.DisplayMode; import net.sourceforge.nattable.util.ArrayUtil; /** * Adds a summary row at the end. Uses {@link ISummaryProvider} to calculate the summaries for all columns. * The default summary provider is the {@link ISummaryProvider#SUM} which adds up all the cells in the * column, if they are numeric values. This layer also adds the following labels: * <ol> * <li>{@link SummaryRowLayer#DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX} + column index</li> * <li>{@link SummaryRowLayer#DEFAULT_SUMMARY_ROW_CONFIG_LABEL} to all cells in the row</li> * </ol> * * Example: column with index 1 will have the DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX + 1 label applied. * Styling and {@link ISummaryProvider} can be hooked up to these labels. * * @see DefaultSummaryRowConfiguration */ public class SummaryRowLayer extends AbstractLayerTransform implements IUniqueIndexLayer { public static final String DEFAULT_SUMMARY_ROW_CONFIG_LABEL = "SummaryRow"; public static final String DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX = "SummaryColumn_"; private final IConfigRegistry configRegistry; private int summaryRowHeight = DataLayer.DEFAULT_ROW_HEIGHT; public SummaryRowLayer(IUniqueIndexLayer underlyingDataLayer, IConfigRegistry configRegistry) { this(underlyingDataLayer, configRegistry, true); } public SummaryRowLayer(IUniqueIndexLayer underlyingDataLayer, IConfigRegistry configRegistry, boolean autoConfigure) { super(underlyingDataLayer); this.configRegistry = configRegistry; if(autoConfigure){ addConfiguration(new DefaultSummaryRowConfiguration()); } } /** * Calculates the summary for the column using the {@link ISummaryProvider} from the {@link IConfigRegistry}.<br/> * In order to prevent the table from freezing (for large data sets), the summary is calculated in a separate Thread. While * summary is being calculated {@link ISummaryProvider#DEFAULT_SUMMARY_VALUE} is returned. * * NOTE: Since this is a {@link IUniqueIndexLayer} sitting close to the {@link DataLayer}, columnPosition == columnIndex */ @Override public Object getDataValueByPosition(final int columnPosition, final int rowPosition) { if (isSummaryRowPosition(rowPosition)) { if (getSummaryFromCache(columnPosition) != null) { return getSummaryFromCache(columnPosition); } else { // Get the summary provider from the configuration registry LabelStack labelStack = getConfigLabelsByPosition(columnPosition, rowPosition); String[] configLabels = labelStack.getLabels().toArray(ArrayUtil.STRING_TYPE_ARRAY); final ISummaryProvider summaryProvider = configRegistry.getConfigAttribute( SummaryRowConfigAttributes.SUMMARY_PROVIDER, DisplayMode.NORMAL, configLabels); // If there is no Summary provider - skip processing if(summaryProvider == ISummaryProvider.NONE){ return ISummaryProvider.DEFAULT_SUMMARY_VALUE; } // Start thread to calculate summary new Thread() { @Override public void run() { Object summaryValue = calculateColumnSummary(columnPosition, summaryProvider); addToCache(columnPosition, summaryValue); fireLayerEvent(new RowUpdateEvent(SummaryRowLayer.this, rowPosition)); } }.start(); } return ISummaryProvider.DEFAULT_SUMMARY_VALUE; } return super.getDataValueByPosition(columnPosition, rowPosition); } private Object calculateColumnSummary(int columnIndex, ISummaryProvider summaryProvider) { Object summaryValue = null; if (summaryProvider != null) { summaryValue = summaryProvider.summarize(columnIndex); } return summaryValue; } /** Cache the calculated summary value, since its CPU intensive */ protected Map<Integer, Object> summaryCache = new HashMap<Integer, Object>(); public Object getSummaryFromCache(Integer columnIndex) { return summaryCache.get(columnIndex); } protected void addToCache(Integer columnIndex, Object summaryValue) { summaryCache.put(columnIndex, summaryValue); } protected void clearSummaryCache() { summaryCache.clear(); } @Override public boolean doCommand(ILayerCommand command) { if (command instanceof RowResizeCommand) { RowResizeCommand rowResizeCommand = (RowResizeCommand) command; if (isSummaryRowPosition(rowResizeCommand.getRowPosition())) { summaryRowHeight = rowResizeCommand.getNewHeight(); return true; } } return super.doCommand(command); } @SuppressWarnings("unchecked") @Override public void handleLayerEvent(ILayerEvent event) { if (event instanceof RowVisualChangeEvent || event instanceof PropertyUpdateEvent) { clearSummaryCache(); } super.handleLayerEvent(event); } @Override public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) { if (isSummaryRowPosition(rowPosition)) { return new LabelStack( DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX + columnPosition, DEFAULT_SUMMARY_ROW_CONFIG_LABEL); } return super.getConfigLabelsByPosition(columnPosition, rowPosition); } @Override public LayerCell getCellByPosition(int columnPosition, int rowPosition) { if (isSummaryRowPosition(rowPosition)) { return new LayerCell(this, columnPosition, rowPosition); } return super.getCellByPosition(columnPosition, rowPosition); } @Override public int getHeight() { return super.getHeight() + getRowHeightByPosition(getRowCount() - 1); } @Override public int getRowCount() { return super.getRowCount() + 1; } @Override public int getRowIndexByPosition(int rowPosition) { if (isSummaryRowPosition(rowPosition)) { return rowPosition; } return super.getRowIndexByPosition(rowPosition); } @Override public int getRowPositionByY(int y) { return LayerUtil.getRowPositionByY(this, y); } private boolean isSummaryRowPosition(int rowPosition) { return rowPosition == super.getRowCount(); } @Override public int getRowHeightByPosition(int rowPosition) { if (isSummaryRowPosition(rowPosition)) { return summaryRowHeight; } return super.getRowHeightByPosition(rowPosition); } @Override public int getPreferredRowCount() { return getRowCount(); } public int getRowPositionByIndex(int rowIndex) { if (rowIndex >= 0 && rowIndex < getRowCount()) { return rowIndex; } else { return -1; } } public int getColumnPositionByIndex(int columnIndex) { if (columnIndex >= 0 && columnIndex < getColumnCount()) { return columnIndex; } else { return -1; } } }
7,546
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CellValueAsStringComparator.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/search/CellValueAsStringComparator.java
package net.sourceforge.nattable.search; import java.util.Comparator; /** * The comparator will base its comparison on the display value of a cell. The * display value is assumed to be a string. * */ public class CellValueAsStringComparator<T extends Comparable<String>> implements Comparator<T> { public CellValueAsStringComparator() { } public int compare(T firstValue, T secondValue) { String firstCellValue = firstValue.toString(); String secondCellValue = secondValue.toString(); return firstCellValue.compareTo(secondCellValue); } }
581
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ISearchDirection.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/search/ISearchDirection.java
package net.sourceforge.nattable.search; public interface ISearchDirection { public static final String SEARCH_FORWARD = "forward"; public static final String SEARCH_BACKWARDS = "backwards"; }
207
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SearchAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/search/action/SearchAction.java
package net.sourceforge.nattable.search.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.search.CellValueAsStringComparator; import net.sourceforge.nattable.search.gui.SearchDialog; import net.sourceforge.nattable.search.strategy.GridSearchStrategy; import net.sourceforge.nattable.ui.action.IKeyAction; import org.eclipse.swt.events.KeyEvent; public class SearchAction implements IKeyAction { private SearchDialog searchDialog; public void run(NatTable natTable, KeyEvent event) { if (searchDialog == null) { searchDialog = SearchDialog.createDialog(natTable.getShell(), natTable); } GridSearchStrategy searchStrategy = new GridSearchStrategy(natTable.getConfigRegistry(), true); searchDialog.setSearchStrategy(searchStrategy, new CellValueAsStringComparator<String>()); searchDialog.open(); } }
876
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultSearchBindings.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/search/config/DefaultSearchBindings.java
package net.sourceforge.nattable.search.config; import net.sourceforge.nattable.config.AbstractUiBindingConfiguration; import net.sourceforge.nattable.search.action.SearchAction; import net.sourceforge.nattable.ui.binding.UiBindingRegistry; import net.sourceforge.nattable.ui.matcher.KeyEventMatcher; import org.eclipse.swt.SWT; public class DefaultSearchBindings extends AbstractUiBindingConfiguration { public void configureUiBindings(UiBindingRegistry uiBindingRegistry) { uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CTRL, 'f'), new SearchAction()); } }
597
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SearchDialog.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/search/gui/SearchDialog.java
package net.sourceforge.nattable.search.gui; import java.util.Comparator; import net.sourceforge.nattable.coordinate.PositionCoordinate; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.ILayerListener; import net.sourceforge.nattable.layer.event.ILayerEvent; import net.sourceforge.nattable.search.ISearchDirection; import net.sourceforge.nattable.search.command.SearchCommand; import net.sourceforge.nattable.search.event.SearchEvent; import net.sourceforge.nattable.search.strategy.ISearchStrategy; 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.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class SearchDialog extends Dialog { private Text findText; private Button findButton; private Button caseSensitiveButton; private Label statusLabel; private Button wrapSearchButton; private Button forwardButton; private final ILayer layer; private ISearchStrategy searchStrategy; private Comparator<?> comparator; private SearchDialog(Shell shell, ILayer layer) { super(shell); this.layer = layer; setShellStyle(SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE); setBlockOnOpen(false); } public static SearchDialog createDialog(Shell shell, ILayer layer) { return new SearchDialog(shell, layer); } public void setSearchStrategy(ISearchStrategy searchStrategy, Comparator<?> comparator) { this.searchStrategy = searchStrategy; this.comparator = comparator; } @Override public void create() { super.create(); getShell().setText("Find"); } @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().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(createInputPanel(composite)); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(createOptionsPanel(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); statusLabel = new Label(panel, SWT.LEFT); statusLabel.setForeground(statusLabel.getDisplay().getSystemColor(SWT.COLOR_RED)); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(statusLabel); findButton = createButton(panel, IDialogConstants.CLIENT_ID, "&Find", false); GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.BOTTOM).grab(false, false).hint(52, SWT.DEFAULT).applyTo(findButton); findButton.setEnabled(false); getShell().setDefaultButton(findButton); findButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doFind(); } }); 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 findLabel = new Label(row, SWT.NONE); findLabel.setText("F&ind:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(findLabel); findText = new Text(row, SWT.SINGLE | SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(findText); findText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { findButton.setEnabled(findText.getText().length() > 0); } }); findText.addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent e) { if (findButton.isEnabled()) { doFind(); } } }); return row; } private Composite createOptionsPanel(final Composite composite) { final Composite row = new Composite(composite, SWT.NONE); row.setLayout(new GridLayout(2,true)); final Group directionGroup = new Group(row, SWT.SHADOW_ETCHED_IN); GridDataFactory.fillDefaults().grab(true, true).applyTo(directionGroup); directionGroup.setText("Direction"); final RowLayout rowLayout = new RowLayout(SWT.VERTICAL); rowLayout.marginHeight = rowLayout.marginWidth = 3; directionGroup.setLayout(rowLayout); forwardButton = new Button(directionGroup, SWT.RADIO); forwardButton.setText("F&orward"); forwardButton.setSelection(true); final Button backwardButton = new Button(directionGroup, SWT.RADIO); backwardButton.setText("&Backward"); final Group optionsGroup = new Group(row, SWT.SHADOW_ETCHED_IN); GridDataFactory.fillDefaults().grab(true, true).applyTo(optionsGroup); optionsGroup.setText("Options"); optionsGroup.setLayout(rowLayout); caseSensitiveButton = new Button(optionsGroup, SWT.CHECK); caseSensitiveButton.setText("&Case Sensitive"); wrapSearchButton = new Button(optionsGroup, SWT.CHECK); wrapSearchButton.setText("&Wrap Search"); wrapSearchButton.setSelection(true); return row; } private void doFind() { BusyIndicator.showWhile(super.getShell().getDisplay(), new Runnable() { private PositionCoordinate searchResultCoordinate; public void run() { searchResultCoordinate = null; statusLabel.setText(""); String searchDirection = forwardButton.getSelection() ? ISearchDirection.SEARCH_FORWARD : ISearchDirection.SEARCH_BACKWARDS; final SearchCommand command = new SearchCommand(findText.getText(), layer, searchStrategy, searchDirection, wrapSearchButton.getSelection(), caseSensitiveButton.getSelection(), comparator); final ILayerListener searchEventListener = initSearchEventListener(); command.setSearchEventListener(searchEventListener); try { // Fire command layer.doCommand(command); if (searchResultCoordinate == null || (searchResultCoordinate.columnPosition < 0 && searchResultCoordinate.rowPosition < 0)) { statusLabel.setText("Text not found"); } } finally { command.getContext().removeLayerListener(searchEventListener); } } private ILayerListener initSearchEventListener() { // Register event listener final ILayerListener searchEventListener = new ILayerListener() { public void handleLayerEvent(ILayerEvent event) { if (event instanceof SearchEvent) { SearchEvent searchEvent = (SearchEvent) event; searchResultCoordinate = searchEvent.getCellCoordinate(); } } }; return searchEventListener; } }); } }
7,774
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SearchGridCellsCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/search/command/SearchGridCellsCommandHandler.java
package net.sourceforge.nattable.search.command; import net.sourceforge.nattable.command.ILayerCommandHandler; import net.sourceforge.nattable.coordinate.PositionCoordinate; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.search.event.SearchEvent; import net.sourceforge.nattable.search.strategy.AbstractSearchStrategy; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.selection.command.SelectCellCommand; public class SearchGridCellsCommandHandler implements ILayerCommandHandler<SearchCommand> { private final SelectionLayer selectionLayer; private PositionCoordinate searchResultCellCoordinate; public SearchGridCellsCommandHandler(SelectionLayer selectionLayer) { this.selectionLayer = selectionLayer; } public Class<SearchCommand> getCommandClass() { return SearchCommand.class; }; public boolean doCommand(ILayer targetLayer, SearchCommand searchCommand) { searchCommand.convertToTargetLayer(targetLayer); AbstractSearchStrategy searchStrategy = (AbstractSearchStrategy) searchCommand.getSearchStrategy(); if (searchCommand.getSearchEventListener() != null) { selectionLayer.addLayerListener(searchCommand.getSearchEventListener()); } PositionCoordinate anchor = selectionLayer.getSelectionAnchor(); if (anchor.columnPosition < 0 || anchor.rowPosition < 0) { anchor = new PositionCoordinate(selectionLayer, 0, 0); } searchStrategy.setContextLayer(targetLayer); Object dataValueToFind = null; if ((dataValueToFind = searchCommand.getSearchText()) == null) { dataValueToFind = selectionLayer.getDataValueByPosition(anchor.columnPosition, anchor.rowPosition); } searchStrategy.setCaseSensitive(searchCommand.isCaseSensitive()); searchStrategy.setWrapSearch(searchCommand.isWrapSearch()); searchStrategy.setSearchDirection(searchCommand.getSearchDirection()); searchStrategy.setComparator(searchCommand.getComparator()); searchResultCellCoordinate = searchStrategy.executeSearch(dataValueToFind); selectionLayer.fireLayerEvent(new SearchEvent(searchResultCellCoordinate)); if (searchResultCellCoordinate != null) { final SelectCellCommand command = new SelectCellCommand(selectionLayer, searchResultCellCoordinate.columnPosition, searchResultCellCoordinate.rowPosition, false, false); command.setForcingEntireCellIntoViewport(true); selectionLayer.doCommand(command); } return true; } public PositionCoordinate getSearchResultCellCoordinate() { return searchResultCellCoordinate; } }
2,612
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SearchCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/search/command/SearchCommand.java
package net.sourceforge.nattable.search.command; import java.util.Comparator; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.ILayerListener; import net.sourceforge.nattable.search.strategy.ISearchStrategy; public class SearchCommand implements ILayerCommand { private ILayer context; private final ISearchStrategy searchStrategy; private final String searchText; private final boolean isWrapSearch; private final boolean isCaseSensitive; private final String searchDirection; private final Comparator<?> comparator; private ILayerListener searchEventListener; public SearchCommand(ILayer layer, ISearchStrategy searchStrategy, String searchDirection, boolean isWrapSearch, boolean isCaseSensitive, Comparator<?> comparator) { this(null, layer, searchStrategy, searchDirection, isWrapSearch, isCaseSensitive, comparator); } public SearchCommand(String searchText, ILayer layer, ISearchStrategy searchStrategy, String searchDirection, boolean isWrapSearch, boolean isCaseSensitive, Comparator<?> comparator) { this.context = layer; this.searchStrategy = searchStrategy; this.searchText = searchText; this.isWrapSearch = isWrapSearch; this.isCaseSensitive = isCaseSensitive; this.searchDirection = searchDirection; this.comparator = comparator; } protected SearchCommand(SearchCommand command) { this.context = command.context; this.searchStrategy = command.searchStrategy; this.searchText = command.searchText; this.isWrapSearch = command.isWrapSearch; this.isCaseSensitive = command.isCaseSensitive; this.searchDirection = command.searchDirection; this.comparator = command.comparator; this.searchEventListener = command.searchEventListener; } public ILayer getContext() { return context; } public ISearchStrategy getSearchStrategy() { return searchStrategy; } public String getSearchText() { return searchText; } public String getSearchDirection() { return searchDirection; } public boolean isWrapSearch() { return isWrapSearch; } public boolean isCaseSensitive() { return isCaseSensitive; } public ILayerListener getSearchEventListener() { return searchEventListener; } public void setSearchEventListener(ILayerListener listener) { this.searchEventListener = listener; } public Comparator<?> getComparator() { return comparator; } public boolean convertToTargetLayer(ILayer targetLayer) { context = targetLayer; return true; } public SearchCommand cloneCommand() { return new SearchCommand(this); } }
2,712
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ISearchStrategy.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/search/strategy/ISearchStrategy.java
package net.sourceforge.nattable.search.strategy; import net.sourceforge.nattable.coordinate.PositionCoordinate; public interface ISearchStrategy { public PositionCoordinate executeSearch(Object valueToMatch); }
227
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowSearchStrategy.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/search/strategy/RowSearchStrategy.java
package net.sourceforge.nattable.search.strategy; import java.util.ArrayList; import java.util.Collections; import java.util.List; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.coordinate.PositionCoordinate; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.search.ISearchDirection; public class RowSearchStrategy extends AbstractSearchStrategy { private final IConfigRegistry configRegistry; private final int[] rowPositions; private final String searchDirection; public RowSearchStrategy(int[] rowPositions, IConfigRegistry configRegistry) { this(rowPositions, configRegistry, ISearchDirection.SEARCH_FORWARD); } public RowSearchStrategy(int[] rowPositions, IConfigRegistry configRegistry, String searchDirection) { this.rowPositions = rowPositions; this.configRegistry = configRegistry; this.searchDirection = searchDirection; } public PositionCoordinate executeSearch(Object valueToMatch) { return CellDisplayValueSearchUtil.findCell(getContextLayer(), configRegistry, getRowCellsToSearch(getContextLayer()), valueToMatch, getComparator(), isCaseSensitive()); } protected PositionCoordinate[] getRowCellsToSearch(ILayer contextLayer) { List<PositionCoordinate> cellsToSearch = new ArrayList<PositionCoordinate>(); for (int rowPosition : rowPositions) { cellsToSearch.addAll(CellDisplayValueSearchUtil.getCellCoordinates(getContextLayer(), 0, rowPosition, contextLayer.getColumnCount(), 1)); } if (searchDirection.equals(ISearchDirection.SEARCH_BACKWARDS)) { Collections.reverse(cellsToSearch); } return cellsToSearch.toArray(new PositionCoordinate[0]); } }
1,720
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z