Esempio n. 1
0
 public static void drawImage(int[][][] pixels, int startX, int startY) {
   // Key idea: draw a bunch (lots of rectangles) with the appropriate color
   DrawObject R = new DrawObject();
   R.pixels = pixels;
   R.startX = startX;
   R.startY = startY;
   R.sequenceNum = currentSequenceNum;
   images.add(R);
   // Rescale if needed.
   int leftX = startX;
   int rightX = startX + pixels.length;
   int lowY = startY;
   int highY = startY + pixels[0].length;
   if (minX > leftX) {
     minX = leftX;
   }
   if (maxX < rightX) {
     maxX = rightX;
   }
   if (minY > lowY) {
     minY = lowY;
   }
   if (maxY < highY) {
     maxY = highY;
   }
   drawArea.repaint();
 }
Esempio n. 2
0
  // takes the most recently enetered keystroke
  // return true if the player has just completed the cheat
  // return false otherwise
  public boolean nextKey(int k) {
    if (cheatCode.get(keys.size()) == k) {
      keys.add(k);
      if (keys.size() == cheatCode.size()) {
        keys.clear();
        return true;
      } else return false;
    }

    // else the player has messed up and has to start over

    keys.clear();
    if (cheatCode.get(0) == k)
      keys.add(k); // if the incorrect keystroke is the start of the sequence we'll use it
    return false;
  }
 public void init(java.util.List<Pair<String, TextWithImports>> data) {
   myData.clear();
   for (Iterator<Pair<String, TextWithImports>> it = data.iterator(); it.hasNext(); ) {
     final Pair<String, TextWithImports> pair = it.next();
     myData.add(new Row(pair.getFirst(), pair.getSecond()));
   }
 }
 public synchronized void actionPerformed(ActionEvent e) {
   java.util.List<JComponent> componentsToRemove = null;
   java.util.List<Part> partsToRemove = null;
   for (JComponent component : animationStateMap.keySet()) {
     component.repaint();
     if (partsToRemove != null) {
       partsToRemove.clear();
     }
     Map<Part, AnimationState> map = animationStateMap.get(component);
     if (!component.isShowing() || map == null || map.size() == 0) {
       if (componentsToRemove == null) {
         componentsToRemove = new ArrayList<JComponent>();
       }
       componentsToRemove.add(component);
       continue;
     }
     for (Part part : map.keySet()) {
       if (map.get(part).isDone()) {
         if (partsToRemove == null) {
           partsToRemove = new ArrayList<Part>();
         }
         partsToRemove.add(part);
       }
     }
     if (partsToRemove != null) {
       if (partsToRemove.size() == map.size()) {
         // animation is done for the component
         if (componentsToRemove == null) {
           componentsToRemove = new ArrayList<JComponent>();
         }
         componentsToRemove.add(component);
       } else {
         for (Part part : partsToRemove) {
           map.remove(part);
         }
       }
     }
   }
   if (componentsToRemove != null) {
     for (JComponent component : componentsToRemove) {
       animationStateMap.remove(component);
     }
   }
   if (animationStateMap.size() == 0) {
     timer.stop();
   }
 }
Esempio n. 5
0
 static void handleMouseDragged(MouseEvent e) {
   DrawObject L = new DrawObject();
   L.scribbleX = e.getX();
   L.scribbleY = e.getY();
   L.scribbleNum = currentScribbleNum;
   scribbles.add(L);
   drawArea.repaint();
 }
Esempio n. 6
0
 public static void drawPoint(double x, double y) {
   DrawObject p = new DrawObject();
   p.color = pointColor;
   p.x = x;
   p.y = y;
   p.diameter = pointDiameter;
   p.sequenceNum = currentSequenceNum;
   if (animationMode) {
     synchronized (animPoints) {
       animPoints.add(p);
     }
   } else {
     synchronized (points) {
       points.add(p);
     }
   }
   drawArea.repaint();
 }
