Examples of PropertyEditor


Examples of Peditor.PropertyEditor



        //this.frameMain=frameMain;

        propertyEditor = new PropertyEditor(this);
        jTabPE.addTab(java.util.ResourceBundle.getBundle("VisualLogic/FrameCircuit").getString("Property-Editor"), propertyEditor);

        projectPalette1 = new ProjectPalette(this);
        jPanel1.add(projectPalette1);
View Full Code Here

Examples of gov.nasa.arc.mct.components.PropertyEditor

    }
   
    @SuppressWarnings({ "rawtypes", "unchecked" })
    private PropertyDescriptor buildMockDescriptor(VisualControlDescriptor vcd) {
        PropertyDescriptor mockDescriptor = Mockito.mock(PropertyDescriptor.class);
        PropertyEditor mockEditor = Mockito.mock(PropertyEditor.class);
       
        Mockito.when(mockDescriptor.getShortDescription()).thenReturn("mock");
        Mockito.when(mockDescriptor.getVisualControlDescriptor()).thenReturn(vcd);
        Mockito.when(mockDescriptor.getPropertyEditor()).thenReturn(mockEditor);
        Mockito.when(mockDescriptor.isFieldMutable()).thenReturn(true);
       
        // Change the result of get() method, to trigger refresh
        Mockito.when(mockEditor.getTags()).thenReturn(Arrays.asList("mock", "other"));
        Mockito.when(mockEditor.getAsText()).thenReturn("mock");
        Mockito.when(mockEditor.getValue()).thenReturn(vcd != VisualControlDescriptor.CheckBox ? "mock" : Boolean.TRUE);      
       
        return mockDescriptor;
    }
View Full Code Here

Examples of java.beans.PropertyEditor

  ce.setValue(initial);
     
      PropertyDialog pd = new PropertyDialog((Frame) null, ce, 100, 100);
      pd.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
      PropertyEditor pe = ((PropertyDialog)e.getSource()).getEditor();
      Object c = (Object)pe.getValue();
      String options = "";
      if (c instanceof OptionHandler) {
        options = Utils.joinOptions(((OptionHandler)c).getOptions());
      }
      System.out.println(c.getClass().getName() + " " + options);
View Full Code Here

