Java 类org.eclipse.ui.IEditorMatchingStrategy 实例源码

项目:xtext-gef    文件:StatemachineDiagramEditor.java   
/**
 * @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.StatemachineDiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor()
            .getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    Messages.StatemachineDiagramEditor_SaveAsErrorTitle,
                    Messages.StatemachineDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor,
                newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    Messages.StatemachineDiagramEditor_SaveErrorTitle,
                    Messages.StatemachineDiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:ROADDesigner    文件:SmcDiagramEditor.java   
/**
 * @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.SmcDiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor()
            .getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    Messages.SmcDiagramEditor_SaveAsErrorTitle,
                    Messages.SmcDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor,
                newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    Messages.SmcDiagramEditor_SaveErrorTitle,
                    Messages.SmcDiagramEditor_SaveErrorMessage, x
                            .getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:HelloBrazil    文件:Wc2014DiagramEditor.java   
/**
 * @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.Wc2014DiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor()
            .getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    Messages.Wc2014DiagramEditor_SaveAsErrorTitle,
                    Messages.Wc2014DiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor,
                newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    Messages.Wc2014DiagramEditor_SaveErrorTitle,
                    Messages.Wc2014DiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:ICSE15_SequenceDiagram_MAVODiagramEditor.java   
/**
* @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(
                edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.diagram.part.Messages.ICSE15_SequenceDiagram_MAVODiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.diagram.part.Messages.ICSE15_SequenceDiagram_MAVODiagramEditor_SaveAsErrorTitle,
                    edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.diagram.part.Messages.ICSE15_SequenceDiagram_MAVODiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.diagram.part.Messages.ICSE15_SequenceDiagram_MAVODiagramEditor_SaveErrorTitle,
                    edu.toronto.cs.se.modelepedia.icse15_sequencediagram_mavo.diagram.part.Messages.ICSE15_SequenceDiagram_MAVODiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:MIDDiagramEditor.java   
/**
 * @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.MIDDiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI
        .getWorkbench()
        .getActiveWorkbenchWindow()
        .getActivePage()
        .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(
                shell,
                Messages.MIDDiagramEditor_SaveAsErrorTitle,
                Messages.MIDDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput)
            .saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    }
    catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(
                shell,
                Messages.MIDDiagramEditor_SaveErrorTitle,
                Messages.MIDDiagramEditor_SaveErrorMessage,
                x.getStatus());
        }
    }
    finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:MIDDiagramEditor.java   
/**
* @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.MIDDiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell, Messages.MIDDiagramEditor_SaveAsErrorTitle,
                    Messages.MIDDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell, Messages.MIDDiagramEditor_SaveErrorTitle,
                    Messages.MIDDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:RelationalDatabase_MAVODiagramEditor.java   
/**
* @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(
                edu.toronto.cs.se.modelepedia.relationaldatabase_mavo.diagram.part.Messages.RelationalDatabase_MAVODiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    edu.toronto.cs.se.modelepedia.relationaldatabase_mavo.diagram.part.Messages.RelationalDatabase_MAVODiagramEditor_SaveAsErrorTitle,
                    edu.toronto.cs.se.modelepedia.relationaldatabase_mavo.diagram.part.Messages.RelationalDatabase_MAVODiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    edu.toronto.cs.se.modelepedia.relationaldatabase_mavo.diagram.part.Messages.RelationalDatabase_MAVODiagramEditor_SaveErrorTitle,
                    edu.toronto.cs.se.modelepedia.relationaldatabase_mavo.diagram.part.Messages.RelationalDatabase_MAVODiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:IStar_MAVODiagramEditor.java   
/**
* @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(
                edu.toronto.cs.se.modelepedia.istar_mavo.diagram.part.Messages.IStar_MAVODiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    edu.toronto.cs.se.modelepedia.istar_mavo.diagram.part.Messages.IStar_MAVODiagramEditor_SaveAsErrorTitle,
                    edu.toronto.cs.se.modelepedia.istar_mavo.diagram.part.Messages.IStar_MAVODiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    edu.toronto.cs.se.modelepedia.istar_mavo.diagram.part.Messages.IStar_MAVODiagramEditor_SaveErrorTitle,
                    edu.toronto.cs.se.modelepedia.istar_mavo.diagram.part.Messages.IStar_MAVODiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:IStarDiagramEditor.java   
/**
 * @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.IStarDiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor()
            .getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    Messages.IStarDiagramEditor_SaveAsErrorTitle,
                    Messages.IStarDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor,
                newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    Messages.IStarDiagramEditor_SaveErrorTitle,
                    Messages.IStarDiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:StateMachineDiagramEditor.java   
/**
 * @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.StateMachineDiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor()
            .getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    Messages.StateMachineDiagramEditor_SaveAsErrorTitle,
                    Messages.StateMachineDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor,
                newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    Messages.StateMachineDiagramEditor_SaveErrorTitle,
                    Messages.StateMachineDiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:StateMachine_MAVODiagramEditor.java   
/**
* @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(
                edu.toronto.cs.se.modelepedia.statemachine_mavo.diagram.part.Messages.StateMachine_MAVODiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    edu.toronto.cs.se.modelepedia.statemachine_mavo.diagram.part.Messages.StateMachine_MAVODiagramEditor_SaveAsErrorTitle,
                    edu.toronto.cs.se.modelepedia.statemachine_mavo.diagram.part.Messages.StateMachine_MAVODiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    edu.toronto.cs.se.modelepedia.statemachine_mavo.diagram.part.Messages.StateMachine_MAVODiagramEditor_SaveErrorTitle,
                    edu.toronto.cs.se.modelepedia.statemachine_mavo.diagram.part.Messages.StateMachine_MAVODiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:StateDiagramEditor.java   
/**
 * @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.StateDiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor()
            .getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    Messages.StateDiagramEditor_SaveAsErrorTitle,
                    Messages.StateDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor,
                newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    Messages.StateDiagramEditor_SaveErrorTitle,
                    Messages.StateDiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:ArmyDiagramEditor.java   
/**
 * @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.ArmyDiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor()
            .getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    Messages.ArmyDiagramEditor_SaveAsErrorTitle,
                    Messages.ArmyDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor,
                newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    Messages.ArmyDiagramEditor_SaveErrorTitle,
                    Messages.ArmyDiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:EconomyDiagramEditor.java   
/**
 * @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.EconomyDiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor()
            .getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    Messages.EconomyDiagramEditor_SaveAsErrorTitle,
                    Messages.EconomyDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor,
                newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    Messages.EconomyDiagramEditor_SaveErrorTitle,
                    Messages.EconomyDiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:ClassDiagramDiagramEditor.java   
/**
* @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.ClassDiagramDiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI
        .getWorkbench()
        .getActiveWorkbenchWindow()
        .getActivePage()
        .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(
                shell,
                Messages.ClassDiagramDiagramEditor_SaveAsErrorTitle,
                Messages.ClassDiagramDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput)
            .saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    }
    catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(
                shell,
                Messages.ClassDiagramDiagramEditor_SaveErrorTitle,
                Messages.ClassDiagramDiagramEditor_SaveErrorMessage,
                x.getStatus());
        }
    }
    finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:ClassDiagram_MAVODiagramEditor.java   
/**
* @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(
                edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part.Messages.ClassDiagram_MAVODiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part.Messages.ClassDiagram_MAVODiagramEditor_SaveAsErrorTitle,
                    edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part.Messages.ClassDiagram_MAVODiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part.Messages.ClassDiagram_MAVODiagramEditor_SaveErrorTitle,
                    edu.toronto.cs.se.modelepedia.classdiagram_mavo.diagram.part.Messages.ClassDiagram_MAVODiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:MMINT    文件:Graph_MAVODiagramEditor.java   
/**
* @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(
                edu.toronto.cs.se.modelepedia.graph_mavo.diagram.part.Messages.Graph_MAVODiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell,
                    edu.toronto.cs.se.modelepedia.graph_mavo.diagram.part.Messages.Graph_MAVODiagramEditor_SaveAsErrorTitle,
                    edu.toronto.cs.se.modelepedia.graph_mavo.diagram.part.Messages.Graph_MAVODiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell,
                    edu.toronto.cs.se.modelepedia.graph_mavo.diagram.part.Messages.Graph_MAVODiagramEditor_SaveErrorTitle,
                    edu.toronto.cs.se.modelepedia.graph_mavo.diagram.part.Messages.Graph_MAVODiagramEditor_SaveErrorMessage,
                    x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}
项目:eclipse-optimus    文件:TransformationDependencyDiagramEditor.java   
/**
 * @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.TransformationDependencyDiagramEditor_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;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell, Messages.TransformationDependencyDiagramEditor_SaveAsErrorTitle,
                    Messages.TransformationDependencyDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell, Messages.TransformationDependencyDiagramEditor_SaveErrorTitle,
                    Messages.TransformationDependencyDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}