当前位置: 首页>>代码示例>>Java>>正文


Java JavaUI.openInEditor方法代码示例

本文整理汇总了Java中org.eclipse.jdt.ui.JavaUI.openInEditor方法的典型用法代码示例。如果您正苦于以下问题:Java JavaUI.openInEditor方法的具体用法?Java JavaUI.openInEditor怎么用?Java JavaUI.openInEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.ui.JavaUI的用法示例。


在下文中一共展示了JavaUI.openInEditor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openInbuiltOperationClass

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
private void openInbuiltOperationClass(String operationName, PropertyDialogButtonBar propertyDialogButtonBar) {
	String operationClassName = null;
	Operations operations = XMLConfigUtil.INSTANCE.getComponent(FilterOperationClassUtility.INSTANCE.getComponentName())
			.getOperations();
	List<TypeInfo> typeInfos = operations.getStdOperation();
	for (int i = 0; i < typeInfos.size(); i++) {
		if (typeInfos.get(i).getName().equalsIgnoreCase(operationName)) {
			operationClassName = typeInfos.get(i).getClazz();
			break;
		}
	}
	propertyDialogButtonBar.enableApplyButton(true);
	javaProject = FilterOperationClassUtility.getIJavaProject();
	if (javaProject != null) {
		try {
			IType findType = javaProject.findType(operationClassName);
			JavaUI.openInEditor(findType);
		} catch (JavaModelException | PartInitException e) {
			Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,Messages.CLASS_NOT_EXIST,null);
			StatusManager.getManager().handle(status, StatusManager.BLOCK);
			logger.error(e.getMessage(), e);
		}
	} else {
		WidgetUtility.errorMessage(Messages.SAVE_JOB_MESSAGE);
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:27,代码来源:ELTOpenFileEditorListener.java

示例2: run

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
@Override
	public void run() {
		ITypeBinding typeBinding = Crystal.getInstance().getTypeBindingFromName(fullyQualifiedName);
		if(typeBinding!=null){
			//get all types & names of fields & methods & class/interface
			IJavaElement javaElement = typeBinding.getJavaElement();
			if (javaElement != null && ASTUtils.isFromSource(typeBinding)) {
				try {
//					EditorUtility.openInEditor(javaElement, true);
					/*
					 * code above causes a bug that if several classes are in
					 * the same java file, always open the first one no matter
					 * which one the user chooses
					 */
					JavaUI.openInEditor(javaElement);
//					IEditorPart javaEditor = JavaUI.openInEditor(javaElement);
//					JavaUI.revealInEditor(javaEditor, javaElement);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		super.run();
	}
 
开发者ID:aroog,项目名称:code,代码行数:25,代码来源:OpenTypeAction.java

示例3: run

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
@Override
public void run(IMarker marker) {
  try {
    IEditorPart part = EditorUtility.isOpenInEditor(cu);
    if (part == null) {
      part = JavaUI.openInEditor(cu, true, false);
      if (part instanceof ITextEditor) {
        ((ITextEditor) part).selectAndReveal(offset, length);
      }
    }
    if (part != null) {
      IEditorInput input = part.getEditorInput();
      IDocument doc = JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getDocument(
          input);
      proposal.apply(doc);
    }
  } catch (CoreException e) {
    CorePluginLog.logError(e);
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:21,代码来源:QuickFixCompletionProposalWrapper.java

示例4: run

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
public void run(IMethod method) {
	if (method == null)
		return;
	if (!ActionUtil.isProcessable(getShell(), method))
		return;

	if (!checkMethod(method)) {
		MessageDialog.openInformation(getShell(), getDialogTitle(),
			Messages.format(ActionMessages.OpenSuperImplementationAction_no_super_implementation, BasicElementLabels.getJavaElementName(method.getElementName())));
		return;
	}

	try {
		IMethod impl= findSuperImplementation(method);
		if (impl != null) {
			JavaUI.openInEditor(impl, true, true);
		}
	} catch (CoreException e) {
		ExceptionHandler.handle(e, getDialogTitle(), ActionMessages.OpenSuperImplementationAction_error_message);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:OpenSuperImplementationAction.java

示例5: run

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
@Override
public void run(IStructuredSelection selection) {
	IMember[] members= getSelectedMembers(selection);
	if (members == null || members.length == 0) {
		return;
	}

	try {
		ICompilationUnit cu= members[0].getCompilationUnit();
		if (!ActionUtil.isEditable(getShell(), cu)) {
			return;
		}

		// open the editor, forces the creation of a working copy
		IEditorPart editor= JavaUI.openInEditor(cu);

		if (ElementValidator.check(members, getShell(), getDialogTitle(), false))
			run(members);
		JavaModelUtil.reconcile(cu);
		EditorUtility.revealInEditor(editor, members[0]);

	} catch (CoreException e) {
		ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.AddJavaDocStubsAction_error_actionFailed);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:AddJavaDocStubAction.java

示例6: open

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
/**
 * Opens and reveals the defining method.
 */
public void open() {
	CompilationUnit ast= SharedASTProvider.getAST(fJavaElement, SharedASTProvider.WAIT_ACTIVE_ONLY, null);
	if (ast != null) {
		ASTNode node= ast.findDeclaringNode(fAstNodeKey);
		if (node instanceof MethodDeclaration) {
			try {
				IMethodBinding methodBinding= ((MethodDeclaration)node).resolveBinding();
				IMethodBinding definingMethodBinding= Bindings.findOverriddenMethod(methodBinding, true);
				if (definingMethodBinding != null) {
					IJavaElement definingMethod= definingMethodBinding.getJavaElement();
					if (definingMethod != null) {
						JavaUI.openInEditor(definingMethod, true, true);
						return;
					}
				}
			} catch (CoreException e) {
				ExceptionHandler.handle(e, JavaEditorMessages.OverrideIndicatorManager_open_error_title, JavaEditorMessages.OverrideIndicatorManager_open_error_messageHasLogEntry);
				return;
			}
		}
	}
	String title= JavaEditorMessages.OverrideIndicatorManager_open_error_title;
	String message= JavaEditorMessages.OverrideIndicatorManager_open_error_message;
	MessageDialog.openError(JavaPlugin.getActiveWorkbenchShell(), title, message);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:OverrideIndicatorManager.java

示例7: run

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
public void run(IMarker marker) {
	try {
		IEditorPart part= EditorUtility.isOpenInEditor(fCompilationUnit);
		if (part == null) {
			part= JavaUI.openInEditor(fCompilationUnit, true, false);
			if (part instanceof ITextEditor) {
				((ITextEditor) part).selectAndReveal(fOffset, fLength);
			}
		}
		if (part != null) {
			IEditorInput input= part.getEditorInput();
			IDocument doc= JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getDocument(input);
			fProposal.apply(doc);
		}
	} catch (CoreException e) {
		JavaPlugin.log(e);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:CorrectionMarkerResolutionGenerator.java

示例8: openInEditor

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
/**
 * Open editor in specific line number
 * 
 * @param javaElement
 *            The java file to be opened
 * @param lineNumber
 *            The line number
 */
public static void openInEditor(IJavaElement javaElement, int lineNumber) {
	try {
		IEditorPart editorPart = JavaUI.openInEditor(javaElement, true, true);
		if (!(editorPart instanceof ITextEditor) || lineNumber <= 0) {
			return;
		}

		ITextEditor editor = (ITextEditor) editorPart;
		IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
		if (document != null) {
			IRegion lineInfo = null;
			lineInfo = document.getLineInformation(lineNumber - 1);
			if (lineInfo != null) {
				editor.selectAndReveal(lineInfo.getOffset(), lineInfo.getLength());
			}
		}
	}
	catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:sromku,项目名称:bugsnag-eclipse-plugin,代码行数:30,代码来源:WorkspaceUtils.java

示例9: openInPerspective

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
private static TypeHierarchyViewPart openInPerspective(IWorkbenchWindow window, IJavaElement[] input) throws WorkbenchException, JavaModelException {
	IWorkbench workbench= JavaPlugin.getDefault().getWorkbench();
	IJavaElement perspectiveInput= input.length == 1 ? input[0] : null;

	if (perspectiveInput != null && input[0] instanceof IMember) {
		if (input[0].getElementType() != IJavaElement.TYPE) {
			perspectiveInput= ((IMember)input[0]).getDeclaringType();
		} else {
			perspectiveInput= input[0];
		}
	}
	IWorkbenchPage page= workbench.showPerspective(JavaUI.ID_HIERARCHYPERSPECTIVE, window, perspectiveInput);

	TypeHierarchyViewPart part= (TypeHierarchyViewPart) page.findView(JavaUI.ID_TYPE_HIERARCHY);
	if (part != null) {
		part.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
	}
	part= (TypeHierarchyViewPart) page.showView(JavaUI.ID_TYPE_HIERARCHY);
	part.setInputElements(input);
	if (perspectiveInput != null) {
		if (page.getEditorReferences().length == 0) {
			JavaUI.openInEditor(input[0], false, false); // only open when the perspective has been created
		}
	}
	return part;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:27,代码来源:OpenTypeHierarchyUtil.java

示例10: openJavaSourceEditor

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
public void openJavaSourceEditor(ApiDescriptor api) {
	if (api != null) {
		CompilationUnit cu = api.getCompilatioinUnit();
		if (cu != null) {
			try {
				// According to the guide
				// http://eclipsesnippets.blogspot.kr/2008/06/programmatically-opening-editor.html
				ITextEditor editor = (ITextEditor)JavaUI.openInEditor(cu.getJavaElement());
				int line = api.getLineNumFromSoot();
				
				if (line > 0) {
					IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
					editor.selectAndReveal(document.getLineOffset(line - 1), document.getLineLength(line-1));
				} else {
					System.err.println("Not valid line number. It is not positive.");
				}
			} catch (PartInitException | JavaModelException | BadLocationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	} else {
		System.err.println("Can't open java editor. ApiDescriptor is NULL.");
	}
}
 
开发者ID:SeoulTech,项目名称:Manal,代码行数:26,代码来源:SuspectCodeEd.java

示例11: open

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
@Override
public void open() {
	try {
		JavaUI.openInEditor(type);
	} catch (PartInitException | JavaModelException e) {
		ErrorUtils.handle(e);
	}
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:9,代码来源:JavaTypeHyperLink.java

示例12: openInEditor

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
private void openInEditor(IJavaElement javaElement) {
	try {
		JavaUI.openInEditor(javaElement);
	} catch (PartInitException | JavaModelException e) {
		EditorUtil.INSTANCE.logError("Cannot open java editor with:"+javaElement,e);
	}
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:8,代码来源:GradleResourceHyperlink.java

示例13: testBuildAddError

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的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

示例14: validateExpectedProposals

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的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

示例15: revealInEditor

import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
@Override
public void revealInEditor(IType objectClass, IJavaElement elementToReveal)
        throws JavaModelException, PartInitException {
    ICompilationUnit compilationUnit = objectClass.getCompilationUnit();
    IEditorPart javaEditor = JavaUI.openInEditor(compilationUnit);
    JavaUI.revealInEditor(javaEditor, elementToReveal);
}
 
开发者ID:maximeAudrain,项目名称:jenerate,代码行数:8,代码来源:JavaUiCodeAppenderImpl.java


注:本文中的org.eclipse.jdt.ui.JavaUI.openInEditor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。