public com.kingdee.bos.ctrl.swing.KDToolBar[] getUIMultiToolBar() {
   java.util.List list = new java.util.ArrayList();
   com.kingdee.bos.ctrl.swing.KDToolBar[] bars = super.getUIMultiToolBar();
   if (bars != null) {
     list.addAll(java.util.Arrays.asList(bars));
   }
   list.add(this.toolBar);
   return (com.kingdee.bos.ctrl.swing.KDToolBar[])
       list.toArray(new com.kingdee.bos.ctrl.swing.KDToolBar[list.size()]);
 }
  private void lookupViewComboAction(ActionEvent e) {
    ObjEntityView fieldLookupView = objEntityViewField.getLookup().getLookupObjEntityView();
    ObjEntityView selectedLookupView = (ObjEntityView) lookupViewCombo.getSelectedItem();

    if (selectedLookupView != fieldLookupView) {
      objEntityViewField.getLookup().setLookupObjEntityView(selectedLookupView);

      dataViewTreeModel.fieldChanged(objEntityViewField);
      dataMapTreeModel.fieldChanged(objEntityViewField);
      fieldsTableModel.fireTableCellUpdated(
          objEntityViewField.getObjEntityView().getIndexOfObjEntityViewField(objEntityViewField),
          4);
    }

    if (selectedLookupView != null) {
      ObjEntityViewField nullField = null;
      java.util.List lookupFields = new ArrayList();
      lookupFields.add(nullField);
      lookupFields.addAll(selectedLookupView.getObjEntityViewFields());

      DefaultComboBoxModel lookupFieldsDefaultModel =
          new DefaultComboBoxModel(lookupFields.toArray());
      lookupFieldCombo.setModel(lookupFieldsDefaultModel);
      ObjEntityViewField fieldLookupField = objEntityViewField.getLookup().getLookupField();
      if (fieldLookupField != null) {
        boolean flagSetSelectedItem = false;
        for (Iterator itr = lookupFields.iterator(); itr.hasNext(); ) {
          ObjEntityViewField field = (ObjEntityViewField) itr.next();
          if ((field != null) && (fieldLookupField.getName().equals(field.getName()))) {
            lookupFieldCombo.setSelectedItem(fieldLookupField);
            flagSetSelectedItem = true;
            break;
          }
        }
        if (!flagSetSelectedItem) {
          lookupFieldCombo.setSelectedIndex(0);
        }
      } else {
        lookupFieldCombo.setSelectedIndex(0);
      }
    } else {
      ObjEntityViewField nullField = null;
      ObjEntityViewField[] fields = new ObjEntityViewField[] {nullField};

      DefaultComboBoxModel fieldsModel = new DefaultComboBoxModel(fields);
      lookupFieldCombo.setModel(fieldsModel);
      lookupFieldCombo.setSelectedIndex(0);
    }
  }
  private void objRelationshipComboAction(ActionEvent e) {
    ObjRelationship selectedObjRelationship =
        (ObjRelationship) objRelationshipCombo.getSelectedItem();
    ObjRelationship fieldObjRelationship = objEntityViewField.getObjRelationship();

    if (selectedObjRelationship != fieldObjRelationship) {
      objEntityViewField.setObjRelationship(selectedObjRelationship);
    }

    if (selectedObjRelationship != null) {
      ObjEntity targetObjEntity = selectedObjRelationship.getTargetObjEntity();

      ObjEntityView nullView = null;
      java.util.List lookupViews = new ArrayList();
      lookupViews.add(nullView);
      lookupViews.addAll(targetObjEntity.getObjEntityViews());

      DefaultComboBoxModel lookupViewModel = new DefaultComboBoxModel(lookupViews.toArray());
      lookupViewCombo.setModel(lookupViewModel);
      ObjEntityView fieldLookupView = objEntityViewField.getLookup().getLookupObjEntityView();
      if (fieldLookupView != null) {
        boolean flagSetSelectedItem = false;
        for (Iterator itr = lookupViews.iterator(); itr.hasNext(); ) {
          ObjEntityView view = (ObjEntityView) itr.next();
          if (fieldLookupView == view) {
            lookupViewCombo.setSelectedItem(fieldLookupView);
            flagSetSelectedItem = true;
            break;
          }
        }
        if (!flagSetSelectedItem) {
          lookupViewCombo.setSelectedIndex(0);
        }
      } else {
        lookupViewCombo.setSelectedIndex(0);
      }
    } else {
      ObjEntityView nullView = null;
      ObjEntityView[] views = new ObjEntityView[] {nullView};
      DefaultComboBoxModel viewsModel = new DefaultComboBoxModel(views);
      lookupViewCombo.setModel(viewsModel);
      lookupViewCombo.setSelectedIndex(0);
    }
  }