Esempio n. 7
0
 public static void drawLabel(double x, double y, String str) {
   DrawObject L = new DrawObject();
   L.color = labelColor;
   L.x = x;
   L.y = y;
   L.str = str;
   L.sequenceNum = currentSequenceNum;
   if (animationMode) {
     synchronized (animLabels) {
       animLabels.add(L);
     }
   } else {
     synchronized (labels) {
       labels.add(L);
     }
   }
   drawArea.repaint();
 }
 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()]);
 }
Esempio n. 9
0
 public static void drawRectangle(double x1, double y1, double width, double height) {
   DrawObject R = new DrawObject();
   R.color = rectangleColor;
   R.x = x1;
   R.y = y1;
   R.width = width;
   R.height = height;
   R.sequenceNum = currentSequenceNum;
   R.drawStroke = drawStroke;
   if (animationMode) {
     synchronized (animRectangles) {
       animRectangles.add(R);
     }
   } else {
     synchronized (rectangles) {
       rectangles.add(R);
     }
   }
   drawArea.repaint();
 }
Esempio n. 10
0
 public void addRow(Component... components) {
   remove(puff);
   final JPanel row = new JPanel();
   row.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseClicked(MouseEvent event) {
           gui.notifyObserver("/use " + rows.indexOf(event.getSource()));
         }
       });
   row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS));
   // row.add(Box.createHorizontalStrut(3));
   row.setMinimumSize(new Dimension(10, 30));
   row.setMaximumSize(new Dimension(250, 30));
   for (Component component : components) {
     row.add(component);
   }
   JButton red = new JButton("x");
   red.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent event) {
           int deleted = rows.indexOf(row);
           gui.notifyObserver("/use " + deleted);
           gui.notifyObserver("/disconnect");
         }
       });
   red.setBackground(Color.PINK.darker());
   red.setForeground(Color.WHITE);
   row.add(Box.createHorizontalGlue());
   row.add(red);
   rows.add(row);
   Component strut = Box.createVerticalStrut(5);
   struts.add(strut);
   add(row);
   add(strut);
   add(puff);
   repaint();
   updateUI();
 }
Esempio n. 11
0
 private void loadLieferant() {
   EntityManager em = Main.getEMF().createEntityManager();
   Query query = em.createQuery("SELECT l FROM Lieferanten l ORDER BY l.firma");
   try {
     java.util.List lieferant = query.getResultList();
     lieferant.add(0, "<html><i>Lieferant nicht &auml;ndern</i></html>");
     cmbLieferant.setModel(tools.Tools.newComboboxModel(new ArrayList<Lieferanten>(lieferant)));
   } catch (Exception e) { // nicht gefunden
     //
   } finally {
     em.close();
   }
 }
Esempio n. 12
0
  @Override
  public void setAIChoices(String[] value) {

    java.util.List<String> choiceList = new ArrayList<String>();
    for (String v : value) {
      choiceList.add(v);
    }

    aiModel.setList(choiceList);

    if (value.length > 0) {
      aiChoices.setValue(value[0]);
    }
  }
Esempio n. 13
0
 public static void drawLineFromEquation(double a, double b, double c) {
   // Draw the equation ax+by+c=0 in the available range.
   DrawObject L = new DrawObject();
   L.color = lineEqnColor;
   L.a = a;
   L.b = b;
   L.c = c;
   L.sequenceNum = currentSequenceNum;
   L.drawStroke = drawStroke;
   synchronized (eqnLines) {
     eqnLines.add(L);
   }
   drawArea.repaint();
 }
  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);
    }
  }
