當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。