private void infoModified() { IFeatureModel featureModel = (IFeatureModel) getPage().getModel(); if (fLicenseFeatureIDText.getText().length() == 0 && fLicenseFeatureVersionText.getText().length() > 0) { fIgnoreChange = true; fLicenseFeatureVersionText.setText(""); //$NON-NLS-1$ fIgnoreChange = false; } if (!fIgnoreChange && featureModel instanceof IEditable) { ((IEditable) featureModel).setDirty(true); markDirty(); } }
@Override protected boolean synchronizeModel(IDocument doc) { Schema schema = (Schema) getModel(); if (schema == null) { // if model is null try to recreate it create(); return getModel() == null; } String text = doc.get(); try (InputStream stream = new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8))) { schema.reload(stream); if (schema instanceof IEditable) { ((IEditable) schema).setDirty(false); } } catch (IOException e) { } return true; }
public void flushEditorInput() { if (!fEditOperations.isEmpty()) { IDocument doc = fDocumentProvider.getDocument(fEditorInput); fDocumentProvider.aboutToChange(fEditorInput); flushModel(doc); fDocumentProvider.changed(fEditorInput); fValidated = false; } else if ((fModel instanceof IEditable) && ((IEditable) fModel).isDirty()) { // When text edit operations are made that cancel each other out, // the editor is not undirtied // e.g. Extensions page: Move an element up and then move it down // back in the same position: Bug # 197831 ((IEditable) fModel).setDirty(false); } }
protected void flushModel(IDocument doc) { boolean flushed = true; if (!fEditOperations.isEmpty()) { try { MultiTextEdit edit = new MultiTextEdit(); if (isNewlineNeeded(doc)) insert(edit, new InsertEdit(doc.getLength(), TextUtilities.getDefaultLineDelimiter(doc))); for (int i = 0; i < fEditOperations.size(); i++) { insert(edit, fEditOperations.get(i)); } if (fModel instanceof IEditingModel) ((IEditingModel) fModel).setStale(true); edit.apply(doc); fEditOperations.clear(); } catch (MalformedTreeException e) { PDEPlugin.logException(e); flushed = false; } catch (BadLocationException e) { PDEPlugin.logException(e); flushed = false; } } // If no errors were encountered flushing the model, then undirty the // model. This needs to be done regardless of whether there are any // edit operations or not; since, the contributed actions need to be // updated and the editor needs to be undirtied if (flushed && (fModel instanceof IEditable)) { ((IEditable) fModel).setDirty(false); } }