Exemplo n.º 1
0
  @SuppressWarnings("unchecked")
  public ViewsPane(Workspace workspace, ViewsPaneMemento memento) {
    this.memento = memento;
    setLayout(new BorderLayout());

    // We need to read in a views configuration file.  Either we find
    // a customised one, or we read in the default one.

    // See if there is a customised file
    String serialisedViews = readViewLayout();
    Reader reader = null;
    if (serialisedViews.length() != 0 && !memento.isForceReset()) {
      // Got a previous config and not trying to reset
      reader = new StringReader(serialisedViews);
    } else {
      // Try and restore
      if (memento.getInitialCongigFileURL() != null) {
        // No file, so default to default one :)
        try {
          reader =
              new InputStreamReader(
                  new BufferedInputStream(memento.getInitialCongigFileURL().openStream()));
        } catch (IOException e) {
          logger.error("An error occurred whilst loading a views configuration file: {}", e);
        }
      }
    }

    if (reader != null) {
      // Got our config file.  Attempt to reannimate the views.
      NodeReanimator nodeReanimator =
          new NodeReanimator(reader, new ViewComponentFactory(workspace));
      SplitterNode node = nodeReanimator.getRootNode();
      nodePanel = new NodePanel(node);
      add(nodePanel);
      dynamicConfigPanel = new DynamicConfigPanel(nodePanel);
    } else {
      // There isn't even a default xml config file.  We don't want the system
      // to keel over, so just create a blank panel (the user can drag views on
      // to it as they wish).
      VerticalSplitterNode node =
          new VerticalSplitterNode(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
      nodePanel = new NodePanel(node);
      add(nodePanel);
      dynamicConfigPanel = new DynamicConfigPanel(nodePanel);
    }
  }
Exemplo n.º 2
0
 /**
  * Gets the layout preferences key for this view panel
  *
  * @return The key
  */
 public String getLayoutPreferencesKey() {
   return "protege-4.1." + memento.getViewPaneId();
 }