當前位置: 首頁>>代碼示例>>Java>>正文


Java IEditorPart.getEditorInput方法代碼示例

本文整理匯總了Java中org.eclipse.ui.IEditorPart.getEditorInput方法的典型用法代碼示例。如果您正苦於以下問題:Java IEditorPart.getEditorInput方法的具體用法?Java IEditorPart.getEditorInput怎麽用?Java IEditorPart.getEditorInput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.ui.IEditorPart的用法示例。


在下文中一共展示了IEditorPart.getEditorInput方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getActiveEditorFile

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
/**
 * Returns the opened file of the currently active editor.
 *
 * Returns null if no editor is open.
 */
private static IFile getActiveEditorFile() {
	IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
			.getActiveEditor();

	if (null == activeEditor) {
		return null;
	}

	IEditorInput input = activeEditor.getEditorInput();

	if (input instanceof FileEditorInput) {
		return ((FileEditorInput) input).getFile();
	} else {
		return null;
	}

}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:23,代碼來源:CreateNewN4JSElementInModuleHandler.java

示例2: addLinterError

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
public static void addLinterError(IEditorPart editor, JenkinsLinterError error) {
	if (editor == null) {
		return;
	}
	if (error == null) {
		return;
	}

	IEditorInput input = editor.getEditorInput();
	if (input == null) {
		return;
	}
	IResource editorResource = input.getAdapter(IResource.class);
	if (editorResource == null) {
		return;
	}
	try {
		linterMarkerHelper.createErrorMarker(editorResource, error.getMessage(), error.getLine());
	} catch (CoreException e) {
		logError("Was not able to add error markers", e);
	}

}
 
開發者ID:de-jcup,項目名稱:eclipse-jenkins-editor,代碼行數:24,代碼來源:JenkinsEditorUtil.java

示例3: canRun

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
public boolean canRun() {

        InputType inputType = getInputType();

        if (inputType.isStructuredSelection()) {
            IStructuredSelection structuredSelection = getCurrentStructuredSelection();
            if (canRunWithStructuredSelection(structuredSelection)) {
                return true;
            }
        }
        else if (inputType.isEditorInput()) {

            IEditorPart editor = getActiveEditor();
            IEditorInput editorInput = (editor != null) ? editor.getEditorInput() : null;

            if (canRunWithEditorInput(editorInput)) {
                return true;
            }
        }
        else if (canRunWithNothing()) {
            return true;
        }

        return false;

    }
 
開發者ID:baloise,項目名稱:eZooKeeper,代碼行數:27,代碼來源:BaseAction.java

示例4: addScriptError

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
public static void addScriptError(IEditorPart editor, int line, BashError error, int severity) {
	if (editor == null) {
		return;
	}
	if (error == null) {
		return;
	}

	IEditorInput input = editor.getEditorInput();
	if (input == null) {
		return;
	}
	IResource editorResource = input.getAdapter(IResource.class);
	if (editorResource == null) {
		return;
	}
	try {
		scriptProblemMarkerHelper.createScriptMarker(severity, editorResource, error.getMessage(), line, error.getStart(),
				+ error.getEnd());
	} catch (CoreException e) {
		logError("Was not able to add error markers", e);
	}

}
 
開發者ID:de-jcup,項目名稱:eclipse-bash-editor,代碼行數:25,代碼來源:BashEditorUtil.java

