use of org.eclipse.ui.IEditorInput in project sling by apache.
the class LinkHelper method activateEditor.
@Override
public void activateEditor(IWorkbenchPage aPage, IStructuredSelection aSelection) {
final Object selectedElement = aSelection.getFirstElement();
if (!(selectedElement instanceof JcrNode)) {
return;
}
final JcrNode node = (JcrNode) selectedElement;
// bring properties view to top, if it is open
// SLING-3641 : moved link-with-editor behavior to the JCR Properties view atm
//TODO: to be reviewed at a later stage with SLING-3641
// IViewPart propertiesView = aPage.findView(IPageLayout.ID_PROP_SHEET);
// if (propertiesView!=null) {
// aPage.bringToTop(propertiesView);
// }
final IResource resource = node.getResource();
if (resource == null || !(resource instanceof IFile)) {
return;
}
final IFile selectedFile = (IFile) resource;
for (final IEditorReference reference : aPage.getEditorReferences()) {
if (reference == null) {
continue;
}
final IEditorInput editorInput;
try {
editorInput = reference.getEditorInput();
} catch (PartInitException e) {
//TODO proper logging
e.printStackTrace();
continue;
}
if (editorInput == null) {
continue;
}
if (!(editorInput instanceof IFileEditorInput)) {
continue;
}
final IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
final IFile file = fileEditorInput.getFile();
if (file == null) {
continue;
}
if (file.equals(selectedFile)) {
aPage.bringToTop(reference.getEditor(true));
}
}
}
use of org.eclipse.ui.IEditorInput in project bndtools by bndtools.
the class PrivatePackagesPart method getJavaProject.
private IJavaProject getJavaProject() {
IFormPage page = (IFormPage) getManagedForm().getContainer();
IEditorInput input = page.getEditorInput();
if (!IFileEditorInput.class.isInstance(input)) {
return null;
}
IProject project = ((IFileEditorInput) input).getFile().getProject();
return JavaCore.create(project);
}
use of org.eclipse.ui.IEditorInput in project bndtools by bndtools.
the class BndSourceEditorPage method getDocument.
private IDocument getDocument() {
IDocumentProvider docProvider = getDocumentProvider();
IEditorInput input = getEditorInput();
return new IDocumentWrapper(docProvider.getDocument(input));
}
use of org.eclipse.ui.IEditorInput in project bndtools by bndtools.
the class JAREntryPart method loadContent.
protected void loadContent() {
if (displayJob != null && displayJob.getState() != Job.NONE)
displayJob.cancel();
if (zipEntry != null && !zipEntry.isDirectory()) {
IEditorInput input = editor.getEditorInput();
final Display display = text.getDisplay();
final URI uri = URIHelper.retrieveFileURI(input);
if (uri != null) {
displayJob = new Job("Load zip content") {
@Override
protected IStatus run(IProgressMonitor monitor) {
File ioFile = new File(uri);
try (ZipFile zipFile = new ZipFile(ioFile)) {
final StringWriter writer = new StringWriter();
if (showAsText)
readAsText(zipFile, zipEntry, charsets[selectedCharset], writer, 1024 * 20, monitor);
else
readAsHex(zipFile, zipEntry, writer, 1024 * 20, 2, monitor);
display.asyncExec(new Runnable() {
@Override
public void run() {
setContent(writer.toString());
}
});
return Status.OK_STATUS;
} catch (IOException e) {
Status status = new Status(IStatus.ERROR, PluginConstants.PLUGIN_ID, 0, "I/O error reading JAR file contents", e);
// ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, status);
return status;
}
}
};
displayJob.schedule();
}
} else {
setContent("");
}
}
use of org.eclipse.ui.IEditorInput in project eclipse.platform.text by eclipse.
the class LastSaveReferenceProvider method setActiveEditor.
@Override
public void setActiveEditor(ITextEditor targetEditor) {
IDocumentProvider provider = null;
IEditorInput input = null;
if (targetEditor != null) {
provider = targetEditor.getDocumentProvider();
input = targetEditor.getEditorInput();
}
// note that they may serve multiple editors
if (provider != fDocumentProvider || input != fEditorInput) {
dispose();
synchronized (fLock) {
fEditor = targetEditor;
fDocumentProvider = provider;
fEditorInput = input;
}
}
}
Aggregations