本文整理汇总了Java中org.eclipse.ui.IWorkbenchPage.getActiveEditor方法的典型用法代码示例。如果您正苦于以下问题:Java IWorkbenchPage.getActiveEditor方法的具体用法?Java IWorkbenchPage.getActiveEditor怎么用?Java IWorkbenchPage.getActiveEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.IWorkbenchPage
的用法示例。
在下文中一共展示了IWorkbenchPage.getActiveEditor方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileEditor
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
private IEditorPart getFileEditor(final IFile file1, final IWorkbenchPage page) {
internalFileEditor = null;
Display.getCurrent().syncExec(new Runnable() {
@Override
public void run() {
try {
internalFileEditor = IDE.openEditor(page, file1, getEditorId(), true);
} catch (PartInitException e) {
e.printStackTrace();
}
}
});
long start = System.currentTimeMillis();
long end = start;
do {
end = System.currentTimeMillis();
} while (page.getActiveEditor() != internalFileEditor && (end - start) < 5000);
return internalFileEditor;
}
示例2: execute
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench==null){
return null;
}
IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
if (activeWorkbenchWindow==null){
return null;
}
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (activePage==null){
return null;
}
IEditorPart editor = activePage.getActiveEditor();
if (editor instanceof BatchEditor){
executeOnBatchEditor((BatchEditor) editor);
}
return null;
}
示例3: execute
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench==null){
return null;
}
IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
if (activeWorkbenchWindow==null){
return null;
}
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (activePage==null){
return null;
}
IEditorPart editor = activePage.getActiveEditor();
if (editor instanceof BashEditor){
executeOnBashEditor((BashEditor) editor);
}
return null;
}
示例4: getEditedFileFolder
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的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;
}
示例5: getEditedFile
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
public static File getEditedFile() {
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();
File f = null;
try {
f = ResourceManager.toFile(file.getFullPath());
} catch (FileNotFoundException e) {
ResourceManager.logException(e);
}
return f;
}
示例6: getCurrentEditorCurrentWord
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
public static String getCurrentEditorCurrentWord(WordSelectionType wordSelectionType) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
/* Extrait l'éditeur courant. */
ITextEditor editor = (ITextEditor) activePage.getActiveEditor();
if (editor == null) {
return null;
}
/* Extrait la sélection courante. */
ITextSelection selection = (ITextSelection) activePage.getSelection();
if (selection == null) {
return null;
}
/* Extrait le document courant. */
IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
/* Extrait le mot sélectionné. */
ITextSelection currentWordSelection = DocumentUtils.findCurrentWord(document, selection, wordSelectionType);
if (currentWordSelection == null) {
return null;
}
return currentWordSelection.getText();
}
示例7: search
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
protected void search(String pattern, SearchType type, boolean withRef) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
IEditorPart editorPart = workbenchPage.getActiveEditor();
if (editorPart instanceof IWithAvroSchemaEditor) {
AvroSchemaEditor schemaEditor = ((IWithAvroSchemaEditor) editorPart).getEditor();
AvroContext masterContext = schemaEditor.getContext().getMaster();
SearchNodeContext searchNodeContext = masterContext.getSearchNodeContext();
if (pattern == null || pattern.trim().isEmpty()) {
searchNodeContext.reset();
} else if (searchNodeContext.searchNodes(type, pattern, withRef)) {
AvroNode node = searchNodeContext.next();
schemaEditor.getContentPart()
.getSchemaViewer(AvroContext.Kind.MASTER)
.setSelection(new StructuredSelection(node), true);
}
refreshCommands(editorPart, SearchNodePropertyTester.PROPERTIES);
}
}
示例8: waitForEditorToBeActive
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
/** Get editor for provided file, returns once editor is active or after timeout */
private static final void waitForEditorToBeActive(IEditorPart internalFileEditor, IWorkbenchPage page) {
long start = System.currentTimeMillis();
long end = start;
do {
end = System.currentTimeMillis();
} while (page.getActiveEditor() != internalFileEditor && (end - start) < 5000);
if (page.getActiveEditor() != internalFileEditor)
logger.warn("selected editor was not activated within timout");
}
示例9: execute
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的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;
}
示例10: test
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的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;
}
示例11: getActiveEditor
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
protected final IEditorPart getActiveEditor() {
IWorkbenchPage workBenchPage = getActiveWorkbenchPage();
if (workBenchPage != null) {
return workBenchPage.getActiveEditor();
}
return null;
}
示例12: createControl
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
@Override
protected Control createControl(Composite parent) {
IWorkbenchPage page = getWorkbenchWindow().getActivePage();
IEditorPart editorPart = page.getActiveEditor();
storePicker = new DbStorePicker(parent, Activator.getDefault().getPreferenceStore(),
editorPart instanceof ProjectEditorDiffer, false, true);
editorPartListener = new EditorPartListener();
page.addPartListener(editorPartListener);
storePicker.addListenerToCombo(e -> {
IEditorPart editor = getWorkbenchWindow().getActivePage().getActiveEditor();
if (editor instanceof SQLEditor) {
((SQLEditor) editor).setCurrentDb(storePicker.getDbInfo());
} else if (editor instanceof ProjectEditorDiffer) {
Object selection = storePicker.getDbInfo();
if (selection == null) {
selection = storePicker.getPathOfFile();
}
((ProjectEditorDiffer) editor).setCurrentDb(selection);
}
});
setSelectionFromPart(getWorkbenchWindow().getActivePage().getActiveEditor());
return storePicker;
}
示例13: getActiveEditor
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
public static IEditorPart getActiveEditor() {
IWorkbenchPage page = getActivePage();
IEditorPart activeEditor = page.getActiveEditor();
return activeEditor;
}
示例14: getActiveEditor
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
/**
* @return IEditorPart
*/
public static IEditorPart getActiveEditor() {
final IWorkbenchPage page = PageUtil.getPage();
return page.getActiveEditor();
}