示例5: getEditedFileFolder

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
public static File getEditedFileFolder() {
	IWorkbenchPage page = null;
	IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
	for (int i = 0; i < windows.length; i++) {
		if (windows[i] != null) {
			IWorkbenchWindow window = windows[i];
			page = windows[i].getActivePage();
			if (page != null)
				break;
		}
	}
	IEditorPart part = page.getActiveEditor();
	FileEditorInput editor = (FileEditorInput) part.getEditorInput();
	IFile file = editor.getFile();
	IFolder folder = (IFolder) file.getParent();
	File f = null;
	try {
		f = ResourceManager.toFile(folder.getFullPath());
	} catch (FileNotFoundException e) {
		ResourceManager.logException(e);
	}
	return f;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:24,代碼來源:EditorHelper.java

示例6: launch

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
@Override
public void launch(IEditorPart editor, String mode) {
	try {
		IEditorInput editorInput = editor.getEditorInput();
		if (editorInput instanceof IFileEditorInput) {
			IFile selectObj = ((IFileEditorInput) editorInput).getFile();
			launchFile(selectObj, mode);
		} else {
			showDialogNotImplemented(editor.getClass().getName());
		}
	} catch (CoreException e) {
		System.out.println(e.getLocalizedMessage() + "\n");
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:15,代碼來源:LaunchXpectShortcut.java

示例7: launch

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
@Override
public void launch(IEditorPart editor, String mode) {
	IEditorInput editorInput = editor.getEditorInput();
	if (editorInput instanceof IFileEditorInput) {
		IFile selectObj = ((IFileEditorInput) editorInput).getFile();
		generateBug(selectObj);
	} else {
		showDialogNotImplemented(editor.getClass().getName());
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:11,代碼來源:GenerateXpectReportShortcut.java

示例8: execute

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {

	final ISelection selection = getCurrentSelection(event);
	if (null == selection) {
		return null;
	}

	if (selection.isEmpty()) {
		return null;
	}

	final AtomicReference<IFile> fileRef = new AtomicReference<>();

	if (selection instanceof IStructuredSelection) {
		final Object element = ((IStructuredSelection) selection).getFirstElement();
		if (element instanceof IFile) {
			fileRef.set((IFile) element);
		}
	} else if (selection instanceof ITextSelection) {
		final IEditorPart editorPart = getActiveEditor(event);
		if (null != editorPart) {
			final IEditorInput input = editorPart.getEditorInput();
			if (input instanceof IFileEditorInput) {
				fileRef.set(((IFileEditorInput) input).getFile());
			}
		}
	}

	if (null != fileRef.get()) {
		final Optional<IFile> generatedSource = fileLocator.tryGetGeneratedSourceForN4jsFile(fileRef.get());
		if (generatedSource.isPresent()) {
			tryOpenFileInEditor(fileRef.get(), generatedSource.get());
		}
	}

	return null;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:39,代碼來源:OpenGeneratedSourceInEditorHandler.java

示例9: getLocationForEditor

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
/**
 * Derives a location URI as expected by {@link TestDiscoveryHelper#collectTests(URI...)} from an editor.
 */
public static final URI getLocationForEditor(IEditorPart editor) {
	final IEditorInput input = editor.getEditorInput();
	if (input instanceof IFileEditorInput)
		return getLocationForEditorInput((IFileEditorInput) input);
	return null;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:10,代碼來源:TestDiscoveryUIUtils.java

示例10: getEditorFile

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
public static IFile getEditorFile(IEditorPart editor) {
	if (editor == null) {
		return null;
	}
	IEditorInput editorInput = editor.getEditorInput();
	if (!(editorInput instanceof FileEditorInput)) {
		return null;
	}

	FileEditorInput fileInput = (FileEditorInput) editorInput;

	return fileInput.getFile();
}
 
開發者ID:sebez,項目名稱:vertigo-chroma-kspplugin,代碼行數:14,代碼來源:UiUtils.java

示例11: getInputFile

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
/**
 * Obtains a file existing on an editor.
 * @param editor the editor
 * @return the file existing on the editor, or <code>null</code> if none
 */
public static IFile getInputFile(IEditorPart editor) {
    IEditorInput input = editor.getEditorInput();
    if (input instanceof IFileEditorInput) {
        IFile file = ((IFileEditorInput)input).getFile();
        return file;
    }
    return null;
}
 
開發者ID:liaoziyang,項目名稱:ContentAssist,代碼行數:14,代碼來源:EditorUtilities.java

示例12: execute

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow == null) {
        return null;
    }
    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
    if (activePage == null) {
        return null;
    }
    IEditorPart editor = activePage.getActiveEditor();
    if (editor == null) {
        return null;
    }
    IEditorInput input = editor.getEditorInput();
    if (input == null || ! (input instanceof FileEditorInput)) {
        return null;
    }
    IFile file = ((FileEditorInput) input).getFile();
    if (file != null && file.getType() == IResource.FILE && file.getFileExtension().equals("java")) {
        utils = new ProjectUtils(file.getProject());
        if (utils.isGluonMobileProject()) {
            ISelection selection = HandlerUtil.getCurrentSelection(event);
            Display.getDefault().asyncExec(() -> new JCode(utils, selection,  (JavaEditor) editor));
        }
    }
    return null;
}
 
開發者ID:gluonhq,項目名稱:ide-plugins,代碼行數:29,代碼來源:InsertGluonFunctionHandler.java

示例13: test

import org.eclipse.ui.IEditorPart; //導入方法依賴的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

示例14: removeLinterErrors

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
public static void removeLinterErrors(IEditorPart editor) {
	if (editor == null) {
		return;
	}
	IEditorInput input = editor.getEditorInput();
	if (input == null) {
		return;
	}
	IResource editorResource = input.getAdapter(IResource.class);
	if (editorResource == null) {
		return;
	}
	linterMarkerHelper.removeMarkers(editorResource);
}
 
開發者ID:de-jcup,項目名稱:eclipse-jenkins-editor,代碼行數:15,代碼來源:JenkinsEditorUtil.java

示例15: removeScriptErrors

import org.eclipse.ui.IEditorPart; //導入方法依賴的package包/類
public static void removeScriptErrors(IEditorPart editor) {
	if (editor == null) {
		return;
	}
	IEditorInput input = editor.getEditorInput();
	if (input == null) {
		return;
	}

}
 
開發者ID:de-jcup,項目名稱:eclipse-batch-editor,代碼行數:11,代碼來源:BatchEditorUtil.java


注:本文中的org.eclipse.ui.IEditorPart.getEditorInput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。