1   package debugger.gui.actions.resources;
2   
3   import debugger.gui.GuiFactory;
4   import debugger.resources.ResourcesFactory;
5   import debugger.resources.lr.LrModel;
6   
7   import javax.swing.*;
8   
9   /**
10   * Copyright (c) Ontos AG (http://www.ontosearch.com).
11   * This class is part of JAPE Debugger component for
12   * GATE (Copyright (c) "The University of Sheffield" see http://gate.ac.uk/) <br>
13   * @author Oleg Mishenko
14   * */
15  public class LrResourceSelectedAction implements Runnable{
16      private static LrResourceSelectedAction ourInstance;
17      private LrModel lrModel;
18  
19      public synchronized static LrResourceSelectedAction getInstance() {
20          if (ourInstance == null) {
21              ourInstance = new LrResourceSelectedAction();
22          }
23          return ourInstance;
24      }
25  
26      private LrResourceSelectedAction() {
27      }
28  
29      public void actionPerformed(LrModel lrModel) {
30          this.lrModel = lrModel;
31          SwingUtilities.invokeLater(this);
32      }
33      public void run()
34      {
35          ResourcesFactory.setCurrentLrModel(lrModel);
36  
37          GuiFactory.getDocumentEditor().getTextPane().setText(
38                  (lrModel == null ? "" : lrModel.getText()));
39          //set border with document name
40          GuiFactory.getDocumentEditor().setBorder(BorderFactory.createTitledBorder(
41                  BorderFactory.createEtchedBorder(),
42                  (lrModel == null ? "No document selected" : lrModel.getName())));
43          GuiFactory.getDocumentEditor().revalidate();
44  
45      }
46  }
47  
48