public static void processParams(String s[]) {
    /**/
    if (s[0].equals("DevData")) {
      if (s.length == 1) {
        Err.error("Need to explicitly specify a database");
      }
      /*
       * Dangerous!
       */
      if (s[1].equals(WombatConnectionEnum.PROD)) {
        Err.error("Cannot work with the " + WombatConnectionEnum.getFromName(s[1]) + " database");
      }
      /**/
      if (s.length == 2) {
        DataStoreFactory dataStoreFactory = new WombatDataStoreFactory();
        dataStoreFactory.addConnection(WombatConnectionEnum.getFromName(s[1]));
        dataStore = dataStoreFactory.getEntityManagedDataStore();
      } else {
        Err.error();
      }
      dataStore.startTx();

      List list = (List) dataStore.get(POJOWombatData.WORKER);
      update(list);
      dataStore.commitTx();
    } else {
      Err.error("Unrecognised param " + s[0]);
    }
  }
  /** Re-create the displayList. Will appear to outside world that only this list exists. */
  public void setList(Object masterElement, Tie tie) {
    Err.pr(
        SdzNote.CANT_ADD_RS,
        "$$$   setList called for reference extent, masterElement: " + masterElement);
    Err.pr(
        SdzNote.CANT_ADD_RS, "$$$   setList called for reference extent, tie: " + tie.hashCode());
    super.setList(masterElement, tie);
    this.tie = tie;
    referenceValue = masterElement;
    displayList.clear();

    Object refVal, element;
    for (Iterator e = hugeList.iterator(); e.hasNext(); ) {
      element = e.next();
      // Err.pr("Looking for " + refField + " in " + element);
      refVal = tie.getFieldValue(element);
      debug(refVal, masterElement);
      if (DOHelperUtils.equalityTest(masterElement, refVal))
      // if(masterElement == refVal)
      {
        Err.pr(SdzNote.CANT_ADD_RS, "Match found on refVal " + refVal);
        displayList.add(element);
      } else {
        //        Err.pr(SdzNote.cantAddRS, "");
        //        Err.pr(SdzNote.cantAddRS, "NO match found on refVal: " + refVal);
        //        Err.pr(SdzNote.cantAddRS, "WHEN CF WITH: " + masterElement);
        //        Err.pr(SdzNote.cantAddRS, "");
      }
    }
    hasCombinationExtent.getCombinationExtent().setList(this, tie);
  }
  private TrialEqualsByProperties() {
    createLoaderForThread(true);
    sbI1 = (SdzBagI) Utils.loadXMLFromResource(filename1, this, false);
    sbI2 = (SdzBagI) Utils.loadXMLFromResource(filename2, this, false);
    Err.pr("sbI1: " + sbI1);
    Err.pr("sbI2: " + sbI2);

    JComponent[] panels1 = sbI1.getPanes();
    JComponent[] panels2 = sbI2.getPanes();
    if (panels1.length != panels2.length) {
      Err.error("Expected the size of the panels to be the same");
    }

    WidgetClassifier wc = new WidgetClassifier();
    ReasonNotEquals.turnOn(true);
    for (int i = 0; i < panels1.length; i++) {
      JComponent component1 = panels1[i];
      JComponent component2 = panels2[i];
      if (ComponentUtils.equalsByProperties(component1, component2, wc)) {
        Err.pr("Found to be equal");
      } else {
        Err.pr("Found to be NOT equal: " + ReasonNotEquals.formatReasons());
        break;
      }
    }
    ReasonNotEquals.turnOn(false);
  }
 public boolean haveFieldsChanged() {
   boolean result = false;
   for (Iterator e = vector.iterator(); e.hasNext(); ) {
     AbstFieldObj fieldObj = (AbstFieldObj) e.next();
     Err.pr(SdzNote.SET_OBJCOMP_TABLE, "fieldObj to consider: " + fieldObj);
     if (fieldObj.haveFieldsChanged()) {
       Err.pr(SdzNote.SET_OBJCOMP_TABLE, "fields have changed for " + fieldObj);
       result = true;
       break;
     }
   }
   return result;
 }
 public void sdzSetup() {
   sbI = (SdzBagI) Utils.loadXMLFromResource(filename, this, false);
   if (sbI == null) {
     Err.error("Reading in not successful, from " + filename);
   }
   dt = new MaintainContactDT(sbI);
   triggers = new MaintainContactTriggers(getDataStore(), queries, dt, sbI);
   if (getApplication() != null) {
     initSdzBag((SdzBag) sbI);
     setPanelNodeTitle(dt.ui0, dt.contactNode, "contactNode");
   } else {
     Err.error(NEED_APPLICATION_MSG);
   }
 }
 ReferenceExtent(IndependentExtent hugeList, HasCombinationExtent ce, Tie tie) {
   if (hugeList == null) {
     Err.error("Cannot create ReferenceNodeExtent with a null hugeList");
   }
   this.hugeList = hugeList;
   times++;
   Err.pr(
       SdzNote.CANT_ADD_RS,
       "hugeList have been set has size " + hugeList.size() + " times " + times);
   if (ce == null) {
     Err.error("Cannot create a ReferenceExtent with a null CombinationExtent");
   }
   this.hasCombinationExtent = ce;
   // ce.addDependent( this, tie);
 }
 private void pr(String txt, boolean force) {
   if (DEBUG) {
     if (
     /*block.getName().equals("Job Node") &&*/ (force || doingNonVisual())) {
       Err.pr(txt);
     }
   }
 }
 public static void main(String s[]) {
   if (s.length != 0) {
     Err.error("No command line parameters are expected for PopulateForDemo");
   } else {
     main();
   }
   System.exit(0);
 }
 public void setBGColor(Object fieldComponent, Object color) {
   if (fieldComponent instanceof Component) {
     Component comp = (Component) fieldComponent;
     comp.setBackground((Color) color);
   } else {
     Err.error("getBGColor(), got a " + fieldComponent.getClass().getName());
   }
 }
 public void handleError(ApplicationError e) {
   List msg = e.getMsg();
   if (msg != null) {
     new MessageDlg(msg, JOptionPane.ERROR_MESSAGE);
     Err.alarm(msg.get(0).toString());
   } else {
     Print.prThrowable(e, "Auto-generated handler");
   }
 }
 void removeClickListeners(Component comp) {
   MouseListener ls[] = comp.getMouseListeners();
   for (int i = 0; i < ls.length; i++) {
     if (ls[i] instanceof ClickListener) {
       comp.removeMouseListener(ls[i]);
       Err.pr(SdzNote.FIELD_VALIDATION, "Removed all focus listeners from " + comp);
     }
   }
 }
 public void setTableObj(FieldObj tableObj) {
   /// fieldObj = tableObj;
   extent = new TempCursorExtent(this, block, tableObj);
   flatColumns = tableObj.getVisualTableAdaptersArrayList();
   nvFlatColumns = tableObj.getNonVisualTableAdaptersArrayList();
   Err.pr(
       SdzNote.MANY_NON_VISUAL_ATTRIBS,
       "NVFlatColumns set in <" + block.getName() + "> and is size " + nvFlatColumns.size());
   // Err.pr( "flatColumns: " + flatColumns);
 }
 /** Like removing all the records of a table but leaving the table there! */
 private static void processParams(String s[]) {
   /**/
   if (s[0].equals("PetstoreData")) {
     if (s.length == 1) {
       Err.error("Need to explicitly specify a database to replay against");
     }
     if (s[1].equals(PetstoreApplicationData.PROD)) {
       Err.error("Cannot replay against the " + PetstoreApplicationData.PROD + " database");
     }
     if (s.length == 2) {
       td = PetstoreApplicationData.getNewInstance(s[1]);
     } else {
       td = PetstoreApplicationData.getNewInstance(s[1], s[2]);
     }
     replay();
   } else {
     Err.error("Unrecognised param " + s[0]);
   }
 }
 public void sdzInit() {
   boolean callDirectly = false;
   Runnable runLater = new RunLater(this);
   try {
     if (SwingUtilities.isEventDispatchThread()) {
       if (!callDirectly) {
         SwingUtilities.invokeLater(runLater);
       } else {
         sdzSetup();
         preForm();
       }
     } else {
       SwingUtilities.invokeAndWait(runLater);
     }
   } catch (InterruptedException e) {
     Err.error(e);
   } catch (InvocationTargetException e) {
     Err.error(e);
   }
 }
 ClickListener createClickListener(Component comp, Object itemAdapter) {
   ClickListener result = null;
   MouseListener ls[] = comp.getMouseListeners();
   for (int i = 0; i < ls.length; i++) {
     if (ls[i] instanceof ClickListener) {
       Err.error("Already have a ClickListenerI on " + comp.getName());
     }
   }
   result = new ClickListener((ItemAdapter) itemAdapter);
   return result;
 }
 public void startTx(String reason) {
   times++;
   Object pm = null;
   if (getEM() != null) {
     pm = getEM().getActualEM();
   }
   Err.pr(
       JDONote.RELOAD_PM_KODO_BUG,
       reason + " in " + this + " with pm: " + pm + " times " + times + " isOnTxn " + isOnTx());
   super.startTx(reason);
 }
 public void setValueAt(Object aValue, int row, int col) {
   int current = applyInsertModeForCursor(block.getIndex());
   /**/
   if (row != current) {
     Err.error("Should be updating the current row, " + current + " not " + row + " for " + block);
     // block.setIndex( true, row);
   }
   /**/
   TableIdEnum id = IdEnum.newTable(getTableControl(), row, col, getColumnClass(col), null);
   TableSignatures.setText(id, aValue);
 }
 /**
  * When the user clicks on this control it calls this, its own action listener method, which
  * propogates the event as well as doing the visible changes.
  */
 public void actionPerformed(ActionEvent e) {
   int shiftToIndex;
   if (e.getSource() == getLShiftRight()) {
     shiftToIndex = getSelected() + 1;
     if (shiftToIndex == labels.length) {
       shiftToIndex = 0;
     }
   } else {
     // Err.pr( "Clicked on a dynamic label called: <" + e.getActionCommand() + ">");
     shiftToIndex = findIndexOfTitle(((NoEdgedButton) e.getSource()).getText());
   }
   if (shiftToIndex != getSelected()) {
     Err.pr(
         SdzNote.EXPANDER_IDX,
         "<"
             + this.getName()
             + "> needs change index to <"
             + shiftToIndex
             + "> from <"
             + getSelected()
             + ">");
     ActionListener actionListener = getActionListener();
     if (actionListener != null) {
       JLabel label = getLabel(shiftToIndex);
       ActionEvent event = new ActionEvent(label, ActionEvent.ACTION_PERFORMED, label.getText());
       actionListener.actionPerformed(event);
     } else {
       Err.pr("No actionListener on <" + getName() + ">");
     }
     setSelected(shiftToIndex);
     for (int i = 0; i < changeListeners.size(); i++) {
       ChangeListener changeListener = changeListeners.get(i);
       ChangeEvent changeEvent = new ChangeEvent(this);
       changeListener.stateChanged(changeEvent);
     }
   } else {
     Err.pr(
         SdzNote.EXPANDER_IDX,
         this.getName() + " thinks that <" + shiftToIndex + "> is already the current index");
   }
 }
 /**
  * Always called on by a server. Getting an EM takes time. On the client it is always done in its
  * own special task.
  *
  * @param enumIdWombat
  */
 public static CayenneWombatDataStore newInstance(WombatConnectionEnum enumIdWombat) {
   CayenneWombatDataStore result;
   Err.pr("Server service: " + enumIdWombat);
   WombatConnections connections = new WombatConnections();
   CayenneSecureConnectionInfo connectionInfo =
       (CayenneSecureConnectionInfo) connections.get(enumIdWombat);
   result = new CayenneWombatDataStore(connectionInfo);
   Err.pr("To try to get an EM");
   /*
   SdzEntityManagerI emI = EntityManagerFactory.createSdzEMI(
       connectionInfo.getORMType(),
       result.getConnectionConfigString(), null);
   */
   SdzEntityManagerI emI =
       CayenneEntityManagerFactory.createSdzEMI(
           result.getCayenneORMType(),
           result.getConnection().getConfigStringName(),
           result.getConnection().getProperties());
   Err.pr("em: " + emI);
   return result;
 }
 /** Rather than using this method, consider finding the button and doing doClick(). */
 public void setSelected(int selected) {
   // Err.pr( "Selecting <" + selected + "> in <" + getName() + "> ID: " + getId());
   if (!BeansUtils.isDesignTime()) {
     // Err.pr( "Not design time, so must be responding to user");
     init(getTitles(labels), selected, getExplanation(), getExtras());
     /* Don't do this, will be recursive Doh!
     ((NoEdgedButton)labels[selected]).doClick();
     */
   } else {
     Err.pr("Design time, so skipping rebuilding");
   }
   this.selected = selected;
 }
 /**
  * Get the connection properties depending on which enumIdWombat are connecting to. Also there are
  * two types of connections. One, the server, is to the actual database. The other type of
  * connection is a client connection, which connects to the server. From the client's point of
  * view this server is know as a host. (The host serves the guest/client). If
  * !fromJDOConnectionServer then we are currently at a client. There is only ever one server for a
  * client, so the logic in here sets the host property in this case.
  *
  * @param connectionInfo
  */
 public CayenneWombatDataStore(CayenneSecureConnectionInfo connectionInfo) {
   Err.pr("Creating a CayenneWombatDataStore");
   boolean client = connectionInfo.getORMType() == ORMTypeEnum.CAYENNE_CLIENT;
   // boolean client = true;
   super.setClasses(CayenneWombatData.getInstance(client).getClasses());
   Assert.isTrue(connectionInfo.getORMType().isCayenne());
   setEstimatedConnectDuration(connectionInfo.getEstimatedConnectDuration());
   setEstimatedLookupDataDuration(connectionInfo.getEstimatedLoadLookupDataDuration());
   setErrorThrower(Session.getErrorThrower());
   setConnectionConfigString(connectionInfo.getConfigStringName());
   setCayenneORMType(connectionInfo.getORMType());
   setDomainQueries(new CayenneWombatDomainQueries(client));
   setName(connectionInfo.getName());
 }