Example #4
0
  public WhatsNew(AbstractProjectViewer pv, boolean onlyShowCurrentVersion)
      throws GeneralException {

    super(pv);

    String wn = Environment.getProperty(Constants.WHATS_NEW_VERSION_VIEWED_PROPERTY_NAME);

    if (wn == null) {

      wn = "0";
    }

    // Get the current whats new version (i.e. old).
    Version lastWhatsNewVersion = new Version(wn);

    boolean betasAllowed =
        Environment.getUserProperties()
            .getPropertyAsBoolean(Constants.OPTIN_TO_BETA_VERSIONS_PROPERTY_NAME);

    try {

      String whatsNew = Environment.getResourceFileAsString(Constants.WHATS_NEW_FILE);

      // Load up all the whats new for greater versions.
      Element root = JDOMUtils.getStringAsElement(whatsNew);

      java.util.List verEls = JDOMUtils.getChildElements(root, XMLConstants.version, false);

      // Assume they are in the right order
      // TODO: Enforce the order and/or sort.
      for (int i = 0; i < verEls.size(); i++) {

        Element vEl = (Element) verEls.get(i);

        String id = JDOMUtils.getAttributeValue(vEl, XMLConstants.id, true);

        Version v = new Version(id);
        /*
                      if ((v.isBeta ())
                          &&
                          (!betasAllowed)
                         )
                      {

                          // Ignore, the user isn't interested in betas.
                          continue;

                      }
        */
        if ((lastWhatsNewVersion.isNewer(v))
            || ((onlyShowCurrentVersion) && (v.isSame(Environment.getQuollWriterVersion())))) {

          String c = WhatsNewComponentProvider.class.getName();

          int ind = c.lastIndexOf(".");

          if (ind > 0) {

            c = c.substring(0, ind);
          }

          WhatsNewComponentProvider compProv = null;

          String cl = JDOMUtils.getAttributeValue(vEl, XMLConstants.clazz, false);

          if (!cl.equals("")) {

            Class clz = null;

            try {

              clz = Class.forName(cl);

              if (WhatsNewComponentProvider.class.isAssignableFrom(clz)) {

                compProv = (WhatsNewComponentProvider) clz.newInstance();
              }

            } catch (Exception e) {

            }
          }

          // This is a version we are interested in.
          java.util.List itemEls =
              JDOMUtils.getChildElements(vEl, WhatsNewItem.XMLConstants.root, true);

          java.util.List<WhatsNewItem> its = new ArrayList();

          for (int j = 0; j < itemEls.size(); j++) {

            Element itEl = (Element) itemEls.get(j);

            WhatsNewItem it = new WhatsNewItem(itEl, compProv, pv);

            if (it.onlyIfCurrentVersion) {

              if (!Environment.getQuollWriterVersion().isSame(v)) {

                continue;
              }
            }

            if ((it.description == null) && (it.component == null)) {

              Environment.logMessage(
                  "Whats new item has no description or component, referenced by: "
                      + JDOMUtils.getPath(itEl));

              continue;
            }

            its.add(it);
          }

          if (its.size() > 0) {

            this.items.put(v, its);
          }
        }
      }

    } catch (Exception e) {

      throw new GeneralException("Unable to init whats new", e);
    }
  }
  private void calcTypeComboAction(ActionEvent e) {
    String comboCalcType = (String) calcTypeCombo.getSelectedItem();
    ObjEntity objEntity = objEntityViewField.getObjEntityView().getObjEntity();

    if (comboCalcType.equals("No Calculation")) {
      objEntityViewField.setCalcType("nocalc");

      objRelationshipCombo.setEnabled(false);
      lookupViewCombo.setEnabled(false);
      lookupFieldCombo.setEnabled(false);

      ObjAttribute nullAttribute = null;
      java.util.List attributes = new ArrayList();
      attributes.add(nullAttribute);
      if (objEntity != null) {
        attributes.addAll(objEntity.getObjAttributes());
      }

      DefaultComboBoxModel attributesDefaultModel = new DefaultComboBoxModel(attributes.toArray());
      objAttributeCombo.setModel(attributesDefaultModel);
      objAttributeCombo.setEnabled(true);
      if (objEntity != null) {
        if (objEntityViewField.getObjAttribute() != null) {
          objAttributeCombo.setSelectedItem(objEntityViewField.getObjAttribute());
        } else {
          objAttributeCombo.setSelectedIndex(0);
        }
      } else {
        objAttributeCombo.setSelectedIndex(0);
      }
    }
    if (comboCalcType.equals("Lookup")) {
      objEntityViewField.setCalcType("lookup");

      objAttributeCombo.setEnabled(false);
      objRelationshipCombo.setEnabled(true);
      lookupViewCombo.setEnabled(true);
      lookupFieldCombo.setEnabled(true);

      ObjRelationship nullRelationship = null;
      java.util.List relationships = new ArrayList();
      relationships.add(nullRelationship);
      if (objEntity != null) {
        relationships.addAll(objEntity.getDataMap().getObjRelationshipsBySourceToOne(objEntity));
      }

      DefaultComboBoxModel relationshipsDefaultModel =
          new DefaultComboBoxModel(relationships.toArray());
      objRelationshipCombo.setModel(relationshipsDefaultModel);

      ObjRelationship fieldRelationship = objEntityViewField.getObjRelationship();
      if (fieldRelationship != null) {
        boolean flagSetSelectedItem = false;
        for (Iterator itr = relationships.iterator(); itr.hasNext(); ) {
          ObjRelationship relationship = (ObjRelationship) itr.next();
          if ((relationship != null)
              && (fieldRelationship.getName().equals(relationship.getName()))) {
            objRelationshipCombo.setSelectedItem(fieldRelationship);
            flagSetSelectedItem = true;
            break;
          }
        }
        if (!flagSetSelectedItem) {
          objRelationshipCombo.setSelectedIndex(0);
        }
      } else {
        objRelationshipCombo.setSelectedIndex(0);
      }
    }
  }