public void propertyChanged(Object source, int propId) { if (propId == IEditorPart.PROP_DIRTY) { if (source == swtXmlEditorPart && !swtXmlEditorPart.isDirty()) { updatePreview(false); } } }
public void propertyChanged(Object source, int propId) { if (propId == IEditorPart.PROP_DIRTY) { if (source == propertiesFileEditorPart && !propertiesFileEditorPart.isDirty()) { updatePreview(true); } } }
private List<? extends IEditorPart> getDirtyEditors() { final List<IEditorPart> dirtyEditors = newArrayList(); for (int i = 0; i < getPageCount(); i++) { final IEditorPart editorPart = getEditor(i); if (editorPart != null && editorPart.isDirty()) { dirtyEditors.add(editorPart); } } return dirtyEditors; }
private static DartEditor getDirtyEditor(IFile file) { IWorkbenchPage activePage = getActivePage(); if (activePage != null) { IEditorPart editor = findEditor(activePage, file); if (editor instanceof DartEditor) { if (editor.isDirty()) { return (DartEditor) editor; } } } return null; }
private void savePubspecFile(IContainer container) { IResource resource = container.findMember(DartCore.PUBSPEC_FILE_NAME); if (resource != null) { IEditorPart editor = EditorUtility.isOpenInEditor(resource); if (editor != null && editor.isDirty()) { if (MessageDialog.openQuestion( getShell(), NLS.bind(ActionMessages.RunPubAction_commandText, command), ActionMessages.RunPubAction_savePubspecMessage)) { editor.doSave(new NullProgressMonitor()); } } } }
public static void deploy(final IFile medToDeploy) { CoreArgCheck.isNotNull(medToDeploy, "medToDeploy is null"); // $NON-NLS-1$ // Check whether there is currently an open editor for the selected Med IEditorPart editor = getOpenEditor(medToDeploy); // If editor is open and dirty, ask user whether to save if ((editor != null) && editor.isDirty()) { if (!MessageDialog.openQuestion( getShell(), Messages.updateMedInRegistryMedDirtyTitle, Messages.updateMedInRegistryMedDirtyMsg)) { return; } editor.doSave(new NullProgressMonitor()); } // If the file has any error markers, user is informed to fix them first if (RegistryDeploymentValidator.checkProblemMarkers(medToDeploy)) { return; } ModelExtensionRegistry registry = ExtensionPlugin.getInstance().getRegistry(); InputStream fileContents = null; try { fileContents = medToDeploy.getContents(); } catch (CoreException e) { UTIL.log( IStatus.ERROR, e, NLS.bind(Messages.medFileGetContentsErrorMsg, medToDeploy.getName())); } if (fileContents != null) { // Parse file contents to get the MED. Show info dialog if parse errors. ModelExtensionDefinition med = null; try { ModelExtensionDefinitionParser parser = new ModelExtensionDefinitionParser(ExtensionPlugin.getInstance().getMedSchema()); med = parser.parse( fileContents, ExtensionPlugin.getInstance().createDefaultModelObjectExtensionAssistant()); if (!parser.getErrors().isEmpty()) { MessageDialog.openError( getShell(), Messages.registerMedActionFailedTitle, NLS.bind(Messages.medFileParseErrorMsg, medToDeploy.getName())); return; } } catch (Exception e) { UTIL.log(e); MessageDialog.openError( getShell(), Messages.registerMedActionFailedTitle, Messages.registerMedActionFailedMsg); return; } // Continue checks on parsable MED if (med != null) { ModelExtensionDefinition medNSPrefixMatch = RegistryDeploymentValidator.getRegisteredMedWithNSPrefix( registry, med.getNamespacePrefix()); ModelExtensionDefinition medNSUriMatch = RegistryDeploymentValidator.getRegisteredMedWithNSUri(registry, med.getNamespaceUri()); boolean nsPrefixConflict = false; boolean nsUriConflict = false; boolean nsPrefixAndUriConflictSameMed = false; boolean nsPrefixConflictMedBuiltIn = false; boolean nsUriConflictMedBuiltIn = false; if (medNSPrefixMatch != null) { nsPrefixConflict = true; nsPrefixConflictMedBuiltIn = medNSPrefixMatch.isBuiltIn(); } if (medNSUriMatch != null) { nsUriConflict = true; nsUriConflictMedBuiltIn = medNSUriMatch.isBuiltIn(); } if (nsPrefixConflict && nsUriConflict && medNSPrefixMatch.equals(medNSUriMatch)) nsPrefixAndUriConflictSameMed = true; // No conflicts - add it to the registry if (!nsPrefixConflict && !nsUriConflict) { // Add the selected Med BusyIndicator.showWhile( Display.getDefault(), new Runnable() { @Override public void run() { internalRun(medToDeploy, false); } }); // If the NS Prefix conflicts with a Built-in, prompt user to fix } else if (nsPrefixConflictMedBuiltIn) { RegistryDeploymentValidator.showMedNSPrefixConflictsWBuiltInDialog(); // If the NS URI conflicts with a Built-in, prompt user to fix } else if (nsUriConflictMedBuiltIn) { RegistryDeploymentValidator.showMedNSUriConflictsWBuiltInDialog(); // If there is (1) just a NS Prefix Conflict or (2) NS Prefix AND URI, but they are same // MED, prompt user // whether to update } else if (nsPrefixConflict && (!nsUriConflict || (nsUriConflict && nsPrefixAndUriConflictSameMed))) { // Do not re-deploy the same MED if (med.equals(medNSPrefixMatch)) { RegistryDeploymentValidator.showMedNSPrefixAlreadyRegisteredDialog(); } else { boolean doUpdate = RegistryDeploymentValidator.showMedNSPrefixAlreadyRegisteredDoUpdateDialog(); if (doUpdate) { // Add the selected Med BusyIndicator.showWhile( Display.getDefault(), new Runnable() { @Override public void run() { internalRun(medToDeploy, true); } }); } } // If there is a NS URI Conflict, prompt user to fix it } else if (nsUriConflict) { RegistryDeploymentValidator.showMedNSUriAlreadyRegisteredDialog(); } } } }