use of org.jkiss.dbeaver.model.data.storage.ExternalContentStorage in project dbeaver by serge-rider.
the class ContentEditorInput method loadFromExternalFile.
void loadFromExternalFile(File extFile, IProgressMonitor monitor) throws CoreException {
try {
release();
contentFile = extFile;
contentDetached = true;
Object value = getValue();
if (value instanceof DBDContent) {
((DBDContent) value).updateContents(new DefaultProgressMonitor(monitor), new ExternalContentStorage(DBWorkbench.getPlatform(), extFile));
} else {
updateStringValueFromFile(extFile);
}
refreshContentParts(extFile);
} catch (Throwable e) {
throw new CoreException(GeneralUtils.makeExceptionStatus(e));
}
}
use of org.jkiss.dbeaver.model.data.storage.ExternalContentStorage in project dbeaver by serge-rider.
the class ContentValueManager method loadFromFile.
public static boolean loadFromFile(final IValueController controller) {
if (!(controller.getValue() instanceof DBDContent)) {
log.error(ResultSetMessages.model_jdbc_bad_content_value_ + controller.getValue());
return false;
}
Shell shell = UIUtils.getShell(controller.getValueSite());
final File openFile = DialogUtils.openFile(shell);
if (openFile == null) {
return false;
}
final DBDContent value = (DBDContent) controller.getValue();
UIUtils.runInUI(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), monitor -> {
try {
DBDContentStorage storage;
if (ContentUtils.isTextContent(value)) {
storage = new ExternalContentStorage(DBWorkbench.getPlatform(), openFile, GeneralUtils.UTF8_ENCODING);
} else {
storage = new ExternalContentStorage(DBWorkbench.getPlatform(), openFile);
}
value.updateContents(monitor, storage);
controller.updateValue(value, true);
} catch (Exception e) {
throw new InvocationTargetException(e);
}
});
return true;
}
use of org.jkiss.dbeaver.model.data.storage.ExternalContentStorage in project dbeaver by dbeaver.
the class ContentEditorInput method loadFromExternalFile.
void loadFromExternalFile(File extFile, IProgressMonitor monitor) throws CoreException {
try {
release();
contentFile = extFile;
contentDetached = true;
Object value = getValue();
if (value instanceof DBDContent) {
((DBDContent) value).updateContents(new DefaultProgressMonitor(monitor), new ExternalContentStorage(DBWorkbench.getPlatform(), extFile));
} else {
updateStringValueFromFile(extFile);
}
refreshContentParts(extFile);
} catch (Throwable e) {
throw new CoreException(GeneralUtils.makeExceptionStatus(e));
}
}
use of org.jkiss.dbeaver.model.data.storage.ExternalContentStorage in project dbeaver by dbeaver.
the class ContentValueManager method loadFromFile.
public static boolean loadFromFile(final IValueController controller) {
if (!(controller.getValue() instanceof DBDContent)) {
log.error(ResultSetMessages.model_jdbc_bad_content_value_ + controller.getValue());
return false;
}
Shell shell = UIUtils.getShell(controller.getValueSite());
final File openFile = DialogUtils.openFile(shell);
if (openFile == null) {
return false;
}
final DBDContent value = (DBDContent) controller.getValue();
UIUtils.runInUI(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), monitor -> {
try {
DBDContentStorage storage;
if (ContentUtils.isTextContent(value)) {
storage = new ExternalContentStorage(DBWorkbench.getPlatform(), openFile, GeneralUtils.UTF8_ENCODING);
} else {
storage = new ExternalContentStorage(DBWorkbench.getPlatform(), openFile);
}
value.updateContents(monitor, storage);
controller.updateValue(value, true);
} catch (Exception e) {
throw new InvocationTargetException(e);
}
});
return true;
}
Aggregations