use of com.twinsoft.convertigo.beans.mobile.components.UIStyle in project convertigo by convertigo.
the class MobileUIComponentTreeObject method openCssFileEditor.
private void openCssFileEditor() {
final UIStyle ms = (UIStyle) getObject();
String filePath = "/_private/editor/" + StringUtils.hash(ms.getParent().getQName()) + "/" + ms.getName() + ".scss";
try {
// Refresh project resource
String projectName = ms.getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
// Close editor
IFile file = project.getFile(filePath);
closeComponentFileEditor(file);
// Write css file
SwtUtils.fillFile(file, formatStyleContent(ms));
// Open file in editor
if (file.exists()) {
IEditorInput input = new ComponentFileEditorInput(file, ms);
if (input != null) {
String editorId = "org.eclipse.ui.genericeditor.GenericEditor";
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editorPart = activePage.openEditor(input, editorId);
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());
String content = unformatStyleContent(ms, doc.get());
if (content != null) {
FormatedContent formatedContent = new FormatedContent(content);
MobileUIComponentTreeObject.this.setPropertyValue("styleContent", formatedContent);
}
}
}
}
});
}
}
} catch (CoreException e) {
ConvertigoPlugin.logException(e, "Unable to open file '" + filePath + "'!");
}
}
use of com.twinsoft.convertigo.beans.mobile.components.UIStyle in project convertigo by convertigo.
the class MobileUIComponentTreeObject method launchEditor.
@Override
public void launchEditor(String editorType) {
UIComponent uic = getObject();
if (uic instanceof UICustom) {
openHtmlFileEditor();
} else if (uic instanceof UIStyle) {
openCssFileEditor();
} else if (uic instanceof UICustomAction) {
String functionMarker = "function:" + ((UICustomAction) uic).getActionName();
editFunction(uic, functionMarker, "actionValue");
} else if (uic instanceof UIFormCustomValidator) {
String functionMarker = "function:" + ((UIFormCustomValidator) uic).getValidatorName();
editFunction(uic, functionMarker, "validatorValue");
} else {
super.launchEditor(editorType);
}
}
Aggregations