use of org.eclipse.ui.part.FileEditorInput in project tdi-studio-se by Talend.
the class TalendJavaSourceViewer method initializeModel.
/*
* (non-Javadoc)
*
* @see org.talend.core.ui.viewer.ReconcilerViewer#initializeModel(IDocument document)
*/
@Override
protected void initializeModel() {
getSourceViewerDecorationSupport().install(JavaPlugin.getDefault().getCombinedPreferenceStore());
this.setRangeIndicator(new DefaultRangeIndicator());
IAnnotationModel model;
IDocument document;
if (checkCode) {
IDocumentProvider provider = JavaPlugin.getDefault().getCompilationUnitDocumentProvider();
IEditorInput ei = new FileEditorInput(file);
try {
provider.connect(ei);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
document = provider.getDocument(ei);
model = provider.getAnnotationModel(ei);
} else {
model = new AnnotationModel();
document = getDocument();
model.connect(document);
}
if (document != null) {
setDocument(document, model);
showAnnotations(model != null && checkCode);
}
super.initializeModel();
}
use of org.eclipse.ui.part.FileEditorInput in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method createFileEditorInput.
protected FileEditorInput createFileEditorInput() {
IPath codePath = processor.getCodePath();
if (codePath == null || codePath.isEmpty()) {
// (should not happen)
try {
processor.initPath();
} catch (ProcessorException e) {
MessageBoxExceptionHandler.process(e);
}
codePath = processor.getCodePath();
}
IFile codeFile = processor.getCodeProject().getFile(codePath);
if (!codeFile.exists()) {
// Create empty one
try {
//$NON-NLS-1$
codeFile.create(new ByteArrayInputStream("".getBytes()), true, null);
} catch (CoreException e) {
// Do nothing.
}
}
return new FileEditorInput(codeFile);
}
use of org.eclipse.ui.part.FileEditorInput in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method updateCodeEditorContent.
private void updateCodeEditorContent() {
if (!(processor.getProperty().getItem() instanceof JobletProcessItem)) {
FileEditorInput input = createFileEditorInput();
codeEditor.setInput(input);
}
}
use of org.eclipse.ui.part.FileEditorInput in project tdi-studio-se by Talend.
the class StandAloneTalendJavaEditor method doSetInput.
@Override
public void doSetInput(IEditorInput input) throws CoreException {
// Lock the process :
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
if (input instanceof RepositoryEditorInput) {
rEditorInput = (RepositoryEditorInput) input;
} else {
FileEditorInput fileInput = (FileEditorInput) input;
rEditorInput = new RepositoryEditorInput(fileInput.getFile(), rEditorInput.getItem());
}
if (rEditorInput.getRepositoryNode() == null) {
// retrieve node
rEditorInput.setRepositoryNode(null);
}
try {
// see bug 1321
item = (FileItem) rEditorInput.getItem();
if (!rEditorInput.isReadOnly()) {
if (getRepositoryFactory().getStatus(item).isPotentiallyEditable()) {
item.getProperty().eAdapters().add(dirtyListener);
repFactory.lock(item);
}
} else {
rEditorInput.getFile().setReadOnly(true);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
rEditorInput.getFile().refreshLocal(IResource.DEPTH_ONE, null);
super.doSetInput(rEditorInput);
setName();
// only for sql template
if (item instanceof SQLPatternItem) {
Workspace ws = (Workspace) ResourcesPlugin.getWorkspace();
ws.broadcastBuildEvent(item, IResourceChangeEvent.POST_CHANGE, 1);
}
}
use of org.eclipse.ui.part.FileEditorInput in project KaiZen-OpenAPI-Editor by RepreZen.
the class TextDocumentMarkerResolution method run.
public void run(IMarker marker) {
try {
IResource resource = marker.getResource();
if (resource.getType() != IResource.FILE) {
throw new CoreException(createStatus(null, "The editor is not a File: " + resource.getName()));
}
IFile file = (IFile) resource;
ITextEditor editor = openTextEditor(file);
IDocument document = editor.getDocumentProvider().getDocument(new FileEditorInput(file));
if (document == null) {
throw new CoreException(createStatus(null, "The document is null"));
}
IRegion region = processFix(document, marker);
if (region != null) {
editor.selectAndReveal(region.getOffset(), region.getLength());
}
} catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
}
}
Aggregations