Пример #1
0
  private void mRemoveNode() {
    String old_node = (String) lstNodes.getSelectedValue();

    java.util.List remove_list =
        ConfigUtilities.getElementsWithDefinition(mBroker.getElements(mContext), old_node);
    for (int i = 0; i < remove_list.size(); i++) {
      mBroker.remove(mContext, (ConfigElement) remove_list.get(i));
    }
  }
Пример #2
0
  /** Gets the GUI component for this pane. */
  public JComponent getGUI() {
    if (cwp == null) {
      Object object = mWhiteBoard.get("device_definition");
      Object ctx_obj = mWhiteBoard.get("context");

      if (null != object
          && object instanceof ConfigDefinition
          && null != ctx_obj
          && ctx_obj instanceof ConfigContext) {
        mConfigContext = (ConfigContext) ctx_obj;

        ConfigDefinition def = (ConfigDefinition) object;
        String token = def.getToken();

        // Create a temporary list of ConfigDefinitions to pass to factory.
        java.util.List def_list = new ArrayList();
        def_list.add(def);

        // Initialize a ConfigElementFactory with the needed
        // ConfigDefinition. And create a new ConfigElement.
        ConfigElementFactory temp_factory = new ConfigElementFactory(def_list);
        mConfigElement = temp_factory.create("New " + token, def);

        List list = CustomEditorRegistry.findEditors(token);

        Color start_color = new Color(160, 160, 180);

        Object color = UIManager.get("window");
        if (null != color && color instanceof Color) {
          start_color = (Color) color;
        } else {
          System.out.println("Could not get the desktop color from the  UIManager.");
        }

        // XXX:This will be used after making findEditors -> findEditor
        // if(null != editor)
        if (null == list || list.size() == 0) {
          System.out.println("No CustomEditors registered for token: " + token);

          JScrollPane scroll_pane = new JScrollPane();
          PropertySheet element_prop_sheet =
              PropertySheetFactory.instance()
                  .makeSheet(mConfigContext, mConfigElement, start_color);

          scroll_pane.getViewport().removeAll();
          scroll_pane.getViewport().add(element_prop_sheet, null);
          cwp = scroll_pane;
        } else if (null != list && list.size() > 0) {
          CustomEditor editor = (CustomEditor) list.get(0);
          cwp = (JComponent) editor.getPanel();
          editor.setConfig(mConfigContext, mConfigElement);
        }
      }
    }
    // cwp.init(mWhiteBoard);
    return cwp;
  }
Пример #3
0
  private void mAddNodeBtn_actionPerformed(ActionEvent e) {
    String host_name = mHostnameField.getText().trim();
    String element_name = "Node(" + host_name + ")";
    java.util.List elts = mBroker.getElements(mContext);
    java.util.List matches = ConfigUtilities.getElementsWithDefinition(elts, element_name);

    if (!host_name.equals("") && matches.size() == 0) {
      // Create a cluster_node element for the node
      ConfigElementFactory factory =
          new ConfigElementFactory(mBroker.getRepository().getAllLatest());
      ConfigElement element = factory.create(element_name, CLUSTER_NODE_TYPE);
      mBroker.add(mContext, element);
      element.setProperty("host_name", 0, host_name);
      element.setProperty("listen_port", 0, "7000");
    }
    mHostnameField.setText("");
  }