use of net.sourceforge.nattable.layer.cell.LayerCell in project translationstudio8 by heartsome.
the class TickUpdateCommandHandler method updateSingleCell.
private void updateSingleCell(TickUpdateCommand command, PositionCoordinate selectedPosition) {
LayerCell cell = selectionLayer.getCellByPosition(selectedPosition.columnPosition, selectedPosition.rowPosition);
IEditableRule editableRule = command.getConfigRegistry().getConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, DisplayMode.EDIT, cell.getConfigLabels().getLabels());
if (editableRule.isEditable(selectedPosition.columnPosition, selectedPosition.rowPosition)) {
selectionLayer.doCommand(new UpdateDataCommand(selectionLayer, selectedPosition.columnPosition, selectedPosition.rowPosition, getNewCellValue(command, cell)));
}
}
use of net.sourceforge.nattable.layer.cell.LayerCell in project translationstudio8 by heartsome.
the class BodyCellEditorMouseEventMatcher method matches.
public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
if (regionLabels != null && regionLabels.hasLabel(GridRegion.BODY)) {
LayerCell cell = natTable.getCellByPosition(natTable.getColumnPositionByX(event.x), natTable.getRowPositionByY(event.y));
ICellEditor cellEditor = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.CELL_EDITOR, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
if (cellEditorClass.isInstance(cellEditor)) {
return true;
}
}
return false;
}
use of net.sourceforge.nattable.layer.cell.LayerCell in project translationstudio8 by heartsome.
the class MouseEditAction method run.
public void run(NatTable natTable, MouseEvent event) {
XLIFFEditorImplWithNatTable xliffEditor = XLIFFEditorImplWithNatTable.getCurrent();
if (xliffEditor == null) {
return;
}
int columnPosition = natTable.getColumnPositionByX(event.x);
int rowPosition = natTable.getRowPositionByY(event.y);
boolean withShiftMask = (event.stateMask & SWT.SHIFT) != 0;
boolean withCtrlMask = (event.stateMask & SWT.CTRL) != 0;
if (!xliffEditor.isHorizontalLayout() && rowPosition != HsMultiActiveCellEditor.targetRowPosition && (rowPosition != HsMultiActiveCellEditor.sourceRowPosition || columnPosition != xliffEditor.getSrcColumnIndex())) {
HsMultiActiveCellEditor.commit(true);
natTable.doCommand(new SelectCellCommand(natTable, columnPosition, rowPosition, withShiftMask, withCtrlMask));
if (columnPosition == xliffEditor.getTgtColumnIndex()) {
HsMultiCellEditorControl.activeSourceAndTargetCell(xliffEditor);
}
} else if (rowPosition != HsMultiActiveCellEditor.targetRowPosition || columnPosition != xliffEditor.getSrcColumnIndex() || columnPosition != xliffEditor.getTgtColumnIndex()) {
HsMultiActiveCellEditor.commit(true);
natTable.doCommand(new SelectCellCommand(natTable, columnPosition, rowPosition, withShiftMask, withCtrlMask));
if (columnPosition == xliffEditor.getSrcColumnIndex() || columnPosition == xliffEditor.getTgtColumnIndex()) {
HsMultiCellEditorControl.activeSourceAndTargetCell(xliffEditor);
}
}
// 点击批注图片时打开编辑批注对话框
Image image = XliffEditorGUIHelper.getImage(ImageName.HAS_NOTE);
// int columnPosition = natTable.getColumnPositionByX(event.x);
// int rowPosition = natTable.getRowPositionByY(event.y);
LayerCell cell = natTable.getCellByPosition(columnPosition, rowPosition);
Rectangle imageBounds = image.getBounds();
if (cell == null) {
return;
}
Rectangle cellBounds = cell.getBounds();
int x = cellBounds.x + imageBounds.width * 3 + 20;
int y = cellBounds.y + CellStyleUtil.getVerticalAlignmentPadding(CellStyleUtil.getCellStyle(cell, natTable.getConfigRegistry()), cellBounds, imageBounds.height);
if (columnPosition == xliffEditor.getStatusColumnIndex() && event.x >= x && event.x <= (x + imageBounds.width) && event.y >= y && event.y <= (y + imageBounds.height)) {
if ((xliffEditor.isHorizontalLayout() && columnPosition == 2) || (!xliffEditor.isHorizontalLayout() && columnPosition == 1)) {
Vector<NoteBean> noteBeans = null;
try {
int rowIndex = natTable.getRowIndexByPosition(rowPosition);
if (!xliffEditor.isHorizontalLayout()) {
rowIndex = rowIndex / VerticalNatTableConfig.ROW_SPAN;
}
noteBeans = xliffEditor.getXLFHandler().getNotes(xliffEditor.getXLFHandler().getRowId(rowIndex));
if (noteBeans != null && noteBeans.size() > 0) {
UpdateNoteDialog dialog = new UpdateNoteDialog(xliffEditor.getSite().getShell(), xliffEditor, rowIndex);
dialog.open();
}
} catch (NavException e) {
e.printStackTrace();
} catch (XPathParseException e) {
e.printStackTrace();
} catch (XPathEvalException e) {
e.printStackTrace();
}
}
}
}
use of net.sourceforge.nattable.layer.cell.LayerCell in project translationstudio8 by heartsome.
the class HsMultiActiveCellEditor method recalculateCellsBounds.
public static void recalculateCellsBounds() {
if (parent == null) {
return;
}
ViewportLayer vLayer = LayerUtil.getLayer(parent, ViewportLayer.class);
if (vLayer == null) {
return;
}
StyledTextCellEditor fc = getFocusCellEditor();
if (sourceEditor != null && sourceEditor.isValid()) {
int rowPosition = vLayer.getRowPositionByIndex(sourceEditor.getRowIndex());
int columnPosition = vLayer.getColumnPositionByIndex(sourceEditor.getColumnIndex());
rowPosition += 1;
if (rowPosition < 1) {
return;
}
LayerCell cell = parent.getCellByPosition(columnPosition, rowPosition);
if (cell == null) {
return;
}
Rectangle cellBounds = cell.getBounds();
if (cellBounds != null) {
Rectangle adjustedCellBounds = parent.getLayerPainter().adjustCellBounds(cellBounds);
sourceEditor.setEditorBounds(adjustedCellBounds, true);
sourceEditor.setColumnPosition(columnPosition);
sourceEditor.setRowPosition(rowPosition);
if (fc == sourceEditor.getCellEditor()) {
sourceEditor.forceFocus();
}
}
}
if (targetEditor != null && targetEditor.isValid()) {
int rowPosition = vLayer.getRowPositionByIndex(targetEditor.getRowIndex());
int columnPosition = vLayer.getColumnPositionByIndex(targetEditor.getColumnIndex());
rowPosition += 1;
if (rowPosition < 1) {
return;
}
LayerCell cell = parent.getCellByPosition(columnPosition, rowPosition);
if (cell == null) {
return;
}
Rectangle cellBounds = cell.getBounds();
if (cellBounds != null) {
Rectangle adjustedCellBounds = parent.getLayerPainter().adjustCellBounds(cellBounds);
targetEditor.setEditorBounds(adjustedCellBounds, true);
targetEditor.setColumnPosition(columnPosition);
targetEditor.setRowPosition(rowPosition);
if (fc == targetEditor.getCellEditor()) {
targetEditor.forceFocus();
}
}
}
}
Aggregations