Ejemplo n.º 1
0
    public void extractPatternInfo(Pattern pattern) {
      if (pattern.getType() != PatternType.STATE) {
        // execute a command on the context that will notify the user about this
      }

      selectedPatternName.setText(pattern.getName());
      selectedPatternClass.setText(pattern.getPatternClass());
      selectedPatternId.setText(pattern.getId());
      selectedPatternDescription.setText(pattern.getDescription());
      selectedPatternQuestion.setText(pattern.getQuestion());
    }
Ejemplo n.º 2
0
 public void patternSelected(Pattern p) {
   if (p.getType() == PatternType.PROPERTY) {}
 }
Ejemplo n.º 3
0
    private JPanel makeCentrePanel() {
      JPanel panel = new JPanel(new BorderLayout());

      JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

      // Set up the construction panel
      JPanel constructionPanel = new JPanel(new BorderLayout());
      sp.setTopComponent(constructionPanel);

      Pattern p = new Pattern();
      p.setName("Property pattern 1");
      p.setId("PropP1");
      p.setDescription("This is a demo PROPERTY pattern to test the display method");
      p.setPatternClass("State pattern class1");
      p.setPatternType(PatternType.PROPERTY);
      p.setQuestion("A state [s] persists indefinitely.");

      // first init all components that will fit here;
      selectedPatternName = new JLabel("");
      selectedPatternName.setForeground(componentForeground);
      selectedPatternId = new JLabel("");
      selectedPatternId.setForeground(componentForeground);
      selectedPatternClass = new JLabel("");
      selectedPatternClass.setForeground(componentForeground);
      selectedPatternDescription = new JTextArea(3, 20);
      selectedPatternDescription.setBorder(
          BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Description"));
      selectedPatternDescription.setEditable(false);
      selectedPatternDescription.setForeground(componentForeground);
      selectedPatternQuestion = new JLabel("");
      selectedPatternQuestion.setForeground(componentForeground);
      stateResultta = new JTextArea(3, 20);
      stateResultta.setForeground(componentForeground);
      stateResultta.setText("Property formula goes here (ex: P=? [ (x > 0) U true ]");
      extractPatternInfo(p);

      JPanel aux1 = new JPanel(new BorderLayout());
      aux1.setBorder(
          BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Pattern Details"));
      JPanel aux2 = new JPanel(new FlowLayout(FlowLayout.LEADING));
      aux2.add(new JLabel("Pattern: "));
      aux2.add(selectedPatternName);
      aux2.add(new JLabel("ID: "));
      aux2.add(selectedPatternId);

      aux1.add(aux2, BorderLayout.NORTH);
      aux1.add(selectedPatternDescription, BorderLayout.CENTER);
      constructionPanel.add(aux1, BorderLayout.NORTH);

      aux1 = new JPanel(new BorderLayout());
      aux1.setBorder(
          BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Builder"));
      JPanel templatePanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
      templatePanel.add(new JLabel("Template: "));
      templatePanel.add(selectedPatternQuestion);
      aux1.add(templatePanel, BorderLayout.NORTH);
      aux1.add(stateResultta, BorderLayout.SOUTH);

      aux2 = new JPanel(new FlowLayout(FlowLayout.LEADING));
      aux2.add(new JLabel("A state "));
      aux2.add(new JComboBox(new String[] {"state1", "state2", "state3"}));
      aux2.add(new JLabel(" persists indefinitely."));
      aux1.add(aux2, BorderLayout.CENTER);

      constructionPanel.add(aux1, BorderLayout.CENTER);

      // set up the states panel
      String[] tempStates = new String[40];
      for (int i = 0; i < tempStates.length; i++) {
        tempStates[i] = "Property " + i;
      }

      stateList = new StateJList(tempStates);
      JScrollPane listContainer = new JScrollPane(stateList);
      listContainer.setBorder(
          BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Properties"));
      sp.setBottomComponent(listContainer);

      panel.add(sp);

      return panel;
    }