本文整理汇总了Java中org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider.aboutToChange方法的典型用法代码示例。如果您正苦于以下问题:Java IDocumentProvider.aboutToChange方法的具体用法?Java IDocumentProvider.aboutToChange怎么用?Java IDocumentProvider.aboutToChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider
的用法示例。
在下文中一共展示了IDocumentProvider.aboutToChange方法的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: performSave
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @generated NOT
*/
protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {
IDocumentProvider provider = getDocumentProvider();
if (provider == null)
return;
try {
provider.aboutToChange(getEditorInput());
IEditorInput input = getEditorInput();
provider.saveDocument(progressMonitor, input, getDocumentProvider().getDocument(input), overwrite);
editorSaved();
}
catch (CoreException x) {
IStatus status = x.getStatus();
if (status == null || status.getSeverity() != IStatus.CANCEL)
handleExceptionOnSave(x, progressMonitor);
}
finally {
provider.changed(getEditorInput());
}
MID mid1 = (MID) this.getDiagram().getElement();
if (mid1.isTypesLevel()) {
MMINT.syncTypeMID(mid1);
// diagram sync required
final String relDiagramId = "edu.toronto.cs.se.mmint.mid.relationship.diagram.part.RelationshipDiagramEditorID";
for (IEditorReference editorRef : PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage()
.getEditorReferences()) {
IEditorPart editorPart = editorRef.getEditor(false);
if (!(editorPart instanceof DiagramDocumentEditor)) {
continue;
}
DiagramDocumentEditor editor = (DiagramDocumentEditor) editorPart;
if (!editor.getSite().getId().equals(relDiagramId)) {
continue;
}
MID mid2 = (MID) editor.getDiagram().getElement().eContainer();
if (mid2.isTypesLevel()) {
IDocumentProvider provider2 = editor.getDocumentProvider();
try {
provider2.synchronize(editorRef.getEditorInput());
}
catch (Exception e) {
MMINTException.print(IStatus.ERROR, "Diagram synchronization failed", e);
}
}
}
}
}
示例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: performSave
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; //导入方法依赖的package包/类
/**
* @generated NOT
*/
protected void performSave(boolean overwrite,
IProgressMonitor progressMonitor) {
IDocumentProvider provider = getDocumentProvider();
if (provider == null)
return;
try {
provider.aboutToChange(getEditorInput());
IEditorInput input = getEditorInput();
provider.saveDocument(progressMonitor, input, getDocumentProvider()
.getDocument(input), overwrite);
editorSaved();
} catch (CoreException x) {
IStatus status = x.getStatus();
if (status == null || status.getSeverity() != IStatus.CANCEL)
handleExceptionOnSave(x, progressMonitor);
} finally {
provider.changed(getEditorInput());
}
MID mid = (MID) this.getDiagram().getElement()
.eContainer();
if (mid.isTypesLevel()) {
MMINT.syncTypeMID(mid);
// diagram sync required
final String midDiagramId = "edu.toronto.cs.se.mmint.mid.diagram.part.MIDDiagramEditorID";
for (IEditorReference editorRef : PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage()
.getEditorReferences()) {
IEditorPart editorPart = editorRef.getEditor(false);
if (!(editorPart instanceof DiagramDocumentEditor)) {
continue;
}
DiagramDocumentEditor editor = (DiagramDocumentEditor) editorPart;
if (!editor.getSite().getId().equals(midDiagramId)) {
continue;
}
MID mid2 = (MID) editor.getDiagram()
.getElement();
if (mid2.isTypesLevel()) {
IDocumentProvider provider2 = editor.getDocumentProvider();
try {
provider2.synchronize(editorRef.getEditorInput());
} catch (Exception e) {
MMINTException.print(IStatus.ERROR,
"Diagram synchronization failed", e);
}
}
}
}
}
示例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(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);
}
}
示例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(
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);
}
}
示例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(
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);
}
}
示例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(
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);
}
}
示例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.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);
}
}
示例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(
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);
}
}
示例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.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);
}
}
示例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.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);
}
}