boolean isIDE = PluginUtils.isIDEEnvironment();
if ( isIDE )
{
// Asking the user for the location where to 'save as' the file
SaveAsDialog dialog = new SaveAsDialog( getSite().getShell() );
if ( !( getEditorInput() instanceof NonExistingServerConfigurationInput ) )
{
dialog.setOriginalFile( ResourcesPlugin.getWorkspace().getRoot().getFile(
new Path( getEditorInput().getToolTipText() ) ) );
}
if ( dialog.open() != Dialog.OK )
{
return false;
}
// Getting if the resulting file
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile( dialog.getResult() );
// Creating the file if it does not exist
if ( !file.exists() )
{
file.create( new ByteArrayInputStream( "".getBytes() ), true, null );
}
// Creating the new input for the editor
FileEditorInput fei = new FileEditorInput( file );
// Saving the file to disk
saveEditorPages( monitor );
saveConfiguration( fei, monitor );
// Setting the new input to the editor
setInput( fei );
}
else
{
Shell shell = getSite().getShell();
boolean canOverwrite = false;
String path = null;
while ( !canOverwrite )
{
// Open FileDialog
FileDialog dialog = new FileDialog( shell, SWT.SAVE );
path = dialog.open();
if ( path == null )
{
return false;
}