Examples of SaveAsDialog


Examples of org.eclipse.ui.dialogs.SaveAsDialog

                    boolean isIDE = CommonUIUtils.isIDEEnvironment();

                    if ( isIDE )
                    {
                        // Asking the user for the location where to 'save as' the file
                        SaveAsDialog dialog = new SaveAsDialog( shell );

                        if ( dialog.open() != Dialog.OK )
                        {
                            return false;
                        }

                        // Getting if the resulting file
                        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile( dialog.getResult() );

                        try
                        {
                            // Creating the file if it does not exist
                            if ( !file.exists() )
                            {
                                file.create( new ByteArrayInputStream( "".getBytes() ), true, null ); //$NON-NLS-1$
                            }

                            // Saving the LDIF to the file in the workspace
                            file.setContents( new ByteArrayInputStream( ldif.toString().getBytes() ), true, true,
                                new NullProgressMonitor() );
                        }
                        catch ( Exception e )
                        {
                            return false;
                        }
                    }
                    else
                    {
                        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;
                            }
View Full Code Here

Examples of org.eclipse.ui.dialogs.SaveAsDialog

        boolean isIDE = CommonUIUtils.isIDEEnvironment();

        if ( isIDE )
        {
            // Asking the user for the location where to 'save as' the file
            final SaveAsDialog dialog = new SaveAsDialog( shell );

            String inputClassName = input.getClass().getName();
            if ( input instanceof FileEditorInput )
            // FileEditorInput class is used when the file is opened
            // from a project in the workspace.
            {
                dialog.setOriginalFile( ( ( FileEditorInput ) input ).getFile() );
            }
            else if ( input instanceof IPathEditorInput )
            {
                dialog.setOriginalFile( ResourcesPlugin.getWorkspace().getRoot()
                    .getFile( ( ( IPathEditorInput ) input ).getPath() ) );
            }
            else if ( inputClassName.equals( "org.eclipse.ui.internal.editors.text.JavaFileEditorInput" ) //$NON-NLS-1$
                || inputClassName.equals( "org.eclipse.ui.ide.FileStoreEditorInput" ) ) //$NON-NLS-1$
            // The class 'org.eclipse.ui.internal.editors.text.JavaFileEditorInput'
            // is used when opening a file from the menu File > Open... in Eclipse 3.2.x
            // The class 'org.eclipse.ui.ide.FileStoreEditorInput' is used when
            // opening a file from the menu File > Open... in Eclipse 3.3.x
            {
                dialog.setOriginalFile( ResourcesPlugin.getWorkspace().getRoot()
                    .getFile( new Path( input.getToolTipText() ) ) );
            }
            else
            {
                dialog.setOriginalName( "config.ldif" ); //$NON-NLS-1$
            }

            // Open the dialog
            if ( openDialogInUIThread( dialog ) != Dialog.OK )
            {
                return null;
            }

            // 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 ); //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.ui.dialogs.SaveAsDialog

    Button btnBrowseSaveAs = new Button(grpSourceForNames, SWT.NONE);
    btnBrowseSaveAs.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        SaveAsDialog dialog = new SaveAsDialog(parentShell);
        dialog.open();
        IPath path = dialog.getResult();
        if (path == null) {
          return;
        } else {
          String saveLocation = path.toPortableString();
          newFilenameText.setText(saveLocation);
View Full Code Here

Examples of org.eclipse.ui.dialogs.SaveAsDialog

   * @generated
   */
  protected void performSaveAs(IProgressMonitor progressMonitor) {
    Shell shell = getSite().getShell();
    IEditorInput input = getEditorInput();
    SaveAsDialog dialog = new SaveAsDialog(shell);
    IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input)
        .getFile() : null;
    if (original != null) {
      dialog.setOriginalFile(original);
    }
    dialog.create();
    IDocumentProvider provider = getDocumentProvider();
    if (provider == null) {
      // editor has been programmatically closed while the dialog was open
      return;
    }
    if (provider.isDeleted(input) && original != null) {
      String message = NLS.bind(
          Messages.DispelDiagramEditor_SavingDeletedFile,
          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;
View Full Code Here

Examples of org.eclipse.ui.dialogs.SaveAsDialog

   * <!-- 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));
      }
View Full Code Here

Examples of org.eclipse.ui.dialogs.SaveAsDialog

   * @generated
   */
  protected void performSaveAs(IProgressMonitor progressMonitor) {
    Shell shell = getSite().getShell();
    IEditorInput input = getEditorInput();
    SaveAsDialog dialog = new SaveAsDialog(shell);
    IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input)
        .getFile()
        : null;
    if (original != null) {
      dialog.setOriginalFile(original);
    }
    dialog.create();
    IDocumentProvider provider = getDocumentProvider();
    if (provider == null) {
      // editor has been programmatically closed while the dialog was open
      return;
    }
    if (provider.isDeleted(input) && original != null) {
      String message = NLS
          .bind(
              eu.admire.visual.pmml.neuralnetwork._40.diagram.part.Messages.PMMLNeuralNetworkDiagramEditor_SavingDeletedFile,
              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;
View Full Code Here

Examples of org.eclipse.ui.dialogs.SaveAsDialog

   * @generated
   */
  protected void performSaveAs(IProgressMonitor progressMonitor) {
    Shell shell = getSite().getShell();
    IEditorInput input = getEditorInput();
    SaveAsDialog dialog = new SaveAsDialog(shell);
    IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input)
        .getFile()
        : null;
    if (original != null) {
      dialog.setOriginalFile(original);
    }
    dialog.create();
    IDocumentProvider provider = getDocumentProvider();
    if (provider == null) {
      // editor has been programmatically closed while the dialog was open
      return;
    }
    if (provider.isDeleted(input) && original != null) {
      String message = NLS
          .bind(
              eu.admire.visual.pmml._40.diagram.part.Messages.PMMLDiagramEditor_SavingDeletedFile,
              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;
View Full Code Here

Examples of org.eclipse.ui.dialogs.SaveAsDialog

   * <!-- 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));
      }
View Full Code Here

Examples of org.eclipse.ui.dialogs.SaveAsDialog

   * <!-- 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));
      }
View Full Code Here

Examples of org.eclipse.ui.dialogs.SaveAsDialog

   * @generated
   */
  protected void performSaveAs(IProgressMonitor progressMonitor) {
    Shell shell = getSite().getShell();
    IEditorInput input = getEditorInput();
    SaveAsDialog dialog = new SaveAsDialog(shell);
    IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input)
        .getFile() : null;
    if (original != null) {
      dialog.setOriginalFile(original);
    }
    dialog.create();
    IDocumentProvider provider = getDocumentProvider();
    if (provider == null) {
      // editor has been programmatically closed while the dialog was open
      return;
    }
    if (provider.isDeleted(input) && original != null) {
      String message = NLS.bind(
          Messages.DispelDiagramEditor_SavingDeletedFile,
          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;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.