Esempio n. 15
0
 public static void drawLine(double x1, double y1, double x2, double y2, boolean isArrow) {
   DrawObject L = new DrawObject();
   L.color = lineColor;
   L.x = x1;
   L.y = y1;
   L.x2 = x2;
   L.y2 = y2;
   if (isArrow) {
     L.color = arrowColor;
     L.isArrow = true;
   }
   L.sequenceNum = currentSequenceNum;
   L.drawStroke = drawStroke;
   if (animationMode) {
     synchronized (animLines) {
       animLines.add(L);
     }
   } else {
     synchronized (lines) {
       lines.add(L);
     }
   }
   drawArea.repaint();
 }
 String[] getContactList() {
   java.util.List cl = new java.util.LinkedList();
   StringTokenizer st = new StringTokenizer(contactList.getText());
   StringBuffer sb = new StringBuffer();
   StringBuffer dbg = new StringBuffer("test applet contactlist: ");
   while (st.hasMoreTokens()) {
     String loginId = st.nextToken().trim();
     if (loginId.length() == 0) continue;
     dbg.append("'" + loginId + "' ");
     cl.add(loginId);
     sb.append(loginId).append('\n');
   }
   CAT.info(dbg.toString());
   contactList.setText(sb.toString());
   return (String[]) cl.toArray(new String[cl.size()]);
 }
Esempio n. 17
0
  private void print(Printer printer, Form form, String printername) {

    java.util.List<PrintListElement> printList = new ArrayList(tblVorrat.getRowCount());
    PrintProcessor pp = ((FrmDesktop) Main.mainframe).getPrintProcessor();

    int[] rows = tblVorrat.getSelectedRows();

    for (int r = 0; r < rows.length; r++) {
      int row = tblVorrat.convertRowIndexToModel(rows[r]);
      Stock stock = ((StockTableModel) tblVorrat.getModel()).getVorrat(row);
      printList.add(new PrintListElement(stock, printer, form, printername));
    }

    Collections.sort(printList); // Sortieren nach den PrimaryKeys
    pp.addPrintJobs(printList);
  }
Esempio n. 18
0
  private static JRadioButton[] buildLangButtons() {
    java.util.List<JRadioButton> btns = new java.util.ArrayList<JRadioButton>();

    for (Language lng : LANGS) {
      JRadioButton btn = new JRadioButton(lng.toString());
      btn.setText(lng.toString());
      btns.add(btn);
    }

    final ButtonGroup group = new ButtonGroup();
    for (final JRadioButton jrb : btns) {
      group.add(jrb);
    }

    JRadioButton[] res = new JRadioButton[btns.size()];
    return btns.toArray(res);
  }
  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);
    }
  }
Esempio n. 20
0
  protected void setPolygonHeight(Point previousMousePoint, Point mousePoint) {
    // Find the closest points between the rays through each screen point, and the ray from the
    // control point
    // and in the direction of the globe's surface normal. Compute the elevation difference between
    // these two
    // points, and use that as the change in polygon height.

    Position referencePos = this.polygon.getReferencePosition();
    if (referencePos == null) return;

    Vec4 referencePoint = this.wwd.getModel().getGlobe().computePointFromPosition(referencePos);

    Vec4 surfaceNormal =
        this.wwd
            .getModel()
            .getGlobe()
            .computeSurfaceNormalAtLocation(
                referencePos.getLatitude(), referencePos.getLongitude());
    Line verticalRay = new Line(referencePoint, surfaceNormal);
    Line screenRay =
        this.wwd.getView().computeRayFromScreenPoint(mousePoint.getX(), mousePoint.getY());
    Line previousScreenRay =
        this.wwd
            .getView()
            .computeRayFromScreenPoint(previousMousePoint.getX(), previousMousePoint.getY());

    Vec4 pointOnLine = AirspaceEditorUtil.nearestPointOnLine(verticalRay, screenRay);
    Vec4 previousPointOnLine =
        AirspaceEditorUtil.nearestPointOnLine(verticalRay, previousScreenRay);

    Position pos = this.wwd.getModel().getGlobe().computePositionFromPoint(pointOnLine);
    Position previousPos =
        this.wwd.getModel().getGlobe().computePositionFromPoint(previousPointOnLine);
    double elevationChange = pos.getElevation() - previousPos.getElevation();

    java.util.List<Position> boundary = new ArrayList<Position>();
    for (LatLon ll : this.polygon.getOuterBoundary()) {
      boundary.add(new Position(ll, ((Position) ll).getElevation() + elevationChange));
    }

    this.polygon.setOuterBoundary(boundary);
  }
