⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 helper.java

📁 CakePHP的Eclipse插件
💻 JAVA
字号:
package org.xicabin.radcake.core.util;

import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbenchPage;

/**
 * Helper function
 * 
 * @author Darcy Young
 */
public abstract class Helper {
	public static IFile getSelectedFile(IWorkbenchPage page) {
		if (null == page)
			return null;
		IFile file = null;
		ISelection selection = page.getSelection();
		if (selection instanceof ITextSelection) {
			IEditorInput editorInput = page.getActiveEditor().getEditorInput();
			if (editorInput instanceof IFileEditorInput) {
				file = ((IFileEditorInput) editorInput).getFile();
			}
		} else if (selection instanceof IStructuredSelection
				&& !selection.isEmpty()) {
			Object element = ((IStructuredSelection) selection)
					.getFirstElement();
			if (element instanceof IFile) {
				file = (IFile) element;
			}
		}
		return file;
	}

	public static String getSelectedText(IWorkbenchPage page) {
		if (null == page)
			return null;
		String text = "";
		ISelection selection = page.getSelection();
		if (selection instanceof ITextSelection) {
			text = ((ITextSelection) selection).getText();
		}
		return text;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -