Ejemplo n.º 1
0
 public static void addPropertyToPropertyMap(String s, StringProperty stringproperty) {
   PropertyTable propertytable = (PropertyTable) cPropertyMap.get(s);
   if (propertytable == null) {
     return;
   } else {
     propertytable.add(stringproperty.name, stringproperty);
     return;
   }
 }
Ejemplo n.º 2
0
  protected static void addProperties(String s, StringProperty astringproperty[]) {
    Class class1;
    try {
      class1 = Class.forName(s);
    } catch (ClassNotFoundException classnotfoundexception) {
      System.out.println("Class " + s + " not found in AddProperties");
      return;
    }
    Class class2 = class1.getSuperclass();
    PropertyTable propertytable = (PropertyTable) cPropertyMap.get(class2.getName());
    PropertyTable propertytable1 = new PropertyTable(propertytable);
    for (int i = 0; i < astringproperty.length; i++) {
      propertytable1.add(astringproperty[i].name, astringproperty[i]);
    }

    cPropertyMap.put(s, propertytable1);
    cClassValues.put(s, new HashMap());
  }
Ejemplo n.º 3
0
  @Override
  public PropertyTable createPropertyTable() {
    PropertyTable table = new PropertyTable();

    Font font = null;
    try {
      font = FontFactory.create(FontFormat.TRUETYPE, new File("OpenSans-Regular.ttf"), Color.BLACK);
    } catch (IOException | FontFormatException e) {
      // Ignore
    }

    table.set(Widget.class, WidgetPropertyKey.MARGIN, new EdgeThickness(4));

    table.set(Container.class, WidgetPropertyKey.PAINTER, new WidgetPainter<Container<?>>());
    table.set(Container.class, WidgetPropertyKey.BACKGROUND, Color.WHITE);

    table.set(TextWidget.class, TextWidgetPropertyKey.PAINTER, new TextWidgetPainter<TextWidget>());
    table.set(TextWidget.class, TextWidgetPropertyKey.FONT, font);
    table.set(TextWidget.class, TextWidgetPropertyKey.TEXT_ALIGNMENT, Direction.CENTER);
    table.set(TextWidget.class, TextWidgetPropertyKey.FOREGROUND, Color.BLACK);
    table.set(TextWidget.class, TextWidgetPropertyKey.DISABLED_FOREGROUND, Color.GRAY);

    table.set(Button.class, ButtonPropertyKey.BORDER, new LineBorder(Color.GRAY));
    table.set(Button.class, ButtonPropertyKey.PADDING, new EdgeThickness(6));
    table.set(Button.class, ButtonPropertyKey.BACKGROUND, Color.WHITE);
    table.set(Button.class, ButtonPropertyKey.ROLLOVER_BACKGROUND, Color.LIGHT_GRAY);
    table.set(Button.class, ButtonPropertyKey.PRESSED_BACKGROUND, Color.GRAY);
    table.set(Button.class, ButtonPropertyKey.ROLLOVER_FOREGROUND, Color.BLACK);

    table.set(TextBox.class, TextWidgetPropertyKey.TEXT_ALIGNMENT, Direction.NORTHWEST);
    table.set(TextBox.class, TextWidgetPropertyKey.BORDER, new LineBorder(Color.GRAY));
    table.set(TextBox.class, TextWidgetPropertyKey.PADDING, new EdgeThickness(6));
    table.set(TextBox.class, TextWidgetPropertyKey.BACKGROUND, Color.WHITE);

    return table;
  }
