本文整理汇总了Java中org.eclipse.ui.ide.IDE.openEditor方法的典型用法代码示例。如果您正苦于以下问题:Java IDE.openEditor方法的具体用法?Java IDE.openEditor怎么用?Java IDE.openEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.ide.IDE
的用法示例。
在下文中一共展示了IDE.openEditor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
@Override
public void run() {
if (isEnabled()) {
try {
ITextEditor editor = (ITextEditor) IDE.openEditor(
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
segment.getParentFile(), EDITOR.SQL, true);
editor.setHighlightRange(segment.offset, segment.length, true);
editor.selectAndReveal(segment.offset, segment.length);
} catch (PartInitException e) {
Log.log(e);
ExceptionNotifier.notifyDefault(Messages.PgNavigatorActionProvider_failed_to_open_editor, e);
}
}
}
示例2: openEditor
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
private Container openEditor(IPath jobFilePath) throws CoreException {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (!isJobAlreadyOpen(jobFilePath)) {
if (ResourcesPlugin.getWorkspace().getRoot().getFile(jobFilePath).exists()) {
IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(jobFilePath);
IDE.openEditor(page, iFile);
} else {
if (jobFilePath.toFile().exists()) {
IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(jobFilePath.toFile());
IEditorInput store = new FileStoreEditorInput(fileStore);
IDE.openEditorOnFileStore(page, fileStore);
}
}
return SubJobUtility.getCurrentEditor().getContainer();
}else
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error",
"Unable to open subjob : "+jobFilePath.lastSegment()+" Subjob is already open \n" +
"Please close the job and retry");
return null;
}
示例3: run
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
@Override
public void run(IIntroSite site, Properties params) {
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IProject project = createProject(monitor);
createExample(project);
}
};
try {
PlatformUI.getWorkbench().getProgressService().run(true, true, op);
final IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
IIntroPart part = introManager.getIntro();
introManager.closeIntro(part);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("hello-world/greeter.sol")));
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: performFinish
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
@Override
public boolean performFinish() {
IFile file = mainPage.createNewFile();
if (file == null) {
return false;
}
selectAndReveal(file);
// Open editor on new file.
IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
try {
if (dw != null) {
IWorkbenchPage page = dw.getActivePage();
if (page != null) {
IDE.openEditor(page, file, true);
}
}
} catch (PartInitException e) {
openError(dw.getShell(), "Problems opening editor", e.getMessage(), e);
}
return true;
}
示例5: openInEditor
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "deprecation", "rawtypes" })
public static void openInEditor(IFile file, int startpos, int length) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
HashMap map = new HashMap();
map.put(IMarker.CHAR_START, new Integer(startpos));
map.put(IMarker.CHAR_END, new Integer(startpos+length));
map.put(IWorkbenchPage.EDITOR_ID_ATTR,
"org.eclipse.ui.DefaultTextEditor");
try {
IMarker marker = file.createMarker(IMarker.TEXT);
marker.setAttributes(map);
IDE.openEditor(page, marker);
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: open
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
/**
* If a platform plugin URI is given, a read-only Xtext editor is opened and returned. {@inheritDoc}
*
* @see {@link org.eclipse.emf.common.util.URI#isPlatformPlugin()}
*/
@Override
public IEditorPart open(final URI uri, final EReference crossReference, final int indexInList, final boolean select) {
IEditorPart result = super.open(uri, crossReference, indexInList, select);
if (result == null && (uri.isPlatformPlugin() || OSGI_RESOURCE_URL_PROTOCOL.equals(uri.scheme()))) {
final IModelLocation modelLocation = getModelLocation(uri.trimFragment());
if (modelLocation != null) {
PlatformPluginStorage storage = new PlatformPluginStorage(modelLocation);
IEditorInput editorInput = new XtextReadonlyEditorInput(storage);
IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
try {
IEditorPart editor = IDE.openEditor(activePage, editorInput, editorID);
selectAndReveal(editor, uri, crossReference, indexInList, select);
return EditorUtils.getXtextEditor(editor);
} catch (WrappedException e) {
LOG.error("Error while opening editor part for EMF URI '" + uri + "'", e.getCause()); //$NON-NLS-1$ //$NON-NLS-2$
} catch (PartInitException partInitException) {
LOG.error("Error while opening editor part for EMF URI '" + uri + "'", partInitException); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
return result;
}
示例7: testTMHighlightInGenericEditorEdit
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
@Test
public void testTMHighlightInGenericEditorEdit() throws IOException, PartInitException {
f = File.createTempFile("test" + System.currentTimeMillis(), ".ts");
FileOutputStream fileOutputStream = new FileOutputStream(f);
fileOutputStream.write("let a = '';".getBytes());
fileOutputStream.close();
f.deleteOnExit();
editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
f.toURI(), editorDescriptor.getId(), true);
StyledText text = (StyledText)editor.getAdapter(Control.class);
new DisplayHelper() {
@Override
protected boolean condition() {
return text.getStyleRanges().length > 1;
}
}.waitForCondition(text.getDisplay(), 3000);
int numberOfRanges = text.getStyleRanges().length;
Assert.assertTrue(numberOfRanges > 1);
text.setText("let a = '';\nlet b = 10;\nlet c = true;");
DisplayHelper.runEventLoop(text.getDisplay(), 3000);
Assert.assertTrue("More styles should have been added", text.getStyleRanges().length > numberOfRanges + 3);
}
示例8: performFinish
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
@Override
public boolean performFinish() {
boolean result = false;
IFile file = page.createNewFile();
result = file != null;
if (result) {
try {
IDE.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), file);
} catch (PartInitException e) {
// TODO: handle exception
e.printStackTrace();
}
}
return result;
}
示例9: performFinish
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean performFinish() {
try {
final String database = page2.getDatabase();
page1.createERDiagram(database);
final IFile file = page1.createNewFile();
if (file == null) {
return false;
}
final IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, file, true);
} catch (final Exception e) {
ERDiagramActivator.showExceptionDialog(e);
}
return true;
}
示例10: gotoBookmark
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
@Override
public boolean gotoBookmark(IWorkbenchWindow window, Bookmark bookmark, IBookmarkLocation bookmarkLocation) {
if (!(bookmarkLocation instanceof RepositoryCommitBookmarkLocation)) {
return false;
}
RepositoryCommitBookmarkLocation repositoryCommitBookmarkLocation = (RepositoryCommitBookmarkLocation) bookmarkLocation;
RepositoryCommit repositoryCommit = repositoryCommitBookmarkLocation.getRepositoryCommit();
CommitEditorInput input = new CommitEditorInput(repositoryCommit);
try {
IDE.openEditor(window.getActivePage(), input, CommitEditor.ID, true);
} catch (PartInitException e) {
return false;
}
return true;
}
示例11: performFinish
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean performFinish() {
try {
String database = this.page2.getDatabase();
this.page1.createERDiagram(database);
IFile file = this.page1.createNewFile();
if (file == null) {
return false;
}
IWorkbenchPage page = this.workbench.getActiveWorkbenchWindow()
.getActivePage();
IDE.openEditor(page, file, true);
} catch (Exception e) {
ERDiagramActivator.showExceptionDialog(e);
}
return true;
}
示例12: openInEditor
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
public static IEditorPart openInEditor(IFile file)
{
if (file != null)
{
IWorkbenchPage p = VelocityPlugin.getActiveWorkbenchWindow().getActivePage();
if (p != null)
{
IEditorPart editorPart = null;
try
{
editorPart = IDE.openEditor(p, file, true);
}
catch (PartInitException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
// initializeHighlightRange(editorPart);
return editorPart;
}
}
return null;
}
示例13: OpenEditor
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
private void OpenEditor(IFile file)
{
if(file == null)
return;
try
{
IWorkbenchPage page = getWorkbenchPage();
if(page != null)
IDE.openEditor(page, file, true);
}
catch(CoreException e)
{
String title = Policy.bind("OpenEditorAction.errorTitle");
String message = Policy.bind("OpenEditorAction.errorMessage");
ErrorDialog.openError(getViewSite().getShell(), title, message, e.getStatus());
}
}
示例14: open
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
public IEditorPart open(URI uri, EReference crossReference, int indexInList, boolean select) {
Iterator<Pair<IStorage, IProject>> storages = mapper.getStorages(uri.trimFragment()).iterator();
if (storages != null && storages.hasNext()) {
try {
IStorage storage = storages.next().getFirst();
// TODO we should create a JarEntryEditorInput if storage is a NonJavaResource from jdt to match the editor input used when double clicking on the same resource in a jar.
IEditorInput editorInput = (storage instanceof IFile) ? new FileEditorInput((IFile) storage)
: new XtextReadonlyEditorInput(storage);
IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = IDE.openEditor(activePage, editorInput, editorID);
selectAndReveal(editor, uri, crossReference, indexInList, select);
return EditorUtils.getXtextEditor(editor);
} catch (WrappedException e) {
logger.error("Error while opening editor part for EMF URI '" + uri + "'", e.getCause());
} catch (PartInitException partInitException) {
logger.error("Error while opening editor part for EMF URI '" + uri + "'", partInitException);
}
}
return null;
}
示例15: openInEditor
import org.eclipse.ui.ide.IDE; //导入方法依赖的package包/类
/**
* Open a file in an editor and return the opened editor part.<br>
* This method will try to open the file in an internal editor, unless there is no editor descriptor assigned to
* that file type.
*
* @param file
* @return The {@link IEditorPart} that was created when the file was opened; Return null in case of an error
*/
public static IEditorPart openInEditor(File file)
{
// NOTE: Moved from PHP's EditorUtils
if (file == null)
{
IdeLog.logError(CommonEditorPlugin.getDefault(),
"Error open a file in the editor", new IllegalArgumentException("file is null")); //$NON-NLS-1$ //$NON-NLS-2$
return null;
}
try
{
URI uri = file.toURI();
IEditorDescriptor desc = getEditorDescriptor(uri);
String editorId = (desc == null) ? IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID : desc.getId();
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
return IDE.openEditor(page, uri, editorId, true);
}
catch (Exception e)
{
IdeLog.logError(CommonEditorPlugin.getDefault(), "Error open a file in the editor", e); //$NON-NLS-1$
}
return null;
}