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
SortColumnCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/sort/command/SortColumnCommand.java
package net.sourceforge.nattable.sort.command; import net.sourceforge.nattable.command.AbstractColumnCommand; import net.sourceforge.nattable.layer.ILayer; public class SortColumnCommand extends AbstractColumnCommand { private boolean accumulate; public SortColumnCommand(ILayer layer, int columnPosition, boolean accumulate) { super(layer, columnPosition); this.accumulate = accumulate; } protected SortColumnCommand(SortColumnCommand command) { super(command); this.accumulate = command.accumulate; } public boolean isAccumulate() { return accumulate; } public SortColumnCommand cloneCommand() { return new SortColumnCommand(this); } }
700
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SortableHeaderTextPainter.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/sort/painter/SortableHeaderTextPainter.java
package net.sourceforge.nattable.sort.painter; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.layer.cell.LayerCell; import net.sourceforge.nattable.painter.cell.CellPainterWrapper; import net.sourceforge.nattable.painter.cell.ICellPainter; import net.sourceforge.nattable.painter.cell.ImagePainter; import net.sourceforge.nattable.painter.cell.TextPainter; import net.sourceforge.nattable.painter.cell.decorator.CellPainterDecorator; import net.sourceforge.nattable.sort.config.DefaultSortConfiguration; import net.sourceforge.nattable.ui.util.CellEdgeEnum; import net.sourceforge.nattable.util.GUIHelper; import org.apache.commons.lang.StringUtils; import org.eclipse.swt.graphics.Image; public class SortableHeaderTextPainter extends CellPainterWrapper { /** * Default setup, uses the {@link TextPainter} as its companion painter */ public SortableHeaderTextPainter() { setWrappedPainter(new CellPainterDecorator(new TextPainter(), CellEdgeEnum.RIGHT, new SortIconPainter(true))); } public SortableHeaderTextPainter(ICellPainter integriorPainter, boolean paintBg) { setWrappedPainter(new CellPainterDecorator(integriorPainter, CellEdgeEnum.RIGHT, new SortIconPainter(paintBg))); } /** * Paints the triangular sort icon images. */ protected static class SortIconPainter extends ImagePainter { public SortIconPainter(boolean paintBg) { super(null, paintBg); } @Override protected Image getImage(LayerCell cell, IConfigRegistry configRegistry) { Image icon = null; if (isSortedAscending(cell)) { icon = selectUpImage(getSortSequence(cell)); } else if (isSortedDescending(cell)) { icon = selectDownImage(getSortSequence(cell)); } return icon; } private boolean isSortedAscending(LayerCell cell) { return cell.getConfigLabels().hasLabel(DefaultSortConfiguration.SORT_UP_CONFIG_TYPE); } private boolean isSortedDescending(LayerCell cell) { return cell.getConfigLabels().hasLabel(DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE); } private int getSortSequence(LayerCell cell) { int sortSeq = 0; for (String configLabel : cell.getConfigLabels().getLabels()) { if (configLabel.startsWith(DefaultSortConfiguration.SORT_SEQ_CONFIG_TYPE)) { String[] tokens = StringUtils.split(configLabel, "_"); sortSeq = Integer.valueOf(tokens[tokens.length - 1]).intValue(); } } return sortSeq; } private Image selectUpImage(int sortSequence) { switch (sortSequence) { case 0: return GUIHelper.getImage("up_0"); case 1: return GUIHelper.getImage("up_1"); case 2: return GUIHelper.getImage("up_2"); default: return GUIHelper.getImage("up_2"); } } private Image selectDownImage(int sortSequence) { switch (sortSequence) { case 0: return GUIHelper.getImage("down_0"); case 1: return GUIHelper.getImage("down_1"); case 2: return GUIHelper.getImage("down_2"); default: return GUIHelper.getImage("down_2"); } } } }
3,119
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SortColumnEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/sort/event/SortColumnEvent.java
package net.sourceforge.nattable.sort.event; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.event.ColumnVisualChangeEvent; public class SortColumnEvent extends ColumnVisualChangeEvent { public SortColumnEvent(ILayer layer, int columnPosition) { super(layer, new Range(columnPosition, columnPosition + 1)); } protected SortColumnEvent(SortColumnEvent event) { super(event); } public SortColumnEvent cloneEvent() { return new SortColumnEvent(this); } }
558
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnHeaderClickEventMatcher.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/sort/event/ColumnHeaderClickEventMatcher.java
package net.sourceforge.nattable.sort.event; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.grid.GridRegion; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.ui.matcher.MouseEventMatcher; import net.sourceforge.nattable.ui.util.CellEdgeDetectUtil; import net.sourceforge.nattable.ui.util.CellEdgeEnum; import net.sourceforge.nattable.util.GUIHelper; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Point; /** * Matches a click on the column header, except if the click is on the column edge.<br/> */ public class ColumnHeaderClickEventMatcher extends MouseEventMatcher { public ColumnHeaderClickEventMatcher(int stateMask, int button) { super(stateMask, GridRegion.COLUMN_HEADER, button); } @Override public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) { return super.matches(natTable, event, regionLabels) && isNearTheHeaderEdge(natTable, event); } private boolean isNearTheHeaderEdge(ILayer natLayer, MouseEvent event) { CellEdgeEnum cellEdge = CellEdgeDetectUtil.getHorizontalCellEdge( natLayer, new Point(event.x, event.y), GUIHelper.DEFAULT_RESIZE_HANDLE_SIZE); return cellEdge == CellEdgeEnum.NONE; } }
1,518
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
GridLayerPrinter.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/print/GridLayerPrinter.java
package net.sourceforge.nattable.print; import java.text.SimpleDateFormat; import java.util.Date; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.grid.layer.GridLayer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.print.command.PrintEntireGridCommand; import net.sourceforge.nattable.print.command.TurnViewportOnCommand; import net.sourceforge.nattable.util.IClientAreaProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Transform; import org.eclipse.swt.printing.PrintDialog; import org.eclipse.swt.printing.Printer; import org.eclipse.swt.printing.PrinterData; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class GridLayerPrinter { private final IConfigRegistry configRegistry; private final ILayer gridLayer; private final IClientAreaProvider originalClientAreaProvider; public static final int FOOTER_HEIGHT_IN_PRINTER_DPI = 300; final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm a"); private final String footerDate; public GridLayerPrinter(GridLayer gridLayer, IConfigRegistry configRegistry) { this.gridLayer = gridLayer; this.configRegistry = configRegistry; this.originalClientAreaProvider = gridLayer.getClientAreaProvider(); this.footerDate = dateFormat.format(new Date()); } /** * Amount to scale the screen resolution by, to match the printer the * resolution. */ private Point computeScaleFactor(Printer printer) { Point screenDPI = Display.getDefault().getDPI(); Point printerDPI = printer.getDPI(); int scaleFactorX = printerDPI.x / screenDPI.x; int scaleFactorY = printerDPI.y / screenDPI.y; return new Point(scaleFactorX, scaleFactorY); } /** * Size of the grid to fit all the contents. */ private Rectangle getTotalGridArea() { return new Rectangle(0, 0, gridLayer.getWidth(), gridLayer.getHeight()); } /** * Calculate number of horizontal and vertical pages needed * to print the entire grid. */ private Point getPageCount(Printer printer){ Rectangle gridArea = getTotalGridArea(); Rectangle printArea = computePrintArea(printer); Point scaleFactor = computeScaleFactor(printer); int numOfHorizontalPages = gridArea.width / (printArea.width / scaleFactor.x); int numOfVerticalPages = gridArea.height / (printArea.height / scaleFactor.y); // Adjusting for 0 index return new Point(numOfHorizontalPages + 1, numOfVerticalPages + 1); } public void print(final Shell shell) { final Printer printer = setupPrinter(shell); if (printer == null) { return; } setGridLayerSize(printer.getPrinterData()); Display.getDefault().asyncExec(new Runnable() { public void run() { if (printer.startJob("NatTable")) { final Rectangle printerClientArea = computePrintArea(printer); final Point scaleFactor = computeScaleFactor(printer); final Point pageCount = getPageCount(printer); GC gc = new GC(printer); // Print pages Left to Right and then Top to Down int currentPage = 1; for (int verticalPageNumber = 0; verticalPageNumber < pageCount.y; verticalPageNumber++) { for (int horizontalPageNumber = 0; horizontalPageNumber < pageCount.x; horizontalPageNumber++) { // Calculate bounds for the next page Rectangle printBounds = new Rectangle((printerClientArea.width / scaleFactor.x) * horizontalPageNumber, ((printerClientArea.height - FOOTER_HEIGHT_IN_PRINTER_DPI) / scaleFactor.y) * verticalPageNumber, printerClientArea.width / scaleFactor.x, (printerClientArea.height - FOOTER_HEIGHT_IN_PRINTER_DPI) / scaleFactor.y); if (shouldPrint(printer.getPrinterData(), currentPage)) { printer.startPage(); Transform printerTransform = new Transform(printer); // Adjust for DPI difference between display and printer printerTransform.scale(scaleFactor.x, scaleFactor.y); // Adjust for margins printerTransform.translate(printerClientArea.x / scaleFactor.x, printerClientArea.y / scaleFactor.y); // Grid will nor automatically print the pages at the left margin. // Example: page 1 will print at x = 0, page 2 at x = 100, page 3 at x = 300 // Adjust to print from the left page margin. i.e x = 0 printerTransform.translate(-1 * printBounds.x, -1 * printBounds.y); gc.setTransform(printerTransform); printGrid(gc, printBounds); printFooter(gc, currentPage, printBounds); printer.endPage(); printerTransform.dispose(); } currentPage++; } } printer.endJob(); gc.dispose(); printer.dispose(); } restoreGridLayerState(); } private void printGrid(GC gc, Rectangle printBounds) { gridLayer.getLayerPainter().paintLayer(gridLayer, gc, 0, 0, printBounds, configRegistry); } private void printFooter(GC gc, int totalPageCount, Rectangle printBounds) { gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); gc.drawLine(printBounds.x, printBounds.y + printBounds.height+10, printBounds.x + printBounds.width, printBounds.y + printBounds.height+10); gc.drawText("Page " + totalPageCount, printBounds.x, printBounds.y + printBounds.height + 15); // Approximate width of the date string: 140 gc.drawText(footerDate, printBounds.x + printBounds.width - 140, printBounds.y + printBounds.height + 15); } }); } /** * Checks if a given page number should be printed. * Page is allowed to print if: * User asked to print all pages or Page in a specified range */ private boolean shouldPrint(PrinterData printerData, int totalPageCount) { if(printerData.scope == PrinterData.PAGE_RANGE){ return totalPageCount >= printerData.startPage && totalPageCount <= printerData.endPage; } return true; } private Printer setupPrinter(final Shell shell) { Printer defaultPrinter = new Printer(); Point pageCount = getPageCount(defaultPrinter); defaultPrinter.dispose(); final PrintDialog printDialog = new PrintDialog(shell); printDialog.setStartPage(1); printDialog.setEndPage(pageCount.x * pageCount.y); printDialog.setScope(PrinterData.ALL_PAGES); PrinterData printerData = printDialog.open(); if(printerData == null){ return null; } return new Printer(printerData); } /** * Expand the client area of the grid such that * all the contents fit in the viewport. This ensures that when the grid prints * we print the <i>entire</i> table. * @param printer */ private void setGridLayerSize(PrinterData printerData) { if (printerData.scope == PrinterData.SELECTION) { gridLayer.setClientAreaProvider(originalClientAreaProvider); return; } final Rectangle fullGridSize = getTotalGridArea(); gridLayer.setClientAreaProvider(new IClientAreaProvider(){ public Rectangle getClientArea() { return fullGridSize; } }); gridLayer.doCommand(new PrintEntireGridCommand()); } private void restoreGridLayerState() { gridLayer.setClientAreaProvider(originalClientAreaProvider); gridLayer.doCommand(new TurnViewportOnCommand()); } /** * Computes the print area, including margins */ private static Rectangle computePrintArea(Printer printer) { // Get the printable area Rectangle rect = printer.getClientArea(); // Compute the trim Rectangle trim = printer.computeTrim(0, 0, 0, 0); // Get the printer's DPI Point dpi = printer.getDPI(); dpi.x = dpi.x / 2; dpi.y = dpi.y / 2; // Calculate the printable area, using 1 inch margins int left = trim.x + dpi.x; if (left < rect.x) left = rect.x; int right = (rect.width + trim.x + trim.width) - dpi.x; if (right > rect.width) right = rect.width; int top = trim.y + dpi.y; if (top < rect.y) top = rect.y; int bottom = (rect.height + trim.y + trim.height) - dpi.y; if (bottom > rect.height) bottom = rect.height; return new Rectangle(left, top, right - left, bottom - top); } }
8,751
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
PrintAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/print/action/PrintAction.java
package net.sourceforge.nattable.print.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.print.command.PrintCommand; import net.sourceforge.nattable.print.command.TurnViewportOffCommand; import net.sourceforge.nattable.print.command.TurnViewportOnCommand; import net.sourceforge.nattable.ui.action.IKeyAction; import org.eclipse.swt.events.KeyEvent; public class PrintAction implements IKeyAction { public void run(NatTable natTable, KeyEvent event) { natTable.doCommand(new TurnViewportOffCommand()); natTable.doCommand(new PrintCommand(natTable.getConfigRegistry(), natTable.getShell())); natTable.doCommand(new TurnViewportOnCommand()); } }
716
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultPrintBindings.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/print/config/DefaultPrintBindings.java
package net.sourceforge.nattable.print.config; import net.sourceforge.nattable.config.AbstractUiBindingConfiguration; import net.sourceforge.nattable.print.action.PrintAction; import net.sourceforge.nattable.ui.binding.UiBindingRegistry; import net.sourceforge.nattable.ui.matcher.KeyEventMatcher; import org.eclipse.swt.SWT; public class DefaultPrintBindings extends AbstractUiBindingConfiguration { public void configureUiBindings(UiBindingRegistry uiBindingRegistry) { uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.CTRL, 'p'), new PrintAction()); } }
594
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
PrintEntireGridCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/print/command/PrintEntireGridCommand.java
package net.sourceforge.nattable.print.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; /** * The viewport picks this up and moved to 0,0 so that * the entire grid can be printed. */ public class PrintEntireGridCommand extends AbstractContextFreeCommand { }
303
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
TurnViewportOffCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/print/command/TurnViewportOffCommand.java
package net.sourceforge.nattable.print.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; /** * This command is handled by the viewport. It essentially causes the viewport * to turn off by relaying all dimension requests to the underlying scrollable * layer. * * This is useful when operations have to be performed on the entire grid * including the areas outside the viewport. Example printing, excel export, * auto resize all columns etc. */ public class TurnViewportOffCommand extends AbstractContextFreeCommand { }
571
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
PrintCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/print/command/PrintCommand.java
package net.sourceforge.nattable.print.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; import net.sourceforge.nattable.config.IConfigRegistry; import org.eclipse.swt.widgets.Shell; public class PrintCommand extends AbstractContextFreeCommand { private final IConfigRegistry configRegistry; private Shell shell; public PrintCommand(IConfigRegistry configRegistry, Shell shell) { this.configRegistry = configRegistry; this.shell = shell; } public IConfigRegistry getConfigRegistry() { return configRegistry; } public Shell getShell() { return shell; } }
630
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
TurnViewportOnCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/print/command/TurnViewportOnCommand.java
package net.sourceforge.nattable.print.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; /** * Restores the viewport to its normal operation. * * @see TurnViewportOffCommand */ public class TurnViewportOnCommand extends AbstractContextFreeCommand { }
296
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
PrintCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/print/command/PrintCommandHandler.java
package net.sourceforge.nattable.print.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.grid.layer.GridLayer; import net.sourceforge.nattable.print.GridLayerPrinter; public class PrintCommandHandler extends AbstractLayerCommandHandler<PrintCommand> { private final GridLayer gridLayer; public PrintCommandHandler(GridLayer defaultGridLayer) { this.gridLayer = defaultGridLayer; } public boolean doCommand(PrintCommand command) { new GridLayerPrinter(gridLayer, command.getConfigRegistry()).print(command.getShell()); return true; } public Class<PrintCommand> getCommandClass() { return PrintCommand.class; } }
717
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ChooseColumnsFromCategoriesCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/columnCategories/ChooseColumnsFromCategoriesCommand.java
package net.sourceforge.nattable.columnCategories; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.command.AbstractContextFreeCommand; import org.eclipse.swt.widgets.Shell; public class ChooseColumnsFromCategoriesCommand extends AbstractContextFreeCommand { private final NatTable natTable; public ChooseColumnsFromCategoriesCommand(NatTable natTable) { this.natTable = natTable; } public NatTable getNatTable() { return natTable; } public Shell getShell() { return natTable.getShell(); } }
562
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ChooseColumnsFromCategoriesCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/columnCategories/ChooseColumnsFromCategoriesCommandHandler.java
package net.sourceforge.nattable.columnCategories; import static net.sourceforge.nattable.columnChooser.ColumnChooserUtils.getHiddenColumnEntries; import static net.sourceforge.nattable.columnChooser.ColumnChooserUtils.getVisibleColumnsEntries; import static net.sourceforge.nattable.util.ObjectUtils.isNotNull; import java.util.ArrayList; import java.util.List; import net.sourceforge.nattable.columnCategories.gui.ColumnCategoriesDialog; import net.sourceforge.nattable.columnChooser.ColumnChooserUtils; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.coordinate.PositionUtil; import net.sourceforge.nattable.grid.layer.ColumnHeaderLayer; import net.sourceforge.nattable.hideshow.ColumnHideShowLayer; import net.sourceforge.nattable.layer.DataLayer; import net.sourceforge.nattable.reorder.command.ColumnReorderCommand; import net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.util.ObjectUtils; public class ChooseColumnsFromCategoriesCommandHandler extends AbstractLayerCommandHandler<ChooseColumnsFromCategoriesCommand> implements IColumnCategoriesDialogListener { private final ColumnHideShowLayer columnHideShowLayer; private final ColumnHeaderLayer columnHeaderLayer; private final DataLayer columnHeaderDataLayer; private final ColumnCategoriesModel model; private ColumnCategoriesDialog dialog; public ChooseColumnsFromCategoriesCommandHandler( ColumnHideShowLayer columnHideShowLayer, ColumnHeaderLayer columnHeaderLayer, DataLayer columnHeaderDataLayer, ColumnCategoriesModel model) { super(); this.columnHideShowLayer = columnHideShowLayer; this.columnHeaderLayer = columnHeaderLayer; this.columnHeaderDataLayer = columnHeaderDataLayer; this.model = model; } @Override protected boolean doCommand(ChooseColumnsFromCategoriesCommand command) { dialog = new ColumnCategoriesDialog( command.getShell(), model, getHiddenColumnEntries(columnHideShowLayer, columnHeaderLayer, columnHeaderDataLayer), getVisibleColumnsEntries(columnHideShowLayer, columnHeaderLayer, columnHeaderDataLayer)); dialog.addListener(this); dialog.open(); return true; } public Class<ChooseColumnsFromCategoriesCommand> getCommandClass() { return ChooseColumnsFromCategoriesCommand.class; } // Listen and respond to the dialog events public void itemsRemoved(List<Integer> removedColumnPositions) { ColumnChooserUtils.hideColumnPositions(removedColumnPositions, columnHideShowLayer); refreshDialog(); } public void itemsSelected(List<Integer> addedColumnIndexes) { ColumnChooserUtils.showColumnIndexes(addedColumnIndexes, columnHideShowLayer); refreshDialog(); } /** * Moves the columns up or down by firing commands on the dialog.<br/> * * Individual columns are moved using the {@link ColumnReorderCommand}<br/> * Contiguously selected columns are moved using the {@link MultiColumnReorderCommand}<br/> */ public void itemsMoved(MoveDirectionEnum direction, List<Integer> selectedPositions) { List<List<Integer>> fromPositions = PositionUtil.getGroupedByContiguous(selectedPositions); List<Integer> toPositions = getDestinationPositions(direction, fromPositions); for (int i = 0; i < fromPositions.size(); i++) { boolean multipleColumnsMoved = fromPositions.get(i).size() > 1; ILayerCommand command = null; if (!multipleColumnsMoved) { int fromPosition = fromPositions.get(i).get(0).intValue(); int toPosition = toPositions.get(i); command = new ColumnReorderCommand(columnHideShowLayer, fromPosition, toPosition); } else if(multipleColumnsMoved){ command = new MultiColumnReorderCommand(columnHideShowLayer, fromPositions.get(i), toPositions.get(i)); } columnHideShowLayer.doCommand(command); } refreshDialog(); } /** * Calculates the destination positions taking into account the move direction * and single/contiguous selection. * * @param selectedPositions grouped together if they are contiguous. * Example: if 2,3,4, 9, 12 are selected, they are grouped as [[2, 3, 4], 9, 12] * While moving up the destination position for [2, 3, 4] is 1 * While moving up the destination position for [2, 3, 4] is 6 */ protected List<Integer> getDestinationPositions(MoveDirectionEnum direction, List<List<Integer>> selectedPositions) { List<Integer> destinationPositions = new ArrayList<Integer>(); for (List<Integer> contiguousPositions : selectedPositions) { switch (direction) { case UP: destinationPositions.add(ObjectUtils.getFirstElement(contiguousPositions) - 1); break; case DOWN: destinationPositions.add(ObjectUtils.getLastElement(contiguousPositions) + 2); default: break; } } return destinationPositions; } private void refreshDialog() { if (isNotNull(dialog)) { dialog.refresh( ColumnChooserUtils.getHiddenColumnEntries(columnHideShowLayer, columnHeaderLayer, columnHeaderDataLayer), ColumnChooserUtils.getVisibleColumnsEntries(columnHideShowLayer, columnHeaderLayer, columnHeaderDataLayer)); } } }
5,391
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
IColumnCategoriesDialogListener.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/columnCategories/IColumnCategoriesDialogListener.java
package net.sourceforge.nattable.columnCategories; import java.util.List; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; public interface IColumnCategoriesDialogListener { void itemsSelected(List<Integer> addedColumnIndexes); void itemsRemoved(List<Integer> removedColumnPositions); void itemsMoved(MoveDirectionEnum direction, List<Integer> selectedPositions); }
418
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
Node.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/columnCategories/Node.java
package net.sourceforge.nattable.columnCategories; import java.io.Serializable; import java.util.ArrayList; import java.util.List; /** * Represents a node of the Tree class. */ public class Node implements Serializable { private static final long serialVersionUID = 7855L; public static enum Type {ROOT, COLUMN, CATEGORY, UNKNOWN}; private Type type; private String data; private List<Node> children; private Node parent; public Node(String data) { this(data, Type.UNKNOWN); } public Node(String newCategoryName, Type type) { setData(newCategoryName); setType(type); } public Node getParent() { return parent; } public void setParent(Node parent) { this.parent = parent; } public void setType(Type type) { this.type = type; } public Type getType() { return type; } /** * Return the children of Node. The Tree is represented by a single * root Node whose children are represented by a List<Node>. Each of * these Node elements in the List can have children. The getChildren() * method will return the children of a Node. * @return the children of Node */ public List<Node> getChildren() { if (this.children == null) { return new ArrayList<Node>(); } return this.children; } /** * Returns the number of immediate children of this Node. * @return the number of immediate children. */ public int getNumberOfChildren() { if (children == null) { return 0; } return children.size(); } /** * Adds a child to the list of children for this Node. The addition of * the first child will create a new List<Node>. * @param child a Node object to set. * @return Child node just added */ public Node addChild(Node child) { if (children == null) { children = new ArrayList<Node>(); } children.add(child); child.setParent(this); return child; } public Node addChildCategory(String categoryName) { return addChild(new Node(categoryName, Type.CATEGORY)); } public void addChildColumnIndexes(int... columnIndexes) { for (int columnIndex : columnIndexes) { addChild(new Node(String.valueOf(columnIndex), Type.COLUMN)); } } /** * Inserts a Node at the specified position in the child list. Will * throw an ArrayIndexOutOfBoundsException if the index does not exist. * @param index the position to insert at. * @param child the Node object to insert. * @throws IndexOutOfBoundsException if thrown. */ public void insertChildAt(int index, Node child) throws IndexOutOfBoundsException { if (index == getNumberOfChildren()) { // this is really an append addChild(child); return; } else { children.get(index); //just to throw the exception, and stop here children.add(index, child); } } /** * Remove the Node element at index index of the List<Node>. * @param index the index of the element to delete. * @throws IndexOutOfBoundsException if thrown. */ public void removeChildAt(int index) throws IndexOutOfBoundsException { children.remove(index); } public String getData() { return this.data; } public void setData(String data) { this.data = data; } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{").append(type).append(",").append(getData().toString()).append(",["); int i = 0; for (Node e : getChildren()) { if (i > 0) { sb.append(","); } sb.append(e.getData().toString()); i++; } sb.append("]").append("}"); return sb.toString(); } }
4,069
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
Tree.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/columnCategories/Tree.java
package net.sourceforge.nattable.columnCategories; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import net.sourceforge.nattable.util.ObjectUtils; /** * Represents a Tree of Objects.<br/> * The Tree is represented as a single rootElement which points to a List<Node> of children.<br/> * * Adapted from public domain code at http://sujitpal.blogspot.com/. */ public class Tree implements Serializable { private static final long serialVersionUID = 6182L; private Node rootElement; /** * Default ctor. */ public Tree() { super(); } /** * Return the root Node of the tree. * @return the root element. */ public Node getRootElement() { return this.rootElement; } /** * Set the root Element for the tree. * @param rootElement the root element to set. */ public void setRootElement(Node rootElement) { this.rootElement = rootElement; } /** * Returns the Tree as a List of Node objects. The elements of the * List are generated from a pre-order traversal of the tree. * @return a List<Node>. */ public List<Node> toList() { List<Node> list = new ArrayList<Node>(); walk(rootElement, list); return list; } /** * Returns a String representation of the Tree. The elements are generated * from a pre-order traversal of the Tree. * @return the String representation of the Tree. */ @Override public String toString() { return toList().toString(); } /** * Walks the Tree in pre-order style. This is a recursive method, and is * called from the toList() method with the root element as the first * argument. It appends to the second argument, which is passed by reference * as it recurses down the tree. * @param element the starting element. * @param list the output of the walk. */ private void walk(Node element, List<Node> list) { list.add(element); for (Node data : element.getChildren()) { walk(data, list); } } /** * Find the Node in the tree containing the supplied data. * Stops searching at the first match. * @return matching Node if found, NULL otherwise */ public Node find(String nodeData) { return find(getRootElement(), nodeData); } /** * Find a Node in a tree, containing the given data * * @param element Node to start searching at * @param nodeData to search for * @return matching Node if found, NULL otherwise */ public Node find(Node element, String nodeData) { if (nodeData.equals(element.getData())) { return element; } for (Node data : element.getChildren()) { Node result = find(data, nodeData); if (result != null) { return result; } } return null; } public void clear() { rootElement = null; } /** * Removes the node with the supplied node data. Deletes the first matching node. * @return TRUE if a node was found and removed */ public boolean remove(String nodeData) { Node nodeToRemove = find(nodeData); if (ObjectUtils.isNotNull(nodeToRemove)) { nodeToRemove.getParent().getChildren().remove(nodeToRemove); nodeToRemove.setParent(null); return true; } return false; } }
3,434
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnCategoriesModel.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/columnCategories/ColumnCategoriesModel.java
package net.sourceforge.nattable.columnCategories; import static net.sourceforge.nattable.util.ObjectUtils.isNotNull; import java.io.Serializable; import net.sourceforge.nattable.columnCategories.Node.Type; public class ColumnCategoriesModel implements Serializable { private static final long serialVersionUID = 4550L; /** Tree of the column category names */ private final Tree tree = new Tree(); public Node addRootCategory(String rootCategoryName) { if(isNotNull(tree.getRootElement())){ throw new IllegalStateException("Root has been set already. Clear using (clear()) to reset."); } Node root = new Node(rootCategoryName, Type.ROOT); tree.setRootElement(root); return root; } public Node addCategory(Node parentCategory, String newCategoryName){ if(tree.getRootElement() == null){ throw new IllegalStateException("Root node must be set (using addRootNode()) before children can be added"); } Node newNode = new Node(newCategoryName, Node.Type.CATEGORY); parentCategory.addChild(newNode); return newNode; } public void addColumnsToCategory(Node parentCategory, int... columnIndexes){ if(parentCategory.getType() != Type.CATEGORY){ throw new IllegalStateException("Columns can be added to a category node only."); } for (Integer columnIndex : columnIndexes) { parentCategory.addChild(new Node(String.valueOf(columnIndex), Type.COLUMN)); } } public void removeColumnIndex(Integer hiddenColumnIndex) { tree.remove(String.valueOf(hiddenColumnIndex)); } public Node getRootCategory() { return tree.getRootElement(); } @Override public String toString() { return tree.toString(); } public void dispose() { tree.clear(); } public void clear() { tree.clear(); } }
1,816
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnCategoriesLabelProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/columnCategories/gui/ColumnCategoriesLabelProvider.java
package net.sourceforge.nattable.columnCategories.gui; import java.util.List; import net.sourceforge.nattable.columnCategories.Node; import net.sourceforge.nattable.columnChooser.ColumnChooserUtils; import net.sourceforge.nattable.columnChooser.ColumnEntry; import net.sourceforge.nattable.util.ObjectUtils; import org.eclipse.jface.viewers.LabelProvider; public class ColumnCategoriesLabelProvider extends LabelProvider { List<ColumnEntry> hiddenEntries; public ColumnCategoriesLabelProvider(List<ColumnEntry> hiddenEntries) { this.hiddenEntries = hiddenEntries; } @Override public String getText(Object element) { Node node = (Node) element; switch (node.getType()) { case CATEGORY: return node.getData(); case COLUMN: int index = Integer.parseInt(node.getData()); ColumnEntry columnEntry = ColumnChooserUtils.find(hiddenEntries, index); if(ObjectUtils.isNull(columnEntry)){ System.err.println( "Column index " + index + " is present " + "in the Column Categories model, " + "but not in the underlying data"); return String.valueOf(index); } return columnEntry.getLabel(); default: return "Unknown"; } } }
1,224
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnCategoriesDialog.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/columnCategories/gui/ColumnCategoriesDialog.java
package net.sourceforge.nattable.columnCategories.gui; import static net.sourceforge.nattable.columnChooser.ColumnChooserUtils.getColumnEntryPositions; import static net.sourceforge.nattable.util.ObjectUtils.isNotEmpty; import java.util.ArrayList; import java.util.List; import net.sourceforge.nattable.columnCategories.ColumnCategoriesModel; import net.sourceforge.nattable.columnCategories.IColumnCategoriesDialogListener; import net.sourceforge.nattable.columnCategories.Node; import net.sourceforge.nattable.columnCategories.Node.Type; import net.sourceforge.nattable.columnChooser.ColumnEntry; import net.sourceforge.nattable.columnChooser.gui.AbstractColumnChooserDialog; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import net.sourceforge.nattable.util.GUIHelper; import net.sourceforge.nattable.util.ObjectUtils; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; 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.Shell; /** * JFace/SWT based column chooser dialog which displays the available/hidden * columns in a tree viewer. This tree viewer is based on the {@link ColumnCategoriesModel}. */ public class ColumnCategoriesDialog extends AbstractColumnChooserDialog { private final ColumnCategoriesModel model; private List<ColumnEntry> hiddenColumnEntries; private List<ColumnEntry> visibleColumnsEntries; private TreeViewer treeViewer; private ListViewer listViewer; private ISelection lastListSelection; public ColumnCategoriesDialog(Shell shell, ColumnCategoriesModel model, List<ColumnEntry> hiddenColumnEntries, List<ColumnEntry> visibleColumnsEntries) { super(shell); this.model = model; this.hiddenColumnEntries = hiddenColumnEntries; this.visibleColumnsEntries = visibleColumnsEntries; setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL | SWT.RESIZE); } @Override public void populateDialogArea(Composite parent) { GridDataFactory.fillDefaults().grab(true, true).applyTo(parent); parent.setLayout(new GridLayout(4, false)); // Labels createLabels(parent, "Available columns", "Selected columns"); GridData gridData = GridDataFactory.fillDefaults().grab(true, true).create(); // Left tree - column categories treeViewer = new TreeViewer(parent); populateAvailableTree(); treeViewer.getControl().setLayoutData(gridData); // Add/remove buttons Composite buttonComposite = new Composite(parent, SWT.NONE); buttonComposite.setLayout(new GridLayout(1, true)); createAddButton(buttonComposite); createRemoveButton(buttonComposite); addListenersToTreeViewer(); // Right list - selected columns listViewer = new ListViewer(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); populateSelectedList(); addListenersToListViewer(); // Up/down buttons Composite upDownbuttonComposite = new Composite(parent, SWT.NONE); upDownbuttonComposite.setLayout(new GridLayout(1, true)); createUpButton(upDownbuttonComposite); createDownButton(upDownbuttonComposite); } private void populateSelectedList() { VisibleColumnsProvider listProvider = new VisibleColumnsProvider(visibleColumnsEntries); listViewer.setContentProvider(listProvider); listViewer.setLabelProvider(listProvider); listViewer.setInput(listProvider); listViewer.setContentProvider(listProvider); listViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); } private void addListenersToTreeViewer() { treeViewer.getControl().addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { addSelected(); } }); } private void addListenersToListViewer() { listViewer.getControl().addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { removeSelected(); } }); listViewer.getControl().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { boolean controlMask = (e.stateMask & SWT.CONTROL) == SWT.CONTROL; if (controlMask && e.keyCode == SWT.ARROW_UP) { moveSelectedUp(); e.doit = false; } else if (controlMask && e.keyCode == SWT.ARROW_DOWN) { moveSelectedDown(); e.doit = false; } } @Override public void keyReleased(KeyEvent e) { if (e.character == ' ') removeSelected(); } }); } private void populateAvailableTree() { AvailableColumnCategoriesProvider provider = new AvailableColumnCategoriesProvider(model); provider.hideEntries(visibleColumnsEntries); treeViewer.setContentProvider(provider); treeViewer.setLabelProvider(new ColumnCategoriesLabelProvider(hiddenColumnEntries)); treeViewer.setInput(provider); } private Button createDownButton(Composite upDownbuttonComposite) { Button downButton = new Button(upDownbuttonComposite, SWT.PUSH); downButton.setImage(GUIHelper.getImage("arrow_down")); downButton.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create()); downButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { moveSelectedDown(); } }); return downButton; } private Button createUpButton(Composite upDownbuttonComposite) { Button upButton = new Button(upDownbuttonComposite, SWT.PUSH); upButton.setImage(GUIHelper.getImage("arrow_up")); upButton.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create()); upButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { moveSelectedUp(); } }); return upButton; } private Button createRemoveButton(Composite buttonComposite) { Button removeButton = new Button(buttonComposite, SWT.PUSH); removeButton.setImage(GUIHelper.getImage("arrow_left")); removeButton.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create()); removeButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { removeSelected(); } }); return removeButton; } private Button createAddButton(Composite buttonComposite) { Button addButton = new Button(buttonComposite, SWT.PUSH); addButton.setImage(GUIHelper.getImage("arrow_right")); addButton.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create()); addButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { addSelected(); } }); return addButton; } // Respond to button clicks / user actions protected void removeSelected() { fireItemsRemoved(getColumnPositionsFromListViewer()); } protected void addSelected() { fireItemsSelected(getColumnIndexesFromTreeNodes()); } protected final void fireItemsSelected(List<Integer> addedColumnIndexes) { if (isNotEmpty(addedColumnIndexes)) { for (Object listener : listeners.getListeners()) { ((IColumnCategoriesDialogListener) listener).itemsSelected(addedColumnIndexes); } } } protected final void fireItemsRemoved(List<Integer> removedColumnPositions) { if (isNotEmpty(removedColumnPositions)) { for (Object listener : listeners.getListeners()) { ((IColumnCategoriesDialogListener) listener).itemsRemoved(removedColumnPositions); } } } protected final void fireItemsMoved(MoveDirectionEnum direction, List<Integer> toPositions) { for (Object listener : listeners.getListeners()) { ((IColumnCategoriesDialogListener) listener).itemsMoved(direction, toPositions); } } protected void moveSelectedUp() { List<Integer> selectedPositions = getColumnEntryPositions(getSelectedColumnEntriesFromListViewer()); // First position selected if(!selectedPositions.contains(0)){ fireItemsMoved(MoveDirectionEnum.UP, selectedPositions); } } protected void moveSelectedDown() { List<Integer> selectedPositions = getColumnEntryPositions(getSelectedColumnEntriesFromListViewer()); // Last position selected if(!selectedPositions.contains(visibleColumnsEntries.size())){ fireItemsMoved(MoveDirectionEnum.DOWN, selectedPositions); } } /** * @return selected column position(s) from the list viewer */ private List<Integer> getColumnPositionsFromListViewer() { return getColumnEntryPositions(getSelectedColumnEntriesFromListViewer()); } private List<ColumnEntry> getSelectedColumnEntriesFromListViewer() { lastListSelection = listViewer.getSelection(); Object[] objects = ((StructuredSelection) lastListSelection).toArray(); List<ColumnEntry> entries = new ArrayList<ColumnEntry>(); for (Object object : objects) { entries.add((ColumnEntry) object); } return entries; } /** * @return selected columns index(s) from the tree viewer */ private List<Integer> getColumnIndexesFromTreeNodes() { Object[] nodes = ((TreeSelection)treeViewer.getSelection()).toArray(); List<Integer> indexes = new ArrayList<Integer>(); for (Object object : nodes) { Node node = (Node) object; if(Type.COLUMN == node.getType()){ indexes.add(Integer.parseInt(node.getData())); } } return indexes; } public void refresh(List<ColumnEntry> hiddenColumnEntries, List<ColumnEntry> visibleColumnsEntries) { this.hiddenColumnEntries = hiddenColumnEntries; this.visibleColumnsEntries = visibleColumnsEntries; populateAvailableTree(); populateSelectedList(); if(ObjectUtils.isNotNull(lastListSelection)){ listViewer.setSelection(lastListSelection); } } }
10,875
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
VisibleColumnsProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/columnCategories/gui/VisibleColumnsProvider.java
package net.sourceforge.nattable.columnCategories.gui; import java.util.List; import net.sourceforge.nattable.columnChooser.ColumnEntry; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; /** * Provides visible columns as {@link ColumnEntry} objects. */ public class VisibleColumnsProvider extends LabelProvider implements IStructuredContentProvider { List<ColumnEntry> visibleColumnsEntries; public VisibleColumnsProvider(List<ColumnEntry> visibleColumnsEntries) { this.visibleColumnsEntries = visibleColumnsEntries; } public Object[] getElements(Object inputElement) { return visibleColumnsEntries.toArray(); } @Override public String getText(Object element) { return ((ColumnEntry) element).getLabel(); } public void dispose() { // No op. } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // No op. } }
1,008
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AvailableColumnCategoriesProvider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/columnCategories/gui/AvailableColumnCategoriesProvider.java
package net.sourceforge.nattable.columnCategories.gui; import static net.sourceforge.nattable.util.ObjectUtils.isNull; import java.util.List; import net.sourceforge.nattable.columnCategories.ColumnCategoriesModel; import net.sourceforge.nattable.columnCategories.Node; import net.sourceforge.nattable.columnChooser.ColumnEntry; import net.sourceforge.nattable.util.ObjectCloner; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; /** * Provides data to the tree viewer representation of Column categories.<br/> * Data is in the form of {@link Node} objects exposed from the {@link ColumnCategoriesModel}<br/> */ public class AvailableColumnCategoriesProvider implements ITreeContentProvider { private final ColumnCategoriesModel model; public AvailableColumnCategoriesProvider(ColumnCategoriesModel model) { this.model = (ColumnCategoriesModel) ObjectCloner.deepCopy(model); } /** * Hide the given {@link ColumnEntry} (ies) i.e. do not show them in the viewer. */ public void hideEntries(List<ColumnEntry> entriesToHide) { for (ColumnEntry hiddenColumnEntry : entriesToHide) { model.removeColumnIndex(hiddenColumnEntry.getIndex()); } } public Object[] getChildren(Object parentElement) { return castToNode(parentElement).getChildren().toArray(); } public Object getParent(Object element) { return castToNode(element).getParent(); } public boolean hasChildren(Object element) { return castToNode(element).getNumberOfChildren() > 0; } public Object[] getElements(Object inputElement) { return isNull(model.getRootCategory()) ? new Object[]{} : model.getRootCategory().getChildren().toArray(); } private Node castToNode(Object element) { return (Node) element; } public void dispose() { // No op. } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // No op. } }
1,976
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SpanningDataLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/SpanningDataLayer.java
package net.sourceforge.nattable.layer; import net.sourceforge.nattable.data.ISpanningDataProvider; import net.sourceforge.nattable.layer.cell.DataCell; import net.sourceforge.nattable.layer.cell.LayerCell; public class SpanningDataLayer extends DataLayer { public SpanningDataLayer(ISpanningDataProvider dataProvider) { super(dataProvider); } public SpanningDataLayer(ISpanningDataProvider dataProvider, int defaultColumnWidth, int defaultRowHeight) { super(dataProvider, defaultColumnWidth, defaultRowHeight); } protected SpanningDataLayer() { super(); } protected SpanningDataLayer(int defaultColumnWidth, int defaultRowHeight) { super(defaultColumnWidth, defaultRowHeight); } @Override public ISpanningDataProvider getDataProvider() { return (ISpanningDataProvider) super.getDataProvider(); } @Override public LayerCell getCellByPosition(int columnPosition, int rowPosition) { if (columnPosition < 0 || columnPosition >= getColumnCount() || rowPosition < 0 || rowPosition >= getRowCount()) { return null; } DataCell dataCell = getDataProvider().getCellByPosition(columnPosition, rowPosition); return new LayerCell(this, columnPosition, rowPosition, dataCell); } }
1,269
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
IUniqueIndexLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/IUniqueIndexLayer.java
package net.sourceforge.nattable.layer; /** * A layer that has a set of column and row indexes that contain no duplicates, * such that there is only one corresponding column or row position for a row or * column index in the layer. */ public interface IUniqueIndexLayer extends ILayer { public int getColumnPositionByIndex(int columnIndex); public int getRowPositionByIndex(int rowIndex); }
401
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SizeConfig.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/SizeConfig.java
package net.sourceforge.nattable.layer; import java.util.Map; import java.util.Properties; import java.util.StringTokenizer; import java.util.TreeMap; import net.sourceforge.nattable.util.GUIHelper; import org.apache.commons.lang.StringUtils; public class SizeConfig { public static final String PERSISTENCE_KEY_DEFAULT_SIZE = ".defaultSize"; public static final String PERSISTENCE_KEY_DEFAULT_SIZES = ".defaultSizes"; public static final String PERSISTENCE_KEY_SIZES = ".sizes"; public static final String PERSISTENCE_KEY_RESIZABLE_BY_DEFAULT = ".resizableByDefault"; public static final String PERSISTENCE_KEY_RESIZABLE_INDEXES = ".resizableIndexes"; private int defaultSize; private final Map<Integer, Integer> defaultSizeMap = new TreeMap<Integer, Integer>(); private final Map<Integer, Integer> sizeMap = new TreeMap<Integer, Integer>(); private final Map<Integer, Boolean> resizablesMap = new TreeMap<Integer, Boolean>(); private boolean resizableByDefault = true; public SizeConfig() {} public SizeConfig(int defaultSize) { this.defaultSize = defaultSize; } // Persistence public void saveState(String prefix, Properties properties) { properties.put(prefix + PERSISTENCE_KEY_DEFAULT_SIZE, String.valueOf(defaultSize)); saveMap(defaultSizeMap, prefix + PERSISTENCE_KEY_DEFAULT_SIZES, properties); saveMap(sizeMap, prefix + PERSISTENCE_KEY_SIZES, properties); properties.put(prefix + PERSISTENCE_KEY_RESIZABLE_BY_DEFAULT, String.valueOf(resizableByDefault)); saveMap(resizablesMap, prefix + PERSISTENCE_KEY_RESIZABLE_INDEXES, properties); } private void saveMap(Map<Integer, ?> map, String key, Properties properties) { if (map.size() > 0) { StringBuilder strBuilder = new StringBuilder(); for (Integer index : map.keySet()) { strBuilder.append(index); strBuilder.append(':'); strBuilder.append(map.get(index)); strBuilder.append(','); } properties.setProperty(key, strBuilder.toString()); } } public void loadState(String prefix, Properties properties) { String persistedDefaultSize = properties.getProperty(prefix + PERSISTENCE_KEY_DEFAULT_SIZE); if (!StringUtils.isEmpty(persistedDefaultSize)) { defaultSize = Integer.valueOf(persistedDefaultSize).intValue(); } String persistedResizableDefault = properties.getProperty(prefix + PERSISTENCE_KEY_RESIZABLE_BY_DEFAULT); if (!StringUtils.isEmpty(persistedResizableDefault)) { resizableByDefault = Boolean.valueOf(persistedResizableDefault).booleanValue(); } loadBooleanMap(prefix + PERSISTENCE_KEY_RESIZABLE_INDEXES, properties, resizablesMap); loadIntegerMap(prefix + PERSISTENCE_KEY_DEFAULT_SIZES, properties, defaultSizeMap); loadIntegerMap(prefix + PERSISTENCE_KEY_SIZES, properties, sizeMap); } private void loadIntegerMap(String key, Properties properties, Map<Integer, Integer> map) { String property = properties.getProperty(key); if (property != null) { map.clear(); StringTokenizer tok = new StringTokenizer(property, ","); while (tok.hasMoreTokens()) { String token = tok.nextToken(); int separatorIndex = token.indexOf(':'); map.put(Integer.valueOf(token.substring(0, separatorIndex)), Integer.valueOf(token.substring(separatorIndex + 1))); } } } private void loadBooleanMap(String key, Properties properties, Map<Integer, Boolean> map) { String property = properties.getProperty(key); if (property != null) { StringTokenizer tok = new StringTokenizer(property, ","); while (tok.hasMoreTokens()) { String token = tok.nextToken(); int separatorIndex = token.indexOf(':'); map.put(Integer.valueOf(token.substring(0, separatorIndex)), Boolean.valueOf(token.substring(separatorIndex + 1))); } } } // Default size public void setDefaultSize(int defaultSize) { this.defaultSize = defaultSize; } public void setDefaultSize(int position, int size) { defaultSizeMap.put(Integer.valueOf(position), Integer.valueOf(size)); } private int getDefaultSize(int position) { int size = getSize(defaultSizeMap, position); if (size >= 0) { return size; } else { return defaultSize; } } // Size public int getAggregateSize(int position) { if (position < 0) { return -1; } else if (position == 0) { return 0; } else if (isAllPositionsSameSize()) { return position * defaultSize; } else { int resizeAggregate = 0; int resizedColumns = 0; for (Integer resizedPosition : sizeMap.keySet()) { if (resizedPosition.intValue() < position) { resizedColumns++; resizeAggregate += sizeMap.get(resizedPosition).intValue(); } else { break; } } return (position * defaultSize) + (resizeAggregate - (resizedColumns * defaultSize)); } } public int getSize(int position) { int size = getSize(sizeMap, position); if (size <= 0 && sizeMap.containsKey(Integer.valueOf(position))) { return GUIHelper.DEFAULT_MIN_DISPLAY_SIZE; } else if (size >= 0) { return size; } else { return getDefaultSize(position); } } public void setSize(int position, int size) { if (isPositionResizable(position)) { sizeMap.put(Integer.valueOf(position), Integer.valueOf(size)); } } // Resizable public boolean isResizableByDefault() { return resizableByDefault; } public boolean isPositionResizable(int position) { Boolean resizable = resizablesMap.get(Integer.valueOf(position)); if (resizable != null) { return resizable.booleanValue(); } return resizableByDefault; } public void setPositionResizable(int position, boolean resizable) { resizablesMap.put(Integer.valueOf(position), Boolean.valueOf(resizable)); } public void setResizableByDefault(boolean resizableByDefault) { resizablesMap.clear(); this.resizableByDefault = resizableByDefault; } // All positions same size public boolean isAllPositionsSameSize() { return defaultSizeMap.size() == 0 && sizeMap.size() == 0; } private int getSize(Map<Integer, Integer> map, int position) { Integer sizeFromMap = map.get(Integer.valueOf(position)); if (sizeFromMap != null) { return sizeFromMap.intValue(); } return -1; } }
6,327
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ZoomLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/ZoomLayer.java
package net.sourceforge.nattable.layer; public class ZoomLayer extends AbstractLayerTransform { private float zoomFactor = 1; public ZoomLayer(ILayer underlyingILayer) { super(underlyingILayer); } public float getZoomFactor() { return zoomFactor; } public void setZoomFactor(float zoomFactor) { this.zoomFactor = zoomFactor; } // Horizontal features // Width @Override public int getWidth() { return (int) (zoomFactor * super.getWidth()); } @Override public int getPreferredWidth() { return (int) (zoomFactor * super.getPreferredWidth()); } @Override public int getColumnWidthByPosition(int columnPosition) { return (int) (zoomFactor * super.getColumnWidthByPosition(columnPosition)); } // X @Override public int getColumnPositionByX(int x) { return super.getColumnPositionByX((int) (x / zoomFactor)); } @Override public int getStartXOfColumnPosition(int columnPosition) { return (int) (zoomFactor * super.getStartXOfColumnPosition(columnPosition)); } // Vertical features // Height @Override public int getHeight() { return (int) (zoomFactor * super.getHeight()); } @Override public int getPreferredHeight() { return (int) (zoomFactor * super.getPreferredHeight()); } @Override public int getRowHeightByPosition(int rowPosition) { return (int) (zoomFactor * super.getRowHeightByPosition(rowPosition)); } // Y @Override public int getRowPositionByY(int y) { return super.getRowPositionByY((int) (y / zoomFactor)); } @Override public int getStartYOfRowPosition(int rowPosition) { return (int) (zoomFactor * super.getStartYOfRowPosition(rowPosition)); } @Override public LabelStack getRegionLabelsByXY(int x, int y) { return super.getRegionLabelsByXY((int) (x / zoomFactor), (int) (y / zoomFactor)); } }
1,819
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ILayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/ILayer.java
package net.sourceforge.nattable.layer; import java.util.Collection; import java.util.Properties; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.config.ConfigRegistry; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.cell.LayerCell; import net.sourceforge.nattable.layer.event.ILayerEvent; import net.sourceforge.nattable.layer.event.IVisualChangeEvent; import net.sourceforge.nattable.painter.layer.ILayerPainter; import net.sourceforge.nattable.persistence.IPersistable; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.style.DisplayMode; import net.sourceforge.nattable.ui.binding.UiBindingRegistry; import net.sourceforge.nattable.util.IClientAreaProvider; import org.eclipse.swt.graphics.Rectangle; /** * <p> * A Layer is a rectangular region of grid cells. A layer has methods to access its columns, rows, width and height. A * layer can be stacked on top of another layer in order to expose a transformed view of its underlying layer's grid * cell structure. * </p> * <p> * Columns and rows in a layer are referenced either by <b>position</b> or <b>index</b>. The position of a column/row in * a layer corresponds to the physical location of the column/row in the layer. The index of a column/row in a layer * corresponds to the location of the column/row in the lowest level layer in the layer stack. These concepts are * illustrated by the following example: * </p> * <pre> * Hide Layer C * 0 1 2 3 4 <- column positions * 1 0 3 4 5 <- column indexes * * Reorder Layer B * 0 1 2 3 4 5 <- column positions * 2 1 0 3 4 5 <- column indexes * * Data Layer A * 0 1 2 3 4 5 <- column positions * 0 1 2 3 4 5 <- column indexes * </pre> * <p> * In the above example, Hide Layer C is stacked on top of Reorder Layer B, which is in turn stacked on top of Data * Layer A. The positions in Data Layer A are the same as its indexes, because it is the lowest level layer in the * stack. Reorder Layer B reorders column 0 of its underlying layer (Data Layer A) after column 2 of its underlying * layer. Hide Layer C hides the first column of its underlying layer (Reorder Layer B). * </p> * <p> * Layers can also be laterally composed into larger layers. For instance, the standard grid layer is composed of a * body layer, column header layer, row header layer, and corner layer: * </p> * <table border=1> * <tr><td>corner</td><td>column header</td></tr> * <tr><td>row header</td><td>body</td></tr> * </table> * * @see CompositeLayer */ public interface ILayer extends ILayerListener, IPersistable { // Persistence /** * Persistables registered with a layer will have a chance to write their data out to the * {@link Properties} instance when the layer is persisted. */ public void registerPersistable(IPersistable persistable); public void unregisterPersistable(IPersistable persistable); // Configuration /** * Every layer gets this call back, starting at the top of the stack. This is triggered * by the {@link NatTable#configure()} method. This is an opportunity to add * any key/mouse bindings and other general configuration. * * @param configRegistry instance owned by {@link NatTable} * @param uiBindingRegistry instance owned by {@link NatTable} */ public void configure(ConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry); // Region /** * Layer can apply its own labels to any cell it wishes. */ public LabelStack getRegionLabelsByXY(int x, int y); // Commands /** * Opportunity to respond to a command as it flows down the stack. If the layer * is not interested in the command it should allow the command to keep traveling * down the stack. * * Note: Before the layer can process a command it <i>must</i> convert the * command to its local co-ordinates using {@link ILayerCommand#convertToTargetLayer(ILayer)} * * @return true if the command has been handled, false otherwise */ public boolean doCommand(ILayerCommand command); // Events /** * Events can be fired to notify other components of the grid.<br/> * Events travel <i>up</i> the layer stack and may cause a repaint. * * Example: When the contents of the grid change {@link IVisualChangeEvent} can be * fired to notify other layers to refresh their caches etc. */ public void fireLayerEvent(ILayerEvent event); public void addLayerListener(ILayerListener listener); public void removeLayerListener(ILayerListener listener); public ILayerPainter getLayerPainter(); // Client area public IClientAreaProvider getClientAreaProvider(); public void setClientAreaProvider(IClientAreaProvider clientAreaProvider); // Horizontal features // Columns /** * Returns the number of columns in this coordinate model. */ public int getColumnCount(); public int getPreferredColumnCount(); /** * Gets the underlying non-transformed column index for the given column position. * @param columnPosition a column position relative to this coordinate model * @return an underlying non-transformed column index, or -1 if the given column position does not exist within this * coordinate system */ public int getColumnIndexByPosition(int columnPosition); /** * Convert a column position to the coordinates of the underlying layer. * This is possible since each layer is aware of its underlying layer. * @param localColumnPosition column position in local (the layer's own) coordinates */ public int localToUnderlyingColumnPosition(int localColumnPosition); public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition); public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges); // Width /** * Returns the total width of this layer. */ public int getWidth(); public int getPreferredWidth(); /** * Returns the width of the given column. * @param columnPosition the column position relative to the associated coordinate system * @return the width of the column, in pixels */ public int getColumnWidthByPosition(int columnPosition); // Column resize public boolean isColumnPositionResizable(int columnPosition); // X /** * Returns the column position that contains the given x coordinate. * @param x a horizontal pixel location relative to the pixel boundary of this layer * @return a column position relative to the associated coordinate system, or -1 if there is no column that contains x */ public int getColumnPositionByX(int x); /** * @param columnPosition * @return starting X coordinate of the column position */ public int getStartXOfColumnPosition(int columnPosition); // Underlying public Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition); // Vertical features // Rows /** * Returns the number of rows in this coordinate model. */ public int getRowCount(); public int getPreferredRowCount(); /** * Gets the underlying non-transformed row index for the given row position. * @param rowPosition a row position relative to this coordinate model * @return an underlying non-transformed row index, or -1 if the given row position does not exist within this * coordinate system */ public int getRowIndexByPosition(int rowPosition); public int localToUnderlyingRowPosition(int localRowPosition); public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition); public Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges); // Height /** * Returns the total height of this layer. */ public int getHeight(); public int getPreferredHeight(); /** * Returns the height of the given row. * @param rowPosition the row position relative to the associated coordinate system * @return the height of the row, in pixels */ public int getRowHeightByPosition(int rowPosition); // Row resize public boolean isRowPositionResizable(int rowPosition); // Y /** * Returns the row position that contains the given y coordinate. * @param y a vertical pixel location relative to the pixel boundary of this layer * @return a row position relative to the associated coordinate system, or -1 if there is no row that contains y */ public int getRowPositionByY(int y); public int getStartYOfRowPosition(int rowPosition); // Underlying public Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition); // Cell features public LayerCell getCellByPosition(int columnPosition, int rowPosition); public Rectangle getBoundsByPosition(int columnPosition, int rowPosition); /** * @return {@link DisplayMode} for the cell at the given position.<br/> * The {@link DisplayMode} affects the settings out of the {@link ConfigRegistry}. * Display mode is <i>NORMAL</i> by default.<br/> * * <b>Example:</b> {@link SelectionLayer} overrides this to return the <i>SELECT</i> * label for cells which are selected. */ public String getDisplayModeByPosition(int columnPosition, int rowPosition); public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition); public Object getDataValueByPosition(int columnPosition, int rowPosition); public ILayer getUnderlyingLayerByPosition(int columnPosition, int rowPosition); }
9,799
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
LayerUtil.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/LayerUtil.java
package net.sourceforge.nattable.layer; public class LayerUtil { public static final int getColumnPositionByX(ILayer layer, int x) { int width = layer.getWidth(); if (x < 0 || x >= width) { return -1; } return findColumnPosition(0, 0, layer, x, width, layer.getColumnCount()); } protected static final int findColumnPosition(int xOffset, int columnOffset, ILayer layer, int x, int totalWidth, int columnCount) { double size = (double) (totalWidth - xOffset) / (columnCount - columnOffset); int columnPosition = columnOffset + (int) ((x - xOffset) / size); int startX = layer.getStartXOfColumnPosition(columnPosition); int endX = startX + layer.getColumnWidthByPosition(columnPosition); if (x < startX) { return findColumnPosition(xOffset, columnOffset, layer, x, startX, columnPosition); } else if (x >= endX) { return findColumnPosition(endX, columnPosition + 1, layer, x, totalWidth, columnCount); } else { return columnPosition; } } public static final int getRowPositionByY(ILayer layer, int y) { int height = layer.getHeight(); if (y < 0 || y >= height) { return -1; } return findRowPosition(0, 0, layer, y, height, layer.getRowCount()); } protected static final int findRowPosition(int yOffset, int rowOffset, ILayer layer, int y, int totalHeight, int rowCount) { double size = (double) (totalHeight - yOffset) / (rowCount - rowOffset); int rowPosition = rowOffset + (int) ((y - yOffset) / size); int startY = layer.getStartYOfRowPosition(rowPosition); int endY = startY + layer.getRowHeightByPosition(rowPosition); if (y < startY) { return findRowPosition(yOffset, rowOffset, layer, y, startY, rowPosition); } else if (y >= endY) { return findRowPosition(endY, rowPosition + 1, layer, y, totalHeight, rowCount); } else { return rowPosition; } } /** * Convert column position from the source layer to the target layer * @param sourceLayer source layer * @param sourceColumnPosition column position in the source layer * @param targetLayer layer to convert the from position to * @return converted column position */ public static final int convertColumnPosition(ILayer sourceLayer, int sourceColumnPosition, IUniqueIndexLayer targetLayer) { if (targetLayer == sourceLayer) { return sourceColumnPosition; } int columnIndex = sourceLayer.getColumnIndexByPosition(sourceColumnPosition); return targetLayer.getColumnPositionByIndex(columnIndex); } /** * Convert row position from the source layer to the target layer * @param sourceLayer source layer * @param sourceRowPosition position in the source layer * @param targetLayer layer to convert the from position to * @return converted row position */ public static final int convertRowPosition(ILayer sourceLayer, int sourceRowPosition, IUniqueIndexLayer targetLayer) { if (targetLayer == sourceLayer) { return sourceRowPosition; } int rowIndex = sourceLayer.getRowIndexByPosition(sourceRowPosition); return targetLayer.getRowPositionByIndex(rowIndex); } }
3,075
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractLayerTransform.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/AbstractLayerTransform.java
package net.sourceforge.nattable.layer; import java.util.ArrayList; 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.cell.IConfigLabelAccumulator; import net.sourceforge.nattable.layer.cell.LayerCell; 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; /** * Abstract base class for layers that expose transformed views of an underlying layer. By default the * AbstractLayerTransform behaves as an identity transform of its underlying layer; that is, it exposes * its underlying layer as is without any changes. Subclasses are expected to override methods in this * class to implement specific kinds of layer transformations. */ public abstract class AbstractLayerTransform extends AbstractLayer { protected ILayer underlyingLayer; public AbstractLayerTransform() { } public AbstractLayerTransform(ILayer underlyingLayer) { setUnderlyingLayer(underlyingLayer); } protected void setUnderlyingLayer(ILayer underlyingLayer) { this.underlyingLayer = underlyingLayer; this.underlyingLayer.setClientAreaProvider(getClientAreaProvider()); this.underlyingLayer.addLayerListener(this); } protected ILayer getUnderlyingLayer() { return underlyingLayer; } // Persistence @Override public void saveState(String prefix, Properties properties) { super.saveState(prefix, properties); underlyingLayer.saveState(prefix, properties); } /** * Underlying layers <i>must</i> load state first.<br/> * If this is not done, {@link IStructuralChangeEvent} from underlying<br/> * layers will reset caches after state has been loaded */ @Override public void loadState(String prefix, Properties properties) { super.loadState(prefix, properties); underlyingLayer.loadState(prefix, properties); } // Configuration @Override public void configure(ConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry) { underlyingLayer.configure(configRegistry, uiBindingRegistry); super.configure(configRegistry, uiBindingRegistry); } @Override public ILayerPainter getLayerPainter() { return underlyingLayer.getLayerPainter(); } // Command @Override public boolean doCommand(ILayerCommand command) { if (super.doCommand(command)) { return true; } if (underlyingLayer != null) { return underlyingLayer.doCommand(command); } return false; } // Client area @Override public void setClientAreaProvider(IClientAreaProvider clientAreaProvider) { super.setClientAreaProvider(clientAreaProvider); if (getUnderlyingLayer() != null) { getUnderlyingLayer().setClientAreaProvider(clientAreaProvider); } } // Horizontal features // Columns public int getColumnCount() { return underlyingLayer.getColumnCount(); } public int getPreferredColumnCount() { return underlyingLayer.getPreferredColumnCount(); } public int getColumnIndexByPosition(int columnPosition) { int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition); return underlyingLayer.getColumnIndexByPosition(underlyingColumnPosition); } public int localToUnderlyingColumnPosition(int localColumnPosition) { return localColumnPosition; } public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) { if (sourceUnderlyingLayer != getUnderlyingLayer()) { return -1; } return underlyingColumnPosition; } public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) { Collection<Range> localColumnPositionRanges = new ArrayList<Range>(); for (Range underlyingColumnPositionRange : underlyingColumnPositionRanges) { localColumnPositionRanges.add( new Range( underlyingToLocalColumnPosition(sourceUnderlyingLayer, underlyingColumnPositionRange.start), underlyingToLocalColumnPosition(sourceUnderlyingLayer, underlyingColumnPositionRange.end) ) ); } return localColumnPositionRanges; } // Width public int getWidth() { return underlyingLayer.getWidth(); } public int getPreferredWidth() { return underlyingLayer.getPreferredWidth(); } public int getColumnWidthByPosition(int columnPosition) { int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition); return underlyingLayer.getColumnWidthByPosition(underlyingColumnPosition); } // Column resize public boolean isColumnPositionResizable(int columnPosition) { int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition); return underlyingLayer.isColumnPositionResizable(underlyingColumnPosition); } // X public int getColumnPositionByX(int x) { return underlyingLayer.getColumnPositionByX(x); } public int getStartXOfColumnPosition(int columnPosition) { int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition); return underlyingLayer.getStartXOfColumnPosition(underlyingColumnPosition); } // Underlying public Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition) { Collection<ILayer> underlyingLayers = new HashSet<ILayer>(); underlyingLayers.add(underlyingLayer); return underlyingLayers; } // Vertical features // Rows public int getRowCount() { return underlyingLayer.getRowCount(); } public int getPreferredRowCount() { return underlyingLayer.getPreferredRowCount(); } public int getRowIndexByPosition(int rowPosition) { int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition); return underlyingLayer.getRowIndexByPosition(underlyingRowPosition); } public int localToUnderlyingRowPosition(int localRowPosition) { return localRowPosition; } public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition) { if (sourceUnderlyingLayer != getUnderlyingLayer()) { return -1; } return underlyingRowPosition; } public Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges) { Collection<Range> localRowPositionRanges = new ArrayList<Range>(); for (Range underlyingRowPositionRange : underlyingRowPositionRanges) { localRowPositionRanges.add( new Range( underlyingToLocalRowPosition(sourceUnderlyingLayer, underlyingRowPositionRange.start), underlyingToLocalRowPosition(sourceUnderlyingLayer, underlyingRowPositionRange.end) ) ); } return localRowPositionRanges; } // Height public int getHeight() { return underlyingLayer.getHeight(); } public int getPreferredHeight() { return underlyingLayer.getPreferredHeight(); } public int getRowHeightByPosition(int rowPosition) { int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition); return underlyingLayer.getRowHeightByPosition(underlyingRowPosition); } // Row resize public boolean isRowPositionResizable(int rowPosition) { int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition); return underlyingLayer.isRowPositionResizable(underlyingRowPosition); } // Y public int getRowPositionByY(int y) { return underlyingLayer.getRowPositionByY(y); } public int getStartYOfRowPosition(int rowPosition) { int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition); return underlyingLayer.getStartYOfRowPosition(underlyingRowPosition); } // Underlying public Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition) { Collection<ILayer> underlyingLayers = new HashSet<ILayer>(); underlyingLayers.add(underlyingLayer); return underlyingLayers; } // Cell features @Override public LayerCell getCellByPosition(int columnPosition, int rowPosition) { int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition); int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition); LayerCell cell = underlyingLayer.getCellByPosition(underlyingColumnPosition, underlyingRowPosition); if (cell != null) { cell.updatePosition( this, underlyingToLocalColumnPosition(underlyingLayer, cell.getOriginColumnPosition()), underlyingToLocalRowPosition(underlyingLayer, cell.getOriginRowPosition()), underlyingToLocalColumnPosition(underlyingLayer, cell.getColumnPosition()), underlyingToLocalRowPosition(underlyingLayer, cell.getRowPosition()) ); } return cell; } @Override public String getDisplayModeByPosition(int columnPosition, int rowPosition) { int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition); int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition); return underlyingLayer.getDisplayModeByPosition(underlyingColumnPosition, underlyingRowPosition); } @Override public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) { int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition); int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition); LabelStack configLabels = underlyingLayer.getConfigLabelsByPosition(underlyingColumnPosition, underlyingRowPosition); IConfigLabelAccumulator configLabelAccumulator = getConfigLabelAccumulator(); if (configLabelAccumulator != null) { configLabelAccumulator.accumulateConfigLabels(configLabels, columnPosition, rowPosition); } String regionName = getRegionName(); if (regionName != null) { configLabels.addLabel(regionName); } return configLabels; } public Object getDataValueByPosition(int columnPosition, int rowPosition) { int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition); int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition); return underlyingLayer.getDataValueByPosition(underlyingColumnPosition, underlyingRowPosition); } // IRegionResolver @Override public LabelStack getRegionLabelsByXY(int x, int y) { LabelStack regionLabels = underlyingLayer.getRegionLabelsByXY(x, y); String regionName = getRegionName(); if (regionName != null) { regionLabels.addLabel(regionName); } return regionLabels; } public ILayer getUnderlyingLayerByPosition(int columnPosition, int rowPosition) { return underlyingLayer; } }
10,899
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
LabelStack.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/LabelStack.java
package net.sourceforge.nattable.layer; import java.util.LinkedList; import java.util.List; public class LabelStack { /** * List implementation saves the overhead of popping labels off * in the {@link #getLabels()} method */ private final List<String> labels = new LinkedList<String>(); public LabelStack(String...labelNames) { for (String label : labelNames) { if (label != null) { labels.add(label); } } } /** * Adds a label to the bottom of the label stack. * @param label */ public void addLabel(String label) { if(! hasLabel(label)){ labels.add(label); } } public List<String> getLabels() { return labels; } public boolean hasLabel(String label) { return labels.contains(label); } @Override public String toString() { return labels.toString(); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LabelStack)) { return false; } LabelStack that = (LabelStack) obj; return this.labels.equals(that.labels); } @Override public int hashCode() { return labels.hashCode(); } }
1,198
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
LayoutCoordinate.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/LayoutCoordinate.java
package net.sourceforge.nattable.layer; public final class LayoutCoordinate { public final int x; public final int y; public LayoutCoordinate(int x, int y) { this.x = x; this.y = y; } public int getColumnPosition() { return x; } public int getRowPosition() { return y; } @Override public String toString() { return getClass().getSimpleName() + "[" + x + "," + y + "]"; } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj.getClass() != getClass()) return true; LayoutCoordinate pc = (LayoutCoordinate) obj; return pc.getRowPosition() == getRowPosition() && pc.getColumnPosition() == getColumnPosition(); } @Override public int hashCode() { int hash = 77; hash = 11 * hash + getRowPosition() + 99; hash = 11 * hash + getColumnPosition(); return hash; } }
877
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DataLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/DataLayer.java
package net.sourceforge.nattable.layer; import java.util.Collection; import java.util.Properties; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.data.IDataProvider; import net.sourceforge.nattable.edit.command.UpdateDataCommandHandler; import net.sourceforge.nattable.layer.event.StructuralRefreshEvent; import net.sourceforge.nattable.resize.command.ColumnResizeCommandHandler; import net.sourceforge.nattable.resize.command.MultiColumnResizeCommandHandler; import net.sourceforge.nattable.resize.command.MultiRowResizeCommandHandler; import net.sourceforge.nattable.resize.command.RowResizeCommandHandler; import net.sourceforge.nattable.resize.event.ColumnResizeEvent; import net.sourceforge.nattable.resize.event.RowResizeEvent; /** * Wraps the {@link IDataProvider}, and serves as the data source for all * other layers. Also, tracks the size of the columns and the rows using * {@link SizeConfig} objects. Since this layer sits directly on top of the * data source, at this layer index == position. */ public class DataLayer extends AbstractLayer implements IUniqueIndexLayer { public static final String PERSISTENCE_KEY_ROW_HEIGHT = ".rowHeight"; public static final String PERSISTENCE_KEY_COLUMN_WIDTH = ".columnWidth"; public static final int DEFAULT_COLUMN_WIDTH = 100; public static final int DEFAULT_ROW_HEIGHT = 20; protected IDataProvider dataProvider; private final SizeConfig columnWidthConfig; private final SizeConfig rowHeightConfig; public DataLayer(IDataProvider dataProvider) { this(dataProvider, DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT); } public DataLayer(IDataProvider dataProvider, int defaultColumnWidth, int defaultRowHeight) { this.dataProvider = dataProvider; columnWidthConfig = new SizeConfig(defaultColumnWidth); rowHeightConfig = new SizeConfig(defaultRowHeight); registerCommandHandlers(); } protected DataLayer() { this(DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT); } protected DataLayer(int defaultColumnWidth, int defaultRowHeight) { columnWidthConfig = new SizeConfig(defaultColumnWidth); rowHeightConfig = new SizeConfig(defaultRowHeight); registerCommandHandlers(); } // Persistence @Override public void saveState(String prefix, Properties properties) { super.saveState(prefix, properties); columnWidthConfig.saveState(prefix + PERSISTENCE_KEY_COLUMN_WIDTH, properties); rowHeightConfig.saveState(prefix + PERSISTENCE_KEY_ROW_HEIGHT, properties); } @Override public void loadState(String prefix, Properties properties) { super.loadState(prefix, properties); columnWidthConfig.loadState(prefix + PERSISTENCE_KEY_COLUMN_WIDTH, properties); rowHeightConfig.loadState(prefix + PERSISTENCE_KEY_ROW_HEIGHT, properties); fireLayerEvent(new StructuralRefreshEvent(this)); } // Configuration private void registerCommandHandlers() { registerCommandHandler(new ColumnResizeCommandHandler(this)); registerCommandHandler(new MultiColumnResizeCommandHandler(this)); registerCommandHandler(new RowResizeCommandHandler(this)); registerCommandHandler(new MultiRowResizeCommandHandler(this)); registerCommandHandler(new UpdateDataCommandHandler(this)); } public IDataProvider getDataProvider() { return dataProvider; } protected void setDataProvider(IDataProvider dataProvider) { this.dataProvider = dataProvider; } // Horizontal features // Columns public int getColumnCount() { return dataProvider.getColumnCount(); } public int getPreferredColumnCount() { return getColumnCount(); } /** * This is the root coordinate system, so the column index is always equal to the column position. */ public int getColumnIndexByPosition(int columnPosition) { if (columnPosition >=0 && columnPosition < getColumnCount()) { return columnPosition; } else { return -1; } } /** * This is the root coordinate system, so the column position is always equal to the column index. */ public int getColumnPositionByIndex(int columnIndex) { if (columnIndex >=0 && columnIndex < getColumnCount()) { return columnIndex; } else { return -1; } } public int localToUnderlyingColumnPosition(int localColumnPosition) { return localColumnPosition; } public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) { return underlyingColumnPosition; } public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) { return underlyingColumnPositionRanges; } // Width public int getWidth() { return columnWidthConfig.getAggregateSize(getColumnCount()); } public int getPreferredWidth() { return getWidth(); } public int getColumnWidthByPosition(int columnPosition) { return columnWidthConfig.getSize(columnPosition); } public void setColumnWidthByPosition(int columnPosition, int width) { columnWidthConfig.setSize(columnPosition, width); fireLayerEvent(new ColumnResizeEvent(this, columnPosition)); } public void setDefaultColumnWidth(int width) { columnWidthConfig.setDefaultSize(width); } public void setDefaultColumnWidthByPosition(int columnPosition, int width) { columnWidthConfig.setDefaultSize(columnPosition, width); } // Column resize public boolean isColumnPositionResizable(int columnPosition) { return columnWidthConfig.isPositionResizable(columnPosition); } public void setColumnPositionResizable(int columnPosition, boolean resizable) { columnWidthConfig.setPositionResizable(columnPosition, resizable); } public void setColumnsResizableByDefault(boolean resizableByDefault) { columnWidthConfig.setResizableByDefault(resizableByDefault); } // Underlying public Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition) { return null; } // Vertical features // Rows public int getRowCount() { return dataProvider.getRowCount(); } public int getPreferredRowCount() { return getRowCount(); } /** * This is the root coordinate system, so the row index is always equal to the row position. */ public int getRowIndexByPosition(int rowPosition) { if (rowPosition >=0 && rowPosition < getRowCount()) { return rowPosition; } else { return -1; } } /** * This is the root coordinate system, so the row position is always equal to the row index. */ public int getRowPositionByIndex(int rowIndex) { if (rowIndex >= 0 && rowIndex < getRowCount()) { return rowIndex; } else { return -1; } } public int localToUnderlyingRowPosition(int localRowPosition) { return localRowPosition; } public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition) { return underlyingRowPosition; } public Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges) { return underlyingRowPositionRanges; } // Height public int getHeight() { return rowHeightConfig.getAggregateSize(getRowCount()); } public int getPreferredHeight() { return getHeight(); } public int getRowHeightByPosition(int rowPosition) { return rowHeightConfig.getSize(rowPosition); } /** * Set current row size without notify resize event; * @param row * @param height ; */ public void setRowHeightByPositionWithoutEvent(int rowPosition, int height) { rowHeightConfig.setSize(rowPosition, height); } public void setRowHeightByPosition(int rowPosition, int height) { rowHeightConfig.setSize(rowPosition, height); fireLayerEvent(new RowResizeEvent(this, rowPosition)); } public void setDefaultRowHeight(int height) { rowHeightConfig.setDefaultSize(height); } public void setDefaultRowHeightByPosition(int rowPosition, int height) { rowHeightConfig.setDefaultSize(rowPosition, height); } // Row resize public boolean isRowPositionResizable(int rowPosition) { return rowHeightConfig.isPositionResizable(rowPosition); } public void setRowPositionResizable(int rowPosition, boolean resizable) { rowHeightConfig.setPositionResizable(rowPosition, resizable); } public void setRowsResizableByDefault(boolean resizableByDefault) { rowHeightConfig.setResizableByDefault(resizableByDefault); } // Underlying public Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition) { return null; } // Cell features public Object getDataValueByPosition(int columnPosition, int rowPosition) { int columnIndex = getColumnIndexByPosition(columnPosition); int rowIndex = getRowIndexByPosition(rowPosition); return dataProvider.getDataValue(columnIndex, rowIndex); } public int getColumnPositionByX(int x) { return LayerUtil.getColumnPositionByX(this, x); } public int getRowPositionByY(int y) { return LayerUtil.getRowPositionByY(this, y); } public int getStartXOfColumnPosition(int columnPosition) { return columnWidthConfig.getAggregateSize(columnPosition); } public int getStartYOfRowPosition(int rowPosition) { return rowHeightConfig.getAggregateSize(rowPosition); } public ILayer getUnderlyingLayerByPosition(int columnPosition, int rowPosition) { return null; } }
9,508
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CompositeLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/CompositeLayer.java
package net.sourceforge.nattable.layer; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Properties; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.config.ConfigRegistry; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.cell.AggregrateConfigLabelAccumulator; import net.sourceforge.nattable.layer.cell.IConfigLabelAccumulator; import net.sourceforge.nattable.layer.cell.LayerCell; 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; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Rectangle; /** * A composite layer is a layer that is made up of a number of underlying child layers. This class assumes that the child * layers are laid out in a regular grid pattern where the child layers in each composite row all have the same number of * rows and the same height, and the child layers in each composite column each have the same number of columns and * the same width. */ public class CompositeLayer extends AbstractLayer { private final int layoutXCount; private final int layoutYCount; private final Map<ILayer, String> childLayerToRegionNameMap = new HashMap<ILayer, String>(); private final Map<String, IConfigLabelAccumulator> regionNameToConfigLabelAccumulatorMap = new HashMap<String, IConfigLabelAccumulator>(); private final Map<ILayer, LayoutCoordinate> childLayerToLayoutCoordinateMap = new HashMap<ILayer, LayoutCoordinate>(); /** Data struct. for child Layers */ private final ILayer[][] childLayerLayout; /** [X][Y] */ private ChildLayerInfo[][] childLayerInfos; private final CompositeLayerPainter compositeLayerPainter = new CompositeLayerPainter(); public CompositeLayer(int layoutXCount, int layoutYCount) { this.layoutXCount = layoutXCount; this.layoutYCount = layoutYCount; childLayerLayout = new ILayer[layoutXCount][layoutYCount]; } // Persistence @Override public void saveState(String prefix, Properties properties) { for (int layoutX = 0; layoutX < layoutXCount; layoutX++) { for (int layoutY = 0; layoutY < layoutYCount; layoutY++) { ILayer childLayer = childLayerLayout[layoutX][layoutY]; if (childLayer != null) { String regionName = childLayerToRegionNameMap.get(childLayer); childLayer.saveState(prefix + "." + regionName, properties); } } } super.saveState(prefix, properties); } @Override public void loadState(String prefix, Properties properties) { for (int layoutX = 0; layoutX < layoutXCount; layoutX++) { for (int layoutY = 0; layoutY < layoutYCount; layoutY++) { ILayer childLayer = childLayerLayout[layoutX][layoutY]; if (childLayer != null) { String regionName = childLayerToRegionNameMap.get(childLayer); childLayer.loadState(prefix + "." + regionName, properties); } } } super.loadState(prefix, properties); } // Configuration @Override public void configure(ConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry) { for (int layoutX = 0; layoutX < layoutXCount; layoutX++) { for (int layoutY = 0; layoutY < layoutYCount; layoutY++) { childLayerLayout[layoutX][layoutY].configure(configRegistry, uiBindingRegistry); } } super.configure(configRegistry, uiBindingRegistry); } @Override public ILayerPainter getLayerPainter() { return compositeLayerPainter; } /** * {@inheritDoc} * Handle commands */ @Override public boolean doCommand(ILayerCommand command) { if (super.doCommand(command)) { return true; } return doCommandOnChildLayers(command); } protected boolean doCommandOnChildLayers(ILayerCommand command) { for (ILayer childLayer : childLayerToLayoutCoordinateMap.keySet()) { ILayerCommand childCommand = command.cloneCommand(); if (childLayer.doCommand(childCommand)) { return true; } } return false; } // Events @Override public void handleLayerEvent(ILayerEvent event) { if (event instanceof IStructuralChangeEvent) { childLayerInfos = null; } super.handleLayerEvent(event); } // Horizontal features // Columns /** * @return total number of columns being displayed * Note: Works off the header layers. */ public int getColumnCount() { ChildLayerInfo lastChildLayerInfo = getChildLayerInfoByLayout(layoutXCount - 1, 0); return lastChildLayerInfo.getColumnPositionOffset() + lastChildLayerInfo.getLayer().getColumnCount(); } public int getPreferredColumnCount() { int preferredColumnCount = 0; for (int layoutX = 0; layoutX < layoutXCount; layoutX++) { preferredColumnCount += childLayerLayout[layoutX][0].getPreferredColumnCount(); } return preferredColumnCount; } /** * @param compositeColumnPosition Column position in the {@link CompositeLayer} * @return column index in the underlying layer. */ public int getColumnIndexByPosition(int compositeColumnPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByColumnPosition(compositeColumnPosition); if (childLayerInfo == null) { return -1; } int childColumnPosition = compositeColumnPosition - childLayerInfo.getColumnPositionOffset(); return childLayerInfo.getLayer().getColumnIndexByPosition(childColumnPosition); } public int localToUnderlyingColumnPosition(int localColumnPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByPosition(localColumnPosition, 0); if (childLayerInfo == null) { return -1; } return localColumnPosition - childLayerInfo.getColumnPositionOffset(); } public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByChildLayer(sourceUnderlyingLayer); if (childLayerInfo == null) { return -1; } return childLayerInfo.columnPositionOffset + underlyingColumnPosition; } public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) { ChildLayerInfo childLayerInfo = getChildLayerInfoByChildLayer(sourceUnderlyingLayer); if (childLayerInfo == null) { return null; } Collection<Range> localColumnPositionRanges = new ArrayList<Range>(); int offset = childLayerInfo.columnPositionOffset; for (Range underlyingColumnPositionRange : underlyingColumnPositionRanges) { localColumnPositionRanges.add(new Range(offset + underlyingColumnPositionRange.start, offset + underlyingColumnPositionRange.end)); } return localColumnPositionRanges; } // Width public int getWidth() { ChildLayerInfo lastChildLayerInfo = getChildLayerInfoByLayout(layoutXCount - 1, 0); return lastChildLayerInfo.getWidthOffset() + lastChildLayerInfo.getLayer().getWidth(); } public int getPreferredWidth() { int preferredWidth = 0; for (int layoutX = 0; layoutX < layoutXCount; layoutX++) { preferredWidth += childLayerLayout[layoutX][0].getPreferredWidth(); } return preferredWidth; } /** * @param compositeColumnPosition position in the composite layer. */ public int getColumnWidthByPosition(int compositeColumnPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByColumnPosition(compositeColumnPosition); if (childLayerInfo == null) { return -1; } int childColumnPosition = compositeColumnPosition - childLayerInfo.getColumnPositionOffset(); return childLayerInfo.getLayer().getColumnWidthByPosition(childColumnPosition); } // Column resize public boolean isColumnPositionResizable(int compositeColumnPosition) { //Only looks at the header ChildLayerInfo childLayerInfo = getChildLayerInfoByPosition(compositeColumnPosition, 0); if (childLayerInfo == null) { return false; } int childColumnPosition = compositeColumnPosition - childLayerInfo.getColumnPositionOffset(); return childLayerInfo.getLayer().isColumnPositionResizable(childColumnPosition); } // X /** * @param x pixel position - starts from 0 */ public int getColumnPositionByX(int x) { ChildLayerInfo childLayerInfo = getChildLayerInfoByX(x); if (childLayerInfo == null) { return -1; } int childX = x - childLayerInfo.getWidthOffset(); int childColumnPosition = childLayerInfo.getLayer().getColumnPositionByX(childX); return childLayerInfo.getColumnPositionOffset() + childColumnPosition; } public int getStartXOfColumnPosition(int columnPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByColumnPosition(columnPosition); if (childLayerInfo == null) { return -1; } int childColumnPosition = columnPosition - childLayerInfo.getColumnPositionOffset(); return childLayerInfo.getWidthOffset() + childLayerInfo.getLayer().getStartXOfColumnPosition(childColumnPosition); } // Underlying public Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition) { Collection<ILayer> underlyingLayers = new HashSet<ILayer>(); int layoutX = 0; while (layoutX < layoutXCount) { ChildLayerInfo childLayerInfo = getChildLayerInfoByLayout(layoutX, 0); if (columnPosition < childLayerInfo.getColumnPositionOffset() + childLayerInfo.getLayer().getColumnCount()) { break; } layoutX++; } if (layoutX >= layoutXCount) { return null; } int layoutY = 0; while (layoutY < layoutYCount) { ChildLayerInfo childLayerInfo = getChildLayerInfoByLayout(layoutX, layoutY); underlyingLayers.add(childLayerInfo.getLayer()); layoutY++; } return underlyingLayers; } // Vertical features // Rows public int getRowCount() { ChildLayerInfo lastChildLayerInfo = getChildLayerInfoByLayout(0, layoutYCount - 1); return lastChildLayerInfo.getRowPositionOffset() + lastChildLayerInfo.getLayer().getRowCount(); } public int getPreferredRowCount() { int preferredRowCount = 0; for (int layoutY = 0; layoutY < layoutYCount; layoutY++) { preferredRowCount += childLayerLayout[0][layoutY].getPreferredRowCount(); } return preferredRowCount; } public int getRowIndexByPosition(int compositeRowPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByRowPosition(compositeRowPosition); if (childLayerInfo == null) { return -1; } int childRowPosition = compositeRowPosition - childLayerInfo.getRowPositionOffset(); return childLayerInfo.getLayer().getRowIndexByPosition(childRowPosition); } public int localToUnderlyingRowPosition(int localRowPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByPosition(0, localRowPosition); if (childLayerInfo == null) { return -1; } return localRowPosition - childLayerInfo.getRowPositionOffset(); } public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByChildLayer(sourceUnderlyingLayer); if (childLayerInfo == null) { return -1; } return childLayerInfo.rowPositionOffset + underlyingRowPosition; } public Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges) { ChildLayerInfo childLayerInfo = getChildLayerInfoByChildLayer(sourceUnderlyingLayer); if (childLayerInfo == null) { return null; } Collection<Range> localRowPositionRanges = new ArrayList<Range>(); int offset = childLayerInfo.rowPositionOffset; for (Range underlyingRowPositionRange : underlyingRowPositionRanges) { localRowPositionRanges.add(new Range(offset + underlyingRowPositionRange.start, offset + underlyingRowPositionRange.end)); } return localRowPositionRanges; } // Height public int getHeight() { ChildLayerInfo lastChildLayerInfo = getChildLayerInfoByLayout(0, layoutYCount - 1); return lastChildLayerInfo.getHeightOffset() + lastChildLayerInfo.getLayer().getHeight(); } public int getPreferredHeight() { int preferredHeight = 0; for (int layoutY = 0; layoutY < layoutYCount; layoutY++) { preferredHeight += childLayerLayout[0][layoutY].getPreferredHeight(); } return preferredHeight; } public int getRowHeightByPosition(int compositeRowPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByRowPosition(compositeRowPosition); if (childLayerInfo == null) { return -1; } int childRowPosition = compositeRowPosition - childLayerInfo.getRowPositionOffset(); return childLayerInfo.getLayer().getRowHeightByPosition(childRowPosition); } // Row resize /** * @return false if the row position is out of bounds */ public boolean isRowPositionResizable(int compositeRowPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByPosition(0, compositeRowPosition); if (childLayerInfo == null) { return false; } int childRowPosition = compositeRowPosition - childLayerInfo.getRowPositionOffset(); return childLayerInfo.getLayer().isRowPositionResizable(childRowPosition); } // Y /** * Get the <i>row</i> position relative to the layer the containing coordinate y. * @param x Mouse event Y position. */ public int getRowPositionByY(int y) { ChildLayerInfo childLayerInfo = getChildLayerInfoByXY(0, y); if (childLayerInfo == null) { return -1; } int childY = y - childLayerInfo.getHeightOffset(); int childRowPosition = childLayerInfo.getLayer().getRowPositionByY(childY); return childLayerInfo.getRowPositionOffset() + childRowPosition; } public int getStartYOfRowPosition(int rowPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByRowPosition(rowPosition); if (childLayerInfo == null) { return -1; } int childRowPosition = rowPosition - childLayerInfo.getRowPositionOffset(); return childLayerInfo.getHeightOffset() + childLayerInfo.getLayer().getStartYOfRowPosition(childRowPosition); } public Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition) { Collection<ILayer> underlyingLayers = new HashSet<ILayer>(); int columnPosition = 0; ChildLayerInfo childLayerInfo = getChildLayerInfoByPosition(columnPosition, rowPosition); while (childLayerInfo != null) { ILayer childLayer = childLayerInfo.getLayer(); underlyingLayers.add(childLayer); columnPosition += childLayer.getColumnCount(); childLayerInfo = getChildLayerInfoByPosition(columnPosition, rowPosition); } return underlyingLayers; } // Cell features @Override public LayerCell getCellByPosition(int compositeColumnPosition, int compositeRowPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByPosition(compositeColumnPosition, compositeRowPosition); if (childLayerInfo == null) { return null; } ILayer childLayer = childLayerInfo.getLayer(); int childColumnPosition = compositeColumnPosition - childLayerInfo.getColumnPositionOffset(); int childRowPosition = compositeRowPosition - childLayerInfo.getRowPositionOffset(); final LayerCell cell = childLayer.getCellByPosition(childColumnPosition, childRowPosition); if (cell != null) { cell.updatePosition( this, underlyingToLocalColumnPosition(childLayer, cell.getOriginColumnPosition()), underlyingToLocalRowPosition(childLayer, cell.getOriginRowPosition()), underlyingToLocalColumnPosition(childLayer, cell.getColumnPosition()), underlyingToLocalRowPosition(childLayer, cell.getRowPosition()) ); } return cell; } @Override public Rectangle getBoundsByPosition(int compositeColumnPosition, int compositeRowPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByPosition(compositeColumnPosition, compositeRowPosition); if (childLayerInfo == null) { return null; } ILayer childLayer = childLayerInfo.getLayer(); int childColumnPosition = compositeColumnPosition - childLayerInfo.getColumnPositionOffset(); int childRowPosition = compositeRowPosition - childLayerInfo.getRowPositionOffset(); final Rectangle bounds = childLayer.getBoundsByPosition(childColumnPosition, childRowPosition); if (bounds != null) { bounds.x += childLayerInfo.widthOffset; bounds.y += childLayerInfo.heightOffset; } return bounds; } /** * @return Rectangle bounding the cell position * x - pixel position of the top left of the rectangle * y - pixel position of the top left of the rectangle * width - in pixels * height - in pixels * Note - All values are -1 for a position out of bounds. */ public Rectangle getCellBounds(int compositeRowPosition, int compositeColumnPosition) { final Rectangle rectangle = new Rectangle(0, 0, 0, 0); rectangle.width = getColumnWidthByPosition(compositeColumnPosition); rectangle.height = getRowHeightByPosition(compositeRowPosition); rectangle.x = getStartXOfColumnPosition(compositeColumnPosition); rectangle.y = getStartYOfRowPosition(compositeRowPosition); return rectangle; } @Override public String getDisplayModeByPosition(int compositeColumnPosition, int compositeRowPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByPosition(compositeColumnPosition, compositeRowPosition); if (childLayerInfo == null) { return super.getDisplayModeByPosition(compositeColumnPosition, compositeRowPosition); } return childLayerInfo.getLayer().getDisplayModeByPosition( compositeColumnPosition - childLayerInfo.getColumnPositionOffset(), compositeRowPosition - childLayerInfo.getRowPositionOffset()); } @Override public LabelStack getConfigLabelsByPosition(int compositeColumnPosition, int compositeRowPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByPosition(compositeColumnPosition, compositeRowPosition); if (childLayerInfo == null) { return new LabelStack(); } ILayer childLayer = childLayerInfo.getLayer(); int childColumnPosition = compositeColumnPosition - childLayerInfo.getColumnPositionOffset(); int childRowPosition = compositeRowPosition - childLayerInfo.getRowPositionOffset(); LabelStack configLabels = childLayer.getConfigLabelsByPosition(childColumnPosition, childRowPosition); String regionName = childLayerToRegionNameMap.get(childLayer); IConfigLabelAccumulator configLabelAccumulator = regionNameToConfigLabelAccumulatorMap.get(regionName); if (configLabelAccumulator != null) { configLabelAccumulator.accumulateConfigLabels(configLabels, childColumnPosition, childRowPosition); } configLabels.addLabel(regionName); return configLabels; } public Object getDataValueByPosition(int compositeColumnPosition, int compositeRowPosition) { ChildLayerInfo childLayerInfo = getChildLayerInfoByPosition(compositeColumnPosition, compositeRowPosition); if (childLayerInfo == null) { return Integer.valueOf(-1); } return childLayerInfo.getLayer().getDataValueByPosition( compositeColumnPosition - childLayerInfo.getColumnPositionOffset(), compositeRowPosition - childLayerInfo.getRowPositionOffset()); } // Child layer stuff public void setChildLayer(String regionName, ILayer childLayer, final int layoutX, final int layoutY) { if (childLayer == null) { throw new IllegalArgumentException("Cannot set null child layer"); } childLayerToRegionNameMap.put(childLayer, regionName); childLayer.addLayerListener(this); childLayerToLayoutCoordinateMap.put(childLayer, new LayoutCoordinate(layoutX, layoutY)); childLayerLayout[layoutX][layoutY] = childLayer; childLayer.setClientAreaProvider(new IClientAreaProvider() { public Rectangle getClientArea() { return getChildClientArea(layoutX, layoutY); } }); } public IConfigLabelAccumulator getConfigLabelAccumulatorByRegionName(String regionName) { return regionNameToConfigLabelAccumulatorMap.get(regionName); } /** * Sets the IConfigLabelAccumulator for the given named region. Replaces any existing IConfigLabelAccumulator. */ public void setConfigLabelAccumulatorForRegion(String regionName, IConfigLabelAccumulator configLabelAccumulator) { regionNameToConfigLabelAccumulatorMap.put(regionName, configLabelAccumulator); } /** * Adds the configLabelAccumulator to the existing label accumulators. */ public void addConfigLabelAccumulatorForRegion(String regionName, IConfigLabelAccumulator configLabelAccumulator) { IConfigLabelAccumulator existingConfigLabelAccumulator = regionNameToConfigLabelAccumulatorMap.get(regionName); AggregrateConfigLabelAccumulator aggregateAccumulator; if (existingConfigLabelAccumulator instanceof AggregrateConfigLabelAccumulator) { aggregateAccumulator = (AggregrateConfigLabelAccumulator) existingConfigLabelAccumulator; } else { aggregateAccumulator = new AggregrateConfigLabelAccumulator(); aggregateAccumulator.add(existingConfigLabelAccumulator); regionNameToConfigLabelAccumulatorMap.put(regionName, aggregateAccumulator); } aggregateAccumulator.add(configLabelAccumulator); } private Rectangle getChildClientArea(final int layoutX, final int layoutY) { final ChildLayerInfo childLayerInfo = getChildLayerInfoByLayout(layoutX, layoutY); final Rectangle compositeClientArea = getClientAreaProvider().getClientArea(); final Rectangle childClientArea = new Rectangle( compositeClientArea.x + childLayerInfo.getWidthOffset(), compositeClientArea.y + childLayerInfo.getHeightOffset(), childLayerInfo.getLayer().getPreferredWidth(), childLayerInfo.getLayer().getPreferredHeight()); final Rectangle intersection = compositeClientArea.intersection(childClientArea); return intersection; } /** * @param layoutX col position in the CompositeLayer * @param layoutY row position in the CompositeLayer * @return child layer according to the Composite Layer Layout */ public ILayer getChildLayerByLayoutCoordinate(int layoutX, int layoutY) { return childLayerLayout[layoutX][layoutY]; } /** * Child layer at the specified pixel position * @param x pixel value * @param y pixel value * @return <i>null</i> if the pixel position is out of bounds. */ public ILayer getChildLayerByXY(int x, int y) { ChildLayerInfo childLayerInfo = getChildLayerInfoByXY(x, y); return (childLayerInfo == null) ? null : childLayerInfo.getLayer(); } /** * @param x pixel position * @param y pixel position * @return Region which the given position is in */ @Override public LabelStack getRegionLabelsByXY(int x, int y) { ChildLayerInfo childLayerInfo = getChildLayerInfoByXY(x, y); if (childLayerInfo == null) { return null; } ILayer childLayer = childLayerInfo.getLayer(); int childX = x - childLayerInfo.getWidthOffset(); int childY = y - childLayerInfo.getHeightOffset(); LabelStack regionLabels = childLayer.getRegionLabelsByXY(childX, childY); String regionName = childLayerToRegionNameMap.get(childLayer); regionLabels.addLabel(regionName); return regionLabels; } public ILayer getUnderlyingLayerByPosition(int columnPosition, int rowPosition) { return getChildLayerInfoByPosition(columnPosition, rowPosition).getLayer(); } // Child layer info private ChildLayerInfo getChildLayerInfoByXY(int x, int y) { int layoutX = 0; while (layoutX < layoutXCount) { ChildLayerInfo childLayerInfo = getChildLayerInfoByLayout(layoutX, 0); if (childLayerInfo == null) { return null; } if (x < childLayerInfo.getWidthOffset() + childLayerInfo.getLayer().getWidth()) { break; } layoutX++; } int layoutY = 0; while (layoutY < layoutYCount) { ChildLayerInfo childLayerInfo = getChildLayerInfoByLayout(layoutX, layoutY); if (childLayerInfo == null) { return null; } if (y < childLayerInfo.getHeightOffset() + childLayerInfo.getLayer().getHeight()) { return childLayerInfo; } layoutY++; } return null; } private ChildLayerInfo getChildLayerInfoByX(int x) { int layoutX = 0; while (layoutX < layoutXCount) { ChildLayerInfo childLayerInfo = getChildLayerInfoByLayout(layoutX, 0); if (childLayerInfo == null) { return null; } if (x < childLayerInfo.getWidthOffset() + childLayerInfo.getLayer().getWidth()) { return childLayerInfo; } layoutX++; } return null; } protected ChildLayerInfo getChildLayerInfoByColumnPosition(int compositeColumnPosition) { int layoutX = 0; while (layoutX < layoutXCount) { ChildLayerInfo childLayerInfo = getChildLayerInfoByLayout(layoutX, 0); if (compositeColumnPosition < childLayerInfo.getColumnPositionOffset() + childLayerInfo.getLayer().getColumnCount()) { return childLayerInfo; } layoutX++; } return null; } protected ChildLayerInfo getChildLayerInfoByRowPosition(int compositeRowPosition) { int layoutY = 0; while (layoutY < layoutYCount) { ChildLayerInfo childLayerInfo = getChildLayerInfoByLayout(0, layoutY); if (compositeRowPosition < childLayerInfo.getRowPositionOffset() + childLayerInfo.getLayer().getRowCount()) { return childLayerInfo; } layoutY++; } return null; } protected ChildLayerInfo getChildLayerInfoByPosition(int compositeColumnPosition, int compositeRowPosition) { int layoutX = 0; while (layoutX < layoutXCount) { ChildLayerInfo childLayerInfo = getChildLayerInfoByLayout(layoutX, 0); if (compositeColumnPosition < childLayerInfo.getColumnPositionOffset() + childLayerInfo.getLayer().getColumnCount()) { break; } layoutX++; } if (layoutX >= layoutXCount) { return null; } int layoutY = 0; while (layoutY < layoutYCount) { ChildLayerInfo childLayerInfo = getChildLayerInfoByLayout(layoutX, layoutY); if (compositeRowPosition < childLayerInfo.getRowPositionOffset() + childLayerInfo.getLayer().getRowCount()) { return childLayerInfo; } layoutY++; } return null; } protected ChildLayerInfo getChildLayerInfoByLayout(int layoutX, int layoutY) { if (layoutX >= layoutXCount || layoutY >= layoutYCount) { return null; } if (childLayerInfos == null) { populateChildLayerInfos(); } return childLayerInfos[layoutX][layoutY]; } protected ChildLayerInfo getChildLayerInfoByChildLayer(ILayer childLayer) { for (int layoutX = 0; layoutX < layoutXCount; layoutX++) { for (int layoutY = 0; layoutY < layoutYCount; layoutY++) { if (childLayer == childLayerLayout[layoutX][layoutY]) { return getChildLayerInfoByLayout(layoutX, layoutY); } } } return null; } /** * * @param isPositionMode flag indicating - search for child layer by position or X/Y values. * @param compositeColumnPositionOrX Composite layer column position or X pixel value * @param compositeRowPositionOrY Composite layer row position or Y pixel value * * @return <i>null</i> if the position or X/y values are outside layer bounds. */ protected void populateChildLayerInfos() { childLayerInfos = new ChildLayerInfo[layoutXCount][layoutYCount]; int columnPositionOffset = 0; int widthOffset = 0; for (int layoutX = 0; layoutX < layoutXCount; layoutX++) { int rowPositionOffset = 0; int heightOffset = 0; for (int layoutY = 0; layoutY < layoutYCount; layoutY++) { ILayer childLayer = childLayerLayout[layoutX][layoutY]; childLayerInfos[layoutX][layoutY] = new ChildLayerInfo(childLayer, columnPositionOffset, rowPositionOffset, widthOffset, heightOffset); if (layoutY < layoutYCount - 1) { rowPositionOffset += childLayer.getRowCount(); heightOffset += childLayer.getHeight(); } } if (layoutX < layoutXCount - 1) { ILayer childLayer = childLayerLayout[layoutX][0]; columnPositionOffset += childLayer.getColumnCount(); widthOffset += childLayer.getWidth(); } } } protected static final class ChildLayerInfo { private final ILayer layer; private final int columnPositionOffset; private final int rowPositionOffset; private final int widthOffset; private final int heightOffset; public ChildLayerInfo( ILayer layer, int columnPositionOffset, int rowPositionOffset, int widthOffset, int heightOffset) { this.layer = layer; this.columnPositionOffset = columnPositionOffset; this.rowPositionOffset = rowPositionOffset; this.widthOffset = widthOffset; this.heightOffset = heightOffset; } public ILayer getLayer() { return layer; } public int getColumnPositionOffset() { return columnPositionOffset; } public int getRowPositionOffset() { return rowPositionOffset; } public int getWidthOffset() { return widthOffset; } public int getHeightOffset() { return heightOffset; } } protected class CompositeLayerPainter implements ILayerPainter { public void paintLayer(ILayer natLayer, GC gc, int xOffset, int yOffset, Rectangle rectangle, IConfigRegistry configuration) { int x = xOffset; for (int layoutX = 0; layoutX < layoutXCount; layoutX++) { int y = yOffset; for (int layoutY = 0; layoutY < layoutYCount; layoutY++) { ILayer childLayer = childLayerLayout[layoutX][layoutY]; Rectangle childLayerRectangle = new Rectangle(x, y, childLayer.getWidth(), childLayer.getHeight()); childLayerRectangle = rectangle.intersection(childLayerRectangle); Rectangle originalClipping = gc.getClipping(); gc.setClipping(childLayerRectangle); childLayer.getLayerPainter().paintLayer(natLayer, gc, x, y, childLayerRectangle, configuration); gc.setClipping(originalClipping); y += childLayer.getHeight(); } x += childLayerLayout[layoutX][0].getWidth(); } } public Rectangle adjustCellBounds(Rectangle cellBounds) { ChildLayerInfo childLayerInfo = getChildLayerInfoByXY(cellBounds.x, cellBounds.y); int widthOffset = childLayerInfo.getWidthOffset(); int heightOffset = childLayerInfo.getHeightOffset(); cellBounds.x -= widthOffset; cellBounds.y -= heightOffset; Rectangle adjustedChildCellBounds = childLayerInfo.getLayer().getLayerPainter().adjustCellBounds(cellBounds); adjustedChildCellBounds.x += widthOffset; adjustedChildCellBounds.y += heightOffset; return adjustedChildCellBounds; } } }
31,176
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ILayerListener.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/ILayerListener.java
package net.sourceforge.nattable.layer; import net.sourceforge.nattable.layer.event.ILayerEvent; /** * Object interested in receiving events related to a {@link ILayer}. */ public interface ILayerListener { /** * Handle an event notification from an {@link ILayer} */ public void handleLayerEvent(ILayerEvent event); }
364
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/AbstractLayer.java
package net.sourceforge.nattable.layer; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.command.ILayerCommandHandler; import net.sourceforge.nattable.config.ConfigRegistry; import net.sourceforge.nattable.config.IConfiguration; import net.sourceforge.nattable.layer.cell.IConfigLabelAccumulator; import net.sourceforge.nattable.layer.cell.LayerCell; import net.sourceforge.nattable.layer.event.ILayerEvent; import net.sourceforge.nattable.layer.event.ILayerEventHandler; import net.sourceforge.nattable.painter.layer.GridLineCellLayerPainter; import net.sourceforge.nattable.painter.layer.ILayerPainter; import net.sourceforge.nattable.persistence.IPersistable; import net.sourceforge.nattable.style.DisplayMode; import net.sourceforge.nattable.ui.binding.UiBindingRegistry; import net.sourceforge.nattable.util.IClientAreaProvider; import org.eclipse.swt.graphics.Rectangle; /** * Base layer implementation with common methods for managing listeners and caching, etc. */ public abstract class AbstractLayer implements ILayer { private String regionName; protected ILayerPainter layerPainter; private IClientAreaProvider clientAreaProvider = IClientAreaProvider.DEFAULT; private IConfigLabelAccumulator configLabelAccumulator; private final Map<Class<? extends ILayerCommand>, ILayerCommandHandler<? extends ILayerCommand>> commandHandlers = new LinkedHashMap<Class<? extends ILayerCommand>, ILayerCommandHandler<? extends ILayerCommand>>(); private final Map<Class<? extends ILayerEvent>, ILayerEventHandler<? extends ILayerEvent>> eventHandlers = new HashMap<Class<? extends ILayerEvent>, ILayerEventHandler<? extends ILayerEvent>>(); private final List<IPersistable> persistables = new LinkedList<IPersistable>(); private final Set<ILayerListener> listeners = new LinkedHashSet<ILayerListener>(); private final Collection<IConfiguration> configurations = new LinkedList<IConfiguration>(); // Regions public LabelStack getRegionLabelsByXY(int x, int y) { LabelStack regionLabels = new LabelStack(); if (regionName != null) { regionLabels.addLabel(regionName); } return regionLabels; } public String getRegionName() { return regionName; } public void setRegionName(String regionName) { this.regionName = regionName; } // Config lables public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) { LabelStack configLabels = new LabelStack(); if (configLabelAccumulator != null) { configLabelAccumulator.accumulateConfigLabels(configLabels, columnPosition, rowPosition); } if (regionName != null) { configLabels.addLabel(regionName); } return configLabels; } public IConfigLabelAccumulator getConfigLabelAccumulator() { return configLabelAccumulator; } public void setConfigLabelAccumulator(IConfigLabelAccumulator cellLabelAccumulator) { this.configLabelAccumulator = cellLabelAccumulator; } // Persistence public void saveState(String prefix, Properties properties) { for (IPersistable persistable : persistables) { persistable.saveState(prefix, properties); } } public void loadState(String prefix, Properties properties) { for (IPersistable persistable : persistables) { persistable.loadState(prefix, properties); } } public void registerPersistable(IPersistable persistable){ persistables.add(persistable); } public void unregisterPersistable(IPersistable persistable){ persistables.remove(persistable); } // Configuration public void addConfiguration(IConfiguration configuration) { configurations.add(configuration); } public void clearConfiguration() { configurations.clear(); } public void configure(ConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry) { for (IConfiguration configuration : configurations) { configuration.configureLayer(this); configuration.configureRegistry(configRegistry); configuration.configureUiBindings(uiBindingRegistry); } } // Commands @SuppressWarnings("unchecked") public boolean doCommand(ILayerCommand command) { for (Class<? extends ILayerCommand> commandClass : commandHandlers.keySet()) { if (commandClass.isInstance(command)) { ILayerCommandHandler commandHandler = commandHandlers.get(commandClass); if (commandHandler.doCommand(this, command)) { return true; } } } return false; } // Command handlers public void registerCommandHandler(ILayerCommandHandler<?> commandHandler) { commandHandlers.put(commandHandler.getCommandClass(), commandHandler); } public void unregisterCommandHandler(Class<? extends ILayerCommand> commandClass) { commandHandlers.remove(commandClass); } // Events public void addLayerListener(ILayerListener listener) { listeners.add(listener); } public void removeLayerListener(ILayerListener listener) { listeners.remove(listener); } /** * Handle layer event notification. Convert it to your context * and propagate <i>UP</i>. * * If you override this method you <strong>MUST NOT FORGET</strong> to raise * the event up the layer stack by calling <code>super.fireLayerEvent(event)</code> * - unless you plan to eat the event yourself. **/ @SuppressWarnings("unchecked") public void handleLayerEvent(ILayerEvent event) { for (Class<? extends ILayerEvent> eventClass : eventHandlers.keySet()) { if (eventClass.isInstance(event)) { ILayerEventHandler eventHandler = eventHandlers.get(eventClass); eventHandler.handleLayerEvent(event); } } // Pass on the event to our parent if (event.convertToLocal(this)) { fireLayerEvent(event); } } public void registerEventHandler(ILayerEventHandler<?> eventHandler) { eventHandlers.put(eventHandler.getLayerEventClass(), eventHandler); } /** * Pass the event to all the {@link ILayerListener} registered on this layer. * A cloned copy is passed to each listener. */ public void fireLayerEvent(ILayerEvent event) { if (listeners.size() > 0) { Iterator<ILayerListener> it = listeners.iterator(); boolean isLastListener = false; do { ILayerListener l = it.next(); isLastListener = !it.hasNext(); // Lookahead // Fire cloned event to first n-1 listeners; fire original event to last listener ILayerEvent eventToFire = isLastListener ? event : event.cloneEvent(); // System.out.println("eventToFire="+eventToFire); l.handleLayerEvent(eventToFire); } while (!isLastListener); } } /** * @return {@link ILayerPainter}. Defaults to {@link GridLineCellLayerPainter} */ public ILayerPainter getLayerPainter() { if (layerPainter == null) { layerPainter = new GridLineCellLayerPainter(); } return layerPainter; } protected void setLayerPainter(ILayerPainter layerPainter) { this.layerPainter = layerPainter; } // Client area public IClientAreaProvider getClientAreaProvider() { return clientAreaProvider; } public void setClientAreaProvider(IClientAreaProvider clientAreaProvider) { this.clientAreaProvider = clientAreaProvider; } @Override public String toString() { return getClass().getSimpleName(); } public LayerCell getCellByPosition(int columnPosition, int rowPosition) { if (columnPosition < 0 || columnPosition >= getColumnCount() || rowPosition < 0 || rowPosition >= getRowCount()) { return null; } return new LayerCell(this, columnPosition, rowPosition); } public Rectangle getBoundsByPosition(int columnPosition, int rowPosition) { LayerCell cell = getCellByPosition(columnPosition, rowPosition); ILayer cellLayer = cell.getLayer(); int originColumnPosition = cell.getOriginColumnPosition(); int originRowPosition = cell.getOriginRowPosition(); int x = cellLayer.getStartXOfColumnPosition(originColumnPosition); int y = cellLayer.getStartYOfRowPosition(originRowPosition); int width = 0; for (int i = 0; i < cell.getColumnSpan(); i++) { width += cellLayer.getColumnWidthByPosition(originColumnPosition + i); } int height = 0; for (int i = 0; i < cell.getRowSpan(); i++) { height += cellLayer.getRowHeightByPosition(originRowPosition + i); } return new Rectangle(x, y, width, height); } public String getDisplayModeByPosition(int columnPosition, int rowPosition) { return DisplayMode.NORMAL; } }
8,869
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DummyGridLayerStack.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/stack/DummyGridLayerStack.java
package net.sourceforge.nattable.layer.stack; import net.sourceforge.nattable.data.IDataProvider; import net.sourceforge.nattable.grid.data.DefaultCornerDataProvider; import net.sourceforge.nattable.grid.data.DefaultRowHeaderDataProvider; import net.sourceforge.nattable.grid.data.DummyBodyDataProvider; import net.sourceforge.nattable.grid.data.DummyColumnHeaderDataProvider; import net.sourceforge.nattable.grid.layer.DefaultGridLayer; public class DummyGridLayerStack extends DefaultGridLayer { public DummyGridLayerStack() { this(20, 20); } public DummyGridLayerStack(int columnCount, int rowCount) { super(true); IDataProvider bodyDataProvider = new DummyBodyDataProvider(columnCount, rowCount); IDataProvider columnHeaderDataProvider = new DummyColumnHeaderDataProvider(bodyDataProvider); IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider); IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider); init(bodyDataProvider, columnHeaderDataProvider, rowHeaderDataProvider, cornerDataProvider); } }
1,151
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnGroupBodyLayerStack.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/stack/ColumnGroupBodyLayerStack.java
package net.sourceforge.nattable.layer.stack; import net.sourceforge.nattable.copy.command.CopyDataCommandHandler; import net.sourceforge.nattable.group.ColumnGroupExpandCollapseLayer; import net.sourceforge.nattable.group.ColumnGroupModel; import net.sourceforge.nattable.group.ColumnGroupReorderLayer; import net.sourceforge.nattable.hideshow.ColumnHideShowLayer; import net.sourceforge.nattable.layer.AbstractLayerTransform; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.reorder.ColumnReorderLayer; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.viewport.ViewportLayer; /** * A pre-configured layer stack which includes the following layers (in that order):<br/> * <ol> * <li>ColumnReorderLayer</li> * <li>ColumnGroupReorderLayer</li> * <li>ColumnHideShowLayer</li> * <li>ColumnGroupExpandCollapseLayer</li> * <li>SelectionLayer</li> * <li>ViewportLayer</li> * </ol> */ public class ColumnGroupBodyLayerStack extends AbstractLayerTransform { private ColumnReorderLayer columnReorderLayer; private ColumnGroupReorderLayer columnGroupReorderLayer; private ColumnHideShowLayer columnHideShowLayer; private ColumnGroupExpandCollapseLayer columnGroupExpandCollapseLayer; private SelectionLayer selectionLayer; private ViewportLayer viewportLayer; public ColumnGroupBodyLayerStack(IUniqueIndexLayer underlyingLayer, ColumnGroupModel columnGroupModel) { columnReorderLayer = new ColumnReorderLayer(underlyingLayer); columnGroupReorderLayer = new ColumnGroupReorderLayer(columnReorderLayer, columnGroupModel); columnHideShowLayer = new ColumnHideShowLayer(columnGroupReorderLayer); columnGroupExpandCollapseLayer = new ColumnGroupExpandCollapseLayer(columnHideShowLayer, columnGroupModel); selectionLayer = new SelectionLayer(columnGroupExpandCollapseLayer); viewportLayer = new ViewportLayer(selectionLayer); setUnderlyingLayer(viewportLayer); registerCommandHandler(new CopyDataCommandHandler(selectionLayer)); } public ColumnReorderLayer getColumnReorderLayer() { return columnReorderLayer; } public ColumnGroupReorderLayer getColumnGroupReorderLayer() { return columnGroupReorderLayer; } public ColumnHideShowLayer getColumnHideShowLayer() { return columnHideShowLayer; } public ColumnGroupExpandCollapseLayer getColumnGroupExpandCollapseLayer() { return columnGroupExpandCollapseLayer; } public SelectionLayer getSelectionLayer() { return selectionLayer; } public ViewportLayer getViewportLayer() { return viewportLayer; } }
2,651
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultBodyLayerStack.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/stack/DefaultBodyLayerStack.java
package net.sourceforge.nattable.layer.stack; import net.sourceforge.nattable.copy.command.CopyDataCommandHandler; import net.sourceforge.nattable.hideshow.ColumnHideShowLayer; import net.sourceforge.nattable.layer.AbstractLayerTransform; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.reorder.ColumnReorderLayer; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.util.IClientAreaProvider; import net.sourceforge.nattable.viewport.ViewportLayer; public class DefaultBodyLayerStack extends AbstractLayerTransform { private final ColumnReorderLayer columnReorderLayer; private final ColumnHideShowLayer columnHideShowLayer; private final SelectionLayer selectionLayer; private final ViewportLayer viewportLayer; public DefaultBodyLayerStack(IUniqueIndexLayer underlyingLayer) { columnReorderLayer = new ColumnReorderLayer(underlyingLayer); columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer); selectionLayer = new SelectionLayer(columnHideShowLayer); viewportLayer = new ViewportLayer(selectionLayer); setUnderlyingLayer(viewportLayer); registerCommandHandler(new CopyDataCommandHandler(selectionLayer)); } @Override public void setClientAreaProvider(IClientAreaProvider clientAreaProvider) { super.setClientAreaProvider(clientAreaProvider); } public ColumnReorderLayer getColumnReorderLayer() { return columnReorderLayer; } public ColumnHideShowLayer getColumnHideShowLayer() { return columnHideShowLayer; } public SelectionLayer getSelectionLayer() { return selectionLayer; } public ViewportLayer getViewportLayer() { return viewportLayer; } }
1,738
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
IConfigLabelAccumulator.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/cell/IConfigLabelAccumulator.java
package net.sourceforge.nattable.layer.cell; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.layer.LabelStack; /** * Resolves the configuration/config label(s) which are tied to a given cell.<br/> * Various attributes can be registered in the {@link IConfigRegistry} against this</br> * label</br> */ public interface IConfigLabelAccumulator { /** * Add labels applicable to this cell position * @param configLabels the labels currently applied to the cell. The labels contributed by this * provider must be <i>added</i> to this stack * @param columnPosition of the cell for which labels are being gathered * @param rowPosition of the cell for which labels are being gathered */ public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition); }
867
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowOverrideLabelAccumulator.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/cell/RowOverrideLabelAccumulator.java
package net.sourceforge.nattable.layer.cell; import java.io.Serializable; import net.sourceforge.nattable.data.IRowDataProvider; import net.sourceforge.nattable.data.IRowIdAccessor; import net.sourceforge.nattable.layer.LabelStack; /** * @see ColumnOverrideLabelAccumulator * @param <T> type of the bean used as the data source for a row */ public class RowOverrideLabelAccumulator<T> extends AbstractOverrider { private IRowDataProvider<T> dataProvider; private IRowIdAccessor<T> idAccessor; public RowOverrideLabelAccumulator(IRowDataProvider<T> dataProvider, IRowIdAccessor<T> idAccessor) { this.dataProvider = dataProvider; this.idAccessor = idAccessor; } public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) { for (String configLabel : getOverrides(idAccessor.getRowId(dataProvider.getRowObject(rowPosition)))) { configLabels.addLabel(configLabel); } } public void registerOverrides(int rowIndex, String...configLabels) { Serializable id = idAccessor.getRowId(dataProvider.getRowObject(rowIndex)); registerOverrides(id, configLabels); } }
1,160
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DataCell.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/cell/DataCell.java
package net.sourceforge.nattable.layer.cell; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; public class DataCell { protected int columnPosition; protected int rowPosition; protected int columnSpan; protected int rowSpan; public DataCell(int columnPosition, int rowPosition) { this(columnPosition, rowPosition, 1, 1); } public DataCell(int columnPosition, int rowPosition, int columnSpan, int rowSpan) { this.columnPosition = columnPosition; this.rowPosition = rowPosition; this.columnSpan = columnSpan; this.rowSpan = rowSpan; } public int getColumnPosition() { return columnPosition; } public int getRowPosition() { return rowPosition; } public int getColumnSpan() { return columnSpan; } public int getRowSpan() { return rowSpan; } public boolean isSpannedCell() { return columnSpan > 1 || rowSpan > 1; } @Override public boolean equals(Object obj) { if (obj instanceof DataCell == false) { return false; } if (this == obj) { return true; } DataCell rhs = (DataCell) obj; return new EqualsBuilder() .append(columnPosition, rhs.columnPosition) .append(rowPosition, rhs.rowPosition) .append(columnSpan, rhs.columnSpan) .append(rowSpan, rhs.rowSpan) .isEquals(); } @Override public int hashCode() { return new HashCodeBuilder(423, 971) .append(columnPosition) .append(rowPosition) .append(columnSpan) .append(rowSpan) .toHashCode(); } }
1,595
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
BodyOverrideConfigLabelAccumulator.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/cell/BodyOverrideConfigLabelAccumulator.java
package net.sourceforge.nattable.layer.cell; import java.util.Arrays; import java.util.List; import net.sourceforge.nattable.layer.LabelStack; /** * Applies the given labels to all the cells in the grid.<br/> * Used to apply styles to the entire grid. */ public class BodyOverrideConfigLabelAccumulator implements IConfigLabelAccumulator { private List<String> configLabels; public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) { configLabels.getLabels().addAll(this.configLabels); } public void registerOverrides(String... configLabels) { this.configLabels = Arrays.asList(configLabels); } public void addOverride(String configLabel) { this.configLabels.add(configLabel); } }
773
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
LayerCell.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/cell/LayerCell.java
package net.sourceforge.nattable.layer.cell; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.LabelStack; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.eclipse.swt.graphics.Rectangle; public class LayerCell { private ILayer layer; private int columnPosition; private int rowPosition; private ILayer sourceLayer; private int originColumnPosition; private int originRowPosition; private int columnSpan; private int rowSpan; private boolean isDisplayModeCached = false; private String displayMode = null; private boolean isConfigLabelsCached = false; private LabelStack configLabels = null; private boolean isDataValueCached = false; private Object dataValue = null; private boolean isBoundsCached = false; private Rectangle bounds = null; public LayerCell(ILayer layer, int columnPosition, int rowPosition, DataCell cell) { this(layer, cell.columnPosition, cell.rowPosition, columnPosition, rowPosition, cell.columnSpan, cell.rowSpan); } public LayerCell(ILayer layer, int columnPosition, int rowPosition) { this(layer, columnPosition, rowPosition, columnPosition, rowPosition, 1, 1); } public LayerCell(ILayer layer, int originColumnPosition, int originRowPosition, int columnPosition, int rowPosition, int columnSpan, int rowSpan) { this.sourceLayer = layer; this.originColumnPosition = originColumnPosition; this.originRowPosition = originRowPosition; this.layer = layer; this.columnPosition = columnPosition; this.rowPosition = rowPosition; this.columnSpan = columnSpan; this.rowSpan = rowSpan; } private boolean isReadMode() { return isDisplayModeCached || isConfigLabelsCached || isDataValueCached || isBoundsCached; } public void updateLayer(ILayer layer) { if (isReadMode()) { throw new IllegalStateException("Cannot update cell once displayMode, configLabels, dataValue, or bounds have been read"); } this.layer = layer; } public void updatePosition(ILayer layer, int originColumnPosition, int originRowPosition, int columnPosition, int rowPosition) { if (isReadMode()) { throw new IllegalStateException("Cannot update cell once displayMode, configLabels, dataValue, or bounds have been read"); } this.layer = layer; this.originColumnPosition = originColumnPosition; this.originRowPosition = originRowPosition; this.columnPosition = columnPosition; this.rowPosition = rowPosition; } public void updateColumnSpan(int columnSpan) { if (isReadMode()) { throw new IllegalStateException("Cannot update cell once displayMode, configLabels, dataValue, or bounds have been read"); } this.columnSpan = columnSpan; } public void updateRowSpan(int rowSpan) { if (isReadMode()) { throw new IllegalStateException("Cannot update cell once displayMode, configLabels, dataValue, or bounds have been read"); } this.rowSpan = rowSpan; } public ILayer getSourceLayer() { return sourceLayer; } public int getOriginColumnPosition() { return originColumnPosition; } public int getOriginRowPosition() { return originRowPosition; } public ILayer getLayer() { return layer; } public int getColumnPosition() { return columnPosition; } public int getRowPosition() { return rowPosition; } public int getColumnSpan() { return columnSpan; } public int getRowSpan() { return rowSpan; } public boolean isSpannedCell() { return columnSpan > 1 || rowSpan > 1; } public String getDisplayMode() { if (!isDisplayModeCached) { isDisplayModeCached = true; displayMode = layer.getDisplayModeByPosition(columnPosition, rowPosition); } return displayMode; } public LabelStack getConfigLabels() { if (!isConfigLabelsCached) { isConfigLabelsCached = true; configLabels = layer.getConfigLabelsByPosition(columnPosition, rowPosition); } return configLabels; } public Object getDataValue() { if (!isDataValueCached) { isDataValueCached = true; dataValue = layer.getDataValueByPosition(columnPosition, rowPosition); } return dataValue; } public Rectangle getBounds() { if (!isBoundsCached) { isBoundsCached = true; bounds = layer.getBoundsByPosition(columnPosition, rowPosition); } return bounds; } @Override public boolean equals(Object obj) { if (obj instanceof LayerCell == false) { return false; } if (this == obj) { return true; } LayerCell rhs = (LayerCell) obj; return new EqualsBuilder() .append(sourceLayer, rhs.sourceLayer) .append(originColumnPosition, rhs.originColumnPosition) .append(originRowPosition, rhs.originRowPosition) .append(columnSpan, rhs.columnSpan) .append(rowSpan, rhs.rowSpan) .isEquals(); } @Override public int hashCode() { return new HashCodeBuilder(771, 855) .append(sourceLayer) .append(originColumnPosition) .append(originRowPosition) .append(columnSpan) .append(rowSpan) .toHashCode(); } @Override public String toString() { return "LayerCell: [" + "Data: " + dataValue + ", sourceLayer: " + sourceLayer.getClass().getSimpleName() + ", originColumnPosition: " + originColumnPosition + ", originRowPosition: " + originRowPosition + ", columnSpan: " + columnSpan + ", rowSpan: " + rowSpan + "]"; } }
5,576
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractOverrider.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/cell/AbstractOverrider.java
package net.sourceforge.nattable.layer.cell; import java.io.Serializable; import java.util.HashMap; import java.util.List; import java.util.Map; import net.sourceforge.nattable.util.ArrayUtil; public abstract class AbstractOverrider implements IConfigLabelAccumulator { private Map<Serializable, List<String>> overrides = new HashMap<Serializable, List<String>>(); public void removeOverride(Serializable key) { overrides.remove(key); } public void registerOverrides(Serializable key, String...configLabels) { List<String> existingOverrides = getOverrides(key); if(existingOverrides == null){ registerOverrides(key, ArrayUtil.asList(configLabels)); } else { existingOverrides.addAll(ArrayUtil.asList(configLabels)); } } public void registerOverrides(Serializable key, List<String> configLabels) { overrides.put(key, configLabels); } public Map<Serializable, List<String>> getOverrides() { return overrides; } public List<String> getOverrides(Serializable key) { return overrides.get(key); } public void addOverrides(Map<Serializable, List<String>> overrides) { this.overrides.putAll(overrides); } }
1,194
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AggregrateConfigLabelAccumulator.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/cell/AggregrateConfigLabelAccumulator.java
package net.sourceforge.nattable.layer.cell; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import net.sourceforge.nattable.layer.LabelStack; /** * An {@link ICellLabelAccumulator} that can aggregate labels from other <code>ICellLabelAccumulator</code>s.<br/> * All the labels provided by the aggregated accumulators are applied to the cell.<be/> */ public class AggregrateConfigLabelAccumulator implements IConfigLabelAccumulator { private List<IConfigLabelAccumulator> accumulators = new ArrayList<IConfigLabelAccumulator>(); public void add(IConfigLabelAccumulator r) { if (r == null) throw new IllegalArgumentException("null"); accumulators.add(r); } public void add(IConfigLabelAccumulator... r) { if (r == null) throw new IllegalArgumentException("null"); accumulators.addAll(Arrays.asList(r)); } public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) { for (IConfigLabelAccumulator accumulator : accumulators) { accumulator.accumulateConfigLabels(configLabels, columnPosition, rowPosition); } } }
1,207
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ClassNameConfigLabelAccumulator.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/cell/ClassNameConfigLabelAccumulator.java
package net.sourceforge.nattable.layer.cell; import net.sourceforge.nattable.data.IRowDataProvider; import net.sourceforge.nattable.layer.LabelStack; /** * Adds the Java class name of the cell's data value as a label. */ public class ClassNameConfigLabelAccumulator implements IConfigLabelAccumulator { private IRowDataProvider<?> dataProvider; public ClassNameConfigLabelAccumulator(IRowDataProvider<?> dataProvider) { this.dataProvider = dataProvider; } public void accumulateConfigLabels(LabelStack configLabel, int columnPosition, int rowPosition) { Object value = dataProvider.getDataValue(columnPosition, rowPosition); if (value != null) { configLabel.addLabel(value.getClass().getName()); } } }
755
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CellOverrideLabelAccumulator.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/cell/CellOverrideLabelAccumulator.java
package net.sourceforge.nattable.layer.cell; import java.io.Serializable; import java.util.List; import net.sourceforge.nattable.data.IRowDataProvider; import net.sourceforge.nattable.layer.LabelStack; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; /* * Allows application of config labels to cell(s) containing a specified data value.<br/> * Internally the class generated a 'key' using a combination of the cell value and its column position. * The registered labels are tracked using this key. * * Note: First Map's key is displayMode, inner Map's key is fieldName, the inner Map's value is cellValue */ public class CellOverrideLabelAccumulator<T> extends AbstractOverrider { private IRowDataProvider<T> dataProvider; public CellOverrideLabelAccumulator(IRowDataProvider<T> dataProvider) { this.dataProvider = dataProvider; } public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) { List<String> cellLabels = getConfigLabels(dataProvider.getDataValue(columnPosition, rowPosition), columnPosition); if (cellLabels == null) { return; } for (String configLabel : cellLabels) { configLabels.addLabel(configLabel); } } protected List<String> getConfigLabels(Object value, int col) { CellValueOverrideKey key = new CellValueOverrideKey(value, col); return getOverrides(key); } /** * Register a config label on the cell * @param cellValue data value of the cell. This is the backing data value, not the display value. * @param col column index of the cell * @param configLabel to apply. Styles for the cell have to be registered against this label. */ public void registerOverride(Object cellValue, int col, String configLabel) { registerOverrides(new CellValueOverrideKey(cellValue, col), configLabel); } } /** * Class used as a key for storing cell labels in an internal map. */ class CellValueOverrideKey implements Serializable { private static final long serialVersionUID = 1L; Object cellValue; int col; CellValueOverrideKey(Object cellValue, int col) { this.cellValue = cellValue; this.col = col; } @Override public boolean equals(Object obj) { if (obj instanceof CellValueOverrideKey == false) { return false; } if (this == obj) { return true; } CellValueOverrideKey rhs = ((CellValueOverrideKey) obj); return new EqualsBuilder().append(cellValue, rhs.cellValue).append(col, rhs.col).isEquals(); } @Override public int hashCode() { return new HashCodeBuilder(1, 3).append(cellValue).append(col).toHashCode(); } public String getComposite() { return cellValue + String.valueOf(col); } }
2,785
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
SimpleConfigLabelAccumulator.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/cell/SimpleConfigLabelAccumulator.java
package net.sourceforge.nattable.layer.cell; import net.sourceforge.nattable.layer.LabelStack; public class SimpleConfigLabelAccumulator implements IConfigLabelAccumulator { private final String configLabel; public SimpleConfigLabelAccumulator(String configLabel) { this.configLabel = configLabel; } public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) { configLabels.addLabel(configLabel); } }
472
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnOverrideLabelAccumulator.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/cell/ColumnOverrideLabelAccumulator.java
package net.sourceforge.nattable.layer.cell; import java.io.Serializable; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.edit.editor.ICellEditor; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.LabelStack; import net.sourceforge.nattable.painter.cell.ICellPainter; import net.sourceforge.nattable.persistence.IPersistable; import net.sourceforge.nattable.style.IStyle; /** * Registers/Adds configuration labels for a given column (by index).<br/> * Custom {@link ICellEditor}, {@link ICellPainter}, {@link IStyle} can then <br/> * be registered in the {@link IConfigRegistry} against these labels. <br/> * * Also @see {@link RowOverrideLabelAccumulator} */ public class ColumnOverrideLabelAccumulator extends AbstractOverrider implements IPersistable { public static final String PERSISTENCE_KEY = ".columnOverrideLabelAccumulator"; private final ILayer layer; public ColumnOverrideLabelAccumulator(ILayer layer) { this.layer = layer; } /** * {@inheritDoc} */ public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) { int columnIndex = layer.getColumnIndexByPosition(columnPosition); List<String> overrides = getOverrides(Integer.valueOf(columnIndex)); if (overrides != null) { for (String configLabel : overrides) { configLabels.addLabel(configLabel); } } } /** * Register labels to be contributed a column. This label will be applied to<br/> * all cells in the column. */ public void registerColumnOverrides(int columnIndex, String... configLabels) { super.registerOverrides(Integer.valueOf(columnIndex), configLabels); } /** * Save the overrides to a properties file. A line is stored for every column.<br/> * * Example for column 0: * prefix.columnOverrideLabelAccumulator.0 = LABEL1,LABEL2 */ public void saveState(String prefix, Properties properties) { Map<Serializable, List<String>> overrides = getOverrides(); for (Map.Entry<Serializable, List<String>> entry : overrides.entrySet()) { StringBuilder strBuilder = new StringBuilder(); for (String columnLabel : entry.getValue()) { strBuilder.append(columnLabel); strBuilder.append(VALUE_SEPARATOR); } //Strip the last comma String propertyValue = strBuilder.toString(); if(propertyValue.endsWith(VALUE_SEPARATOR)){ propertyValue = propertyValue.substring(0, propertyValue.length() - 1); } String propertyKey = prefix + PERSISTENCE_KEY + DOT + entry.getKey(); properties.setProperty(propertyKey, propertyValue); } } /** * Load the overrides state from the given properties file.<br/> * @see CellOverrideLabelAccumulator#saveState() */ public void loadState(String prefix, Properties properties) { Set<Object> keySet = properties.keySet(); for (Object key : keySet) { String keyString = (String) key; if(keyString.contains(PERSISTENCE_KEY)){ String labelsFromPropertyValue = properties.getProperty(keyString).trim(); String columnIndexFromKey = keyString.substring(keyString.lastIndexOf(DOT) + 1); registerColumnOverrides(Integer.parseInt(columnIndexFromKey), labelsFromPropertyValue.split(VALUE_SEPARATOR)); } } } }
3,442
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultRowHeaderLayerConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/config/DefaultRowHeaderLayerConfiguration.java
package net.sourceforge.nattable.layer.config; import net.sourceforge.nattable.config.AggregateConfiguration; import net.sourceforge.nattable.grid.GridRegion; import net.sourceforge.nattable.grid.layer.RowHeaderLayer; import net.sourceforge.nattable.resize.config.DefaultRowResizeBindings; /** * Default setup for the Row header area. Added by the {@link RowHeaderLayer} * Override the methods in this class to customize style / UI bindings. * * @see GridRegion */ public class DefaultRowHeaderLayerConfiguration extends AggregateConfiguration { public DefaultRowHeaderLayerConfiguration() { addRowHeaderStyleConfig(); addRowHeaderUIBindings(); } protected void addRowHeaderStyleConfig() { addConfiguration(new DefaultRowHeaderStyleConfiguration()); } protected void addRowHeaderUIBindings() { addConfiguration(new DefaultRowResizeBindings()); } }
902
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultColumnHeaderLayerConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/config/DefaultColumnHeaderLayerConfiguration.java
package net.sourceforge.nattable.layer.config; import net.sourceforge.nattable.config.AggregateConfiguration; import net.sourceforge.nattable.grid.layer.ColumnHeaderLayer; import net.sourceforge.nattable.resize.config.DefaultColumnResizeBindings; /** * Sets up Column header styling and resize bindings. * Added by the {@link ColumnHeaderLayer} */ public class DefaultColumnHeaderLayerConfiguration extends AggregateConfiguration { public DefaultColumnHeaderLayerConfiguration() { addColumnHeaderStyleConfig(); addColumnHeaderUIBindings(); } protected void addColumnHeaderUIBindings() { addConfiguration(new DefaultColumnResizeBindings()); } protected void addColumnHeaderStyleConfig() { addConfiguration(new DefaultColumnHeaderStyleConfiguration()); } }
804
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultColumnHeaderStyleConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/config/DefaultColumnHeaderStyleConfiguration.java
package net.sourceforge.nattable.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.GridRegion; import net.sourceforge.nattable.painter.cell.ICellPainter; import net.sourceforge.nattable.painter.cell.TextPainter; import net.sourceforge.nattable.painter.cell.decorator.BeveledBorderDecorator; import net.sourceforge.nattable.style.BorderStyle; import net.sourceforge.nattable.style.CellStyleAttributes; import net.sourceforge.nattable.style.DisplayMode; 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.graphics.Font; import org.eclipse.swt.graphics.FontData; /** * Sets up column header styling. * Added by {@link DefaultColumnHeaderLayerConfiguration} */ public class DefaultColumnHeaderStyleConfiguration extends AbstractRegistryConfiguration { public Font font = GUIHelper.getFont(new FontData("Verdana", 10, SWT.NORMAL)); public Color bgColor = GUIHelper.COLOR_WIDGET_BACKGROUND; public Color fgColor = GUIHelper.COLOR_WIDGET_FOREGROUND; public HorizontalAlignmentEnum hAlign = HorizontalAlignmentEnum.CENTER; public VerticalAlignmentEnum vAlign = VerticalAlignmentEnum.MIDDLE; public BorderStyle borderStyle = null; public ICellPainter cellPainter = new BeveledBorderDecorator(new TextPainter()); public void configureRegistry(IConfigRegistry configRegistry) { configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, GridRegion.COLUMN_HEADER); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, GridRegion.CORNER); // Normal Style cellStyle = new Style(); cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, bgColor); cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, fgColor); cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, hAlign); cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, vAlign); cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, borderStyle); cellStyle.setAttributeValue(CellStyleAttributes.FONT, font); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, GridRegion.COLUMN_HEADER); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, GridRegion.CORNER); } }
2,813
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DefaultRowHeaderStyleConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/config/DefaultRowHeaderStyleConfiguration.java
package net.sourceforge.nattable.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.GridRegion; import net.sourceforge.nattable.painter.cell.ICellPainter; import net.sourceforge.nattable.painter.cell.TextPainter; import net.sourceforge.nattable.style.BorderStyle; import net.sourceforge.nattable.style.CellStyleAttributes; import net.sourceforge.nattable.style.DisplayMode; 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.graphics.Font; import org.eclipse.swt.graphics.FontData; public class DefaultRowHeaderStyleConfiguration extends AbstractRegistryConfiguration { public Font font = GUIHelper.getFont(new FontData("Verdana", 10, SWT.NORMAL)); public Color bgColor = GUIHelper.COLOR_WIDGET_BACKGROUND; public Color fgColor = GUIHelper.COLOR_WIDGET_FOREGROUND; public HorizontalAlignmentEnum hAlign = HorizontalAlignmentEnum.CENTER; public VerticalAlignmentEnum vAlign = VerticalAlignmentEnum.MIDDLE; public BorderStyle borderStyle = null; public ICellPainter cellPainter = new TextPainter(); public void configureRegistry(IConfigRegistry configRegistry) { configureRowHeaderCellPainter(configRegistry); configureRowHeaderStyle(configRegistry); } protected void configureRowHeaderStyle(IConfigRegistry configRegistry) { Style cellStyle = new Style(); cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, bgColor); cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, fgColor); cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, hAlign); cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, vAlign); cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, borderStyle); cellStyle.setAttributeValue(CellStyleAttributes.FONT, font); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, GridRegion.ROW_HEADER); } protected void configureRowHeaderCellPainter(IConfigRegistry configRegistry) { configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, GridRegion.ROW_HEADER); } }
2,585
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnStyleChooserConfiguration.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/config/ColumnStyleChooserConfiguration.java
package net.sourceforge.nattable.layer.config; import net.sourceforge.nattable.config.AbstractRegistryConfiguration; import net.sourceforge.nattable.config.IConfigRegistry; import net.sourceforge.nattable.layer.AbstractLayer; import net.sourceforge.nattable.layer.cell.ColumnOverrideLabelAccumulator; import net.sourceforge.nattable.style.editor.command.DisplayColumnStyleEditorCommandHandler; /** * Registers the {@link DisplayColumnStyleEditorCommandHandler} * */ public class ColumnStyleChooserConfiguration extends AbstractRegistryConfiguration { private AbstractLayer bodyLayer; private ColumnOverrideLabelAccumulator labelAccumulator; public ColumnStyleChooserConfiguration(AbstractLayer bodyLayer) { this.bodyLayer = bodyLayer; labelAccumulator = new ColumnOverrideLabelAccumulator(bodyLayer); bodyLayer.setConfigLabelAccumulator(labelAccumulator); } public void configureRegistry(IConfigRegistry configRegistry) { DisplayColumnStyleEditorCommandHandler columnChooserCommandHandler = new DisplayColumnStyleEditorCommandHandler(labelAccumulator, configRegistry); bodyLayer.registerCommandHandler(columnChooserCommandHandler); } }
1,195
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
StructuralRefreshEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/StructuralRefreshEvent.java
package net.sourceforge.nattable.layer.event; import java.util.Arrays; import java.util.Collection; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.graphics.Rectangle; /** * General event indicating that structures cached by the layers need refreshing. <br/> * TIP: Consider throwing a more focused event (subclass) if you need to do this. */ public class StructuralRefreshEvent implements IStructuralChangeEvent { private ILayer layer; public StructuralRefreshEvent(ILayer layer) { this.layer = layer; } protected StructuralRefreshEvent(StructuralRefreshEvent event) { this.layer = event.layer; } public ILayer getLayer() { return layer; } public boolean convertToLocal(ILayer localLayer) { layer = localLayer; return true; } public Collection<Rectangle> getChangedPositionRectangles() { return Arrays.asList(new Rectangle[] { new Rectangle(0, 0, layer.getColumnCount(), layer.getRowCount()) }); } public boolean isHorizontalStructureChanged() { return true; } public boolean isVerticalStructureChanged() { return true; } public Collection<StructuralDiff> getColumnDiffs() { return null; } public Collection<StructuralDiff> getRowDiffs() { return null; } public ILayerEvent cloneEvent() { return this; } }
1,358
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ILayerEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/ILayerEvent.java
package net.sourceforge.nattable.layer.event; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.command.ILayerCommandHandler; import net.sourceforge.nattable.layer.ILayer; /** * Event fired by the {@link ILayerCommandHandler} classes (usually to signal to handling of a {@link ILayerCommand}).<br/> * Every layer in the grid is given a chance to respond to an event via {@link ILayer#handleLayerEvent(ILayerEvent)}. * * @see ILayerEventHandler */ public interface ILayerEvent { /** * Convert the column/row positions carried by the event to the layer about to * handle the event. * @param localLayer layer about to receive the event * @return TRUE if successfully converted, FALSE otherwise */ public boolean convertToLocal(ILayer localLayer); /** * @return A cloned copy of the event. This cloned copy is provided to each listener. */ public ILayerEvent cloneEvent(); }
967
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowStructuralRefreshEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/RowStructuralRefreshEvent.java
package net.sourceforge.nattable.layer.event; import net.sourceforge.nattable.layer.ILayer; /** * @see ColumnStructuralRefreshEvent */ public class RowStructuralRefreshEvent extends StructuralRefreshEvent { public RowStructuralRefreshEvent(ILayer layer) { super(layer); } @Override public boolean isVerticalStructureChanged() { return true; } @Override public boolean isHorizontalStructureChanged() { return false; } }
465
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowStructuralChangeEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/RowStructuralChangeEvent.java
package net.sourceforge.nattable.layer.event; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.graphics.Rectangle; /** * @see ColumnStructuralChangeEvent */ public abstract class RowStructuralChangeEvent extends RowVisualChangeEvent implements IStructuralChangeEvent { public RowStructuralChangeEvent(ILayer layer, Range...rowPositionRanges) { this(layer, Arrays.asList(rowPositionRanges)); } public RowStructuralChangeEvent(ILayer layer, Collection<Range> rowPositionRanges) { super(layer, rowPositionRanges); } protected RowStructuralChangeEvent(RowStructuralChangeEvent event) { super(event); } @Override public Collection<Rectangle> getChangedPositionRectangles() { Collection<Rectangle> changedPositionRectangles = new ArrayList<Rectangle>(); int columnCount = getLayer().getColumnCount(); int rowCount = getLayer().getRowCount(); for (Range range : getRowPositionRanges()) { changedPositionRectangles.add(new Rectangle(0, range.start, columnCount, rowCount - range.start)); } return changedPositionRectangles; } public boolean isHorizontalStructureChanged() { return false; } public Collection<StructuralDiff> getColumnDiffs() { return null; } public boolean isVerticalStructureChanged() { return true; } }
1,488
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
VisualRefreshEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/VisualRefreshEvent.java
package net.sourceforge.nattable.layer.event; import java.util.Arrays; import java.util.Collection; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.graphics.Rectangle; public abstract class VisualRefreshEvent implements IVisualChangeEvent { private ILayer layer; public VisualRefreshEvent(ILayer layer) { this.layer = layer; } protected VisualRefreshEvent(VisualRefreshEvent event) { this.layer = event.layer; } public ILayer getLayer() { return layer; } public boolean convertToLocal(ILayer localLayer) { layer = localLayer; return true; } public Collection<Rectangle> getChangedPositionRectangles() { return Arrays.asList(new Rectangle[] { new Rectangle(0, 0, layer.getColumnCount(), layer.getRowCount()) }); } }
813
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnStructuralRefreshEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/ColumnStructuralRefreshEvent.java
package net.sourceforge.nattable.layer.event; import net.sourceforge.nattable.layer.ILayer; /** * General event indicating that columns cached by the layers need refreshing. <br/> * * Note: As opposed to the the {@link ColumnStructuralChangeEvent} this event does not <br/> * indicate the specific columns which have changed. <br/> */ public class ColumnStructuralRefreshEvent extends StructuralRefreshEvent { public ColumnStructuralRefreshEvent(ILayer layer) { super(layer); } @Override public boolean isHorizontalStructureChanged() { return true; } @Override public boolean isVerticalStructureChanged() { return false; } }
678
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
PropertyUpdateEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/PropertyUpdateEvent.java
package net.sourceforge.nattable.layer.event; import java.beans.PropertyChangeEvent; import java.util.Arrays; import java.util.Collection; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.graphics.Rectangle; public class PropertyUpdateEvent<T> implements IVisualChangeEvent { private final PropertyChangeEvent propertyChangeEvent = null; private final T sourceBean; private final String propertyName; private final Object newValue; private final Object oldValue; private ILayer layer; public PropertyUpdateEvent(ILayer layer, T sourceBean, String propertyName, Object oldValue, Object newValue) { this.layer = layer; this.sourceBean = sourceBean; this.propertyName = propertyName; this.oldValue = oldValue; this.newValue = newValue; } // Interface methods public ILayerEvent cloneEvent() { return new PropertyUpdateEvent<T>(this.layer, this.sourceBean, this.propertyName, this.oldValue, this.newValue); } public boolean convertToLocal(ILayer localLayer) { this.layer = localLayer; return true; } public Collection<Rectangle> getChangedPositionRectangles() { return Arrays.asList(new Rectangle(0, 0, layer.getWidth(), layer.getHeight())); } public ILayer getLayer() { return layer; } // Accessors public PropertyChangeEvent getPropertyChangeEvent() { return propertyChangeEvent; } public T getSourceBean() { return sourceBean; } public String getPropertyName() { return propertyName; } public Object getNewValue() { return newValue; } public Object getOldValue() { return oldValue; } }
1,650
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnStructuralChangeEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/ColumnStructuralChangeEvent.java
package net.sourceforge.nattable.layer.event; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.graphics.Rectangle; /** * Event indicating a change in the structure of the columns. <br/> * This event carried ColumnDiffs (Collection<StructuralDiff>) indicating the columns which have changed.<br/> */ public abstract class ColumnStructuralChangeEvent extends ColumnVisualChangeEvent implements IStructuralChangeEvent { public ColumnStructuralChangeEvent(ILayer layer, Range...columnPositionRanges) { this(layer, Arrays.asList(columnPositionRanges)); } public ColumnStructuralChangeEvent(ILayer layer, Collection<Range> columnPositionRanges) { super(layer, columnPositionRanges); } protected ColumnStructuralChangeEvent(ColumnStructuralChangeEvent event) { super(event); } @Override public Collection<Rectangle> getChangedPositionRectangles() { Collection<Rectangle> changedPositionRectangles = new ArrayList<Rectangle>(); Collection<Range> columnPositionRanges = getColumnPositionRanges(); if (columnPositionRanges != null && columnPositionRanges.size() > 0) { int leftmostColumnPosition = Integer.MAX_VALUE; for (Range range : columnPositionRanges) { if (range.start < leftmostColumnPosition) { leftmostColumnPosition = range.start; } } int columnCount = getLayer().getColumnCount(); int rowCount = getLayer().getRowCount(); changedPositionRectangles.add(new Rectangle(leftmostColumnPosition, 0, columnCount - leftmostColumnPosition, rowCount)); } return changedPositionRectangles; } public boolean isHorizontalStructureChanged() { return true; } public boolean isVerticalStructureChanged() { return false; } public Collection<StructuralDiff> getRowDiffs() { return null; } }
1,991
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowDeleteEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/RowDeleteEvent.java
package net.sourceforge.nattable.layer.event; import java.util.ArrayList; import java.util.Collection; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.event.StructuralDiff.DiffTypeEnum; public class RowDeleteEvent extends RowStructuralChangeEvent { public RowDeleteEvent(ILayer layer, int rowPosition) { this(layer, new Range(rowPosition, rowPosition + 1)); } public RowDeleteEvent(ILayer layer, Range rowPositionRange) { super(layer, rowPositionRange); } protected RowDeleteEvent(RowDeleteEvent event) { super(event); } public RowDeleteEvent cloneEvent() { return new RowDeleteEvent(this); } public Collection<StructuralDiff> getRowDiffs() { Collection<StructuralDiff> rowDiffs = new ArrayList<StructuralDiff>(); for (Range range : getRowPositionRanges()) { new StructuralDiff(DiffTypeEnum.DELETE, range, new Range(range.start, range.start)); } return rowDiffs; } }
1,039
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowInsertEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/RowInsertEvent.java
package net.sourceforge.nattable.layer.event; import java.util.ArrayList; import java.util.Collection; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.event.StructuralDiff.DiffTypeEnum; public class RowInsertEvent extends RowStructuralChangeEvent { public RowInsertEvent(ILayer layer, int rowPosition) { this(layer, new Range(rowPosition, rowPosition + 1)); } public RowInsertEvent(ILayer layer, Range rowPositionRange) { super(layer, rowPositionRange); } public RowInsertEvent(RowInsertEvent event) { super(event); } public RowInsertEvent cloneEvent() { return new RowInsertEvent(this); } public Collection<StructuralDiff> getRowDiffs() { Collection<StructuralDiff> rowDiffs = new ArrayList<StructuralDiff>(); for (Range range : getRowPositionRanges()) { new StructuralDiff(DiffTypeEnum.ADD, new Range(range.start, range.start), range); } return rowDiffs; } }
1,034
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
StructuralDiff.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/StructuralDiff.java
package net.sourceforge.nattable.layer.event; import net.sourceforge.nattable.coordinate.Range; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; public class StructuralDiff { public enum DiffTypeEnum { ADD, CHANGE, DELETE; } private DiffTypeEnum diffType; private Range beforePositionRange; private Range afterPositionRange; public StructuralDiff(DiffTypeEnum diffType, Range beforePositionRange, Range afterPositionRange) { this.diffType = diffType; this.beforePositionRange = beforePositionRange; this.afterPositionRange = afterPositionRange; } public DiffTypeEnum getDiffType() { return diffType; } public Range getBeforePositionRange() { return beforePositionRange; } public Range getAfterPositionRange() { return afterPositionRange; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if ((obj instanceof StructuralDiff) == false) { return false; } StructuralDiff that = (StructuralDiff) obj; return new EqualsBuilder() .append(this.diffType, that.diffType) .append(this.beforePositionRange, that.beforePositionRange) .append(this.afterPositionRange, that.afterPositionRange) .isEquals(); } @Override public int hashCode() { return new HashCodeBuilder(57, 55) .append(diffType) .append(beforePositionRange) .append(afterPositionRange) .toHashCode(); } @Override public String toString() { return getClass().getSimpleName() + " " + diffType + " before: " + beforePositionRange + " after: " + afterPositionRange; } }
1,709
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ILayerEventHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/ILayerEventHandler.java
package net.sourceforge.nattable.layer.event; public interface ILayerEventHandler <T extends ILayerEvent> { public void handleLayerEvent(T event); public Class<T> getLayerEventClass(); }
204
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
IStructuralChangeEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/IStructuralChangeEvent.java
package net.sourceforge.nattable.layer.event; import java.util.Collection; /** * An event indicating a structural change to the layer. A structural change is * defined as something that modifies the number of columns/rows in the layer or * their associated widths/heights. */ public interface IStructuralChangeEvent extends IVisualChangeEvent { public boolean isHorizontalStructureChanged(); public Collection<StructuralDiff> getColumnDiffs(); public boolean isVerticalStructureChanged(); public Collection<StructuralDiff> getRowDiffs(); }
559
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ColumnVisualChangeEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/ColumnVisualChangeEvent.java
package net.sourceforge.nattable.layer.event; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.graphics.Rectangle; public abstract class ColumnVisualChangeEvent implements IVisualChangeEvent { private ILayer layer; private Collection<Range> columnPositionRanges; public ColumnVisualChangeEvent(ILayer layer, Range...columnPositionRanges) { this(layer, Arrays.asList(columnPositionRanges)); } public ColumnVisualChangeEvent(ILayer layer, Collection<Range> columnPositionRanges) { this.layer = layer; this.columnPositionRanges = columnPositionRanges; } // Copy constructor protected ColumnVisualChangeEvent(ColumnVisualChangeEvent event) { this.layer = event.layer; this.columnPositionRanges = event.columnPositionRanges; } public ILayer getLayer() { return layer; } public Collection<Range> getColumnPositionRanges() { return columnPositionRanges; } protected void setColumnPositionRanges(Collection<Range> columnPositionRanges) { this.columnPositionRanges = columnPositionRanges; } public boolean convertToLocal(ILayer localLayer) { columnPositionRanges = localLayer.underlyingToLocalColumnPositions(layer, columnPositionRanges); layer = localLayer; return columnPositionRanges != null && columnPositionRanges.size() > 0; } public Collection<Rectangle> getChangedPositionRectangles() { Collection<Rectangle> changedPositionRectangles = new ArrayList<Rectangle>(); int rowCount = layer.getRowCount(); for (Range range : columnPositionRanges) { changedPositionRectangles.add(new Rectangle(range.start, 0, range.end - range.start, rowCount)); } return changedPositionRectangles; } @Override public String toString() { return getClass().getSimpleName(); } }
1,969
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractContextFreeEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/AbstractContextFreeEvent.java
package net.sourceforge.nattable.layer.event; import net.sourceforge.nattable.layer.ILayer; public abstract class AbstractContextFreeEvent implements ILayerEvent { public boolean convertToLocal(ILayer localLayer) { return true; } }
251
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowVisualChangeEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/RowVisualChangeEvent.java
package net.sourceforge.nattable.layer.event; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.graphics.Rectangle; public abstract class RowVisualChangeEvent implements IVisualChangeEvent { private ILayer layer; private Collection<Range> rowPositionRanges = new ArrayList<Range>(); public RowVisualChangeEvent(ILayer layer, Range...rowPositionRanges) { this(layer, Arrays.asList(rowPositionRanges)); } public RowVisualChangeEvent(ILayer layer, Collection<Range> rowPositionRanges) { this.layer = layer; this.rowPositionRanges = rowPositionRanges; } // Copy constructor protected RowVisualChangeEvent(RowVisualChangeEvent event) { this.layer = event.layer; this.rowPositionRanges = event.rowPositionRanges; } public ILayer getLayer() { return layer; } public Collection<Range> getRowPositionRanges() { return rowPositionRanges; } public boolean convertToLocal(ILayer localLayer) { rowPositionRanges = localLayer.underlyingToLocalRowPositions(layer, rowPositionRanges); layer = localLayer; return rowPositionRanges != null && rowPositionRanges.size() > 0; } public Collection<Rectangle> getChangedPositionRectangles() { Collection<Rectangle> changedPositionRectangles = new ArrayList<Rectangle>(); int columnCount = layer.getColumnCount(); for (Range range : rowPositionRanges) { changedPositionRectangles.add(new Rectangle(0, range.start, columnCount, range.end - range.start)); } return changedPositionRectangles; } public String toString() { return getClass().getSimpleName(); } }
1,785
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
IVisualChangeEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/IVisualChangeEvent.java
package net.sourceforge.nattable.layer.event; import java.util.Collection; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.graphics.Rectangle; /** * An event which indicates a visible change to one or more cells in the layer. * A visible change simply indicates that one or more cells should be redrawn. * It does not imply a structural change to the layer. This means that cached * structure does not need to be invalidated due to visible change events. */ public interface IVisualChangeEvent extends ILayerEvent { /** * Get the layer that the visible change event is originating from. */ public ILayer getLayer(); /** * Get the position rectangles that have changed and need to be redrawn. * If no rectangles are returned, then the receiver should assume that the * entire layer is changed and will need to be redrawn. */ public Collection<Rectangle> getChangedPositionRectangles(); }
967
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CellVisualChangeEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/CellVisualChangeEvent.java
package net.sourceforge.nattable.layer.event; import java.util.Arrays; import java.util.Collection; import net.sourceforge.nattable.layer.ILayer; import org.eclipse.swt.graphics.Rectangle; public class CellVisualChangeEvent implements IVisualChangeEvent { private ILayer layer; int columnPosition; int rowPosition; public CellVisualChangeEvent(ILayer layer, int columnPosition, int rowPosition) { this.layer = layer; this.columnPosition = columnPosition; this.rowPosition = rowPosition; } protected CellVisualChangeEvent(CellVisualChangeEvent event) { this.layer = event.layer; this.columnPosition = event.columnPosition; this.rowPosition = event.rowPosition; } public ILayer getLayer() { return layer; } public int getColumnPosition() { return columnPosition; } public int getRowPosition() { return rowPosition; } public boolean convertToLocal(ILayer localLayer) { columnPosition = localLayer.underlyingToLocalColumnPosition(getLayer(), columnPosition); rowPosition = localLayer.underlyingToLocalRowPosition(getLayer(), rowPosition); layer = localLayer; return columnPosition >= 0 && rowPosition >= 0 && columnPosition < layer.getColumnCount() && rowPosition < layer.getRowCount(); } public Collection<Rectangle> getChangedPositionRectangles() { return Arrays.asList(new Rectangle[] { new Rectangle(columnPosition, rowPosition, 1, 1) }); } public CellVisualChangeEvent cloneEvent() { return new CellVisualChangeEvent(this); } }
1,571
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RowUpdateEvent.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/layer/event/RowUpdateEvent.java
package net.sourceforge.nattable.layer.event; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.layer.ILayer; public class RowUpdateEvent extends RowVisualChangeEvent { public RowUpdateEvent(ILayer layer, int rowPosition) { this(layer, new Range(rowPosition, rowPosition + 1)); } public RowUpdateEvent(ILayer layer, Range rowPositionRange) { super(layer, rowPositionRange); } public RowUpdateEvent(RowUpdateEvent event) { super(event); } public RowUpdateEvent cloneEvent() { return new RowUpdateEvent(this); } }
595
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractMultiColumnCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/command/AbstractMultiColumnCommand.java
package net.sourceforge.nattable.command; import java.util.Collection; import java.util.HashSet; import net.sourceforge.nattable.coordinate.ColumnPositionCoordinate; import net.sourceforge.nattable.layer.ILayer; public abstract class AbstractMultiColumnCommand implements ILayerCommand { protected Collection<ColumnPositionCoordinate> columnPositionCoordinates; protected AbstractMultiColumnCommand(ILayer layer, int...columnPositions) { setColumnPositions(layer, columnPositions); } protected AbstractMultiColumnCommand(AbstractMultiColumnCommand command) { this.columnPositionCoordinates = new HashSet<ColumnPositionCoordinate>(command.columnPositionCoordinates); } public Collection<Integer> getColumnPositions() { Collection<Integer> columnPositions = new HashSet<Integer>(); for (ColumnPositionCoordinate columnPositionCoordinate : columnPositionCoordinates) { columnPositions.add(Integer.valueOf(columnPositionCoordinate.columnPosition)); } return columnPositions; } protected final void setColumnPositions(ILayer layer, int...columnPositions) { columnPositionCoordinates = new HashSet<ColumnPositionCoordinate>(); for (int columnPosition : columnPositions) { columnPositionCoordinates.add(new ColumnPositionCoordinate(layer, columnPosition)); } } public boolean convertToTargetLayer(ILayer targetLayer) { Collection<ColumnPositionCoordinate> convertedColumnPositionCoordinates = new HashSet<ColumnPositionCoordinate>(); for (ColumnPositionCoordinate columnPositionCoordinate : columnPositionCoordinates) { ColumnPositionCoordinate convertedColumnPositionCoordinate = LayerCommandUtil.convertColumnPositionToTargetContext(columnPositionCoordinate, targetLayer); if (convertedColumnPositionCoordinate != null) { convertedColumnPositionCoordinates.add(convertedColumnPositionCoordinate); } } columnPositionCoordinates = convertedColumnPositionCoordinates; return columnPositionCoordinates.size() > 0; } }
2,043
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
DisposeResourcesCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/command/DisposeResourcesCommand.java
package net.sourceforge.nattable.command; import net.sourceforge.nattable.NatTable; /** * Command fired by {@link NatTable} just before it is disposed.<br/> * This command can be handled by layers which need to dispose resources (to avoid memory leaks). <br/> * * @see GlazedListsEventLayer */ public class DisposeResourcesCommand extends AbstractContextFreeCommand { }
391
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ILayerCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/command/ILayerCommand.java
package net.sourceforge.nattable.command; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.grid.layer.GridLayer; import net.sourceforge.nattable.layer.ILayer; /** * Commands are fired by NatTable in response to user actions. * Commands flow down the layer stack until they are processed by an * {@link ILayer} or an associated {@link ILayerCommandHandler}. * Commands can be fired from code by invoking {@link NatTable#doCommand(ILayerCommand)} */ public interface ILayerCommand { /** * Convert the row/column coordinates the command might be carrying from the source layer * to the destination (target) layer.<br/> * * @return true if the command is valid after conversion, false if the command is no longer valid. * Note: most commands are not processed if they fail conversion. */ public boolean convertToTargetLayer(ILayer targetLayer); /** * Same semantics as {@link Object#clone()} * Used to make a copies of the command if has to passed to different layer stacks. * * @see GridLayer#doCommand(ILayerCommand) */ public ILayerCommand cloneCommand(); }
1,161
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractPositionCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/command/AbstractPositionCommand.java
package net.sourceforge.nattable.command; import net.sourceforge.nattable.coordinate.PositionCoordinate; import net.sourceforge.nattable.layer.ILayer; public abstract class AbstractPositionCommand implements ILayerCommand { private PositionCoordinate positionCoordinate; protected AbstractPositionCommand(ILayer layer, int columnPosition, int rowPosition) { positionCoordinate = new PositionCoordinate(layer, columnPosition, rowPosition); } protected AbstractPositionCommand(AbstractPositionCommand command) { this.positionCoordinate = command.positionCoordinate; } public boolean convertToTargetLayer(ILayer targetLayer) { positionCoordinate = LayerCommandUtil.convertPositionToTargetContext(positionCoordinate, targetLayer); return positionCoordinate != null; } public int getColumnPosition() { return positionCoordinate.getColumnPosition(); } public int getRowPosition() { return positionCoordinate.getRowPosition(); } @Override public String toString() { return this.getClass().getSimpleName() + " columnPosition=" + positionCoordinate.getColumnPosition() + ", rowPosition=" + positionCoordinate.getRowPosition(); } }
1,202
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractColumnCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/command/AbstractColumnCommand.java
package net.sourceforge.nattable.command; import net.sourceforge.nattable.coordinate.ColumnPositionCoordinate; import net.sourceforge.nattable.layer.ILayer; public abstract class AbstractColumnCommand implements ILayerCommand { private ColumnPositionCoordinate columnPositionCoordinate; protected AbstractColumnCommand(ILayer layer, int columnPosition) { columnPositionCoordinate = new ColumnPositionCoordinate(layer, columnPosition); } protected AbstractColumnCommand(AbstractColumnCommand command) { this.columnPositionCoordinate = command.columnPositionCoordinate; } public boolean convertToTargetLayer(ILayer targetLayer) { columnPositionCoordinate = LayerCommandUtil.convertColumnPositionToTargetContext(columnPositionCoordinate, targetLayer); return columnPositionCoordinate != null; } public ILayer getLayer() { return columnPositionCoordinate.getLayer(); } public int getColumnPosition() { return columnPositionCoordinate.getColumnPosition(); } @Override public String toString() { return this.getClass().getSimpleName() + " columnPosition=" + columnPositionCoordinate.getColumnPosition(); } }
1,180
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
LayerCommandUtil.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/command/LayerCommandUtil.java
package net.sourceforge.nattable.command; import java.util.Collection; import net.sourceforge.nattable.coordinate.ColumnPositionCoordinate; import net.sourceforge.nattable.coordinate.PositionCoordinate; import net.sourceforge.nattable.coordinate.RowPositionCoordinate; import net.sourceforge.nattable.layer.ILayer; public class LayerCommandUtil { public static PositionCoordinate convertPositionToTargetContext(PositionCoordinate positionCoordinate, ILayer targetLayer) { ILayer layer = positionCoordinate.getLayer(); if (layer == targetLayer) { return positionCoordinate; } int columnPosition = positionCoordinate.getColumnPosition(); int underlyingColumnPosition = layer.localToUnderlyingColumnPosition(columnPosition); if (underlyingColumnPosition < 0) { return null; } int rowPosition = positionCoordinate.getRowPosition(); int underlyingRowPosition = layer.localToUnderlyingRowPosition(rowPosition); if (underlyingRowPosition < 0) { return null; } ILayer underlyingLayer = layer.getUnderlyingLayerByPosition(columnPosition, rowPosition); if (underlyingLayer == null) { return null; } return convertPositionToTargetContext(new PositionCoordinate(underlyingLayer, underlyingColumnPosition, underlyingRowPosition), targetLayer); } public static ColumnPositionCoordinate convertColumnPositionToTargetContext(ColumnPositionCoordinate columnPositionCoordinate, ILayer targetLayer) { if (columnPositionCoordinate != null) { ILayer layer = columnPositionCoordinate.getLayer(); if (layer == targetLayer) { return columnPositionCoordinate; } int columnPosition = columnPositionCoordinate.getColumnPosition(); int underlyingColumnPosition = layer.localToUnderlyingColumnPosition(columnPosition); if (underlyingColumnPosition < 0) { return null; } Collection<ILayer> underlyingLayers = layer.getUnderlyingLayersByColumnPosition(columnPosition); if (underlyingLayers != null) { for (ILayer underlyingLayer : underlyingLayers) { if (underlyingLayer != null) { ColumnPositionCoordinate convertedColumnPositionCoordinate = convertColumnPositionToTargetContext(new ColumnPositionCoordinate(underlyingLayer, underlyingColumnPosition), targetLayer); if (convertedColumnPositionCoordinate != null) { return convertedColumnPositionCoordinate; } } } } } return null; } public static RowPositionCoordinate convertRowPositionToTargetContext(RowPositionCoordinate rowPositionCoordinate, ILayer targetLayer) { if (rowPositionCoordinate != null) { ILayer layer = rowPositionCoordinate.getLayer(); if (layer == targetLayer) { return rowPositionCoordinate; } int rowPosition = rowPositionCoordinate.getRowPosition(); int underlyingRowPosition = layer.localToUnderlyingRowPosition(rowPosition); if (underlyingRowPosition < 0) { return null; } Collection<ILayer> underlyingLayers = layer.getUnderlyingLayersByRowPosition(rowPosition); if (underlyingLayers != null) { for (ILayer underlyingLayer : underlyingLayers) { if (underlyingLayer != null) { RowPositionCoordinate convertedRowPositionCoordinate = convertRowPositionToTargetContext(new RowPositionCoordinate(underlyingLayer, underlyingRowPosition), targetLayer); if (convertedRowPositionCoordinate != null) { return convertedRowPositionCoordinate; } } } } } return null; } }
3,476
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractMultiRowCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/command/AbstractMultiRowCommand.java
package net.sourceforge.nattable.command; import java.util.Collection; import java.util.HashSet; import net.sourceforge.nattable.coordinate.RowPositionCoordinate; import net.sourceforge.nattable.layer.ILayer; public abstract class AbstractMultiRowCommand implements ILayerCommand { private Collection<RowPositionCoordinate> rowPositionCoordinates; protected AbstractMultiRowCommand(ILayer layer, int...rowPositions) { setRowPositions(layer, rowPositions); } protected AbstractMultiRowCommand(AbstractMultiRowCommand command) { this.rowPositionCoordinates = new HashSet<RowPositionCoordinate>(command.rowPositionCoordinates); } public Collection<Integer> getRowPositions() { Collection<Integer> rowPositions = new HashSet<Integer>(); for (RowPositionCoordinate rowPositionCoordinate : rowPositionCoordinates) { rowPositions.add(Integer.valueOf(rowPositionCoordinate.rowPosition)); } return rowPositions; } protected final void setRowPositions(ILayer layer, int...rowPositions) { rowPositionCoordinates = new HashSet<RowPositionCoordinate>(); for (int rowPosition : rowPositions) { rowPositionCoordinates.add(new RowPositionCoordinate(layer, rowPosition)); } } public boolean convertToTargetLayer(ILayer targetLayer) { Collection<RowPositionCoordinate> convertedRowPositionCoordinates = new HashSet<RowPositionCoordinate>(); for (RowPositionCoordinate rowPositionCoordinate : rowPositionCoordinates) { RowPositionCoordinate convertedRowPositionCoordinate = LayerCommandUtil.convertRowPositionToTargetContext(rowPositionCoordinate, targetLayer); if (convertedRowPositionCoordinate != null) { convertedRowPositionCoordinates.add(convertedRowPositionCoordinate); } } rowPositionCoordinates = convertedRowPositionCoordinates; return rowPositionCoordinates.size() > 0; } }
1,894
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractContextFreeCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/command/AbstractContextFreeCommand.java
package net.sourceforge.nattable.command; import net.sourceforge.nattable.layer.ILayer; public abstract class AbstractContextFreeCommand implements ILayerCommand { public boolean convertToTargetLayer(ILayer targetLayer) { return true; } public AbstractContextFreeCommand cloneCommand() { return this; } }
336
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractRowCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/command/AbstractRowCommand.java
package net.sourceforge.nattable.command; import net.sourceforge.nattable.coordinate.RowPositionCoordinate; import net.sourceforge.nattable.layer.ILayer; public abstract class AbstractRowCommand implements ILayerCommand { private RowPositionCoordinate rowPositionCoordinate; protected AbstractRowCommand(ILayer layer, int rowPosition) { rowPositionCoordinate = new RowPositionCoordinate(layer, rowPosition); } protected AbstractRowCommand(AbstractRowCommand command) { this.rowPositionCoordinate = command.rowPositionCoordinate; } public boolean convertToTargetLayer(ILayer targetLayer) { rowPositionCoordinate = LayerCommandUtil.convertRowPositionToTargetContext(rowPositionCoordinate, targetLayer); return rowPositionCoordinate != null; } public int getRowPosition() { return rowPositionCoordinate.getRowPosition(); } @Override public String toString() { return this.getClass().getSimpleName() + " rowPosition=" + rowPositionCoordinate.getRowPosition(); } }
1,030
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
AbstractLayerCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/command/AbstractLayerCommandHandler.java
package net.sourceforge.nattable.command; import net.sourceforge.nattable.layer.ILayer; public abstract class AbstractLayerCommandHandler<T extends ILayerCommand> implements ILayerCommandHandler<T> { public final boolean doCommand(ILayer targetLayer, T command) { if (command.convertToTargetLayer(targetLayer)) { return doCommand(command); } return false; } protected abstract boolean doCommand(T command); }
428
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ILayerCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/command/ILayerCommandHandler.java
package net.sourceforge.nattable.command; import net.sourceforge.nattable.layer.ILayer; public interface ILayerCommandHandler <T extends ILayerCommand> { public Class<T> getCommandClass(); /** * @param command * @return true if the command has been handled, false otherwise */ public boolean doCommand(ILayer targetLayer, T command); }
368
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CopyDataAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/copy/action/CopyDataAction.java
package net.sourceforge.nattable.copy.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.copy.command.CopyDataToClipboardCommand; import net.sourceforge.nattable.ui.action.IKeyAction; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.events.KeyEvent; public class CopyDataAction implements IKeyAction { public void run(NatTable natTable, KeyEvent event) { natTable.doCommand(new CopyDataToClipboardCommand(new Clipboard(event.display), "\t", "\n")); } }
518
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CopyDataToClipboardCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/copy/command/CopyDataToClipboardCommand.java
package net.sourceforge.nattable.copy.command; import org.eclipse.swt.dnd.Clipboard; import net.sourceforge.nattable.command.AbstractContextFreeCommand; public class CopyDataToClipboardCommand extends AbstractContextFreeCommand { private final Clipboard clipboard; private final String cellDelimeter; private final String rowDelimeter; public CopyDataToClipboardCommand(Clipboard clipboard, String cellDelimeter, String rowDelimeter) { this.clipboard = clipboard; this.cellDelimeter = cellDelimeter; this.rowDelimeter = rowDelimeter; } public Clipboard getClipboard() { return clipboard; } public String getCellDelimeter() { return cellDelimeter; } public String getRowDelimeter() { return rowDelimeter; } }
776
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CopyDataCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/copy/command/CopyDataCommandHandler.java
package net.sourceforge.nattable.copy.command; import java.util.Set; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.copy.serializing.CopyDataToClipboardSerializer; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.cell.LayerCell; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.serializing.ISerializer; public class CopyDataCommandHandler extends AbstractLayerCommandHandler<CopyDataToClipboardCommand> { private final SelectionLayer selectionLayer; private final ILayer columnHeaderLayer; private final ILayer rowHeaderLayer; public CopyDataCommandHandler(SelectionLayer selectionLayer) { this(selectionLayer, null, null); } public CopyDataCommandHandler(SelectionLayer selectionLayer, ILayer columnHeaderLayer, ILayer rowHeaderLayer) { this.selectionLayer = selectionLayer; this.columnHeaderLayer = columnHeaderLayer; this.rowHeaderLayer = rowHeaderLayer; } public boolean doCommand(CopyDataToClipboardCommand command) { ISerializer serializer = new CopyDataToClipboardSerializer(assembleCopiedDataStructure(), command); serializer.serialize(); return true; } public Class<CopyDataToClipboardCommand> getCommandClass() { return CopyDataToClipboardCommand.class; } protected LayerCell[][] assembleCopiedDataStructure() { final Set<Range> selectedRows = selectionLayer.getSelectedRows(); final int rowOffset = columnHeaderLayer != null ? columnHeaderLayer.getRowCount() : 0; // Add offset to rows, remember they need to include the column header as a row final LayerCell[][] copiedCells = new LayerCell[selectionLayer.getSelectedRowCount() + rowOffset][1]; if (columnHeaderLayer != null) { copiedCells[0] = assembleColumnHeaders(selectionLayer.getSelectedColumns()); } for (Range range : selectedRows) { for (int rowPosition = range.start; rowPosition < range.end; rowPosition++) { copiedCells[(rowPosition - range.start) + rowOffset] = assembleBody(rowPosition); } } return copiedCells; } /** * FIXME When we implement column groups, keep in mind this method assumes the ColumnHeaderLayer is has only a height of 1 row. * @return */ protected LayerCell[] assembleColumnHeaders(int... selectedColumnPositions) { final int columnOffset = rowHeaderLayer.getColumnCount(); final LayerCell[] cells = new LayerCell[selectedColumnPositions.length + columnOffset]; for (int columnPosition = 0; columnPosition < selectedColumnPositions.length; columnPosition++) { // Pad the width of the vertical layer cells[columnPosition + columnOffset] = columnHeaderLayer.getCellByPosition(selectedColumnPositions[columnPosition], 0); } return cells; } /** * FIXME Assumes row headers have only one column. * @param lastSelectedColumnPosition * @param currentRowPosition * @return */ protected LayerCell[] assembleBody(int currentRowPosition) { final int[] selectedColumns = selectionLayer.getSelectedColumns(); final int columnOffset = rowHeaderLayer != null ? rowHeaderLayer.getColumnCount() : 0; final LayerCell[] bodyCells = new LayerCell[selectedColumns.length + columnOffset]; if (rowHeaderLayer != null) { bodyCells[0] = rowHeaderLayer.getCellByPosition(0, currentRowPosition); } for (int columnPosition = 0; columnPosition < selectedColumns.length; columnPosition++) { final int selectedColumnPosition = selectedColumns[columnPosition]; if (selectionLayer.isCellPositionSelected(selectedColumnPosition, currentRowPosition)) { bodyCells[columnPosition + columnOffset] = selectionLayer.getCellByPosition(selectedColumnPosition, currentRowPosition); } } return bodyCells; } }
3,886
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
CopyDataToClipboardSerializer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/copy/serializing/CopyDataToClipboardSerializer.java
package net.sourceforge.nattable.copy.serializing; import net.sourceforge.nattable.copy.command.CopyDataToClipboardCommand; import net.sourceforge.nattable.layer.cell.LayerCell; import net.sourceforge.nattable.serializing.ISerializer; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; public class CopyDataToClipboardSerializer implements ISerializer { private final LayerCell[][] copiedCells; private final CopyDataToClipboardCommand command; public CopyDataToClipboardSerializer(LayerCell[][] copiedCells, CopyDataToClipboardCommand command) { this.copiedCells = copiedCells; this.command = command; } public void serialize() { final Clipboard clipboard = command.getClipboard(); final String cellDelimeter = command.getCellDelimeter(); final String rowDelimeter = command.getRowDelimeter(); final TextTransfer textTransfer = TextTransfer.getInstance(); final StringBuilder textData = new StringBuilder(); int currentRow = 0; for (LayerCell[] cells : copiedCells) { int currentCell = 0; for (LayerCell cell : cells) { final String delimeter = ++currentCell < cells.length ? cellDelimeter : ""; if (cell != null) { textData.append(cell.getDataValue() + delimeter); } else { textData.append(delimeter); } } if (++currentRow < copiedCells.length) { textData.append(rowDelimeter); } } clipboard.setContents(new Object[]{textData.toString()}, new Transfer[]{textTransfer}); } }
1,570
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
HorizontalScrollBarHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/HorizontalScrollBarHandler.java
package net.sourceforge.nattable.viewport; import static net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum.LEFT; import static net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum.RIGHT; import net.sourceforge.nattable.layer.LayerUtil; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.ScrollBar; /** * Listener for the Horizontal scroll bar events on the Viewport Layer. State is * exposed to this class from the viewport, since it works in close conjnuction * with it. */ public class HorizontalScrollBarHandler extends ScrollBarHandlerTemplate { public HorizontalScrollBarHandler(ViewportLayer viewportLayer, ScrollBar scrollBar) { super(viewportLayer, scrollBar); } /** * In a normal scenario scroll by the width of the viewport. * If the col being scrolled is wider than above, use the col width */ @Override int pageScrollDistance() { int widthOfColBeingScrolled = scrollableLayer.getColumnWidthByPosition(getScrollablePosition()); int viewportWidth = viewportLayer.getClientAreaWidth(); int scrollWidth = (widthOfColBeingScrolled > viewportWidth) ? widthOfColBeingScrolled : viewportWidth; return scrollWidth; } @Override int getSpanByPosition(int scrollablePosition) { return scrollableLayer.getColumnWidthByPosition(scrollablePosition); } @Override int getScrollablePosition() { return LayerUtil.convertColumnPosition(viewportLayer, 0, scrollableLayer); } @Override int getStartPixelOfPosition(int position){ return scrollableLayer.getStartXOfColumnPosition(position); } @Override int getPositionByPixel(int pixelValue) { return scrollableLayer.getColumnPositionByX(pixelValue); } @Override void setViewportOrigin(int position) { viewportLayer.invalidateHorizontalStructure(); viewportLayer.setOriginColumnPosition(position); scrollBar.setIncrement(viewportLayer.getColumnWidthByPosition(0)); } @Override MoveDirectionEnum scrollDirectionForEventDetail(int eventDetail){ return (eventDetail == SWT.PAGE_UP || eventDetail == SWT.ARROW_UP ) ? LEFT : RIGHT; } @Override boolean keepScrolling() { return !viewportLayer.isLastColumnCompletelyDisplayed(); } @Override int getViewportWindowSpan() { return viewportLayer.getClientAreaWidth(); } @Override int getScrollableLayerSpan() { return scrollableLayer.getWidth(); } }
2,527
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
VerticalScrollBarHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/VerticalScrollBarHandler.java
package net.sourceforge.nattable.viewport; import static net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum.DOWN; import static net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum.UP; import net.sourceforge.nattable.layer.LayerUtil; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.ScrollBar; /** * Listener for the Vertical scroll bar events. */ public class VerticalScrollBarHandler extends ScrollBarHandlerTemplate implements Listener { public VerticalScrollBarHandler(ViewportLayer viewportLayer, ScrollBar scrollBar) { super(viewportLayer, scrollBar); } /** * In a normal scenario scroll by the height of the viewport. If the row * being scrolled is wider than above, use the row height */ @Override int pageScrollDistance() { int heightOfRowBeingScrolled = scrollableLayer.getRowHeightByPosition(getScrollablePosition()); int viewportHeight = viewportLayer.getClientAreaHeight(); return (heightOfRowBeingScrolled > viewportHeight) ? heightOfRowBeingScrolled : viewportHeight; } @Override int getSpanByPosition(int scrollablePosition) { return scrollableLayer.getRowHeightByPosition(scrollablePosition); } /** * Convert Viewport 0 pos -> Scrollable 0 pos * * @return */ @Override int getScrollablePosition() { return LayerUtil.convertRowPosition(viewportLayer, 0, scrollableLayer); } @Override int getStartPixelOfPosition(int position) { return scrollableLayer.getStartYOfRowPosition(position); } @Override int getPositionByPixel(int pixelValue) { return scrollableLayer.getRowPositionByY(pixelValue); } @Override void setViewportOrigin(int position) { viewportLayer.invalidateVerticalStructure(); viewportLayer.setOriginRowPosition(position); scrollBar.setIncrement(viewportLayer.getRowHeightByPosition(0)); } @Override MoveDirectionEnum scrollDirectionForEventDetail(int eventDetail) { return (eventDetail == SWT.PAGE_UP || eventDetail == SWT.ARROW_UP) ? UP : DOWN; } @Override boolean keepScrolling() { return !viewportLayer.isLastRowCompletelyDisplayed(); } @Override int getViewportWindowSpan() { return viewportLayer.getClientAreaHeight(); } @Override int getScrollableLayerSpan() { return scrollableLayer.getHeight(); } }
2,471
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ViewportLayer.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/ViewportLayer.java
package net.sourceforge.nattable.viewport; import java.util.ArrayList; import java.util.List; import net.sourceforge.nattable.command.ILayerCommand; import net.sourceforge.nattable.coordinate.PositionCoordinate; import net.sourceforge.nattable.coordinate.Range; import net.sourceforge.nattable.grid.command.ClientAreaResizeCommand; import net.sourceforge.nattable.layer.AbstractLayerTransform; import net.sourceforge.nattable.layer.ILayer; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.layer.LayerUtil; import net.sourceforge.nattable.layer.event.ILayerEvent; import net.sourceforge.nattable.layer.event.IStructuralChangeEvent; import net.sourceforge.nattable.print.command.PrintEntireGridCommand; import net.sourceforge.nattable.print.command.TurnViewportOffCommand; import net.sourceforge.nattable.print.command.TurnViewportOnCommand; import net.sourceforge.nattable.selection.ScrollSelectionCommandHandler; import net.sourceforge.nattable.selection.SelectionLayer; import net.sourceforge.nattable.selection.command.MoveSelectionCommand; import net.sourceforge.nattable.selection.command.ScrollSelectionCommand; import net.sourceforge.nattable.selection.event.CellSelectionEvent; import net.sourceforge.nattable.selection.event.ColumnSelectionEvent; import net.sourceforge.nattable.selection.event.RowSelectionEvent; import net.sourceforge.nattable.viewport.command.RecalculateScrollBarsCommandHandler; import net.sourceforge.nattable.viewport.command.ShowCellInViewportCommandHandler; import net.sourceforge.nattable.viewport.command.ShowColumnInViewportCommandHandler; import net.sourceforge.nattable.viewport.command.ShowRowInViewportCommandHandler; import net.sourceforge.nattable.viewport.command.ViewportSelectColumnCommandHandler; import net.sourceforge.nattable.viewport.command.ViewportSelectRowCommandHandler; import net.sourceforge.nattable.viewport.event.ScrollEvent; import net.sourceforge.nattable.viewport.event.ViewportEventHandler; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.ScrollBar; /** * Viewport - the visible area of NatTable * Places a 'viewport' over the table. Introduces scroll bars over the table and * keeps them in sync with the data being displayed. This is typically placed over the * {@link SelectionLayer}. */ public class ViewportLayer extends AbstractLayerTransform implements IUniqueIndexLayer { private HorizontalScrollBarHandler hBarListener; private VerticalScrollBarHandler vBarListener; private final IUniqueIndexLayer scrollableLayer; // The viewport origin, in scrollable position coordinates. private final PositionCoordinate origin = new PositionCoordinate(this, 0, 0); private final PositionCoordinate minimumOrigin = new PositionCoordinate(this, 0, 0); private boolean viewportOff = false; private int viewportOffOriginCol, viewportOnOriginRow = 0; // Cache private List<Integer> cachedColumnIndexOrder; private List<Integer> cachedRowIndexOrder; private int cachedClientAreaWidth = 0; private int cachedClientAreaHeight = 0; private int cachedWidth = -1; private int cachedHeight = -1; public ViewportLayer(IUniqueIndexLayer underlyingLayer) { super(underlyingLayer); this.scrollableLayer = underlyingLayer; registerCommandHandler(new RecalculateScrollBarsCommandHandler(this)); registerCommandHandler(new ScrollSelectionCommandHandler(this)); registerCommandHandler(new ShowCellInViewportCommandHandler(this)); registerCommandHandler(new ShowColumnInViewportCommandHandler(this)); registerCommandHandler(new ShowRowInViewportCommandHandler(this)); registerCommandHandler(new ViewportSelectColumnCommandHandler(this)); registerCommandHandler(new ViewportSelectRowCommandHandler(this)); registerEventHandler(new ViewportEventHandler(this)); } // Origin public int getMinimumOriginColumnPosition() { return minimumOrigin.columnPosition; } public void setMinimumOriginColumnPosition(int minColumnPosition) { int previousOriginColumnPosition = origin.columnPosition; if (previousOriginColumnPosition == minimumOrigin.columnPosition || getOriginColumnPosition() < minColumnPosition) { minimumOrigin.columnPosition = minColumnPosition; setOriginColumnPosition(minColumnPosition); } else { setOriginColumnPosition(getOriginColumnPosition() + minColumnPosition - minimumOrigin.columnPosition); minimumOrigin.columnPosition = minColumnPosition; } if (origin.columnPosition != previousOriginColumnPosition) { invalidateHorizontalStructure(); } recalculateHorizontalScrollBar(); } public int getMinimumOriginRowPosition() { return minimumOrigin.rowPosition; } public void setMinimumOriginRowPosition(int minRowPosition) { int previousOriginRowPosition = origin.rowPosition; if (getOriginRowPosition() < minRowPosition) { setOriginRowPosition(minRowPosition); } else { setOriginRowPosition(getOriginRowPosition() + minRowPosition - minimumOrigin.rowPosition); } minimumOrigin.rowPosition = minRowPosition; if (origin.rowPosition != previousOriginRowPosition) { invalidateVerticalStructure(); } recalculateVerticalScrollBar(); } public void setMinimumOriginPosition(int minColumnPosition, int minRowPosition) { setMinimumOriginColumnPosition(minColumnPosition); setMinimumOriginRowPosition(minRowPosition); } public int getOriginColumnPosition() { return viewportOff ? minimumOrigin.columnPosition : origin.columnPosition; } public void setOriginColumnPosition(int scrollableColumnPosition) { if (scrollableColumnPosition < minimumOrigin.columnPosition) { scrollableColumnPosition = minimumOrigin.columnPosition; } if (scrollableColumnPosition >= getUnderlyingLayer().getColumnCount()) { scrollableColumnPosition = getUnderlyingLayer().getColumnCount() - 1; } int originalOriginColumnPosition = getOriginColumnPosition(); origin.columnPosition = scrollableColumnPosition; int adjustedOriginColumnPosition = adjustColumnOrigin(); if (adjustedOriginColumnPosition != originalOriginColumnPosition && getUnderlyingLayer().getColumnIndexByPosition(scrollableColumnPosition) >= 0) { invalidateHorizontalStructure(); origin.columnPosition = adjustedOriginColumnPosition; fireScrollEvent(); } } public int getOriginRowPosition() { return viewportOff ? minimumOrigin.rowPosition : origin.rowPosition; } public void setOriginRowPosition(int scrollableRowPosition) { if (scrollableRowPosition < minimumOrigin.rowPosition) { scrollableRowPosition = minimumOrigin.rowPosition; } int originalOriginRowPosition = getOriginRowPosition(); origin.rowPosition = scrollableRowPosition; int adjustedOriginRowPosition = adjustRowOrigin(); if (adjustedOriginRowPosition != originalOriginRowPosition && getUnderlyingLayer().getRowIndexByPosition(scrollableRowPosition) >= 0) { invalidateVerticalStructure(); origin.rowPosition = adjustedOriginRowPosition; fireScrollEvent(); } } public void resetOrigin() { int previousOriginColumnPosition = origin.columnPosition; int previousOriginRowPosition = origin.rowPosition; minimumOrigin.columnPosition = 0; origin.columnPosition = 0; minimumOrigin.rowPosition = 0; origin.rowPosition = 0; if (origin.columnPosition != previousOriginColumnPosition) { invalidateHorizontalStructure(); } if (origin.rowPosition != previousOriginRowPosition) { invalidateVerticalStructure(); } } // Horizontal features // Columns /** * @return <i>visible</i> column count * Note: This takes care of the frozen columns */ @Override public int getColumnCount() { if (viewportOff) { return scrollableLayer.getColumnCount() - minimumOrigin.columnPosition; } else { return getColumnIndexes().size(); } } public int getColumnPositionByIndex(int columnIndex) { return scrollableLayer.getColumnPositionByIndex(columnIndex) - getOriginColumnPosition(); } @Override public int localToUnderlyingColumnPosition(int localColumnPosition) { return getOriginColumnPosition() + localColumnPosition; } @Override public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) { if (sourceUnderlyingLayer != getUnderlyingLayer()) { return -1; } return underlyingColumnPosition - getOriginColumnPosition(); } private List<Integer> getColumnIndexes() { if (cachedColumnIndexOrder == null) { int availableWidth = getClientAreaWidth(); if (availableWidth >= 0) { if (getOriginColumnPosition() < minimumOrigin.columnPosition) { origin.columnPosition = minimumOrigin.columnPosition; } recalculateAvailableWidthAndColumnIndexes(); } } return cachedColumnIndexOrder; } // Width /** * @return the width of the total number of visible columns */ @Override public int getWidth() { if (viewportOff) { return scrollableLayer.getWidth() - scrollableLayer.getStartXOfColumnPosition(minimumOrigin.columnPosition); } if (cachedWidth < 0) { recalculateAvailableWidthAndColumnIndexes(); } return cachedWidth; } // Column resize @Override public boolean isColumnPositionResizable(int columnPosition) { return getUnderlyingLayer().isColumnPositionResizable(getOriginColumnPosition() + columnPosition); } // X @Override public int getColumnPositionByX(int x) { int originX = getUnderlyingLayer().getStartXOfColumnPosition(getOriginColumnPosition()); return getUnderlyingLayer().getColumnPositionByX(originX + x) - getOriginColumnPosition(); } @Override public int getStartXOfColumnPosition(int columnPosition) { return getUnderlyingLayer().getStartXOfColumnPosition(getOriginColumnPosition() + columnPosition) - getUnderlyingLayer().getStartXOfColumnPosition(getOriginColumnPosition()); } // Vertical features // Rows /** * @return total number of rows visible in the viewport */ @Override public int getRowCount() { if (viewportOff) { return scrollableLayer.getRowCount() - minimumOrigin.rowPosition; } return getRowIndexes().size(); } public int getRowPositionByIndex(int rowIndex) { return scrollableLayer.getRowPositionByIndex(rowIndex) - getOriginRowPosition(); } @Override public int localToUnderlyingRowPosition(int localRowPosition) { return getOriginRowPosition() + localRowPosition; } @Override public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition) { if (sourceUnderlyingLayer != getUnderlyingLayer()) { return -1; } return underlyingRowPosition - getOriginRowPosition(); } private List<Integer> getRowIndexes() { if (cachedRowIndexOrder == null) { int availableHeight = getClientAreaHeight(); if (availableHeight >= 0) { if (getOriginRowPosition() < minimumOrigin.rowPosition) { origin.rowPosition = minimumOrigin.rowPosition; } recalculateAvailableHeightAndRowIndexes(); } } return cachedRowIndexOrder; } // Height @Override public int getHeight() { if (viewportOff) { return scrollableLayer.getHeight() - scrollableLayer.getStartYOfRowPosition(minimumOrigin.rowPosition); } if (cachedHeight < 0) { recalculateAvailableHeightAndRowIndexes(); } return cachedHeight; } // Row resize // Y @Override public int getRowPositionByY(int y) { int originY = getUnderlyingLayer().getStartYOfRowPosition(getOriginRowPosition()); return getUnderlyingLayer().getRowPositionByY(originY + y) - getOriginRowPosition(); } @Override public int getStartYOfRowPosition(int rowPosition) { return getUnderlyingLayer().getStartYOfRowPosition(getOriginRowPosition() + rowPosition) - getUnderlyingLayer().getStartYOfRowPosition(getOriginRowPosition()); } // Cell features @Override public Rectangle getBoundsByPosition(int columnPosition, int rowPosition) { int underlyingColumnPosition = localToUnderlyingColumnPosition(columnPosition); int underlyingRowPosition = localToUnderlyingRowPosition(rowPosition); Rectangle bounds = getUnderlyingLayer().getBoundsByPosition(underlyingColumnPosition, underlyingRowPosition); bounds.x -= getUnderlyingLayer().getStartXOfColumnPosition(getOriginColumnPosition()); bounds.y -= getUnderlyingLayer().getStartYOfRowPosition(getOriginRowPosition()); return bounds; } /** * Clear horizontal caches */ public void invalidateHorizontalStructure() { cachedColumnIndexOrder = null; cachedClientAreaWidth = 0; cachedWidth = -1; } /** * Clear vertical caches */ public void invalidateVerticalStructure() { cachedRowIndexOrder = null; cachedClientAreaHeight = 0; cachedHeight = -1; } /** * This method will add the indexes of the column which fit in the available * view port width. Every time a column is added, the available width is * reduced by the width of the added column. * * @param availableWidth * @param displayableColumns * all indexes * @param columnIndex * to try and add to the displayable columns * @return */ protected void recalculateAvailableWidthAndColumnIndexes() { int availableWidth = getClientAreaWidth(); ILayer underlyingLayer = getUnderlyingLayer(); cachedWidth = 0; cachedColumnIndexOrder = new ArrayList<Integer>(); for (int columnPosition = getOriginColumnPosition(); columnPosition < underlyingLayer.getColumnCount() && availableWidth > 0; columnPosition++) { int columnIndex = underlyingLayer.getColumnIndexByPosition(columnPosition); int width = underlyingLayer.getColumnWidthByPosition(columnPosition); availableWidth -= width; cachedWidth += width; cachedColumnIndexOrder.add(Integer.valueOf(columnIndex)); } int lastColumnPosition = underlyingLayer.getColumnCount() - 1; if (origin.columnPosition > lastColumnPosition) { origin.columnPosition = lastColumnPosition; } } protected void recalculateAvailableHeightAndRowIndexes() { int availableHeight = getClientAreaHeight(); ILayer underlyingLayer = getUnderlyingLayer(); cachedHeight = 0; cachedRowIndexOrder = new ArrayList<Integer>(); for (int currentPosition = getOriginRowPosition(); currentPosition < underlyingLayer.getRowCount() && availableHeight > 0; currentPosition++) { int rowIndex = underlyingLayer.getRowIndexByPosition(currentPosition); int height = underlyingLayer.getRowHeightByPosition(rowIndex); availableHeight -= height; cachedHeight += height; cachedRowIndexOrder.add(Integer.valueOf(rowIndex)); } int lastRowPosition = underlyingLayer.getRowCount() - 1; if (origin.rowPosition > lastRowPosition) { origin.rowPosition = (lastRowPosition < 0) ? 0 : lastRowPosition; } } /** * Srcolls the table so that the specified cell is visible i.e. in the Viewport * @param scrollableColumnPosition * @param scrollableRowPosition * @param forceEntireCellIntoViewport */ public void moveCellPositionIntoViewport(int scrollableColumnPosition, int scrollableRowPosition, boolean forceEntireCellIntoViewport) { moveColumnPositionIntoViewport(scrollableColumnPosition, forceEntireCellIntoViewport); moveRowPositionIntoViewport(scrollableRowPosition, forceEntireCellIntoViewport); } /** * Scrolls the viewport (if required) so that the specified column is visible. * @param scrollableColumnPosition column position in terms of the Scrollable Layer */ public void moveColumnPositionIntoViewport(int scrollableColumnPosition, boolean forceEntireCellIntoViewport) { ILayer underlyingLayer = getUnderlyingLayer(); if (underlyingLayer.getColumnIndexByPosition(scrollableColumnPosition) >= 0) { if (scrollableColumnPosition >= getMinimumOriginColumnPosition()) { int originColumnPosition = getOriginColumnPosition(); if (scrollableColumnPosition < originColumnPosition) { // Move left setOriginColumnPosition(scrollableColumnPosition); } else { int scrollableColumnStartX = underlyingLayer.getStartXOfColumnPosition(scrollableColumnPosition); int scrollableColumnEndX = scrollableColumnStartX + underlyingLayer.getColumnWidthByPosition(scrollableColumnPosition); int clientAreaWidth = getClientAreaWidth(); int viewportEndX = underlyingLayer.getStartXOfColumnPosition(getOriginColumnPosition()) + clientAreaWidth; if (viewportEndX < scrollableColumnEndX) { int targetOriginColumnPosition; if (forceEntireCellIntoViewport || isLastColumn(scrollableColumnPosition)) { targetOriginColumnPosition = underlyingLayer.getColumnPositionByX(scrollableColumnEndX - clientAreaWidth) + 1; } else { targetOriginColumnPosition = underlyingLayer.getColumnPositionByX(scrollableColumnStartX - clientAreaWidth) + 1; } // Move right setOriginColumnPosition(targetOriginColumnPosition); } } } } } /** * @see {@link #moveColumnPositionIntoViewport(int, boolean)} */ public void moveRowPositionIntoViewport(int scrollableRowPosition, boolean forceEntireCellIntoViewport) { ILayer underlyingLayer = getUnderlyingLayer(); if (underlyingLayer.getRowIndexByPosition(scrollableRowPosition) >= 0) { if (scrollableRowPosition >= getMinimumOriginRowPosition()) { int originRowPosition = getOriginRowPosition(); if (scrollableRowPosition < originRowPosition) { // Move up setOriginRowPosition(scrollableRowPosition); } else { int scrollableRowStartY = underlyingLayer.getStartYOfRowPosition(scrollableRowPosition); int scrollableRowEndY = scrollableRowStartY + underlyingLayer.getRowHeightByPosition(scrollableRowPosition); int clientAreaHeight = getClientAreaHeight(); int viewportEndY = underlyingLayer.getStartYOfRowPosition(getOriginRowPosition()) + clientAreaHeight; if (viewportEndY < scrollableRowEndY) { int targetOriginRowPosition; if (forceEntireCellIntoViewport || isLastRow(scrollableRowPosition)) { targetOriginRowPosition = underlyingLayer.getRowPositionByY(scrollableRowEndY - clientAreaHeight) + 1; } else { targetOriginRowPosition = underlyingLayer.getRowPositionByY(scrollableRowStartY - clientAreaHeight) + 1; } // Move down setOriginRowPosition(targetOriginRowPosition); } } } } } private boolean isLastColumn(int scrollableColumnPosition) { return scrollableColumnPosition == getUnderlyingLayer().getColumnCount()-1; } private boolean isLastRow(int scrollableRowPosition) { return scrollableRowPosition == getUnderlyingLayer().getRowCount()-1; } private void fireScrollEvent() { fireLayerEvent(new ScrollEvent(this)); } @Override public boolean doCommand(ILayerCommand command) { if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) { ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command; ScrollBar hBar = clientAreaResizeCommand.getScrollable().getHorizontalBar(); ScrollBar vBar = clientAreaResizeCommand.getScrollable().getVerticalBar(); if (hBarListener == null) { hBarListener = new HorizontalScrollBarHandler(this, hBar); } if (vBarListener == null) { vBarListener = new VerticalScrollBarHandler(this, vBar); } handleGridResize(); return true; } else if (command instanceof TurnViewportOffCommand) { viewportOffOriginCol = localToUnderlyingColumnPosition(0); viewportOnOriginRow = localToUnderlyingRowPosition(0); viewportOff = true; return true; } else if (command instanceof TurnViewportOnCommand) { viewportOff = false; setOriginColumnPosition(viewportOffOriginCol); setOriginRowPosition(viewportOnOriginRow); return true; } else if (command instanceof PrintEntireGridCommand) { moveCellPositionIntoViewport(0, 0, false); } return super.doCommand(command); } private void recalculateHorizontalScrollBar() { if (hBarListener != null) { hBarListener.recalculateScrollBarSize(); } } private void recalculateVerticalScrollBar() { if (vBarListener != null) { vBarListener.recalculateScrollBarSize(); } } public void recalculateScrollBars() { recalculateHorizontalScrollBar(); recalculateVerticalScrollBar(); } protected void handleGridResize() { setOriginColumnPosition(origin.columnPosition); recalculateHorizontalScrollBar(); setOriginRowPosition(origin.rowPosition); recalculateVerticalScrollBar(); } /** * @see #adjustRowOrigin() */ protected int adjustColumnOrigin() { if (getColumnCount() == 0) { return 0; } int availableWidth = getClientAreaWidth() - getWidth(); if (availableWidth < 0) { return getOriginColumnPosition(); } int originColumnPosition = getOriginColumnPosition(); int previousColPosition = LayerUtil.convertColumnPosition(this, 0, scrollableLayer) - 1; while (previousColPosition >= 0) { int previousColWidth = getUnderlyingLayer().getColumnWidthByPosition(previousColPosition); if (availableWidth >= previousColWidth && originColumnPosition - 1 >= minimumOrigin.columnPosition) { originColumnPosition--; availableWidth -= previousColWidth; } else { break; } previousColPosition--; } return originColumnPosition; } /** * If the client area size is greater than the content size, * calculate number of rows to add to viewport i.e move the origin */ protected int adjustRowOrigin() { if (getRowCount() == 0) { return 0; } int availableHeight = getClientAreaHeight() - getHeight(); if (availableHeight < 0) { return getOriginRowPosition(); } int originRowPosition = getOriginRowPosition(); int previousRowPosition = LayerUtil.convertRowPosition(this, 0, scrollableLayer) - 1; // Can we fit another row ? while (previousRowPosition >= 0) { int previousRowHeight = getUnderlyingLayer().getRowHeightByPosition(previousRowPosition); if (availableHeight >= previousRowHeight && originRowPosition - 1 >= minimumOrigin.rowPosition) { originRowPosition--; availableHeight -= previousRowHeight; } else { break; } previousRowPosition--; } return originRowPosition; } public void scrollVerticallyByAPage(ScrollSelectionCommand scrollSelectionCommand) { getUnderlyingLayer().doCommand(scrollVerticallyByAPageCommand(scrollSelectionCommand)); } protected MoveSelectionCommand scrollVerticallyByAPageCommand(ScrollSelectionCommand scrollSelectionCommand) { return new MoveSelectionCommand(scrollSelectionCommand.getDirection(), getRowCount(), scrollSelectionCommand.isShiftMask(), scrollSelectionCommand.isControlMask()); } protected boolean isLastColumnCompletelyDisplayed() { int lastDisplayableColumnIndex = getUnderlyingLayer().getColumnIndexByPosition(getUnderlyingLayer().getColumnCount() - 1); int visibleColumnCount = getColumnCount(); int lastVisibleColumnIndex = getColumnIndexByPosition(visibleColumnCount - 1); return (lastVisibleColumnIndex == lastDisplayableColumnIndex) && (getClientAreaWidth() >= getWidth()); } protected boolean isLastRowCompletelyDisplayed() { int lastDisplayableRowIndex = getUnderlyingLayer().getRowIndexByPosition(getUnderlyingLayer().getRowCount() - 1); int visibleRowCount = getRowCount(); int lastVisibleRowIndex = getRowIndexByPosition(visibleRowCount - 1); return (lastVisibleRowIndex == lastDisplayableRowIndex) && (getClientAreaHeight() >= getHeight()); } // Event handling @Override public void handleLayerEvent(ILayerEvent event) { if (event instanceof IStructuralChangeEvent) { IStructuralChangeEvent structuralChangeEvent = (IStructuralChangeEvent) event; if (structuralChangeEvent.isHorizontalStructureChanged()) { invalidateHorizontalStructure(); } if (structuralChangeEvent.isVerticalStructureChanged()) { invalidateVerticalStructure(); } } if (event instanceof CellSelectionEvent) { processSelection((CellSelectionEvent) event); } else if (event instanceof ColumnSelectionEvent) { processColumnSelection((ColumnSelectionEvent) event); } else if (event instanceof RowSelectionEvent) { processRowSelection((RowSelectionEvent) event); } super.handleLayerEvent(event); } /** * Handle the {@link CellSelectionEvent} * @param selectionEvent */ private void processSelection(CellSelectionEvent selectionEvent) { moveCellPositionIntoViewport(selectionEvent.getColumnPosition(), selectionEvent.getRowPosition(), selectionEvent.isForcingEntireCellIntoViewport()); adjustHorizontalScrollBar(); adjustVerticalScrollBar(); } private void processColumnSelection(ColumnSelectionEvent selectionEvent) { for (Range columnPositionRange : selectionEvent.getColumnPositionRanges()) { moveColumnPositionIntoViewport(columnPositionRange.end - 1, false); adjustHorizontalScrollBar(); } } private void processRowSelection(RowSelectionEvent selectionEvent) { for (Range columnPositionRange : selectionEvent.getRowPositionRanges()) { moveRowPositionIntoViewport(columnPositionRange.end - 1, false); } adjustVerticalScrollBar(); } private void adjustHorizontalScrollBar() { if (hBarListener != null) { hBarListener.adjustScrollBar(); } } private void adjustVerticalScrollBar() { if (vBarListener != null) { vBarListener.adjustScrollBar(); } } // Accessors public int getClientAreaWidth() { int clientAreaWidth = getClientAreaProvider().getClientArea().width; if (clientAreaWidth != cachedClientAreaWidth) { invalidateHorizontalStructure(); cachedClientAreaWidth = clientAreaWidth; } return cachedClientAreaWidth; } public int getClientAreaHeight() { int clientAreaHeight = getClientAreaProvider().getClientArea().height; if (clientAreaHeight != cachedClientAreaHeight) { invalidateVerticalStructure(); cachedClientAreaHeight = clientAreaHeight; } return cachedClientAreaHeight; } public SelectionLayer getSelectionLayer() { return (SelectionLayer) getUnderlyingLayer(); } public IUniqueIndexLayer getScrollableLayer() { return scrollableLayer; } @Override public String toString() { return "Viewport Layer"; } }
26,791
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ScrollBarHandlerTemplate.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/ScrollBarHandlerTemplate.java
package net.sourceforge.nattable.viewport; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.selection.SelectionLayer.MoveDirectionEnum; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.ScrollBar; public abstract class ScrollBarHandlerTemplate implements Listener { public static final int DEFAULT_OFFSET = 1; protected final ViewportLayer viewportLayer; protected final IUniqueIndexLayer scrollableLayer; protected final ScrollBar scrollBar; public ScrollBarHandlerTemplate(ViewportLayer viewportLayer, ScrollBar scrollBar) { this.viewportLayer = viewportLayer; this.scrollableLayer = viewportLayer.getScrollableLayer(); this.scrollBar = scrollBar; this.scrollBar.addListener(SWT.Selection, this); } public void handleEvent(Event event) { ScrollBar scrollBar = (ScrollBar) event.widget; int position = getPositionByPixel(scrollBar.getSelection()); setViewportOrigin(position); } void adjustScrollBar() { if (scrollBar.isDisposed()) { return; } int scrollablePosition = getScrollablePosition(); int startPixel = getStartPixelOfPosition(scrollablePosition); scrollBar.setSelection(startPixel); } void recalculateScrollBarSize() { if (scrollBar.isDisposed()) { return; } int scrollableLayerSpan = getScrollableLayerSpan(); int viewportWindowSpan = getViewportWindowSpan(); int max = scrollableLayerSpan + getScrollBarOverhang(); if (! scrollBar.isDisposed()) { scrollBar.setMaximum(max); } scrollBar.setPageIncrement(viewportWindowSpan); int thumbSize; if (viewportWindowSpan < max) { thumbSize = viewportWindowSpan; scrollBar.setEnabled(true); scrollBar.setVisible(true); } else { thumbSize = max; scrollBar.setEnabled(false); scrollBar.setVisible(false); } scrollBar.setThumb(thumbSize); } /** * Overhang - the extra white area left at the right/bottom edge * (due to the first column aligning with the left edge) */ protected int getScrollBarOverhang() { /* * If the scrollbar is moved to its max extent and the left/topmost cell is partially visible, then the viewport * would be snapped back to align with the left/top edge of the first visible cell as above, but this would then * move the right/bottommost cell out of the viewport. In this case there would be no way to view the * right/bottommost edge of the right/bottommost cells. In order to remedy this, an overhang size is calculated * and added to the size of the underlying scrollable area when calculating the scroll handle sizes, like so * (this example is for column widths; similar logic applies for row heights): * * a. take the width of the viewport * b. take the width of the underlying scrollable area * c. subtract the width of the viewport from the width of the scrollable area to get an x pixel position * d. find the column at the x pixel position * e. find the start x pixel position of the column found in d * f. if the start x pixel position in e is not equal to the x pixel position in c, then we must calculate an * overhang * g. overhang = width of column d - (x pixel position found in c - start x position of column d) * * The scrollbar handle width is then proportional to the viewport width compared to the scrollable area width * plus this overhang. The end effect is that when the scroll handle is moved to its maximal position, instead * of the left edge of the viewport being positioned in the middle of a cell, it will be positioned on the right * edge of that cell (or the left edge of the next cell). The last cell will then be completely visible, along * with some extra white space. */ int viewportWindowSpan = getViewportWindowSpan(); if (viewportWindowSpan <= 0 || viewportWindowSpan >= getScrollableLayerSpan()) { return 0; } int edgePixel = getScrollableLayerSpan() - viewportWindowSpan; int positionAtEdge = getPositionByPixel(edgePixel); int startPixelOfPositionAtEdge = getStartPixelOfPosition(positionAtEdge); int overhang = 0; if (edgePixel != startPixelOfPositionAtEdge) { overhang = (getSpanByPosition(positionAtEdge)) - (edgePixel - startPixelOfPositionAtEdge); } return overhang; } /** * Methods to be implemented by the Horizontal/Vertical scroll bar handlers. * @return */ abstract int getViewportWindowSpan(); abstract int getScrollableLayerSpan(); abstract boolean keepScrolling(); abstract int pageScrollDistance(); abstract int getSpanByPosition(int scrollablePosition); abstract int getScrollablePosition(); abstract int getStartPixelOfPosition(int position); abstract int getPositionByPixel(int pixelValue); abstract void setViewportOrigin(int position); abstract MoveDirectionEnum scrollDirectionForEventDetail(int eventDetail); }
5,056
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ViewportSelectRowAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/action/ViewportSelectRowAction.java
package net.sourceforge.nattable.viewport.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.ui.action.IMouseAction; import net.sourceforge.nattable.viewport.command.ViewportSelectRowCommand; import org.eclipse.swt.events.MouseEvent; /** * Event fired when the <i>ctrl</i> key is pressed and the row header is clicked. * Note: Fires command in NatTable coordinates. * * @see NatTable#configureMouseBindings() */ public class ViewportSelectRowAction implements IMouseAction { private final boolean withShiftMask; private final boolean withControlMask; public ViewportSelectRowAction(boolean withShiftMask, boolean withControlMask) { this.withShiftMask = withShiftMask; this.withControlMask = withControlMask; } public void run(NatTable natTable, MouseEvent event) { natTable.doCommand(new ViewportSelectRowCommand(natTable, natTable.getRowPositionByY(event.y), withShiftMask, withControlMask)); } }
986
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ViewportSelectColumnAction.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/action/ViewportSelectColumnAction.java
package net.sourceforge.nattable.viewport.action; import net.sourceforge.nattable.NatTable; import net.sourceforge.nattable.ui.action.IMouseAction; import net.sourceforge.nattable.viewport.command.ViewportSelectColumnCommand; import org.eclipse.swt.events.MouseEvent; /** * Action indicating that the user has specifically selected a column header. */ public class ViewportSelectColumnAction implements IMouseAction { private final boolean withShiftMask; private final boolean withControlMask; public ViewportSelectColumnAction(boolean withShiftMask, boolean withControlMask) { this.withShiftMask = withShiftMask; this.withControlMask = withControlMask; } public void run(NatTable natTable, MouseEvent event) { natTable.doCommand(new ViewportSelectColumnCommand(natTable, natTable.getColumnPositionByX(event.x), withShiftMask, withControlMask)); } }
898
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ShowCellInViewportCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/command/ShowCellInViewportCommandHandler.java
package net.sourceforge.nattable.viewport.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.viewport.ViewportLayer; public class ShowCellInViewportCommandHandler extends AbstractLayerCommandHandler<ShowCellInViewportCommand> { private final ViewportLayer viewportLayer; public ShowCellInViewportCommandHandler(ViewportLayer viewportLayer) { this.viewportLayer = viewportLayer; } public Class<ShowCellInViewportCommand> getCommandClass() { return ShowCellInViewportCommand.class; } @Override protected boolean doCommand(ShowCellInViewportCommand command) { viewportLayer.moveCellPositionIntoViewport(command.getColumnPosition(), command.getRowPosition(), false); return true; } }
764
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
RecalculateScrollBarsCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/command/RecalculateScrollBarsCommand.java
package net.sourceforge.nattable.viewport.command; import net.sourceforge.nattable.command.AbstractContextFreeCommand; public class RecalculateScrollBarsCommand extends AbstractContextFreeCommand { public RecalculateScrollBarsCommand() { } }
257
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ShowRowInViewportCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/command/ShowRowInViewportCommand.java
package net.sourceforge.nattable.viewport.command; import net.sourceforge.nattable.command.AbstractRowCommand; import net.sourceforge.nattable.layer.ILayer; public class ShowRowInViewportCommand extends AbstractRowCommand { public ShowRowInViewportCommand(ILayer layer, int rowPosition) { super(layer, rowPosition); } protected ShowRowInViewportCommand(ShowRowInViewportCommand command) { super(command); } public ShowRowInViewportCommand cloneCommand() { return new ShowRowInViewportCommand(this); } }
544
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ViewportSelectRowCommand.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/command/ViewportSelectRowCommand.java
package net.sourceforge.nattable.viewport.command; import net.sourceforge.nattable.command.AbstractRowCommand; import net.sourceforge.nattable.layer.ILayer; /** * Command to select a row. * Note: The row position is in top level composite Layer (NatTable) coordinates */ public class ViewportSelectRowCommand extends AbstractRowCommand { private final boolean withShiftMask; private final boolean withControlMask; public ViewportSelectRowCommand(ILayer layer, int rowPosition, boolean withShiftMask, boolean withControlMask) { super(layer, rowPosition); this.withShiftMask = withShiftMask; this.withControlMask = withControlMask; } protected ViewportSelectRowCommand(ViewportSelectRowCommand command) { super(command); this.withShiftMask = command.withShiftMask; this.withControlMask = command.withControlMask; } public boolean isWithShiftMask() { return withShiftMask; } public boolean isWithControlMask() { return withControlMask; } public ViewportSelectRowCommand cloneCommand() { return new ViewportSelectRowCommand(this); } }
1,116
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ShowColumnInViewportCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/command/ShowColumnInViewportCommandHandler.java
package net.sourceforge.nattable.viewport.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.viewport.ViewportLayer; public class ShowColumnInViewportCommandHandler extends AbstractLayerCommandHandler<ShowColumnInViewportCommand> { private final ViewportLayer viewportLayer; public ShowColumnInViewportCommandHandler(ViewportLayer viewportLayer) { this.viewportLayer = viewportLayer; } public Class<ShowColumnInViewportCommand> getCommandClass() { return ShowColumnInViewportCommand.class; } @Override protected boolean doCommand(ShowColumnInViewportCommand command) { viewportLayer.moveColumnPositionIntoViewport(command.getColumnPosition(), false); return true; } }
752
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z
ViewportSelectRowCommandHandler.java
/FileExtraction/Java_unseen/heartsome_translationstudio8/others/net.sourceforge.nattable.core/src/net/sourceforge/nattable/viewport/command/ViewportSelectRowCommandHandler.java
package net.sourceforge.nattable.viewport.command; import net.sourceforge.nattable.command.AbstractLayerCommandHandler; import net.sourceforge.nattable.layer.IUniqueIndexLayer; import net.sourceforge.nattable.selection.command.SelectRowsCommand; import net.sourceforge.nattable.viewport.ViewportLayer; public class ViewportSelectRowCommandHandler extends AbstractLayerCommandHandler<ViewportSelectRowCommand> { private final ViewportLayer viewportLayer; public ViewportSelectRowCommandHandler(ViewportLayer viewportLayer) { this.viewportLayer = viewportLayer; } public Class<ViewportSelectRowCommand> getCommandClass() { return ViewportSelectRowCommand.class; } @Override protected boolean doCommand(ViewportSelectRowCommand command) { IUniqueIndexLayer scrollableLayer = viewportLayer.getScrollableLayer(); int scrollableColumnPosition = viewportLayer.getOriginColumnPosition(); int scrollableRowPosition = viewportLayer.localToUnderlyingRowPosition(command.getRowPosition()); scrollableLayer.doCommand(new SelectRowsCommand(scrollableLayer, scrollableColumnPosition, new int[] { scrollableRowPosition }, command.isWithShiftMask(), command.isWithControlMask())); return true; } }
1,217
Java
.java
heartsome/translationstudio8
83
45
18
2014-06-03T17:56:15Z
2020-10-13T06:46:15Z