Search in sources :

Example 31 with SaveAsDialog

use of org.eclipse.ui.dialogs.SaveAsDialog in project InformationSystem by ObeoNetwork.

the class ToolkitsEditor 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));
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) SaveAsDialog(org.eclipse.ui.dialogs.SaveAsDialog) FileEditorInput(org.eclipse.ui.part.FileEditorInput)

Example 32 with SaveAsDialog

use of org.eclipse.ui.dialogs.SaveAsDialog in project InformationSystem by ObeoNetwork.

the class ViewEditor 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));
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) SaveAsDialog(org.eclipse.ui.dialogs.SaveAsDialog) FileEditorInput(org.eclipse.ui.part.FileEditorInput)

Example 33 with SaveAsDialog

use of org.eclipse.ui.dialogs.SaveAsDialog in project InformationSystem by ObeoNetwork.

the class BindingTreeEditor method performSaveAs.

/**
 * Perform the saveAs action.
 *
 * @param progressMonitor
 *            The progress monitor
 */
private void performSaveAs(final IProgressMonitor progressMonitor) {
    final Shell shell = getSite().getShell();
    final IEditorInput input = getEditorInput();
    final SaveAsDialog dialog = new SaveAsDialog(shell);
    final IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null;
    if (original != null) {
        dialog.setOriginalFile(original);
    }
    dialog.create();
    if (dialog.open() == Window.CANCEL) {
        if (progressMonitor != null) {
            progressMonitor.setCanceled(true);
        }
    } else {
        final IPath filePath = dialog.getResult();
        if (filePath == null) {
            if (progressMonitor != null) {
                progressMonitor.setCanceled(true);
            }
            return;
        }
        final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
        final IFile file = workspaceRoot.getFile(filePath);
        final IEditorInput newInput = new FileEditorInput(file);
        // Check if the editor is already open
        final IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
        final IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
        for (int i = 0; i < editorRefs.length; i++) {
            if (matchingStrategy.matches(editorRefs[i], newInput)) {
                return;
            }
        }
        final boolean success = false;
        if (progressMonitor != null) {
            progressMonitor.setCanceled(!success);
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) SaveAsDialog(org.eclipse.ui.dialogs.SaveAsDialog) Shell(org.eclipse.swt.widgets.Shell) IEditorReference(org.eclipse.ui.IEditorReference) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IEditorMatchingStrategy(org.eclipse.ui.IEditorMatchingStrategy) IFileEditorInput(org.eclipse.ui.IFileEditorInput) IFileEditorInput(org.eclipse.ui.IFileEditorInput) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IEditorInput(org.eclipse.ui.IEditorInput)

Example 34 with SaveAsDialog

use of org.eclipse.ui.dialogs.SaveAsDialog in project InformationSystem by ObeoNetwork.

the class ScaffoldEditor 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));
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) SaveAsDialog(org.eclipse.ui.dialogs.SaveAsDialog) FileEditorInput(org.eclipse.ui.part.FileEditorInput)

Example 35 with SaveAsDialog

use of org.eclipse.ui.dialogs.SaveAsDialog in project InformationSystem by ObeoNetwork.

the class ExtensionUtilitiesEditor 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));
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) SaveAsDialog(org.eclipse.ui.dialogs.SaveAsDialog) FileEditorInput(org.eclipse.ui.part.FileEditorInput)

Aggregations

IPath (org.eclipse.core.runtime.IPath)42 SaveAsDialog (org.eclipse.ui.dialogs.SaveAsDialog)42 IFile (org.eclipse.core.resources.IFile)39 FileEditorInput (org.eclipse.ui.part.FileEditorInput)35 IWorkspace (org.eclipse.core.resources.IWorkspace)5 CoreException (org.eclipse.core.runtime.CoreException)5 Shell (org.eclipse.swt.widgets.Shell)4 IFileEditorInput (org.eclipse.ui.IFileEditorInput)4 File (java.io.File)3 IEditorInput (org.eclipse.ui.IEditorInput)3 FileStoreEditorInput (org.eclipse.ui.ide.FileStoreEditorInput)3 IFileStore (org.eclipse.core.filesystem.IFileStore)2 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 IFigure (org.eclipse.draw2d.IFigure)2 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)2 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 FileDialog (org.eclipse.swt.widgets.FileDialog)2