Ejemplo n.º 1
0
  public void loadState(Element element) {
    mySelectedIndex = 0;
    try {
      mySelectedIndex = Integer.parseInt(element.getAttributeValue(ATTRIBUTE_SELECTED_INDEX));
    } catch (NumberFormatException ignored) {
      // nothing to be done
    }

    //noinspection unchecked
    for (Element child : (Iterable<Element>) element.getChildren()) {
      if (ELEMENT_TODO_PANEL.equals(child.getName())) {
        String id = child.getAttributeValue(ATTRIBUTE_ID);
        if (VALUE_SELECTED_FILE.equals(id)) {
          myCurrentPanelSettings.readExternal(child);
        } else if (VALUE_ALL.equals(id)) {
          myAllPanelSettings.readExternal(child);
        } else if (VALUE_DEFAULT_CHANGELIST.equals(id)) {
          myChangeListTodosPanelSettings.readExternal(child);
        } else {
          throw new IllegalArgumentException("unknown id: " + id);
        }
      }
    }
  }
Ejemplo n.º 2
0
  public Element getState() {
    Element element = new Element("TodoView");
    if (myContentManager != null) { // all panel were constructed
      Content content = myContentManager.getSelectedContent();
      element.setAttribute(
          ATTRIBUTE_SELECTED_INDEX, Integer.toString(myContentManager.getIndexOfContent(content)));
    }

    Element selectedFileElement = new Element(ELEMENT_TODO_PANEL);
    selectedFileElement.setAttribute(ATTRIBUTE_ID, VALUE_SELECTED_FILE);
    myCurrentPanelSettings.writeExternal(selectedFileElement);
    element.addContent(selectedFileElement);

    Element allElement = new Element(ELEMENT_TODO_PANEL);
    allElement.setAttribute(ATTRIBUTE_ID, VALUE_ALL);
    myAllPanelSettings.writeExternal(allElement);
    element.addContent(allElement);

    Element changeListElement = new Element(ELEMENT_TODO_PANEL);
    changeListElement.setAttribute(ATTRIBUTE_ID, VALUE_DEFAULT_CHANGELIST);
    myChangeListTodosPanelSettings.writeExternal(changeListElement);
    element.addContent(changeListElement);
    return element;
  }