Esempio n. 21
0
  protected void moveControlPoint(
      ControlPointMarker controlPoint, Point lastMousePoint, Point moveToPoint) {
    View view = this.wwd.getView();
    Globe globe = this.wwd.getModel().getGlobe();

    Position refPos = controlPoint.getPosition();
    if (refPos == null) return;

    Line ray = view.computeRayFromScreenPoint(moveToPoint.getX(), moveToPoint.getY());
    Line previousRay = view.computeRayFromScreenPoint(lastMousePoint.getX(), lastMousePoint.getY());

    Vec4 vec = AirspaceEditorUtil.intersectGlobeAt(this.wwd, refPos.getElevation(), ray);
    Vec4 previousVec =
        AirspaceEditorUtil.intersectGlobeAt(this.wwd, refPos.getElevation(), previousRay);

    if (vec == null || previousVec == null) {
      return;
    }

    Position pos = globe.computePositionFromPoint(vec);
    Position previousPos = globe.computePositionFromPoint(previousVec);
    LatLon change = pos.subtract(previousPos);

    java.util.List<LatLon> boundary = new ArrayList<LatLon>();
    for (LatLon ll : this.polygon.getOuterBoundary()) {
      boundary.add(ll);
    }

    boundary.set(controlPoint.getIndex(), new Position(pos.add(change), refPos.getAltitude()));

    // ExtrudedPolygon ensures that the last boundary position is the same as the first. Remove the
    // last point
    // before setting the boundary.
    boundary.remove(boundary.size() - 1);

    this.polygon.setOuterBoundary(boundary);
  }
 private void setupIcons(JDialog dialog) {
   java.util.List list = new ArrayList();
   list.add(imageIcon.getImage());
   list.add(imageIconBig.getImage());
   dialog.setIconImages(list);
 }
Esempio n. 23
0
 public void addRow(final String name, final TextWithImports expressionWithImports) {
   myData.add(new Row(name, expressionWithImports));
   final int lastRow = myData.size() - 1;
   fireTableRowsInserted(lastRow, lastRow);
 }
Esempio n. 24
0
 public void addLanguageSelectionListener(LanguageListener listener) {
   langListeners.add(listener);
 }
  private java.util.List<Component> addCommands() {
    java.util.List<Component> list = new ArrayList<Component>();

    /** * _ _ | \ | | _____ __ | \| |/ _ \ \ /\ / / | |\ | __/\ V V / |_| \_|\___| \_/\_/ */
    JideButton addButton =
        GUITools.createHyperlinkButton(
            SYSTools.xx("misc.commands.new"),
            new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")),
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent actionEvent) {
                if (!resident.isActive()) {
                  OPDE.getDisplayManager()
                      .addSubMessage(new DisplayMessage("misc.msg.cantChangeInactiveResident"));
                  return;
                }
                new DlgValue(
                    new ResValue(resident, LIQUIDBALANCE),
                    DlgValue.MODE_NEW,
                    new Closure() {
                      @Override
                      public void execute(Object o) {
                        ResValue myValue = null;

                        if (o != null) {

                          EntityManager em = OPDE.createEM();
                          try {
                            em.getTransaction().begin();
                            myValue = em.merge((ResValue) o);
                            em.lock(em.merge(resident), LockModeType.OPTIMISTIC);
                            em.getTransaction().commit();

                          } catch (OptimisticLockException ole) {
                            OPDE.warn(ole);
                            if (em.getTransaction().isActive()) {
                              em.getTransaction().rollback();
                            }
                            if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                              OPDE.getMainframe().emptyFrame();
                              OPDE.getMainframe().afterLogin();
                            }
                            OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
                          } catch (Exception e) {
                            if (em.getTransaction().isActive()) {
                              em.getTransaction().rollback();
                            }
                            OPDE.fatal(e);
                          } finally {
                            em.close();
                          }

                          startDay = new LocalDate(myValue.getPit());
                          loadLeftTable();
                          loadRightTable(startDay, startDay);
                        }
                      }
                    });
              }
            });
    list.add(addButton);

    JideButton controlButton =
        GUITools.createHyperlinkButton(
            SYSTools.xx("nursingrecords.vitalparameters.btnControlling.tooltip"),
            SYSConst.icon22magnify1,
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent actionEvent) {
                if (!resident.isActive()) {
                  OPDE.getDisplayManager()
                      .addSubMessage(new DisplayMessage("misc.msg.cantChangeInactiveResident"));
                  return;
                }
                new DlgValueControl(
                    resident,
                    new Closure() {
                      @Override
                      public void execute(Object o) {
                        if (o != null) {
                          EntityManager em = OPDE.createEM();
                          try {
                            em.getTransaction().begin();
                            Resident myResident = em.merge(resident);
                            em.lock(myResident, LockModeType.OPTIMISTIC);
                            myResident.setControlling((Properties) o);
                            em.getTransaction().commit();
                            resident = myResident;
                          } catch (OptimisticLockException ole) {
                            OPDE.warn(ole);
                            if (em.getTransaction().isActive()) {
                              em.getTransaction().rollback();
                            }
                            if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                              OPDE.getMainframe().emptyFrame();
                              OPDE.getMainframe().afterLogin();
                            }
                            OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
                          } catch (Exception e) {
                            if (em.getTransaction().isActive()) {
                              em.getTransaction().rollback();
                            }
                            OPDE.fatal(e);
                          } finally {
                            em.close();
                          }
                          parseControlling();
                          loadLeftTable();
                        }
                      }
                    });
              }
            });
    list.add(controlButton);

    return list;
  }
