本文整理匯總了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;
}