use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class ReflectionFactory method updatePersistenceAndEditorKits.
public static void updatePersistenceAndEditorKits(ILanguageKit languageKit) {
InternalILanguageKit internalILanguageKit = (InternalILanguageKit) languageKit;
for (IPersistenceKit persistenceKit : getPersistenceKits()) if (persistenceKit.canApply(languageKit))
internalILanguageKit.addPersistenceKit(persistenceKit);
else
internalILanguageKit.removePersistenceKit(persistenceKit);
for (IEditorKit editorKit : getEditorKits()) if (editorKit.canApply(languageKit))
internalILanguageKit.addEditorKit(editorKit);
else
internalILanguageKit.removeEditorKit(editorKit);
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class TargetModelBlock method createContents.
@Override
protected void createContents(Composite composite) {
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
int widthHint = UIUtils.getButtonWidthHint(composite);
browseChooser = new WholeModelBrowseChooser(composite, SWT.NONE, widthHint);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 300;
browseChooser.setLayoutData(gd);
browseChooser.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
IFile file = browseChooser.getFile();
if (file != null)
modelPath = file.getFullPath().toPortableString();
IPersistenceKit persistenceKit = browseChooser.getPersistenceKit();
if (persistenceKit != null)
persistenceKitId = persistenceKit.getId();
updateLaunchConfiguration();
}
});
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class EditorPart method doSaveAs.
@Override
public void doSaveAs() {
IEntity entityContents = getComponent().getViewer().getEntityContents();
Set<IPersistenceKit> persistenceKits = new HashSet<IPersistenceKit>();
for (IPersistenceKit persistenceKit : ReflectionFactory.getPersistenceKits()) if (persistenceKit.canApply(entityContents))
persistenceKits.add(persistenceKit);
SaveAsModelDialog dialog = new SaveAsModelDialog(getSite().getWorkbenchWindow().getShell(), getContext(), persistenceKits);
if (dialog.open() == Dialog.CANCEL)
return;
IPersistenceKit persistenceKit = dialog.getPersistenceKit();
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(dialog.getResult());
try {
// perform save to new file
IFilePersistenceProvider pp = new IFilePersistenceProvider(file);
persistenceKit.writeModel(entityContents, pp);
// update default editor in package explorer
IDE.setDefaultEditor(file, ReflectionFactory.getEditorIdFromPersistenceKit(persistenceKit));
// update model input
getContext().set(IModelInput.class, new ModelInput(getContext(), pp, persistenceKit.getId()));
// update editor input
setInputWithNotify(new FileEditorInput(file));
// update editor's tab label
setPartName(file.getName());
// reset entity contents command stack and dirty state
getComponent().getViewer().setEntityContents(entityContents);
} catch (Exception e) {
E4Utils.reportError(getContext(), "Write Model errors", StringUtils.errorMessage(e), e);
}
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class ModelMergeViewer method readSideModel.
protected void readSideModel(MergeSide side, Object input, String label) {
IEntity sideModel = null;
if (input != null)
try {
IStreamContentAccessor accessor = (IStreamContentAccessor) input;
// TODO
IPersistenceKit persistenceKit = ReflectionFactory.getDefaultPersistenceKit();
sideModel = persistenceKit.readModel(new StreamPersistenceProvider(accessor.getContents()));
} catch (Exception e) {
E4Utils.reportError(getContext(), "Model Merge Viewer", "Unable to read the model", e);
// TODO ? sideModel = Status model instance with failure info
}
setSideModel(side, sideModel != null ? sideModel : CommonsEntityFactory.instance.createResolver(), label);
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class ModelMergeViewer method getSideModelBytes.
protected byte[] getSideModelBytes(MergeSide side) {
try {
// TODO
IPersistenceKit persistenceKit = ReflectionFactory.getDefaultPersistenceKit();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
persistenceKit.writeModel(getSideModel(side), new StreamPersistenceProvider(baos));
return baos.toByteArray();
} catch (Exception e) {
throw new IllegalStateException("cannot gather contents of " + side.name().toLowerCase() + " pane", e);
}
}
Aggregations