本文整理汇总了Java中org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor类的典型用法代码示例。如果您正苦于以下问题:Java CompilationUnitEditor类的具体用法?Java CompilationUnitEditor怎么用?Java CompilationUnitEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompilationUnitEditor类属于org.eclipse.jdt.internal.ui.javaeditor包,在下文中一共展示了CompilationUnitEditor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getGWTProblemsInEditor
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
private List<GWTJavaProblem> getGWTProblemsInEditor(CompilationUnitEditor editor)
throws Exception {
List<GWTJavaProblem> problems = new ArrayList<GWTJavaProblem>();
Field annotationProblemField = CompilationUnitDocumentProvider.ProblemAnnotation.class.getDeclaredField("fProblem");
annotationProblemField.setAccessible(true);
IEditorInput editorInput = editor.getEditorInput();
IDocumentProvider documentProvider = editor.getDocumentProvider();
IAnnotationModel annotationModel = documentProvider.getAnnotationModel(editorInput);
Iterator<?> iter = annotationModel.getAnnotationIterator();
while (iter.hasNext()) {
Object annotation = iter.next();
if (annotation instanceof CompilationUnitDocumentProvider.ProblemAnnotation) {
CompilationUnitDocumentProvider.ProblemAnnotation problemAnnotation = (ProblemAnnotation) annotation;
if (problemAnnotation.getMarkerType().equals(GWTJavaProblem.MARKER_ID)) {
GWTJavaProblem problem = (GWTJavaProblem) annotationProblemField.get(problemAnnotation);
problems.add(problem);
}
}
}
return problems;
}
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:25,代码来源:JavaCompilationParticipantTest.java
示例2: GetterSetterTreeSelectionDialog
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
public GetterSetterTreeSelectionDialog(Shell parent, ILabelProvider labelProvider, AddGetterSetterContentProvider contentProvider, CompilationUnitEditor editor, IType type) throws JavaModelException {
super(parent, labelProvider, contentProvider, editor, type, false);
fContentProvider= contentProvider;
fPreviousSelectedFinals= new ArrayList<GetterSetterEntry>();
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
IDialogSettings dialogSettings= JavaPlugin.getDefault().getDialogSettings();
fSettings= dialogSettings.getSection(SETTINGS_SECTION);
if (fSettings == null) {
fSettings= dialogSettings.addNewSection(SETTINGS_SECTION);
fSettings.put(SORT_ORDER, false);
fSettings.put(ALLOW_SETTERS_FOR_FINALS, false);
}
fSortOrder= fSettings.getBoolean(SORT_ORDER);
fAllowSettersForFinals= fSettings.getBoolean(ALLOW_SETTERS_FOR_FINALS);
fSettersForFinalFieldsFilter= new SettersForFinalFieldsFilter(contentProvider);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:AddGetterSetterAction.java
示例3: GenerateConstructorUsingFieldsSelectionDialog
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
public GenerateConstructorUsingFieldsSelectionDialog(Shell parent, ILabelProvider labelProvider, GenerateConstructorUsingFieldsContentProvider contentProvider, CompilationUnitEditor editor, IType type, IMethodBinding[] superConstructors) throws JavaModelException {
super(parent, labelProvider, contentProvider, editor, type, true);
fTreeViewerAdapter= new GenerateConstructorUsingFieldsTreeViewerAdapter();
fSuperConstructors= superConstructors;
IDialogSettings dialogSettings= JavaPlugin.getDefault().getDialogSettings();
fGenConstructorSettings= dialogSettings.getSection(SETTINGS_SECTION);
if (fGenConstructorSettings == null) {
fGenConstructorSettings= dialogSettings.addNewSection(SETTINGS_SECTION);
fGenConstructorSettings.put(OMIT_SUPER, false);
}
final boolean isEnum= type.isEnum();
fOmitSuper= fGenConstructorSettings.getBoolean(OMIT_SUPER) || isEnum;
if (isEnum)
setVisibility(Modifier.PRIVATE);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:GenerateConstructorUsingFieldsSelectionDialog.java
示例4: fillMenu
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
public static void fillMenu(IMenuManager menu, CompilationUnitEditor editor, SurroundWithTryCatchAction surroundWithTryCatchAction, SurroundWithTryMultiCatchAction surroundWithTryMultiCatchAction) {
IAction[] actions= getTemplateActions(editor);
surroundWithTryCatchAction.update(editor.getSelectionProvider().getSelection());
boolean addSurroundWithTryCatchAction= surroundWithTryCatchAction.isEnabled() && !isInJavadoc(editor);
boolean addSurroundWithTryMultiCatchAction= surroundWithTryMultiCatchAction.isEnabled() && !isInJavadoc(editor);
if ((actions == null || actions.length == 0) && (!addSurroundWithTryCatchAction && !addSurroundWithTryMultiCatchAction)) {
menu.add(NONE_APPLICABLE_ACTION);
} else {
if (addSurroundWithTryCatchAction)
menu.add(surroundWithTryCatchAction);
if (addSurroundWithTryMultiCatchAction)
menu.add(surroundWithTryMultiCatchAction);
menu.add(new Separator(TEMPLATE_GROUP));
for (int i= 0; actions != null && i < actions.length; i++)
menu.add(actions[i]);
}
menu.add(new Separator(CONFIG_GROUP));
menu.add(new ConfigureTemplatesAction());
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:SurroundWithTemplateMenuAction.java
示例5: run
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void run(IAction action) {
IWorkbenchPart activePart= JavaPlugin.getActivePage().getActivePart();
if (!(activePart instanceof CompilationUnitEditor))
return;
final CompilationUnitEditor editor= (CompilationUnitEditor)activePart;
new JDTQuickMenuCreator(editor) {
@Override
protected void fillMenu(IMenuManager menu) {
SurroundWithTryCatchAction surroundWithTryCatch= SurroundWithActionGroup.createSurroundWithTryCatchAction(editor);
SurroundWithTryMultiCatchAction surroundWithTryMultiCatch= SurroundWithActionGroup.createSurroundWithTryMultiCatchAction(editor);
SurroundWithTemplateMenuAction.fillMenu(menu, editor, surroundWithTryCatch, surroundWithTryMultiCatch);
}
}.createMenu();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:SurroundWithTemplateMenuAction.java
示例6: JavaReconciler
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
/**
* Creates a new reconciler.
*
* @param editor the editor
* @param strategy the reconcile strategy
* @param isIncremental <code>true</code> if this is an incremental reconciler
*/
public JavaReconciler(ITextEditor editor, JavaCompositeReconcilingStrategy strategy, boolean isIncremental) {
super(strategy, isIncremental);
fTextEditor= editor;
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=63898
// when re-using editors, a new reconciler is set up by the source viewer
// and the old one uninstalled. However, the old reconciler may still be
// running.
// To avoid having to reconcilers calling CompilationUnitEditor.reconciled,
// we synchronized on a lock object provided by the editor.
// The critical section is really the entire run() method of the reconciler
// thread, but synchronizing process() only will keep JavaReconcilingStrategy
// from running concurrently on the same editor.
// TODO remove once we have ensured that there is only one reconciler per editor.
if (editor instanceof CompilationUnitEditor)
fMutex= ((CompilationUnitEditor) editor).getReconcilerLock();
else
fMutex= new Object(); // Null Object
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:JavaReconciler.java
示例7: registerCommands
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
public void registerCommands(CompilationUnitEditor editor) {
IWorkbench workbench= PlatformUI.getWorkbench();
ICommandService commandService= (ICommandService) workbench.getAdapter(ICommandService.class);
IHandlerService handlerService= (IHandlerService) workbench.getAdapter(IHandlerService.class);
if (commandService == null || handlerService == null) {
return;
}
if (fCorrectionHandlerActivations != null) {
JavaPlugin.logErrorMessage("correction handler activations not released"); //$NON-NLS-1$
}
fCorrectionHandlerActivations= new ArrayList<IHandlerActivation>();
Collection<String> definedCommandIds= commandService.getDefinedCommandIds();
for (Iterator<String> iter= definedCommandIds.iterator(); iter.hasNext();) {
String id= iter.next();
if (id.startsWith(ICommandAccess.COMMAND_ID_PREFIX)) {
boolean isAssist= id.endsWith(ICommandAccess.ASSIST_SUFFIX);
CorrectionCommandHandler handler= new CorrectionCommandHandler(editor, id, isAssist);
IHandlerActivation activation= handlerService.activateHandler(id, handler, new LegacyHandlerSubmissionExpression(null, null, editor.getSite()));
fCorrectionHandlerActivations.add(activation);
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:CorrectionCommandInstaller.java
示例8: GenerateToStringDialog
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
public GenerateToStringDialog(Shell shell, CompilationUnitEditor editor, IType type, IVariableBinding[] fields, IVariableBinding[] inheritedFields, IVariableBinding[] selectedFields,
IMethodBinding[] methods, IMethodBinding[] inheritededMethods) throws JavaModelException {
super(shell, new BindingLabelProvider(), new GenerateToStringContentProvider(fields, inheritedFields, methods, inheritededMethods), editor, type, false);
setEmptyListMessage(JavaUIMessages.GenerateHashCodeEqualsDialog_no_entries);
List<Object> selected= new ArrayList<Object>(Arrays.asList(selectedFields));
if (selectedFields.length == fields.length && selectedFields.length > 0)
selected.add(getContentProvider().getParent(selectedFields[0]));
setInitialElementSelections(selected);
setTitle(JavaUIMessages.GenerateToStringDialog_dialog_title);
setMessage(JavaUIMessages.GenerateToStringDialog_select_fields_to_include);
setValidator(new GenerateToStringValidator(fields.length + inheritedFields.length, methods.length + inheritededMethods.length));
setSize(60, 18);
setInput(new Object());
fGenerationSettings= new ToStringGenerationSettings(getDialogSettings());
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:GenerateToStringDialog.java
示例9: test
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if ("gluonMobileFound".equals(property)) {
try {
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow == null) {
return false;
}
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (activePage == null) {
return false;
}
IWorkbenchPart activePart = activePage.getActivePart();
if (activePart == null || ! (activePart instanceof CompilationUnitEditor)) {
return false;
}
IEditorPart editor = activePage.getActiveEditor();
if (editor == null) {
return false;
}
IEditorInput input = editor.getEditorInput();
if (input == null || ! (input instanceof FileEditorInput)) {
return false;
}
IFile file = ((FileEditorInput) input).getFile();
if (file != null && file.getType() == IResource.FILE && file.getFileExtension().equals("java")) {
ProjectUtils utils = new ProjectUtils(file.getProject());
return utils.isGluonMobileProject();
}
} catch (Exception e) { }
}
return false;
}
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:34,代码来源:InsertFunctionTester.java
示例10: uninstall
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
@Override
public void uninstall() {
if (monitor != null) {
monitor.setCanceled(true);
}
removeReconcileListener((CompilationUnitEditor) getTextEditor());
getStrategy().dispose();
}
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:9,代码来源:JavaCodeLensController.java
示例11: refresh
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
@Override
public void refresh() {
getStrategy().initialReconcile();
if (!listenerAdded) {
addReconcileListener((CompilationUnitEditor) getTextEditor());
listenerAdded = true;
}
}
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:9,代码来源:JavaCodeLensController.java
示例12: addReconcileListener
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
private void addReconcileListener(CompilationUnitEditor textEditor) {
try {
Method m = CompilationUnitEditor.class.getDeclaredMethod("addReconcileListener",
IJavaReconcilingListener.class);
m.setAccessible(true);
m.invoke(textEditor, this);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:12,代码来源:JavaCodeLensController.java
示例13: removeReconcileListener
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
private void removeReconcileListener(CompilationUnitEditor textEditor) {
try {
Method m = CompilationUnitEditor.class.getDeclaredMethod("removeReconcileListener",
IJavaReconcilingListener.class);
m.setAccessible(true);
m.invoke(textEditor, this);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:12,代码来源:JavaCodeLensController.java
示例14: testBuildAddError
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
public void testBuildAddError() throws Exception {
IProject project = getTestProject().getProject();
// Verify that we have 1 existing GWT problem marker
IMarker[] markers = getGWTProblemMarkers(project);
assertEquals(1, markers.length);
ICompilationUnit cu = testClass.getCompilationUnit();
// Open the test class in the editor
CompilationUnitEditor editor = (CompilationUnitEditor) JavaUI.openInEditor(cu);
IEditorInput editorInput = editor.getEditorInput();
// Edit the document to create a new error (add 'foobar' to the front of
// the class name in a Java reference)
IDocument document = editor.getDocumentProvider().getDocument(editorInput);
TextEdit errorEdit = new InsertEdit(254, "foobar");
errorEdit.apply(document);
// Save the changes
editor.doSave(null);
// Rebuild the project
rebuildTestProject();
// Verify that we now have 2 GWT problem markers
markers = getGWTProblemMarkers(project);
assertEquals(2, markers.length);
}
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:29,代码来源:JavaCompilationParticipantTest.java
示例15: assertNoProposals
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
private static void assertNoProposals(IProgressMonitor monitor,
JsniMethodBodyCompletionProposalComputer jcpc,
CompilationUnitEditor cuEditor, ISourceViewer viewer, int offset) {
assertEquals(0, jcpc.computeCompletionProposals(
new JavaContentAssistInvocationContext(viewer, offset, cuEditor),
monitor).size());
}
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:8,代码来源:JsniMethodBodyCompletionProposalComputerTest.java
示例16: validateExpectedProposals
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
/**
* If length of line at 'lineNum' is 'len', then validate all proposals for invocation
* index varying from '(len - numCharsCompleted)' to 'len'.
*/
private static void validateExpectedProposals(IJavaProject javaProject,
String fullyQualifiedClassName, String source, int lineNum, int numCharsCompleted,
String... expectedProposals) throws CoreException, BadLocationException {
IProgressMonitor monitor = new NullProgressMonitor();
ICompilationUnit iCompilationUnit = JavaProjectUtilities.createCompilationUnit(
javaProject, fullyQualifiedClassName, source);
CompilationUnitEditor cuEditor = (CompilationUnitEditor) JavaUI.openInEditor(iCompilationUnit);
ISourceViewer viewer = cuEditor.getViewer();
IDocument document = viewer.getDocument();
IRegion lineInformation = document.getLineInformation(lineNum);
JsniMethodBodyCompletionProposalComputer jcpc = new JsniMethodBodyCompletionProposalComputer();
for (int numCharsToOverwrite = 0; numCharsToOverwrite <= numCharsCompleted;
numCharsToOverwrite++){
int invocationOffset = lineInformation.getOffset()
+ lineInformation.getLength() - numCharsToOverwrite;
JavaContentAssistInvocationContext context = new JavaContentAssistInvocationContext(
viewer, invocationOffset, cuEditor);
List<ICompletionProposal> completions = jcpc.computeCompletionProposals(
context, monitor);
int indentationUnits = JsniMethodBodyCompletionProposalComputer.measureIndentationUnits(
document, lineNum, lineInformation.getOffset(), javaProject);
List<String> expected = createJsniBlocks(javaProject, indentationUnits,
expectedProposals);
for (int i = 0; i < expected.size(); i++){
String expectedBlock = expected.get(i).substring(numCharsCompleted - numCharsToOverwrite);
expected.set(i, expectedBlock);
}
assertExpectedProposals(expected, completions, numCharsToOverwrite);
}
}
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:40,代码来源:JsniMethodBodyCompletionProposalComputerTest.java
示例17: getOpenJavaEditors
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
public static IEditorReference[] getOpenJavaEditors(IProject project) {
List<IEditorReference> projectOpenJavaEditors = new ArrayList<IEditorReference>();
try {
IWorkbenchPage page = JavaPlugin.getActivePage();
if (page != null) {
// Iterate through all the open editors
IEditorReference[] openEditors = page.getEditorReferences();
for (IEditorReference openEditor : openEditors) {
IEditorPart editor = openEditor.getEditor(false);
// Only look for Java Editor and subclasses
if (editor instanceof CompilationUnitEditor) {
IEditorInput input = openEditor.getEditorInput();
IJavaProject inputProject = EditorUtility.getJavaProject(input);
// See if the editor is editing a file in this project
if (inputProject != null && inputProject.getProject().equals(project)) {
projectOpenJavaEditors.add(openEditor);
}
}
}
}
} catch (PartInitException e) {
GWTPluginLog.logError(e);
}
return projectOpenJavaEditors.toArray(new IEditorReference[0]);
}
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:29,代码来源:GWTProjectPropertyPage.java
示例18: run
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
private void run(IJavaElement element, boolean lightweight) throws CoreException {
// Work around for http://dev.eclipse.org/bugs/show_bug.cgi?id=19104
if (! ActionUtil.isEditable(fEditor, getShell(), element))
return;
//XXX workaround bug 31998
if (ActionUtil.mustDisableJavaModelAction(getShell(), element))
return;
if (lightweight && fEditor instanceof CompilationUnitEditor && ! (element instanceof IPackageFragment)) {
new RenameLinkedMode(element, (CompilationUnitEditor) fEditor).start();
} else {
RefactoringExecutionStarter.startRenameRefactoring(element, getShell());
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:RenameJavaElementAction.java
示例19: RenameLinkedMode
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
public RenameLinkedMode(IJavaElement element, CompilationUnitEditor editor) {
Assert.isNotNull(element);
Assert.isNotNull(editor);
fEditor= editor;
fJavaElement= element;
fFocusEditingSupport= new FocusEditingSupport();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:RenameLinkedMode.java
示例20: SurroundWithTryCatchAction
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入依赖的package包/类
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
* @param editor the compilation unit editor
*
* @noreference This constructor is not intended to be referenced by clients.
*/
public SurroundWithTryCatchAction(CompilationUnitEditor editor) {
super(editor.getEditorSite());
setText(RefactoringMessages.SurroundWithTryCatchAction_label);
fEditor= editor;
setEnabled(isApplicable());
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.SURROUND_WITH_TRY_CATCH_ACTION);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:SurroundWithTryCatchAction.java
注:本文中的org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论