Ejemplo n.º 4
0
  public Component getTableCellEditorComponent(
      JTable table, Object value, boolean isSelected, int row, int column) {
    _pTable = (PropertyTable) table;
    _row = row;
    _column = column;
    _p = ((Property) _pTable.getProperties().elementAt(row));

    oldpValue = _p.getValue(); // new

    PropertiesTableReader _pReader = new PropertiesTableReader();
    String[] primitiveAry = {"java.lang.String", "java.lang.Integer", "java.lang.Double"};
    String type = _p.getType();

    int i = 0;
    while (!(_valueType.equals(TYPE_PRIMITIVE)) && i < primitiveAry.length) {

      if (type.equalsIgnoreCase(primitiveAry[i])) {
        _valueType = TYPE_PRIMITIVE;
      }
      i++;
    }
    if (type.equals("mcomponent.distribution.Transform")) {
      _valueType = TYPE_TRANSFORM;
    } else if (type.equals("mcomponent.distribution.Distribution")) {
      _valueType = TYPE_DISTRIBUTION;
    }
    if (type.equals("mcomponent.distribution.Transform")) {
      _valueType = TYPE_TRANSFORM;
    } else if (type.equals("mcomponent.distribution.ObjectCreator")) {
      _valueType = TYPE_OBJECT_CREATOR;
    } else if (type.equals("animation.Animation")) {
      _valueType = TYPE_ANIMATION;
    } else if (type.equals("mcomponent.distribution.SplitterModel")) {
      _valueType = TYPE_SPLITTERMODEL;
    } else if (type.equals("mcomponent.distribution.MergerModel")) {
      _valueType = TYPE_MERGERMODEL;
    } else if (type.equals("chart.Presentation")) {
      _valueType = TYPE_PRESENTATION;
    } else if (type.equals("chart.DataProcessor")) {
      _valueType = TYPE_DATA_PROCESSOR;
    }
    if (_valueType.equals(TYPE_PRIMITIVE)) {

      _tField = new TableTextField();
      if (_p.getValue() == null) {
        _tField.setText("");
      } else {
        _tField.setText(String.valueOf(_p.getValue()));
      }
      _editorComponent = _tField;
    } else if (_valueType.equals(TYPE_OBJECT_CREATOR)) {
      JButton jb = new JButton("...");

      // Here's the code that brings up the dialog.
      jb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              System.err.println("Property:" + _p);
              System.err.println("Property(type):" + _p.getType());
              System.err.println("Property(name):" + _p.getName());
              System.err.println("Property(value):" + _p.getValue());
              ObjectCreatorDialog ObjectCreatorDialog =
                  new ObjectCreatorDialog(DiagramShape.getDiagram().getFrame(), _p, _tField);
              ObjectCreatorDialog.setVisible(true);
              _p.setValue(ObjectCreatorDialog.getPropertyValue());
            }
          });

      _tField = new TableTextField();
      if (_p.getValue() != null) {
        String className = (_p.getValue().getClass().getName());
        String classNameOnly = className.substring((className.lastIndexOf(".") + 1));
        _tField.setText(classNameOnly);
        _tField.setObject(_p.getValue());
      }
      _tField.setLayout(new BorderLayout());
      _tField.add("East", jb);
      _tField.setEditable(false);
      _editorComponent = _tField;
    } else if (_valueType.equals(TYPE_TRANSFORM)) {
      JButton jb = new JButton("...");

      // Here's the code that brings up the dialog.
      jb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              System.err.println("Property:" + _p);
              System.err.println("Property(type):" + _p.getType());
              System.err.println("Property(name):" + _p.getName());
              System.err.println("Property(value):" + _p.getValue());
              TransformDialog transformDialog =
                  new TransformDialog(DiagramShape.getDiagram().getFrame(), _p, _tField);
              transformDialog.setVisible(true);
              _p.setValue(transformDialog.getPropertyValue());
            }
          });

      _tField = new TableTextField();
      if (_p.getValue() != null) {
        String className = (_p.getValue().getClass().getName());
        String classNameOnly = className.substring((className.lastIndexOf(".") + 1));
        _tField.setText(classNameOnly);
        _tField.setObject(_p.getValue());
      }
      _tField.setLayout(new BorderLayout());
      _tField.add("East", jb);
      _tField.setEditable(false);
      _editorComponent = _tField;
    } else if (_valueType.equals(TYPE_DISTRIBUTION)) {
      JButton jb = new JButton("...");

      // Here's the code that brings up the dialog.
      jb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              DistributionDialog distributionDialog =
                  new DistributionDialog(DiagramShape.getDiagram().getFrame(), _p, _tField);
              distributionDialog.setVisible(true);
              _p.setValue(distributionDialog.getPropertyValue());
            }
          });

      _tField = new TableTextField();
      if (_p.getValue() != null) {

        String className = (_p.getValue().getClass().getName());
        String classNameOnly = className.substring((className.lastIndexOf(".") + 1));
        _tField.setText(classNameOnly);
        _tField.setObject(_p.getValue());
      }
      _tField.setLayout(new BorderLayout());
      _tField.add("East", jb);
      _tField.setEditable(false);
      _editorComponent = _tField;
    } else if (_valueType.equals(TYPE_ANIMATION)) {
      JButton jb = new JButton("...");

      // Here's the code that brings up the dialog.
      jb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              AnimationTransformDialog animationTransformDialog =
                  new AnimationTransformDialog(DiagramShape.getDiagram().getFrame(), _p, _tField);
              animationTransformDialog.setVisible(true);
              _p.setValue(animationTransformDialog.getPropertyValue());
            }
          });

      _tField = new TableTextField();
      if (_p.getValue() != null) {

        String className = (_p.getValue().getClass().getName());
        String classNameOnly = className.substring((className.lastIndexOf(".") + 1));
        _tField.setText(classNameOnly);
        _tField.setObject(_p.getValue());
      }
      _tField.setLayout(new BorderLayout());
      _tField.add("East", jb);
      _tField.setEditable(false);
      _editorComponent = _tField;
    } else if (_valueType.equals(TYPE_SPLITTERMODEL)) {
      JButton jb = new JButton("...");

      // Here's the code that brings up the dialog.
      jb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              System.err.println("Property:" + _p);
              System.err.println("Property(type):" + _p.getType());
              System.err.println("Property(name):" + _p.getName());
              System.err.println("Property(value):" + _p.getValue());
              SplitterModelDialog splitterModelDialog =
                  new SplitterModelDialog(DiagramShape.getDiagram().getFrame(), _p, _tField);
              splitterModelDialog.setVisible(true);
              _p.setValue(splitterModelDialog.getPropertyValue());
            }
          });

      _tField = new TableTextField();
      if (_p.getValue() != null) {
        String className = (_p.getValue().getClass().getName());
        String classNameOnly = className.substring((className.lastIndexOf(".") + 1));
        _tField.setText(classNameOnly);
        _tField.setObject(_p.getValue());
      }
      _tField.setLayout(new BorderLayout());
      _tField.add("East", jb);
      _tField.setEditable(false);
      _editorComponent = _tField;
    } else if (_valueType.equals(TYPE_MERGERMODEL)) {
      JButton jb = new JButton("...");

      // Here's the code that brings up the dialog.
      jb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              System.err.println("Property:" + _p);
              System.err.println("Property(type):" + _p.getType());
              System.err.println("Property(name):" + _p.getName());
              System.err.println("Property(value):" + _p.getValue());
              MergerModelDialog mergerModelDialog =
                  new MergerModelDialog(DiagramShape.getDiagram().getFrame(), _p, _tField);
              mergerModelDialog.setVisible(true);
              _p.setValue(mergerModelDialog.getPropertyValue());
            }
          });

      _tField = new TableTextField();
      if (_p.getValue() != null) {
        String className = (_p.getValue().getClass().getName());
        String classNameOnly = className.substring((className.lastIndexOf(".") + 1));
        _tField.setText(classNameOnly);
        _tField.setObject(_p.getValue());
      }
      _tField.setLayout(new BorderLayout());
      _tField.add("East", jb);
      _tField.setEditable(false);
      _editorComponent = _tField;
    } else if (_valueType.equals(TYPE_PRESENTATION)) {
      JButton jb = new JButton("...");

      // Here's the code that brings up the dialog.
      jb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              System.err.println("Property:" + _p);
              System.err.println("Property(type):" + _p.getType());
              System.err.println("Property(name):" + _p.getName());
              System.err.println("Property(value):" + _p.getValue());
              DataProcessorDialog dataProcessorDialog =
                  new DataProcessorDialog(DiagramShape.getDiagram().getFrame(), _p, _tField);
              dataProcessorDialog.setVisible(true);
              _p.setValue(dataProcessorDialog.getPropertyValue());
            }
          });

      _tField = new TableTextField();
      if (_p.getValue() != null) {
        String className = (_p.getValue().getClass().getName());
        String classNameOnly = className.substring((className.lastIndexOf(".") + 1));
        _tField.setText(classNameOnly);
        _tField.setObject(_p.getValue());
      }
      _tField.setLayout(new BorderLayout());
      _tField.add("East", jb);
      _tField.setEditable(false);
      _editorComponent = _tField;
    } else if (_valueType.equals(TYPE_DATA_PROCESSOR)) {
      JButton jb = new JButton("...");

      // Here's the code that brings up the dialog.
      jb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              System.err.println("Property:" + _p);
              System.err.println("Property(type):" + _p.getType());
              System.err.println("Property(name):" + _p.getName());
              System.err.println("Property(value):" + _p.getValue());
              MergerModelDialog mergerModelDialog =
                  new MergerModelDialog(DiagramShape.getDiagram().getFrame(), _p, _tField);
              mergerModelDialog.setVisible(true);
              _p.setValue(mergerModelDialog.getPropertyValue());
            }
          });

      _tField = new TableTextField();
      if (_p.getValue() != null) {
        String className = (_p.getValue().getClass().getName());
        String classNameOnly = className.substring((className.lastIndexOf(".") + 1));
        _tField.setText(classNameOnly);
        _tField.setObject(_p.getValue());
      }
      _tField.setLayout(new BorderLayout());
      _tField.add("East", jb);
      _tField.setEditable(false);
      _editorComponent = _tField;
    } else {
      String[] typeAry = _pReader.getType(type);
      String[] choiceAry = new String[typeAry.length];

      for (int j = 0; j < typeAry.length; j++) {
        StringTokenizer st = new StringTokenizer(typeAry[j], ".");
        int count = st.countTokens();
        while (count != 1) {
          st.nextToken();
          count--;
        }

        choiceAry[j] = st.nextToken();
        _tComboBox = new TableComboBox(choiceAry);
      }

      if (_p.getValue() != null) {
        _tComboBox.setObject(_p.getValue());
      }

      _editorComponent = _tComboBox;
    }

    return editorComponent();
  }
Ejemplo n.º 5
0
 public void setPropertyValue(Object object) {
   _p.setValue(object);
   _pTable.getProperties().setElementAt(_p, _row);
 }