use of net.heartsome.cat.ts.ui.xliffeditor.nattable.dialog.UpdateNoteDialog in project translationstudio8 by heartsome.
the class EditSelectionSegmentNotesHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
if (editorPart instanceof XLIFFEditorImplWithNatTable) {
XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editorPart;
if (xliffEditor.getSelectedRows().length == 0) {
return null;
}
if (xliffEditor.getSelectedRows().length > 1) {
MessageDialog.openInformation(xliffEditor.getSite().getShell(), Messages.getString("menu.BodyMenuConfiguration.msgTitle"), Messages.getString("menu.BodyMenuConfiguration.msg5"));
return null;
}
UpdateNoteDialog dialog = new UpdateNoteDialog(xliffEditor.getSite().getShell(), xliffEditor, xliffEditor.getSelectedRows()[0]);
dialog.open();
}
return null;
}
use of net.heartsome.cat.ts.ui.xliffeditor.nattable.dialog.UpdateNoteDialog 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();
}
}
}
}
Aggregations