use of com.twinsoft.convertigo.eclipse.editors.ngx.ComponentFileEditorInput in project convertigo by convertigo.
the class NgxComponentTreeObject method closeAllEditors.
public void closeAllEditors(boolean save) {
MobileComponent mc = getObject();
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (activePage != null) {
IEditorReference[] editorRefs = activePage.getEditorReferences();
for (int i = 0; i < editorRefs.length; i++) {
IEditorReference editorRef = (IEditorReference) editorRefs[i];
try {
IEditorInput editorInput = editorRef.getEditorInput();
if (editorInput != null && editorInput instanceof ComponentFileEditorInput) {
if (((ComponentFileEditorInput) editorInput).is(mc) || ((ComponentFileEditorInput) editorInput).isChildOf(mc)) {
activePage.closeEditor(editorRef.getEditor(false), save);
}
}
} catch (Exception e) {
}
}
}
}
use of com.twinsoft.convertigo.eclipse.editors.ngx.ComponentFileEditorInput in project convertigo by convertigo.
the class NgxComponentTreeObject method closeComponentFileEditor.
protected void closeComponentFileEditor(final IFile file) {
try {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IContainer parent = file.getParent();
String extension = file.getFileExtension();
for (IEditorReference editorReference : activePage.getEditorReferences()) {
IEditorInput editorInput = editorReference.getEditorInput();
if (editorInput instanceof ComponentFileEditorInput) {
ComponentFileEditorInput cfei = (ComponentFileEditorInput) editorInput;
IFile oldFile = cfei.getFile();
if (parent.equals(oldFile.getParent()) && extension.equals(oldFile.getFileExtension())) {
activePage.closeEditor(editorReference.getEditor(false), true);
return;
}
}
}
} catch (Exception e) {
}
}
use of com.twinsoft.convertigo.eclipse.editors.ngx.ComponentFileEditorInput in project convertigo by convertigo.
the class NgxUIComponentTreeObject method editCompTsFile.
public void editCompTsFile() {
if (!(getObject() instanceof ISharedComponent)) {
return;
}
final UISharedComponent comp = (UISharedComponent) getObject();
try {
// Refresh project resource
String projectName = comp.getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// Close editor
String filePath = comp.getProject().getMobileBuilder().getTempTsRelativePath((ISharedComponent) comp);
IFile file = project.getFile(filePath);
closeComponentFileEditor(file);
// Write temporary file
comp.getProject().getMobileBuilder().writeCompTempTs((ISharedComponent) comp);
file.refreshLocal(IResource.DEPTH_ZERO, null);
// Open file in editor
if (file.exists()) {
IEditorInput input = new ComponentFileEditorInput(file, comp);
if (input != null) {
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
String editorId = desc.getId();
IEditorPart editorPart = activePage.openEditor(input, editorId);
addMarkers(file, editorPart);
editorPart.addPropertyListener(new IPropertyListener() {
boolean isFirstChange = false;
@Override
public void propertyChanged(Object source, int propId) {
if (source instanceof ITextEditor) {
if (propId == IEditorPart.PROP_DIRTY) {
if (!isFirstChange) {
isFirstChange = true;
return;
}
isFirstChange = false;
ITextEditor editor = (ITextEditor) source;
IDocumentProvider dp = editor.getDocumentProvider();
IDocument doc = dp.getDocument(editor.getEditorInput());
FormatedContent scriptContent = new FormatedContent(MobileBuilder.getMarkers(doc.get()));
NgxUIComponentTreeObject.this.setPropertyValue("scriptContent", scriptContent);
}
}
}
});
}
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to open typescript file for component '" + comp.getName() + "'!");
}
}
Aggregations