use of org.eclipse.ui.ISaveablePart in project tdi-studio-se by Talend.
the class ExportJobScriptAction method checkDirtyPart.
/**
* DOC Administrator Comment method "checkDirtyPart".
*
* @param workbench
*/
@SuppressWarnings("restriction")
private boolean checkDirtyPart(IWorkbench workbench) {
ISaveablePart[] parts = null;
IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
for (IWorkbenchWindow window : windows) {
IWorkbenchPage[] pages = window.getPages();
for (IWorkbenchPage page : pages) {
parts = page.getDirtyEditors();
}
}
if (parts != null && parts.length > 0) {
return true;
}
return false;
}
use of org.eclipse.ui.ISaveablePart in project dbeaver by dbeaver.
the class DataSourceHandler method disconnectDataSource.
public static void disconnectDataSource(DBPDataSourceContainer dataSourceContainer, @Nullable final Runnable onFinish) {
// Save users
for (DBPDataSourceUser user : dataSourceContainer.getUsers()) {
if (user instanceof ISaveablePart) {
if (!SaveChangesHandler.validateAndSave(new VoidProgressMonitor(), (ISaveablePart) user)) {
return;
}
}
}
if (!checkAndCloseActiveTransaction(dataSourceContainer)) {
return;
}
if (dataSourceContainer instanceof DataSourceDescriptor && dataSourceContainer.isConnected()) {
final DataSourceDescriptor dataSourceDescriptor = (DataSourceDescriptor) dataSourceContainer;
if (!ArrayUtils.isEmpty(Job.getJobManager().find(dataSourceDescriptor))) {
// Already connecting/disconnecting - just return
return;
}
final DisconnectJob disconnectJob = new DisconnectJob(dataSourceDescriptor);
disconnectJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
IStatus result = disconnectJob.getConnectStatus();
if (onFinish != null) {
onFinish.run();
} else if (!result.isOK()) {
DBUserInterface.getInstance().showError(disconnectJob.getName(), null, result);
}
}
});
// Run in UI thread to update actions (some Eclipse magic)
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
disconnectJob.schedule();
}
});
}
}
use of org.eclipse.ui.ISaveablePart in project yamcs-studio by yamcs.
the class OPIEditor method getPropertySheetPage.
/**
* Returns the undoable <code>PropertySheetPage</code> for this editor.
*
* @return the undoable <code>PropertySheetPage</code>
*/
protected PropertySheetPage getPropertySheetPage() {
if (undoablePropertySheetPage == null) {
undoablePropertySheetPage = new PropertySheetPage() {
@Override
protected ISaveablePart getSaveablePart() {
return null;
}
};
undoablePropertySheetPage.setRootEntry(new UndoablePropertySheetEntry(getCommandStack()));
}
return undoablePropertySheetPage;
}
use of org.eclipse.ui.ISaveablePart in project dbeaver by serge-rider.
the class DataSourceHandler method disconnectDataSource.
public static void disconnectDataSource(DBPDataSourceContainer dataSourceContainer, @Nullable final Runnable onFinish) {
// Save users
for (DBPDataSourceTask user : dataSourceContainer.getTasks()) {
if (user instanceof ISaveablePart) {
if (!SaveChangesHandler.validateAndSave(new VoidProgressMonitor(), (ISaveablePart) user)) {
return;
}
}
}
if (!checkAndCloseActiveTransaction(dataSourceContainer)) {
return;
}
if (dataSourceContainer instanceof DataSourceDescriptor && dataSourceContainer.isConnected()) {
final DataSourceDescriptor dataSourceDescriptor = (DataSourceDescriptor) dataSourceContainer;
if (!ArrayUtils.isEmpty(Job.getJobManager().find(dataSourceDescriptor))) {
// Already connecting/disconnecting - just return
return;
}
final DisconnectJob disconnectJob = new DisconnectJob(dataSourceDescriptor);
disconnectJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
IStatus result = disconnectJob.getConnectStatus();
if (onFinish != null) {
onFinish.run();
} else if (!result.isOK()) {
DBWorkbench.getPlatformUI().showError(disconnectJob.getName(), null, result);
}
DataSourcePropertyTester.firePropertyChange(DataSourcePropertyTester.PROP_CONNECTED);
}
});
disconnectJob.schedule();
}
}
Aggregations