本文整理汇总了Java中org.eclipse.ui.console.TextConsoleViewer.getDocument方法的典型用法代码示例。如果您正苦于以下问题:Java TextConsoleViewer.getDocument方法的具体用法?Java TextConsoleViewer.getDocument怎么用?Java TextConsoleViewer.getDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.console.TextConsoleViewer
的用法示例。
在下文中一共展示了TextConsoleViewer.getDocument方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: consoleDispatch
import org.eclipse.ui.console.TextConsoleViewer; //导入方法依赖的package包/类
/**
* @see com.mulgasoft.emacsplus.commands.SexpBaseBackwardHandler#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
*/
public Object consoleDispatch(final TextConsoleViewer viewer, final IConsoleView activePart, ExecutionEvent event) {
IDocument doc = viewer.getDocument();
boolean isBackup = getUniversalCount() > 0; // normal direction
ITextSelection selection = (ITextSelection) viewer.getSelectionProvider().getSelection();
try {
int offset = doTransform(doc, selection, viewer.getTextWidget().getCaretOffset(),isBackup);
if (offset == NO_OFFSET) {
unbalanced(activePart,false);
} else {
endTransform(viewer, offset, selection, new TextSelection(null,offset,offset - selection.getOffset()));
}
} catch (BadLocationException e) {}
return null;
}
示例2: consoleDispatch
import org.eclipse.ui.console.TextConsoleViewer; //导入方法依赖的package包/类
/**
* @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
*/
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
IDocument document = viewer.getDocument();
ITextSelection currentSelection = (ITextSelection)viewer.getSelectionProvider().getSelection();
ITextSelection selection = null;
try {
selection = getNextSexp(document, currentSelection);
if (selection == null) {
selection = currentSelection;
unbalanced(activePart,true);
return null;
} else {
return endTransform(viewer, selection.getOffset(), currentSelection, selection);
}
} catch (BadLocationException e) {
}
return null;
}
示例3: consoleDispatch
import org.eclipse.ui.console.TextConsoleViewer; //导入方法依赖的package包/类
/**
* @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(org.eclipse.ui.console.TextConsoleViewer, org.eclipse.ui.console.IConsoleView, org.eclipse.core.commands.ExecutionEvent)
*/
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
IDocument document = viewer.getDocument();
ITextSelection currentSelection = (ITextSelection)viewer.getSelectionProvider().getSelection();
ITextSelection selection = new TextSelection(document, viewer.getTextWidget().getCaretOffset(), 0);
try {
selection = getNextSexp(document, selection);
if (selection == null) {
selection = currentSelection;
unbalanced(activePart,true);
return null;
} else {
return endTransform(viewer, selection.getOffset() + selection.getLength(), currentSelection, selection);
}
} catch (BadLocationException e) {
}
return null;
}
示例4: consoleDispatch
import org.eclipse.ui.console.TextConsoleViewer; //导入方法依赖的package包/类
/**
* @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(org.eclipse.ui.console.TextConsoleViewer, IConsoleView, ExecutionEvent)
*/
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
IDocument doc = viewer.getDocument();
int action = -1;
try {
StyledText st = viewer.getTextWidget();
action = getDispatchId(getId(event, viewer));
if (action > -1) {
// set up for kill ring
doc.addDocumentListener(KillRing.getInstance());
// setUpUndo(viewer);
st.invokeAction(action);
}
} finally {
// remove kill ring behavior
if (action > -1) {
doc.removeDocumentListener(KillRing.getInstance());
}
KillRing.getInstance().setKill(null, false);
}
return null;
}
示例5: consoleDispatch
import org.eclipse.ui.console.TextConsoleViewer; //导入方法依赖的package包/类
/**
* @see com.mulgasoft.emacsplus.commands.ConsoleCmdHandler#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
*/
@Override
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
Object result = null;
IDocument doc = viewer.getDocument();
try {
IWorkbenchPartSite site = activePart.getSite();
if (site != null) {
IHandlerService service = (IHandlerService) site.getService(IHandlerService.class);
if (doc != null && service != null) {
doc.addDocumentListener(KillRing.getInstance());
String cmdId = getId(event, viewer);
if (cmdId != null) {
result = service.executeCommand(cmdId, null);
}
}
}
} catch (CommandException e) {
// Shouldn't happen as the Command id will be null or valid
e.printStackTrace();
} finally {
if (doc != null) {
doc.removeDocumentListener(KillRing.getInstance());
}
// clear kill command flag
KillRing.getInstance().setKill(null, false);
}
MarkUtils.clearConsoleMark(viewer);
return result;
}
示例6: consoleDispatch
import org.eclipse.ui.console.TextConsoleViewer; //导入方法依赖的package包/类
/**
* When called from a console context, will use ST.CUT
*
* @see com.mulgasoft.emacsplus.commands.ConsoleCmdHandler#consoleDispatch(TextConsoleViewer,
* IConsoleView, ExecutionEvent)
*/
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
if (viewer.isEditable()) {
IDocument doc = viewer.getDocument();
StyledText st = viewer.getTextWidget();
int offset = st.getCaretOffset();
try {
IRegion info = doc.getLineInformationOfOffset(offset);
int noffset = info.getOffset() + info.getLength();
if (offset == noffset) {
int line = doc.getLineOfOffset(offset);
if (++line < doc.getNumberOfLines()) {
noffset = doc.getLineOffset(line);
if (noffset == doc.getLength()) {
noffset = offset;
}
}
}
if (offset != noffset) {
st.redraw();
st.setSelection(offset, noffset);
KillRing.getInstance().setKill(CUT_LINE_TO_END, false);
return super.consoleDispatch(viewer, activePart, event);
}
viewer.refresh();
} catch (BadLocationException e) {
}
}
return null;
}
示例7: browseRing
import org.eclipse.ui.console.TextConsoleViewer; //导入方法依赖的package包/类
/**
* Navigate up or down the ring entry by entry
*
* @param viewer the viewer on the console
* @param dir FORWARD or BACKWARD
*/
private void browseRing(TextConsoleViewer viewer, int dir) {
IDocument doc = viewer.getDocument();
StyledText st = viewer.getTextWidget();
if (doc != null && st != null) {
int lines = doc.getNumberOfLines();
int off = st.getCaretOffset();
try {
int l = doc.getLineOfOffset(off);
KilledText okill = offsetHash.get(doc.getLineOffset(l));
KilledText nkill = null;
int noff = -1;
while ((l = l+dir) > -1 && l < lines){
off = doc.getLineOffset(l);
KilledText tkill = offsetHash.get(off);
if (nkill == null) {
if (tkill != null && tkill != okill) {
nkill = offsetHash.get(off);
noff = off;
if (dir == FORWARD) {
break;
}
}
} else {
if (tkill != null && tkill != nkill){
break;
} else {
noff = off;
}
}
}
if (noff > -1) {
st.setCaretOffset(noff);
viewer.revealRange(noff, 0);
}
}catch (BadLocationException e) {
}
}
}
示例8: getLineOffset
import org.eclipse.ui.console.TextConsoleViewer; //导入方法依赖的package包/类
/**
* Get the line offset of the cursor
*
* @param viewer the console viewer
* @return the line offset
*/
private int getLineOffset(TextConsoleViewer viewer) {
int result = -1;
IDocument doc = viewer.getDocument();
StyledText st = viewer.getTextWidget();
if (doc != null && st != null) {
int off = st.getCaretOffset();
try {
IRegion info = doc.getLineInformationOfOffset(off);
result = info.getOffset();
}catch (BadLocationException e) {
}
}
return result;
}
示例9: consoleDispatch
import org.eclipse.ui.console.TextConsoleViewer; //导入方法依赖的package包/类
/**
* @see com.mulgasoft.emacsplus.commands.SexpBaseForwardHandler#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
*/
public Object consoleDispatch(final TextConsoleViewer viewer, final IConsoleView activePart, ExecutionEvent event) {
IDocument doc = viewer.getDocument();
ITextSelection currentSelection = (ITextSelection) viewer.getSelectionProvider().getSelection();
ITextSelection selection = downList(doc, currentSelection);
if (selection == null) {
unbalanced(activePart,false);
} else {
endTransform(viewer,selection.getOffset() + selection.getLength(), currentSelection, selection);
}
return null;
}