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


Java IWorkbenchPage.getActiveEditor方法代码示例

本文整理汇总了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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:21,代码来源:AbstractBuilderParticipantTest.java

示例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;
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:22,代码来源:AbstractBatchEditorHandler.java

示例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;
}
 
开发者ID:de-jcup,项目名称:eclipse-bash-editor,代码行数:22,代码来源:AbstractBashEditorHandler.java

示例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;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:24,代码来源:EditorHelper.java

示例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;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:23,代码来源:EditorHelper.java

示例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();
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:27,代码来源:UiUtils.java

示例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);
    }
}
 
开发者ID:Talend,项目名称:avro-schema-editor,代码行数:21,代码来源:SearchNodeControl.java

示例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");
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:12,代码来源:EditorsUtil.java

示例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;
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:29,代码来源:InsertGluonFunctionHandler.java

示例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;
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:34,代码来源:InsertFunctionTester.java

示例11: getActiveEditor

import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
protected final IEditorPart getActiveEditor() {
    IWorkbenchPage workBenchPage = getActiveWorkbenchPage();
    if (workBenchPage != null) {
        return workBenchPage.getActiveEditor();
    }
    return null;
}
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:8,代码来源:BaseAction.java

示例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;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:30,代码来源:DBStoreCombo.java

示例13: getActiveEditor

import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
public static IEditorPart getActiveEditor() {
	IWorkbenchPage page = getActivePage();
	IEditorPart activeEditor = page.getActiveEditor();
	return activeEditor;
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:6,代码来源:EclipseUtil.java

示例14: getActiveEditor

import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
/**
 * @return IEditorPart
 */
public static IEditorPart getActiveEditor() {
	final IWorkbenchPage page = PageUtil.getPage();
	return page.getActiveEditor();
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:8,代码来源:PageUtil.java


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