Examples of java.beans.PropertyEditor

    // Determine if the current object is an array
    m_ElementEditor = null; m_ListModel = null;
    removeAll();
    if ((o != null) && (o.getClass().isArray())) {
      Class elementClass = o.getClass().getComponentType();   
      PropertyEditor editor = PropertyEditorManager.findEditor(elementClass);
      Component view = null;
      ListCellRenderer lcr = new DefaultListCellRenderer();
      if (editor != null) {
  if (editor instanceof GenericObjectEditor) {
    ((GenericObjectEditor) editor).setClassType(elementClass);
  }

        //setting the value in the editor so that
        //we don't get a NullPointerException
        //when we do getAsText() in the constructor of
        //PropertyValueSelector()
  if(Array.getLength(o) > 0) {
    editor.setValue(makeCopy(Array.get(o,0)));
  } else {
    if (editor instanceof GenericObjectEditor) {
      ((GenericObjectEditor)editor).setDefaultValue();
    } else {  
            try {
              if (editor instanceof FileEditor) {
                editor.setValue(new java.io.File("-NONE-"));
              } else {
                editor.setValue(elementClass.newInstance());
              }
            } catch(Exception ex) {
              m_ElementEditor=null;
              System.err.println(ex.getMessage());
              add(m_Label, BorderLayout.CENTER);
              m_Support.firePropertyChange("", null, null);
              validate();
              return;
            }
    }
  }
       
  if (editor.isPaintable() && editor.supportsCustomEditor()) {
    view = new PropertyPanel(editor);
    lcr = new EditorListCellRenderer(editor.getClass(), elementClass);
  } else if (editor.getTags() != null) {
    view = new PropertyValueSelector(editor);
  } else if (editor.getAsText() != null) {
    view = new PropertyText(editor);
  }
      }
      if (view == null) {
  System.err.println("No property editor for class: "
         + elementClass.getName());
      } else {
        m_ElementEditor = editor;
        try {
          m_Editor = editor.getClass().newInstance();
        } catch (InstantiationException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        } catch (IllegalAccessException e1) {
          // TODO Auto-generated catch block
View Full Code Here

Examples of java.beans.PropertyEditor

              final Object value,
              final int index,
              final boolean isSelected,
              final boolean cellHasFocus) {
      try {
  final PropertyEditor e = (PropertyEditor)m_EditorClass.newInstance();
  if (e instanceof GenericObjectEditor) {
    //    ((GenericObjectEditor) e).setDisplayOnly(true);
    ((GenericObjectEditor) e).setClassType(m_ValueClass);
  }
  e.setValue(value);
  return new JPanel() {
   
    private static final long serialVersionUID = -3124434678426673334L;

    public void paintComponent(Graphics g) {

      Insets i = this.getInsets();
      Rectangle box = new Rectangle(i.left, i.top,
            this.getWidth() - i.right,
            this.getHeight() - i.bottom );
      g.setColor(isSelected
           ? list.getSelectionBackground()
           : list.getBackground());
      g.fillRect(0, 0, this.getWidth(), this.getHeight());
      g.setColor(isSelected
           ? list.getSelectionForeground()
           : list.getForeground());
      e.paintValue(g, box);
    }
   
    public Dimension getPreferredSize() {

      Font f = this.getFont();
View Full Code Here

Examples of java.beans.PropertyEditor

      try {
  Object args[] = { };
  Object value = getter.invoke(m_Target, args);
  m_Values[i] = value;

  PropertyEditor editor = null;
  Class pec = m_Properties[i].getPropertyEditorClass();
  if (pec != null) {
    try {
      editor = (PropertyEditor)pec.newInstance();
    } catch (Exception ex) {
      // Drop through.
    }
  }
  if (editor == null) {
    editor = PropertyEditorManager.findEditor(type);
  }
  m_Editors[i] = editor;

  // If we can't edit this component, skip it.
  if (editor == null) {
    // If it's a user-defined property we give a warning.
    String getterClass = m_Properties[i].getReadMethod()
      .getDeclaringClass().getName();
    /*
    if (getterClass.indexOf("java.") != 0) {
      System.err.println("Warning: Can't find public property editor"
             + " for property \"" + name + "\" (class \""
             + type.getName() + "\").  Skipping.");
    }
    */
    continue;
  }
  if (editor instanceof GenericObjectEditor) {
    ((GenericObjectEditor) editor).setClassType(type);
  }
 
  if (editor instanceof EnvironmentHandler) {
    ((EnvironmentHandler)editor).setEnvironment(m_env);
  }

  // Don't try to set null values:
  if (value == null) {
    // If it's a user-defined property we give a warning.
    String getterClass = m_Properties[i].getReadMethod()
      .getDeclaringClass().getName();
    /*
    if (getterClass.indexOf("java.") != 0) {
      System.err.println("Warning: Property \"" + name
             + "\" has null initial value.  Skipping.");
    }
    */
    continue;
  }

  editor.setValue(value);

  // now look for a TipText method for this property
        String tipName = name + "TipText";
  for (int j = 0; j < m_Methods.length; j++) {
    String mname = m_Methods[j].getDisplayName();
    Method meth = m_Methods[j].getMethod();
    if (mname.equals(tipName)) {
      if (meth.getReturnType().equals(String.class)) {
        try {
    String tempTip = (String)(meth.invoke(m_Target, args));
    int ci = tempTip.indexOf('.');
    if (ci < 0) {
      m_TipTexts[i] = tempTip;
    } else {
      m_TipTexts[i] = tempTip.substring(0, ci);
    }
                if (m_HelpText != null) {
                  if (firstTip) {
                    m_HelpText.append("OPTIONS\n");
                    firstTip = false;
                  }
                  m_HelpText.append(name).append(" -- ");
                  m_HelpText.append(tempTip).append("\n\n");
                  //jt.setText(m_HelpText.toString());
                }
        } catch (Exception ex) {

        }
        break;
      }
    }
  }   

  // Now figure out how to display it...
  if (editor.isPaintable() && editor.supportsCustomEditor()) {
    view = new PropertyPanel(editor);
  } else if (editor.supportsCustomEditor() && (editor.getCustomEditor() instanceof JComponent)) {
    view = (JComponent) editor.getCustomEditor();
  } else if (editor.getTags() != null) {
    view = new PropertyValueSelector(editor);
  } else if (editor.getAsText() != null) {
    view = new PropertyText(editor);
  } else {
    System.err.println("Warning: Property \"" + name
           + "\" has non-displayabale editor.  Skipping.");
    continue;
  }
 
  editor.addPropertyChangeListener(this);

      } catch (InvocationTargetException ex) {
  System.err.println("Skipping property " + name
         + " ; exception on target: "
         + ex.getTargetException());
View Full Code Here

Examples of java.beans.PropertyEditor

   */
  synchronized void wasModified(PropertyChangeEvent evt) {

    //    System.err.println("wasModified");
    if (evt.getSource() instanceof PropertyEditor) {
      PropertyEditor editor = (PropertyEditor) evt.getSource();
      for (int i = 0 ; i < m_Editors.length; i++) {
  if (m_Editors[i] == editor) {
    PropertyDescriptor property = m_Properties[i];
    Object value = editor.getValue();
    m_Values[i] = value;
    Method setter = property.getWriteMethod();
    try {
      Object args[] = { value };
      args[0] = value;
View Full Code Here

Examples of java.beans.PropertyEditor

        }

        ensureNamespaceDefined(writer, attList, namespace);
        try
        {
          final PropertyEditor propertyEditor = attrMeta.getEditor();
          if (propertyEditor != null)
          {
            propertyEditor.setValue(value);
            attList.setAttribute(namespace, name, propertyEditor.getAsText());
          }
          else
          {
            final String attrValue = ConverterRegistry.toAttributeValue(value);
            attList.setAttribute(namespace, name, attrValue);
View Full Code Here

Examples of java.beans.PropertyEditor

          continue;
        }

        try
        {
          final PropertyEditor propertyEditor = attrMeta.getEditor();
          if (propertyEditor != null)
          {

            propertyEditor.setValue(value);
            final String text = propertyEditor.getAsText();

            final AttributeList attList = new AttributeList();
            if (attList.isNamespaceUriDefined(namespace) == false &&
                writer.isNamespaceDefined(namespace) == false)
            {
View Full Code Here

Examples of java.beans.PropertyEditor

          attList.addNamespaceDeclaration("autoGenNs", namespace);
        }

        try
        {
          final PropertyEditor propertyEditor = attrMeta.getEditor();
          final String textValue;
          if (propertyEditor != null)
          {
            propertyEditor.setValue(value);
            textValue = propertyEditor.getAsText();
          }
          else
          {
            textValue = ConverterRegistry.toAttributeValue(value);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.