Esempio n. 26
0
  // constructor takes variable number of arguments and puts them in cheatCode list
  public Cheat(int... c) {
    cheatCode = new ArrayList<Integer>();
    keys = new ArrayList<Integer>();

    for (int i = 0; i < c.length; i++) cheatCode.add(c[i]);
  }
  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);
      }
    }
  }
Esempio n. 28
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);
    }
  }
Esempio n. 29
0
  private void playerSetup() {

    players = new ArrayList(twoPlayerRB.isSelected() ? 2 : 1);
    if (mouseRB.isSelected()) {
      MouseControlledPlayer p1 =
          new MouseControlledPlayer(width / 2, height / 2, 3, true, this, 3, 1, width);
      addMouseMotionListener(p1);
      addMouseListener(p1);
      players.add(p1);
    } else {
      KeyboardControlledPlayer p1 =
          new KeyboardControlledPlayer(
              width / 2,
              height / 2,
              3,
              true,
              this,
              3,
              KeyEvent.VK_W,
              KeyEvent.VK_A,
              KeyEvent.VK_S,
              KeyEvent.VK_D,
              keyboardSpeedS1.getValue(),
              KeyEvent.VK_SPACE,
              KeyEvent.VK_F,
              1,
              width);
      KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(p1);
      players.add(p1);
    }

    if (twoPlayerRB.isSelected()) {
      if (mouseRB.isSelected()) {
        KeyboardControlledPlayer p2 =
            new KeyboardControlledPlayer(
                width / 2,
                height / 2,
                3,
                true,
                this,
                3,
                KeyEvent.VK_W,
                KeyEvent.VK_A,
                KeyEvent.VK_S,
                KeyEvent.VK_D,
                keyboardSpeedS2.getValue(),
                KeyEvent.VK_SPACE,
                KeyEvent.VK_F,
                2,
                width);
        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(p2);
        players.add(p2);
      } else {
        KeyboardControlledPlayer p2 =
            new KeyboardControlledPlayer(
                width / 2,
                height / 2,
                3,
                true,
                this,
                3,
                KeyEvent.VK_NUMPAD8,
                KeyEvent.VK_NUMPAD4,
                KeyEvent.VK_NUMPAD5,
                KeyEvent.VK_NUMPAD6,
                keyboardSpeedS2.getValue(),
                KeyEvent.VK_NUMPAD0,
                KeyEvent.VK_NUMPAD1,
                2,
                width);
        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(p2);
        players.add(p2);
      }
    }
  }