Example #1
0
 private void updateSettings() {
   try {
     GuardedDocument<Section> doc = this.getDocument();
     this.m_settings.setScript(doc.getText(0, doc.getLength()));
     Set<Section> guardedSections = doc.getGuardedSections();
     Map<Section, int[]> sectionParts = new EnumMap<>(Section.class);
     for (Section section : guardedSections) {
       GuardedSection guardedSection = doc.getGuardedSection(section);
       sectionParts.put(
           section,
           new int[] {guardedSection.getStart().getOffset(), guardedSection.getEnd().getOffset()});
     }
     this.m_settings.setScriptParts(sectionParts);
   } catch (BadLocationException e) {
     // this should never happen
     throw new IllegalStateException(e);
   }
 }
Example #2
0
 /** Initialize Section.Imports and GUARDED_FIELDS with information from the settings. */
 private void initGuardedSection(final GuardedDocument<Section> doc) {
   try {
     GuardedSection imports = doc.getGuardedSection(Section.Imports);
     imports.setText(this.createImportsSection());
     GuardedSection fields = doc.getGuardedSection(Section.Fields);
     fields.setText(this.createFieldsSection());
     GuardedSection main = doc.getGuardedSection(Section.MainStart);
     main.setText(this.createMainSection());
   } catch (BadLocationException e) {
     throw new IllegalStateException(e.getMessage(), e);
   }
 }