drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/common/editor/action/ExportImageDialog.java
protected void okPressed() {
        // Get new path.
        IPath path = resourceGroup.getContainerFullPath().append(
                resourceGroup.getResource());

        //If the user does not supply a file extension and if the save 
        //as dialog was provided a default file name append the extension 
        //of the default filename to the new name
        if (path.getFileExtension() == null) {
            if (originalFile != null && originalFile.getFileExtension() != null) {
                path = path.addFileExtension(originalFile.getFileExtension());
            } else if (originalName != null) {
                int pos = originalName.lastIndexOf('.');
                if (++pos > 0 && pos < originalName.length()) {
                    path = path.addFileExtension(originalName.substring(pos));
                }
            }
        }

        // If the path already exists then confirm overwrite.
        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
        if (file.exists()) {
            String[] buttons = new String[] { IDialogConstants.YES_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };
            String question = NLS.bind(
                    IDEWorkbenchMessages.SaveAsDialog_overwriteQuestion, path
                            .toString());
            MessageDialog d = new MessageDialog(getShell(),
                    IDEWorkbenchMessages.Question,
                    null, question, MessageDialog.QUESTION, buttons, 0);
            int overwrite = d.open();
            switch (overwrite) {
            case 0: // Yes
                break;
            case 1: // No
                return;
            case 2: // Cancel
            default:
                cancelPressed();
                return;
            }
        }

        // Store path and close.
        result = path;
        close();
    }
protected void okPressed() {
        // Get new path.
        IPath path = resourceGroup.getContainerFullPath().append(
                resourceGroup.getResource());

        //If the user does not supply a file extension and if the save 
        //as dialog was provided a default file name append the extension 
        //of the default filename to the new name
        if (path.getFileExtension() == null) {
            if (originalFile != null && originalFile.getFileExtension() != null) {
                path = path.addFileExtension(originalFile.getFileExtension());
            } else if (originalName != null) {
                int pos = originalName.lastIndexOf('.');
                if (++pos > 0 && pos < originalName.length()) {
                    path = path.addFileExtension(originalName.substring(pos));
                }
            }
        }

        // If the path already exists then confirm overwrite.
        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
        if (file.exists()) {
            String[] buttons = new String[] { IDialogConstants.YES_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };
            String question = NLS.bind(
                    IDEWorkbenchMessages.SaveAsDialog_overwriteQuestion, path
                            .toString());
            MessageDialog d = new MessageDialog(getShell(),
                    IDEWorkbenchMessages.Question,
                    null, question, MessageDialog.QUESTION, buttons, 0);
            int overwrite = d.open();
            switch (overwrite) {
            case 0: // Yes
                break;
            case 1: // No
                return;
            case 2: // Cancel
            default:
                cancelPressed();
                return;
            }
        }

        // Store path and close.
        result = path;
        close();
    }
protected void okPressed ( ) { // Get new path. IPath path = resourceGroup . getContainerFullPath ( ) . append ( resourceGroup . getResource ( ) ) ; //If the user does not supply a file extension and if the save  //as dialog was provided a default file name append the extension  //of the default filename to the new name if ( path . getFileExtension ( ) == null ) { if ( originalFile != null && originalFile . getFileExtension ( ) != null ) { path = path . addFileExtension ( originalFile . getFileExtension ( ) ) ; } else if ( originalName != null ) { int pos = originalName . lastIndexOf ( ' ' ) ; if ( ++ pos > 0 && pos < originalName . length ( ) ) { path = path . addFileExtension ( originalName . substring ( pos ) ) ; } } } // If the path already exists then confirm overwrite. IFile file = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ; if ( file . exists ( ) ) { String [ ] buttons = new String [ ] { IDialogConstants . YES_LABEL , IDialogConstants . NO_LABEL , IDialogConstants . CANCEL_LABEL } ; String question = NLS . bind ( IDEWorkbenchMessages . SaveAsDialog_overwriteQuestion , path . toString ( ) ) ; MessageDialog d = new MessageDialog ( getShell ( ) , IDEWorkbenchMessages . Question , null , question , MessageDialog . QUESTION , buttons , 0 ) ; int overwrite = d . open ( ) ; switch ( overwrite ) { case 0 : // Yes break ; case 1 : // No return ; case 2 : // Cancel default : cancelPressed ( ) ; return ; } } // Store path and close. result = path ; close ( ) ; }
/* (non-Javadoc)
Method declared on Dialog.
/ * ( non - Javadoc ) Method declared on Dialog .