本文整理汇总了Java中org.eclipse.jface.text.ITextOperationTarget.canDoOperation方法的典型用法代码示例。如果您正苦于以下问题:Java ITextOperationTarget.canDoOperation方法的具体用法?Java ITextOperationTarget.canDoOperation怎么用?Java ITextOperationTarget.canDoOperation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.ITextOperationTarget
的用法示例。
在下文中一共展示了ITextOperationTarget.canDoOperation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createContentAssistActionHandler
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
private ActionHandler createContentAssistActionHandler(
final ITextOperationTarget textOperationTarget) {
Action proposalAction = new Action() {
@Override
public void run() {
if (textOperationTarget
.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS)
&& getTextWidget().isFocusControl())
textOperationTarget
.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
}
};
proposalAction
.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
return new ActionHandler(proposalAction);
}
示例2: run
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
@Override
public void run() {
try {
// Move offset to the line of the annotation, if necessary
IDocument document = getDocument();
int annotationLine = ruler.getLineOfLastMouseButtonActivity();
int annotationLineOffet = document.getLineOffset(annotationLine);
Point currentSelection = textEditor.getInternalSourceViewer().getSelectedRange();
int currentLine = document.getLineOfOffset(currentSelection.x);
if (currentLine != annotationLine)
textEditor.getInternalSourceViewer().setSelectedRange(annotationLineOffet, 0);
// show QuickFix dialog
ITextOperationTarget operation = (ITextOperationTarget) textEditor.getAdapter(ITextOperationTarget.class);
final int opCode = ISourceViewer.QUICK_ASSIST;
if (operation != null && operation.canDoOperation(opCode))
operation.doOperation(opCode);
} catch (BadLocationException e) {
// Ignore -> do nothing
}
}
示例3: runWithEvent
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
@Override
public void runWithEvent(Event event) {
if (fAnnotation instanceof OverrideIndicatorManager.OverrideIndicator) {
((OverrideIndicatorManager.OverrideIndicator)fAnnotation).open();
return;
}
if (fHasCorrection) {
ITextOperationTarget operation= (ITextOperationTarget) fTextEditor.getAdapter(ITextOperationTarget.class);
final int opCode= ISourceViewer.QUICK_ASSIST;
if (operation != null && operation.canDoOperation(opCode)) {
fTextEditor.selectAndReveal(fPosition.getOffset(), fPosition.getLength());
operation.doOperation(opCode);
}
return;
}
super.run();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:JavaSelectAnnotationRulerAction.java
示例4: isEnabled
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
@Override
public boolean isEnabled() {
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor instanceof de.darwinspl.preferences.resource.dwprofile.ui.DwprofileEditor) {
ITextOperationTarget operationTarget = (ITextOperationTarget) activeEditor.getAdapter(ITextOperationTarget.class);
return (operationTarget != null && operationTarget.canDoOperation(ITextOperationTarget.PREFIX) && operationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
}
return false;
}
示例5: isEnabled
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
@Override
public boolean isEnabled() {
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor instanceof eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionEditor) {
ITextOperationTarget operationTarget = (ITextOperationTarget) activeEditor.getAdapter(ITextOperationTarget.class);
return (operationTarget != null && operationTarget.canDoOperation(ITextOperationTarget.PREFIX) && operationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
}
return false;
}
示例6: isEnabled
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
@Override
public boolean isEnabled() {
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor instanceof eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaEditor) {
ITextOperationTarget operationTarget = (ITextOperationTarget) activeEditor.getAdapter(ITextOperationTarget.class);
return (operationTarget != null && operationTarget.canDoOperation(ITextOperationTarget.PREFIX) && operationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
}
return false;
}
示例7: isEnabled
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
@Override
public boolean isEnabled() {
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor instanceof eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueEditor) {
ITextOperationTarget operationTarget = (ITextOperationTarget) activeEditor.getAdapter(ITextOperationTarget.class);
return (operationTarget != null && operationTarget.canDoOperation(ITextOperationTarget.PREFIX) && operationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
}
return false;
}
示例8: isEnabled
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
@Override
public boolean isEnabled() {
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor instanceof eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingEditor) {
ITextOperationTarget operationTarget = (ITextOperationTarget) activeEditor.getAdapter(ITextOperationTarget.class);
return (operationTarget != null && operationTarget.canDoOperation(ITextOperationTarget.PREFIX) && operationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
}
return false;
}
示例9: isEnabled
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
@Override
public boolean isEnabled() {
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor instanceof eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsEditor) {
ITextOperationTarget operationTarget = (ITextOperationTarget) activeEditor.getAdapter(ITextOperationTarget.class);
return (operationTarget != null && operationTarget.canDoOperation(ITextOperationTarget.PREFIX) && operationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
}
return false;
}
示例10: isEnabled
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
@Override
public boolean isEnabled() {
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor instanceof eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestEditor) {
ITextOperationTarget operationTarget = (ITextOperationTarget) activeEditor.getAdapter(ITextOperationTarget.class);
return (operationTarget != null && operationTarget.canDoOperation(ITextOperationTarget.PREFIX) && operationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
}
return false;
}
示例11: execute
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISourceViewer viewer = null;
Object activeFocusControl = HandlerUtil.getVariable(event, "activeFocusControl"); //$NON-NLS-1$
if (activeFocusControl instanceof Control) {
Control control = (Control) activeFocusControl;
if (!control.isDisposed()) {
viewer = (ISourceViewer) control.getData(ISourceViewer.class.getName());
}
}
if (viewer == null) {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof JsonEditor) {
viewer = ((JsonEditor) editor).getProjectionViewer();
}
}
if (viewer != null) {
ITextOperationTarget operationTarget = viewer.getTextOperationTarget();
if (operationTarget.canDoOperation(QUICK_OUTLINE)) {
operationTarget.doOperation(QUICK_OUTLINE);
}
}
return null;
}
示例12: annotationDefaultSelected
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
@Override
public void annotationDefaultSelected(VerticalRulerEvent event) {
Annotation annotation= event.getSelectedAnnotation();
IAnnotationModel model= getAnnotationModel();
if (isOverrideIndicator(annotation)) {
((OverrideIndicatorManager.OverrideIndicator)annotation).open();
return;
}
if (isBreakpoint(annotation))
triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK, event.getEvent());
Position position= model.getPosition(annotation);
if (position == null)
return;
if (isQuickFixTarget(annotation)) {
ITextOperationTarget operation= (ITextOperationTarget) getTextEditor().getAdapter(ITextOperationTarget.class);
final int opCode= ISourceViewer.QUICK_ASSIST;
if (operation != null && operation.canDoOperation(opCode)) {
getTextEditor().selectAndReveal(position.getOffset(), position.getLength());
operation.doOperation(opCode);
return;
}
}
// default:
super.annotationDefaultSelected(event);
}
示例13: computeEnablement
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
private boolean computeEnablement(ITextEditor editor) {
if (editor == null)
return false;
ITextOperationTarget target= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
if (target == null || ! target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS))
return false;
IJavaProject javaProject = EditorUtility.getJavaProject(editor.getEditorInput());
if (! fCategory.matches(javaProject))
return false;
ISelection selection= editor.getSelectionProvider().getSelection();
return isValidSelection(selection);
}
示例14: isTargetOperationEnabled
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
protected boolean isTargetOperationEnabled() {
ITextEditor editor = getTextEditor();
if(editor != null) {
fOperationTarget = (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
}
return fOperationTarget != null &&
fOperationTarget.canDoOperation(ITextOperationTarget.PREFIX) &&
fOperationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX);
}
示例15: execute
import org.eclipse.jface.text.ITextOperationTarget; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
de.darwinspl.preferences.resource.dwprofile.ui.DwprofileEditor editor = null;
if (editorPart instanceof de.darwinspl.preferences.resource.dwprofile.ui.DwprofileEditor) {
editor = (de.darwinspl.preferences.resource.dwprofile.ui.DwprofileEditor) editorPart;
operationTarget = (ITextOperationTarget) editorPart.getAdapter(ITextOperationTarget.class);
document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
}
if (editor == null || operationTarget == null || document == null) {
return null;
}
prefixesMap = new LinkedHashMap<String, String[]>();
prefixesMap.put(IDocument.DEFAULT_CONTENT_TYPE, COMMENT_PREFIXES);
ISelection currentSelection = editor.getSelectionProvider().getSelection();
final int operationCode;
if (isSelectionCommented(currentSelection)) {
operationCode = ITextOperationTarget.STRIP_PREFIX;
} else {
operationCode = ITextOperationTarget.PREFIX;
}
if (!operationTarget.canDoOperation(operationCode)) {
return null;
}
Shell shell = editorPart.getSite().getShell();
Display display = null;
if (shell != null && !shell.isDisposed()) {
display = shell.getDisplay();
}
BusyIndicator.showWhile(display, new Runnable() {
public void run() {
operationTarget.doOperation(operationCode);
}
});
return null;
}