Exemple #22
0
 public StartupKodo() {
   RosterSessionUtils.setMemoryProperty("thickClient", "false");
   if (CONNECTION == WombatConnectionEnum.REMOTE_WOMBAT_KODO) {
     RosterSessionUtils.setMemoryProperty("live", "true");
   } else {
     RosterSessionUtils.setMemoryProperty("live", "false");
   }
   RosterSessionUtils.setMemoryProperty("memory", "false");
   init();
   Err.setVisualDurationMonitor(true);
   dataStoreFactory.addConnection(CONNECTION);
   if (CONNECTION == WombatConnectionEnum.REMOTE_WOMBAT_KODO) {
     PropertiesChecker propertiesChecker =
         new PropertiesChecker(getPropertyFileName(), properties, this.getClass().getName());
     propertiesChecker.chkSecureServicePropertiesSet();
   }
 }
 /** Setup data so will give a full roster no matter which month, no matter what time */
 private void populateFromDemoData() {
   SdzEntityManagerI pm = dataStore.getEM();
   pm.registerPersistentAll(demoDataCayenne.newWorkers);
   pm.registerPersistentAll(demoDataCayenne.newBMs);
   pm.registerPersistentAll(demoDataCayenne.newRSs);
   pm.registerPersistentAll(demoDataCayenne.newUsers);
   pm.registerPersistentAll(
       demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_DAY_IN_WEEK));
   pm.registerPersistentAll(
       demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_FLEXIBILITY));
   pm.registerPersistentAll(
       demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_MONTH_IN_YEAR));
   pm.registerPersistentAll(
       demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_INTERVAL));
   pm.registerPersistentAll(
       demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_FLEXIBILITY));
   pm.registerPersistentAll(
       demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_SENIORITY));
   pm.registerPersistentAll(demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_SEX));
   pm.registerPersistentAll(
       demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_WEEK_IN_MONTH));
   pm.registerPersistentAll(
       demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_WHICH_SHIFT));
   Err.pr(
       "Population complete, have added "
           + demoDataCayenne.newWorkers.size()
           + " Workers and "
           + demoDataCayenne.newRSs.size()
           + " RosterSlots and "
           + demoDataCayenne.newUsers.size()
           + " UserDetails and "
           + demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_SENIORITY).size()
           + " Seniorities and "
           + demoDataCayenne.newBMs.size()
           + " BuddyManagers to the database");
   Print.prList(
       demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_SENIORITY), "seniorities");
 }
 private static void update(Collection list) {
   int timesFound = 0;
   Worker nullWorker = null;
   for (Iterator iter = list.iterator(); iter.hasNext(); ) {
     Worker vol = (Worker) iter.next();
     if (
     // (
     // vol.getChristianName() != null &&
     // vol.getChristianName().equals( "Bart")
     // ) ||
     vol.equals(Worker.NULL)) {
       timesFound++;
       if (timesFound > 1) {
         Err.error("Should only be one NULL volunteer");
       }
       nullWorker = vol;
       Err.pr("NULL vol have found is " + nullWorker);
     }
   }
   if (nullWorker == null) {
     Err.pr("Could not find a worker equal to NULL, so creating one");
     nullWorker = new Worker();
   }
   nullWorker.setDummy(true);
   Err.pr(
       JDONote.APPEARS_CONSTRUCTOR_NOT_CALLED,
       "Why have to do this - Worker's constructor s/do it");
   if (nullWorker.getBelongsToGroup() != null) {
     Err.pr(JDONote.APPEARS_CONSTRUCTOR_NOT_CALLED, "appears Constructor was called");
   } else {
     Err.pr(JDONote.APPEARS_CONSTRUCTOR_NOT_CALLED, "appears Constructor was NOT called");
   }
   nullWorker.setBelongsToGroup(nullWorker);
   dataStore.getEM().registerPersistent(nullWorker);
   Err.pr("MADE A NULL WORKER, " + nullWorker);
 }
 public void setMethod(Object fieldComponent, Object arg) {
   Err.error(
       "Either have not specified a setMethod method in *ControlInfoImpl "
           + "or have not overridden this method in a subclass");
 }
 public void removeMouseListener(MouseListener l) {
   Err.error("Code now!");
   super.removeMouseListener(l);
 }
 /**
  * Current reference value is implicitly set. Are careful to insert in same relative order,
  * although this depends on hugeList being an ordered list (later NavExtent can have an isOrdered
  * method so can code both ways).
  */
 public void insert(Object obj, int index) {
   tie.setFieldValue(obj, referenceValue);
   Err.pr(SdzNote.BG_ADD, "--------------ReferenceExtent.insert()ing " + obj);
   displayList.add(index, obj);
   relativePositionInsert(obj, displayList, hugeList);
 }
 public Object getMethod(Object fieldComponent) {
   Err.error(
       "Either have not specified a get method in *ControlInfoImpl "
           + "or have not overridden this method in a subclass");
   return null;
 }
  public void init(
      List<String> titles, int selected, String explanation, List<ExpanderControlTransObj> extras) {
    this.selected = selected;
    Err.pr(SdzNote.EXPANDER_IDX, "init on <" + getName() + ">, selected <" + selected + ">");
    if (SdzNote.EXPANDER_IDX.isVisible() && "chkIntoExisting".equals(getName()) && selected == 0) {
      Err.pr("Selecting 0 not happening on DB (solution was to write toString())");
    }
    removeAll();
    ModernTableLayout modernTableLayout = new ModernTableLayout();
    modernTableLayout.insertColumn(0, LEFT_EDGE_WIDTH);
    modernTableLayout.insertColumn(1, 25 - LEFT_EDGE_WIDTH);
    modernTableLayout.insertColumn(2, GAP_WIDTH);
    int count = NUM_LEAD_COLS;
    for (int i = 0; i < titles.size(); i++) {
      String title = titles.get(i);
      long labelWidth;
      if (sizeIncreasesWhenSelected) {
        labelWidth = WidgetUtils.calcPixelWidthOfStringOnComponent(title, TYPICAL_BIG_CONTAINER);
      } else {
        labelWidth = WidgetUtils.calcPixelWidthOfStringOnComponent(title, TYPICAL_SIZED_CONTAINER);
      }
      modernTableLayout.insertColumn(count, labelWidth);
      count++;
      IconLabel iconLabel = getIconLabelAt(i, extras);
      if (iconLabel != null) {
        Icon icon = iconLabel.getIcon();
        if (icon != null) {
          modernTableLayout.insertColumn(count, icon.getIconWidth() + 7);
          count++;
        } else {
          Err.error("Expect there to always be an icon in an IconLabel");
        }
      }
      modernTableLayout.insertColumn(count, GAP_WIDTH);
      count++;
    }
    modernTableLayout.insertRow(0, ModernTableLayout.FILL);
    setLayout(modernTableLayout);
    NoEdgedButton[] labels = new NoEdgedButton[titles.size()];
    lShiftRight = new NoEdgedButton();
    add(lShiftRight, "1,0");
    count = NUM_LEAD_COLS;
    for (int i = 0; i < titles.size(); i++) {
      NoEdgedButton item = new NoEdgedButton();
      addMouseListeners(item, mouseListeners);
      item.setActionListener(this);
      if (i == selected) {
        if (sizeIncreasesWhenSelected) {
          item.setFont(BIG_BOLD_FONT);
        } else {
          item.setFont(BOLD_FONT);
        }
        if (foregroundChangesWhenSelected) {
          item.setForeground(PURPLE);
        }
      } else {
        item.setFont(NORMAL_FONT);
        item.setForeground(null);
      }
      item.setName("lExpander control item number " + i);
      String title = titles.get(i);
      item.setText(title);
      item.setHorizontalAlignment(SwingConstants.LEADING);
      add(item, count + ", 0");
      count++;
      IconLabel iconLabel = getIconLabelAt(i, extras);
      if (iconLabel != null) {
        addMouseListeners(iconLabel, mouseListeners);
        add(iconLabel, count + ", 0");
        count++;
      }
      count++;
      labels[i] = item;
      if (extras != null && extras.size() > i) {
        if (extras.get(i).getBackground() != null) {
          labels[i].setOpaque(true);
          labels[i].setBackground(extras.get(i).getBackground());
        } else {
          // Err.error( "Do we just setBackground() to null and opaque to false?");
          labels[i].setOpaque(false);
          labels[i].setBackground(null);
        }
        if (selected == i && foregroundChangesWhenSelected) {
          /*
           * Never override the selected foreground being purple if
           * selected being purple is what has been specified.
           */
        } else {
          if (extras.get(i).getForeground() != null) {
            labels[i].setForeground(extras.get(i).getForeground());
          } else {
            labels[i].setForeground(null);
          }
        }
        if (extras.get(i).getToolTipText() != null) {
          labels[i].setToolTipText(extras.get(i).getToolTipText());
        } else {
          labels[i].setToolTipText(null);
        }
        if (iconLabel != null) {
          if (extras.get(i).getIconToolTipText() != null) {
            iconLabel.setToolTipText(extras.get(i).getIconToolTipText());
          } else {
            iconLabel.setToolTipText(null);
          }
        }
      }
    }

    lShiftRight.setName("lShiftRight");
    lShiftRight.setToolTipText(explanation);
    lShiftRight.setActionListener(this);
    PortableImageIcon portableImageIcon =
        PortableImageIcon.createImageIcon(
            "images/control_end_blue.png", "Change View", PortableImageIcon.STDERR_MSG);
    if (portableImageIcon != null) {
      lShiftRight.setIcon(portableImageIcon);
    }

    setLShiftRight(lShiftRight);
    setName("ExpanderControl");
    setLabels(labels);
    setExplanation(explanation);
    /*
    setBackgrounds( backgrounds);
    setForegrounds( foregrounds);
    setToolTipTexts( toolTipTexts);
    */
    setExtras(extras);
  }
 public void requestFocusMethod(Object fieldComponent) {
   Err.error(
       "Either have not specified a requestFocus method in *ControlInfoImpl "
           + "or have not overridden this method in a subclass");
 }