/** * Builds the FSTModel of the feature project and creates a list of all directives with valid * colors * * @return the directive list */ private void createDirectiveList() { directiveMap.clear(); validDirectiveList.clear(); FSTModel model = project.getFSTModel(); if (model == null) { composer.buildFSTModel(); model = project.getFSTModel(); } if (model == null) { return; } int index = 0; for (FSTFeature fstFeature : model.getFeatures()) { for (FSTRole role : fstFeature.getRoles()) { if (file.equals(role.getFile())) { for (FSTDirective dir : role.getDirectives()) { directiveMap.put(dir.getId(), dir); index++; } } } } for (int i = 0; i < index; i++) { FSTDirective dir = directiveMap.get(i); if (dir != null && ColorList.isValidColor(dir.getColor())) { validDirectiveList.add(dir); } } }
/** Retrieves the FSTDirectives from the changed document. */ private LinkedList<FSTDirective> getNewDirectives() { Vector<String> lines = new Vector<String>(); for (int i = 0; i < document.getNumberOfLines(); i++) { try { lines.add(document.get(document.getLineOffset(i), document.getLineLength(i))); } catch (BadLocationException e) { UIPlugin.getDefault().logError(e); } } return composer.buildModelDirectivesForFile(lines); }
private ColorAnnotationModel( IDocument document, IFile file, IFeatureProject project, ITextEditor editor) { this.document = document; this.project = project; this.file = file; composer = project.getComposer(); composer.initialize(project); docLines = document.getNumberOfLines(); docLength = document.getLength(); updateAnnotations(true); editor.addPropertyListener( new IPropertyListener() { @Override public void propertyChanged(Object source, int propId) { if (propId == IEditorPart.PROP_DIRTY && !((ITextEditor) source).isDirty()) { updateAnnotations(true); } } }); }