예제 #1
0
 public void render(RequestContext context) throws Exception {
   super.render(context);
   Element parent = getElement();
   DomUtils.removeChildElements(parent);
   Element child = tree.render(context, parent.getOwnerDocument());
   parent.appendChild(child);
 }
예제 #2
0
  public void initialize(RequestContext context, XmlComponent xmlComp, Element element)
      throws Exception {
    super.initialize(context, xmlComp, element);

    // must access the bean, so it has to be a FormComponent
    formComp = (FormComponent) xmlComp;

    String ref = XoplonCtrl.getModelReference(element);
    Object bean = formComp.getBean();
    TreeModel tm = (TreeModel) PropertyUtils.getProperty(bean, ref);
    tree = new TreeComponent(element.getAttribute("id"), formComp, tm);

    DefaultSelectionModel dsm = new DefaultSelectionModel();
    String selmode = element.getAttribute("selmode");
    if ("href".equals(selmode)) dsm.setMode(SelectionModel.SINGLE_SELECTION_HREF);
    else if ("single".equals(selmode)) dsm.setMode(SelectionModel.SINGLE_SELECTION);
    else if ("multi".equals(selmode)) dsm.setMode(SelectionModel.MULTIPLE_SELECTION);
    else if ("button".equals(selmode)) dsm.setMode(SelectionModel.MULTIPLE_SELECTION_BUTTON);
    else dsm.setMode(SelectionModel.NO_SELECTION);
    tree.setSelectionModel(dsm);
    if (tm instanceof SelectionChangeListener)
      dsm.addSelectionListener((SelectionChangeListener) tm);

    // override border by setting an attribute
    String border = element.getAttribute("border");
    if (border.length() > 0) tree.setBorder(border);

    // override width by setting an attribute
    String width = element.getAttribute("width");
    if (width.length() > 0) tree.setWidth(width);

    // override renderId Attribute always
    tree.setRenderId(element.getAttribute("id"));

    // click in tree should validate the user input in form fields
    tree.addFormListener(formComp);
    formComp.addFormListener(tree);

    tree.initialize(context);
  }
예제 #3
0
 public void destroy(HttpSession session) throws Exception {
   tree.destroy(session);
   super.destroy(session);
 }
