use of org.eclipse.ui.dialogs.SaveAsDialog in project iobserve-analysis by research-iobserve.
the class systemadaptationEditor method doSaveAs.
/**
* This also changes the editor's input.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void doSaveAs() {
SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
saveAsDialog.open();
IPath path = saveAsDialog.getResult();
if (path != null) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if (file != null) {
doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file));
}
}
}
use of org.eclipse.ui.dialogs.SaveAsDialog in project iobserve-analysis by research-iobserve.
the class cloudprofileEditor method doSaveAs.
/**
* This also changes the editor's input.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void doSaveAs() {
SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
saveAsDialog.open();
IPath path = saveAsDialog.getResult();
if (path != null) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if (file != null) {
doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file));
}
}
}
use of org.eclipse.ui.dialogs.SaveAsDialog in project jbosstools-hibernate by jbosstools.
the class AbstractQueryEditor method performSaveAs.
/**
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#performSaveAs(IProgressMonitor)
* the same method except line: "dialog.setOriginalName(getSaveAsFileExtension());"
*/
protected void performSaveAs(IProgressMonitor progressMonitor) {
Shell shell = getSite().getShell();
final IEditorInput input = getEditorInput();
IDocumentProvider provider = getDocumentProvider();
final IEditorInput newInput;
if (input instanceof IURIEditorInput && !(input instanceof IFileEditorInput)) {
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
IPath oldPath = URIUtil.toPath(((IURIEditorInput) input).getURI());
if (oldPath != null) {
dialog.setFileName(oldPath.lastSegment());
dialog.setFilterPath(oldPath.toOSString());
}
String path = dialog.open();
if (path == null) {
if (progressMonitor != null)
progressMonitor.setCanceled(true);
return;
}
// Check whether file exists and if so, confirm overwrite
final File localFile = new File(path);
if (localFile.exists()) {
MessageDialog overwriteDialog = new MessageDialog(shell, HibernateConsoleMessages.AbstractQueryEditor_save_as, null, MessageFormat.format(HibernateConsoleMessages.AbstractQueryEditor_already_exists_do_you_want_to_replace_it, path), MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, // 'No' is the default
1);
if (overwriteDialog.open() != Window.OK) {
if (progressMonitor != null) {
progressMonitor.setCanceled(true);
return;
}
}
}
IFileStore fileStore;
try {
fileStore = EFS.getStore(localFile.toURI());
} catch (CoreException ex) {
HibernateConsolePlugin.getDefault().log(ex.getStatus());
String title = HibernateConsoleMessages.AbstractQueryEditor_problems_during_save_as;
String msg = MessageFormat.format(HibernateConsoleMessages.AbstractQueryEditor_save_could_not_be_completed, ex.getMessage());
MessageDialog.openError(shell, title, msg);
return;
}
IFile file = getWorkspaceFile(fileStore);
if (file != null)
newInput = new FileEditorInput(file);
else
newInput = new FileStoreEditorInput(fileStore);
} else {
SaveAsDialog dialog = new SaveAsDialog(shell);
IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null;
if (original != null) {
dialog.setOriginalFile(original);
} else {
dialog.setOriginalName(getSaveAsFileExtension());
}
dialog.create();
if (provider.isDeleted(input) && original != null) {
String message = MessageFormat.format(HibernateConsoleMessages.AbstractQueryEditor_the_original_file_has_been_deleted_or_is_not_accessible, original.getName());
dialog.setErrorMessage(null);
dialog.setMessage(message, IMessageProvider.WARNING);
}
if (dialog.open() == Window.CANCEL) {
if (progressMonitor != null)
progressMonitor.setCanceled(true);
return;
}
IPath filePath = dialog.getResult();
if (filePath == null) {
if (progressMonitor != null)
progressMonitor.setCanceled(true);
return;
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IFile file = workspace.getRoot().getFile(filePath);
newInput = new FileEditorInput(file);
}
if (provider == null) {
// editor has programmatically been closed while the dialog was open
return;
}
boolean success = false;
try {
provider.aboutToChange(newInput);
provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true);
success = true;
} catch (CoreException x) {
final IStatus status = x.getStatus();
if (status == null || status.getSeverity() != IStatus.CANCEL) {
String title = HibernateConsoleMessages.AbstractQueryEditor_problems_during_save_as;
String msg = MessageFormat.format(HibernateConsoleMessages.AbstractQueryEditor_save_could_not_be_completed, x.getMessage());
MessageDialog.openError(shell, title, msg);
}
} finally {
provider.changed(newInput);
if (success)
setInput(newInput);
}
if (progressMonitor != null)
progressMonitor.setCanceled(!success);
}
use of org.eclipse.ui.dialogs.SaveAsDialog in project Malai by arnobl.
the class ActionEditor method doSaveAs.
/**
* This also changes the editor's input.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void doSaveAs() {
SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
saveAsDialog.open();
IPath path = saveAsDialog.getResult();
if (path != null) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if (file != null) {
doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file));
}
}
}
use of org.eclipse.ui.dialogs.SaveAsDialog in project Malai by arnobl.
the class EventEditor method doSaveAs.
/**
* This also changes the editor's input.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void doSaveAs() {
SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
saveAsDialog.open();
IPath path = saveAsDialog.getResult();
if (path != null) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if (file != null) {
doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file));
}
}
}
Aggregations