use of org.eclipse.ui.dialogs.SaveAsDialog in project Malai by arnobl.
the class InteractionEditor 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 WidgetEditor 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 linuxtools by eclipse.
the class STDataViewersExportToCSVDialog method handleBrowseWorkspace.
private void handleBrowseWorkspace() {
SaveAsDialog dialog = new SaveAsDialog(getShell());
dialog.setTitle("Output file");
if (dialog.open() == IDialogConstants.OK_ID) {
IPath p = dialog.getResult();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IFile file = workspace.getRoot().getFile(p);
outputFile.setText(file.getLocation().toOSString());
}
}
use of org.eclipse.ui.dialogs.SaveAsDialog in project liferay-ide by liferay.
the class InputContext method doSaveAs.
/**
* @param monitor
*/
public void doSaveAs(IProgressMonitor monitor) throws Exception {
// Get the editor shell
IDEFormEditor editor = getEditor();
Shell shell = editor.getSite().getShell();
// Create the save as dialog
SaveAsDialog dialog = new SaveAsDialog(shell);
// Set the initial file name to the original file name
IFile file = null;
if (_fEditorInput instanceof IFileEditorInput) {
file = ((IFileEditorInput) _fEditorInput).getFile();
dialog.setOriginalFile(file);
}
// Create the dialog
dialog.create();
if (_fDocumentProvider.isDeleted(_fEditorInput) && (file != null)) {
String message = NLS.bind("File does not exist: {0}", file.getName());
dialog.setErrorMessage(null);
dialog.setMessage(message, IMessageProvider.WARNING);
}
if (dialog.open() == Window.OK) {
// Get the path to where the new file will be stored
IPath path = dialog.getResult();
_handleSaveAs(monitor, path);
}
}
use of org.eclipse.ui.dialogs.SaveAsDialog in project jbosstools-hibernate by jbosstools.
the class ExportImageAction method run.
public void run() {
boolean createdSaveDialog = false;
if (saveDialog == null) {
saveDialog = new SaveAsDialog(getDiagramViewer().getSite().getWorkbenchWindow().getShell());
createdSaveDialog = true;
}
saveDialog.setOriginalName(getDiagramViewer().getStoreFileName());
saveDialog.open();
final IPath pathSave = saveDialog.getResult();
saveDialog = null;
if (pathSave == null) {
return;
}
final IFigure fig = ((ScalableFreeformRootEditPart) getDiagramViewer().getEditPartViewer().getRootEditPart()).getLayer(LayerConstants.PRINTABLE_LAYERS);
int imageTypeTmp = SWT.IMAGE_BMP;
String ext = pathSave.getFileExtension();
if (ext != null) {
ext = ext.toLowerCase();
if (ext.endsWith("jpg")) {
// $NON-NLS-1$
imageTypeTmp = SWT.IMAGE_JPEG;
} else if (ext.endsWith("png")) {
// $NON-NLS-1$
imageTypeTmp = SWT.IMAGE_PNG;
} else if (ext.endsWith("gif")) {
// $NON-NLS-1$
imageTypeTmp = SWT.IMAGE_GIF;
} else if (ext.endsWith("bmp")) {
// $NON-NLS-1$
imageTypeTmp = SWT.IMAGE_BMP;
}
}
IPath pathTmp = pathSave;
if (ext == null) {
// $NON-NLS-1$
pathTmp = pathTmp.addFileExtension("bmp");
}
final IPath path = pathTmp;
final int imageType = imageTypeTmp;
final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
public void execute(final IProgressMonitor monitor) {
ByteArrayInputStream inputStream = null;
try {
if (file != null) {
byte[] imageData = createImage(fig, imageType);
if (file.exists()) {
file.delete(true, null);
}
if (!file.exists()) {
inputStream = new ByteArrayInputStream(imageData);
file.create(inputStream, true, null);
}
}
} catch (CoreException e) {
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("ExportImageAction", e);
if (showErrDialog) {
MessageDialog.openInformation(getDiagramViewer().getSite().getShell(), DiagramViewerMessages.ExportImageAction_error, DiagramViewerMessages.ExportImageAction_failed_to_export_image + e.getMessage());
}
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// ignore
}
}
}
}
};
try {
new ProgressMonitorDialog(createdSaveDialog ? getDiagramViewer().getSite().getWorkbenchWindow().getShell() : null).run(false, true, op);
} catch (InvocationTargetException e) {
} catch (InterruptedException e) {
}
}
Aggregations