예제 #4
0
  public void realize(XMLTree xtXMLTree) {
    try {
      TreeComponent tcSiteTreeComponent;
      TreeComponent tcSiteTreeComponentParent;
      TreeComponent tcXMLTopTreeComponent;
      TreeVisit tvTreeVisit;
      TreeVisitToFindTreeComponent tvftcTreeVisitToFindTreeComponent;
      TreeComponent tcSiteToRemoveTreeComponent;

      tcSiteTreeComponent = xtXMLTree.getSelectedTreeComponent();

      if (tcSiteTreeComponent.getChildCount() != 0) {
        JOptionPane.showMessageDialog(
            null, "The site is not empty", "DeleteSite", JOptionPane.ERROR_MESSAGE);

        return;
      }

      if (JOptionPane.showOptionDialog(
              null,
              "Are you sure?",
              "DeleteSite",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              null,
              null)
          == 1) return;

      if (ConfigurationTransaction.beginGUIConfigurationTransaction(
              _xtfcXMLTreeForConfiguration.getXML().getFile(), _pProperties.getProperty("login"))
          != 0) {
        JOptionPane.showMessageDialog(
            null,
            "beginGUIConfigurationTransaction failed",
            "DeleteSite",
            JOptionPane.ERROR_MESSAGE);

        return;
      }

      tcSiteTreeComponentParent = (TreeComponent) tcSiteTreeComponent.getParent();

      xtXMLTree.setSelectedTreeComponent(tcSiteTreeComponentParent);
      tcSiteTreeComponentParent.remove(tcSiteTreeComponent);
      tcSiteTreeComponentParent.refreshSubTree();

      // XMLTreeForContents
      tcXMLTopTreeComponent = _xtfcXMLTreeForContents.getXMLTopTreeComponent();
      tvftcTreeVisitToFindTreeComponent =
          new TreeVisitToFindTreeComponent(
              "Site", tcSiteTreeComponent.getAttributeValue("Identifier"));
      tvTreeVisit = new TreeVisit(tvftcTreeVisitToFindTreeComponent);

      if (tvTreeVisit.preOrderVisit(tcXMLTopTreeComponent) != 0) {
        JOptionPane.showMessageDialog(
            null, "preOrderVisit failed", "DeleteSite", JOptionPane.ERROR_MESSAGE);

        if (ConfigurationTransaction.rollbackGUIConfigurationTransaction(
                _xtfcXMLTreeForConfiguration.getXML().getFile())
            != 0) {
          JOptionPane.showMessageDialog(
              null,
              "rollbackGUIConfigurationTransaction failed",
              "DeleteSite",
              JOptionPane.ERROR_MESSAGE);
        }

        return;
      }

      if ((tcSiteToRemoveTreeComponent = tvftcTreeVisitToFindTreeComponent.getTreeComponentFound())
          == null) {
        JOptionPane.showMessageDialog(
            null,
            "TreeComponent not found (TagName: Site, Identifier: "
                + tcSiteTreeComponent.getAttributeValue("Identifier")
                + ")",
            "DeleteSite",
            JOptionPane.ERROR_MESSAGE);

        if (ConfigurationTransaction.rollbackGUIConfigurationTransaction(
                _xtfcXMLTreeForConfiguration.getXML().getFile())
            != 0) {
          JOptionPane.showMessageDialog(
              null,
              "rollbackGUIConfigurationTransaction failed",
              "DeleteSite",
              JOptionPane.ERROR_MESSAGE);
        }

        return;
      }
      tcXMLTopTreeComponent.remove(tcSiteToRemoveTreeComponent);
      tcXMLTopTreeComponent.refreshSubTree();

      // XMLTreeForMonitor
      tcXMLTopTreeComponent = _xtfmXMLTreeForMonitor.getXMLTopTreeComponent();
      tvftcTreeVisitToFindTreeComponent =
          new TreeVisitToFindTreeComponent(
              "Site", tcSiteTreeComponent.getAttributeValue("Identifier"));
      tvTreeVisit = new TreeVisit(tvftcTreeVisitToFindTreeComponent);

      if (tvTreeVisit.preOrderVisit(tcXMLTopTreeComponent) != 0) {
        JOptionPane.showMessageDialog(
            null, "preOrderVisit failed", "DeleteSite", JOptionPane.ERROR_MESSAGE);

        if (ConfigurationTransaction.rollbackGUIConfigurationTransaction(
                _xtfcXMLTreeForConfiguration.getXML().getFile())
            != 0) {
          JOptionPane.showMessageDialog(
              null,
              "rollbackGUIConfigurationTransaction failed",
              "DeleteSite",
              JOptionPane.ERROR_MESSAGE);
        }

        return;
      }

      if ((tcSiteToRemoveTreeComponent = tvftcTreeVisitToFindTreeComponent.getTreeComponentFound())
          == null) {
        JOptionPane.showMessageDialog(
            null,
            "TreeComponent not found (TagName: Site, Identifier: "
                + tcSiteTreeComponent.getAttributeValue("Identifier")
                + ")",
            "DeleteSite",
            JOptionPane.ERROR_MESSAGE);

        if (ConfigurationTransaction.rollbackGUIConfigurationTransaction(
                _xtfcXMLTreeForConfiguration.getXML().getFile())
            != 0) {
          JOptionPane.showMessageDialog(
              null,
              "rollbackGUIConfigurationTransaction failed",
              "DeleteSite",
              JOptionPane.ERROR_MESSAGE);
        }

        return;
      }
      tcXMLTopTreeComponent.remove(tcSiteToRemoveTreeComponent);
      tcXMLTopTreeComponent.refreshSubTree();

      if (ConfigurationTransaction.commitGUIConfigurationTransaction(
              _xtfcXMLTreeForConfiguration, _xtfcXMLTreeForConfiguration.getFunctionalities())
          != 0) {
        JOptionPane.showMessageDialog(
            null,
            "commitGUIConfigurationTransaction failed",
            "DeleteSite",
            JOptionPane.ERROR_MESSAGE);

        return;
      }
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          null, "DeleteSite ERROR: " + e, "DeleteSite", JOptionPane.ERROR_MESSAGE);

      if (ConfigurationTransaction.rollbackGUIConfigurationTransaction(
              _xtfcXMLTreeForConfiguration.getXML().getFile())
          != 0) {
        JOptionPane.showMessageDialog(
            null,
            "rollbackGUIConfigurationTransaction failed",
            "DeleteSite",
            JOptionPane.ERROR_MESSAGE);
      }

      return;
    }
  }