Java Code Examples for org.eclipse.swt.custom.StyledText#forceFocus()
The following examples show how to use
org.eclipse.swt.custom.StyledText#forceFocus() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompositeTabFolder.java From ldparteditor with MIT License | 6 votes |
public void cut() { CompositeTab selection = (CompositeTab) this.getSelection(); if (selection != null && !selection.getState().getFileNameObj().isReadOnly()) { final StyledText ct = selection.getTextComposite(); if (!selection.getState().getFileNameObj().getVertexManager().isUpdated()){ ct.copy(); return; } final int x = ct.getSelection().x; if (ct.getSelection().y == x) { final int start = ct.getOffsetAtLine(ct.getLineAtOffset(x)); ct.setSelection(start, start + ct.getLine(ct.getLineAtOffset(x)).length()); } final int x2 = ct.getSelection().x; if (ct.getSelection().y == x2) { ct.forceFocus(); return; } ct.cut(); ct.forceFocus(); } }
Example 2
Source File: CompositeTabFolder.java From ldparteditor with MIT License | 6 votes |
public void delete() { CompositeTab selection = (CompositeTab) this.getSelection(); if (selection != null && !selection.getState().getFileNameObj().isReadOnly()) { if (!selection.getState().getFileNameObj().getVertexManager().isUpdated()){ return; } final StyledText ct = selection.getTextComposite(); final int x = ct.getSelection().x; if (ct.getSelection().y == x) { final int start = ct.getOffsetAtLine(ct.getLineAtOffset(x)); ct.setSelection(start, start + ct.getLine(ct.getLineAtOffset(x)).length()); } final int x2 = ct.getSelection().x; if (ct.getSelection().y == x2) { ct.forceFocus(); return; } ct.insert(""); //$NON-NLS-1$ ct.setSelection(new Point(x, x)); ct.forceFocus(); } }
Example 3
Source File: CompositeTab.java From ldparteditor with MIT License | 6 votes |
public void hideSelection() { if (!state.getFileNameObj().getVertexManager().isUpdated()){ return; } final DatFile df = state.getFileNameObj(); final VertexManager vm = df.getVertexManager(); vm.addSnapshot(); final StyledText st = getTextComposite(); int s1 = st.getSelectionRange().x; int s2 = s1 + st.getSelectionRange().y; int fromLine = s1 > -1 ? st.getLineAtOffset(s1) : s1 * -1; int toLine = s2 > -1 ? st.getLineAtOffset(s2) : s2 * -1; fromLine++; toLine++; Text2SelectionConverter.convert(fromLine, toLine, df); vm.hideSelection(); df.addHistory(); st.redraw(0, 0, st.getBounds().width, st.getBounds().height, true); st.forceFocus(); }
Example 4
Source File: CompositeTab.java From ldparteditor with MIT License | 6 votes |
public void showSelection() { if (!state.getFileNameObj().getVertexManager().isUpdated()){ return; } final DatFile df = state.getFileNameObj(); final VertexManager vm = df.getVertexManager(); vm.addSnapshot(); final StyledText st = getTextComposite(); int s1 = st.getSelectionRange().x; int s2 = s1 + st.getSelectionRange().y; int fromLine = s1 > -1 ? st.getLineAtOffset(s1) : s1 * -1; int toLine = s2 > -1 ? st.getLineAtOffset(s2) : s2 * -1; fromLine++; toLine++; Text2SelectionConverter.convert(fromLine, toLine, df); vm.showSelection(); df.addHistory(); st.redraw(0, 0, st.getBounds().width, st.getBounds().height, true); st.forceFocus(); }
Example 5
Source File: CellEditor.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
@Override protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) { if (originalCanonicalValue == null || !(originalCanonicalValue instanceof CellEditorCanonicalValue)) { return null; } StyledText textControl = createTextControl(parent); // init style IStyle cellStyle = getCellStyle(); textControl.setBackground(GUIHelper.getColor(210, 210, 240)); textControl.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR)); //textControl.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT)); textControl.setLineSpacing(TmxEditorConstanst.SEGMENT_LINE_SPACING); textControl.setLeftMargin(TmxEditorConstanst.SEGMENT_LEFT_MARGIN); textControl.setRightMargin(TmxEditorConstanst.SEGMENT_RIGHT_MARGIN); textControl.setTopMargin(TmxEditorConstanst.SEGMENT_TOP_MARGIN); textControl.setBottomMargin(TmxEditorConstanst.SEGMENT_TOP_MARGIN); textControl.setIME(new IME(textControl, SWT.NONE)); setCanonicalValue(originalCanonicalValue); textControl.forceFocus(); return textControl; }
Example 6
Source File: CompositeTabFolder.java From ldparteditor with MIT License | 5 votes |
public void copy() { CompositeTab selection = (CompositeTab) this.getSelection(); if (selection != null) { final StyledText ct = selection.getTextComposite(); final int x = ct.getSelection().x; if (ct.getSelection().y == x) { final int start = ct.getOffsetAtLine(ct.getLineAtOffset(x)); ct.setSelection(start, start + ct.getLine(ct.getLineAtOffset(x)).length()); } ct.copy(); ct.forceFocus(); } }
Example 7
Source File: CompositeTabFolder.java From ldparteditor with MIT License | 5 votes |
public void paste() { CompositeTab selection = (CompositeTab) this.getSelection(); if (selection != null && !selection.getState().getFileNameObj().isReadOnly()) { if (!selection.getState().getFileNameObj().getVertexManager().isUpdated()){ return; } final StyledText ct = selection.getTextComposite(); ct.paste(); ct.forceFocus(); } }
Example 8
Source File: StyledTextCellEditor.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
protected Control activateCell(final Composite parent, HsMultiCellEditor hsCellEditor) { this.hsCellEditor = hsCellEditor; StyledText text = createTextControl(parent); text.setBounds(hsCellEditor.getEditorBounds()); // analyzeCellType(); // 分析单元格类型。 this.cellType = hsCellEditor.getType(); if (cellType == NatTableConstant.TARGET) { this.source = HsMultiActiveCellEditor.getSourceEditor().getOriginalCanonicalValue().toString(); viewer.setSource(source); // 设置原文本,用来解析内部标记 } editableManager.judgeEditable(); // 判断“可编辑”状态; // If we have an initial value, then Object originalCanonicalValue = this.hsCellEditor.getOriginalCanonicalValue(); if (originalCanonicalValue != null) { setCanonicalValue(new UpdateDataBean(originalCanonicalValue.toString(), null, null)); } else { setCanonicalValue(new UpdateDataBean()); } // 改变关闭状态标识 close = false; xliffEditor.getTable().addDisposeListener(this); text.forceFocus(); // 初始化撤销/重做管理器,设置步长为 50。 viewer.initUndoManager(50); // 绑定全局 Edit 菜单 actionHandler.addTextViewer(viewer); text.addKeyListener(movedKeyListener); // 移除向上和向下键默认事件处理,将此部分实现放到upAndDownKeyListener监听中 text.setKeyBinding(SWT.ARROW_DOWN, SWT.NULL); text.setKeyBinding(SWT.ARROW_UP, SWT.NULL); return text; }