本文整理汇总了Java中org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider.isDeleted方法的典型用法代码示例。如果您正苦于以下问题:Java IDocumentProvider.isDeleted方法的具体用法?Java IDocumentProvider.isDeleted怎么用?Java IDocumentProvider.isDeleted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider
的用法示例。
在下文中一共展示了IDocumentProvider.isDeleted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例2: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例3: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例4: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例5: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例6: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例7: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例8: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例9: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例10: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例11: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例12: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例13: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例14: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}
示例15: performSaveAs
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @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);
}
}