Beispiel #1
0
 public void setEditMode(boolean s) {
   if (!s) pane.setEditMode(s);
   else {
     int edits = ParamInfo.getEditItems();
     if ((edits & ParamInfo.TOOLPANELS) > 0) pane.setEditMode(true);
     else pane.setEditMode(false);
   }
 }
Beispiel #2
0
  public VTabbedToolPanel(SessionShare sshare, AppIF appIF) {
    // super( new BorderLayout() );
    this.sshare = sshare;
    this.appIF = appIF;
    this.tabbedToolPanel = new JPanel();
    this.pinPanel = this;
    this.selectedTabName = null;
    setPinObj(this.tabbedToolPanel);
    this.tabbedToolPanel.setLayout(new BorderLayout());
    this.tabbedPane = new JTabbedPane();
    panelName = "Tab Panel";
    setTitle(panelName);
    setName(panelName);

    tabbedPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            tabChanged();
            /**
             * ** the following was moved to tabChanged() if(tabbedPane.getTabCount() > 1 &&
             * Util.getRQPanel() != null) { int ind = tabbedPane.getSelectedIndex(); if(ind >= 0 &&
             * ind < tabbedPane.getTabCount())
             * Util.getRQPanel().updatePopup(tabbedPane.getTitleAt(ind)); } *********
             */
          }
        });

    // Add Mouse Listener for CSH
    MouseAdapter ml = new CSHMouseAdapter();
    tabbedPane.addMouseListener(ml);

    Object obj = sshare.userInfo().get("canvasnum");
    if (obj != null) {
      Dimension dim = (Dimension) obj;
      nviews = (dim.height) * (dim.width);
    } else nviews = 1;

    for (int i = 0; i < nviews; i++) tp_paneInfo[i] = new Hashtable();

    /*
    obj = sshare.userInfo().get("activeWin");
    if(obj != null) {
               vpId = ((Integer)obj).intValue();
    } else vpId = 0;
            */

    // System.out.println("VToolPanel nviews vpId "+nviews+" "+vpId);

    fillHashtable();
    Util.setVTabbedToolPanel(this);
    ParamInfo.addEditListener(this);
  }
Beispiel #3
0
  public ObjectDescription generateObjectDescription(Object o, Integer objID, boolean addObject) {

    ObjectDescription result = null;

    // Object annotations
    ObjectInfo objectInfo = null;

    Annotation[] objectAnnotations = o.getClass().getAnnotations();

    for (Annotation a : objectAnnotations) {
      if (a.annotationType().equals(ObjectInfo.class)) {
        objectInfo = (ObjectInfo) a;
        break;
      }
    }

    if (addObject) {
      ObjectEntry oEntry = new ObjectEntry(o);
      if (objID != null) {
        objects.addWithID(oEntry, objID);
      } else {
        objects.add(oEntry);
        objID = oEntry.getID();
      }
    }

    boolean hasCustomReferenceMethod = false;

    // we need special treatment for proxy objects
    if (o instanceof ProxyObject) {
      ProxyObject proxy = (ProxyObject) o;

      result = proxy.getObjectDescription();

      result.setName(o.getClass().getName());

      result.setID(objID);

      // update objID of methods
      for (MethodDescription mDesc : result.getMethods()) {
        mDesc.setObjectID(objID);
      }

    } else {
      result = new ObjectDescription();
      result.setInfo(objectInfo);

      result.setName(o.getClass().getName());

      result.setID(objID);

      Class<?> c = o.getClass();

      Method[] theMethods = null;

      if (objectInfo != null && objectInfo.showInheritedMethods()) {
        theMethods = c.getMethods();
      } else {
        ArrayList<Method> methods = new ArrayList<Method>();

        // methods declared by class c
        for (Method m : c.getDeclaredMethods()) {
          methods.add(m);
        }

        // methods declared in superclasses of c
        for (Method m : c.getMethods()) {
          MethodInfo info = m.getAnnotation(MethodInfo.class);
          // if m is marked as inheritGUI this method will
          // be visualized even if it is a method declared
          // in a superclass of c
          if (info != null && info.inheritGUI()) {
            if (!methods.contains(m)) {
              methods.add(m);
            }
          }
        }

        Method[] tmpArray = new Method[methods.size()];

        theMethods = methods.toArray(tmpArray);
      }

      for (int i = 0; i < theMethods.length; i++) {

        // filter groovy object specific methods
        String method = theMethods[i].getName();
        boolean isGroovyObject = o instanceof GroovyObject;
        boolean isGroovyMethod =
            method.equals("setProperty")
                || method.equals("getProperty")
                || method.equals("invokeMethod")
                || method.equals("getMetaClass")
                || method.equals("setMetaClass"); // ||
        //                            // the following methods are only present
        //                            // for Groovy >= 1.6
        //                            method.equals("super$1$wait") ||
        //                            method.equals("super$1$toString") ||
        //                            method.equals("super$1$notify") ||
        //                            method.equals("super$1$notifyAll") ||
        //                            method.equals("super$1$getClass") ||
        //                            method.equals("super$1$equals") ||
        //                            method.equals("super$1$clone") ||
        //                            method.equals("super$1$hashCode") ||
        //                            method.equals("super$1$finalize");

        // For Groovy >= 1.6 private methods have $ sign in their
        // name, e.g.,
        //   private doSomething()
        // will be changed to
        //   this$2$doSomething()
        // which is unfortunately accessible and thus will be
        // visualized by vrl.
        // To prevent groovys strange behavior
        // methods with $ sign are ignored and treated as private.
        boolean isPrivateGroovyMethod = method.contains("$");

        // TODO improve that code!
        if ((isGroovyObject && isGroovyMethod) || isPrivateGroovyMethod) {
          continue;
        }

        Class[] parameterTypes = theMethods[i].getParameterTypes();

        Annotation[][] allParameterAnnotations = theMethods[i].getParameterAnnotations();

        ArrayList<String> paramNames = new ArrayList<String>();

        ArrayList<ParamInfo> paramAnnotations = new ArrayList<ParamInfo>();
        ArrayList<ParamGroupInfo> paramGroupAnnotations = new ArrayList<ParamGroupInfo>();

        // retrieving annotation information for each parameter
        for (int j = 0; j < allParameterAnnotations.length; j++) {

          Annotation[] annotations = allParameterAnnotations[j];

          // add name element and set it to null
          // because we don't know if parameter j is annotated
          paramNames.add(null);
          paramAnnotations.add(null);
          paramGroupAnnotations.add(null);

          // check all annotations of parameter j
          // if we have a ParamInfo annotation retrieve data
          // and store it as element of paramName
          for (Annotation a : annotations) {
            if (a.annotationType().equals(ParamInfo.class)) {
              ParamInfo n = (ParamInfo) a;
              if (!n.name().equals("")) {
                paramNames.set(j, n.name());
              }
              paramAnnotations.set(j, n);
            } else {
              if (a.annotationType().equals(ParamGroupInfo.class)) {
                ParamGroupInfo n = (ParamGroupInfo) a;
                paramGroupAnnotations.set(j, n);
              }
            }
          } // end for a
        } // end for j

        // convert list to array
        String[] parameterNames = paramNames.toArray(new String[paramNames.size()]);

        ParamInfo[] parameterAnnotations =
            paramAnnotations.toArray(new ParamInfo[paramAnnotations.size()]);

        ParamGroupInfo[] parameterGroupAnnotations =
            paramGroupAnnotations.toArray(new ParamGroupInfo[paramGroupAnnotations.size()]);

        Class returnType = theMethods[i].getReturnType();

        String methodString = theMethods[i].getName();
        String methodTitle = "";
        String returnValueName = null;

        int modifiers = theMethods[i].getModifiers();

        String modifierString = Modifier.toString(modifiers);

        // Method Annotations
        Annotation[] annotations = theMethods[i].getAnnotations();
        MethodInfo methodInfo = null;

        OutputInfo outputInfo = null;

        boolean interactive = true;
        boolean hide = false;

        for (Annotation a : annotations) {
          if (a.annotationType().equals(MethodInfo.class)) {
            MethodInfo n = (MethodInfo) a;

            methodTitle = n.name();
            interactive = n.interactive();
            hide = n.hide();
            returnValueName = n.valueName();

            methodInfo = n;
          }

          if (a.annotationType().equals(OutputInfo.class)) {
            outputInfo = (OutputInfo) a;
          }
        }

        if (theMethods[i].getAnnotation(ReferenceMethodInfo.class) != null) {
          hasCustomReferenceMethod = true;
          MethodDescription customReferenceMethod =
              new MethodDescription(
                  objID,
                  0,
                  methodString,
                  methodTitle,
                  null,
                  parameterTypes,
                  parameterNames,
                  parameterAnnotations,
                  parameterGroupAnnotations,
                  returnType,
                  returnValueName,
                  interactive,
                  methodInfo,
                  outputInfo);

          if (customReferenceMethod.getParameterTypes() == null
              || customReferenceMethod.getParameterTypes().length != 1) {
            throw new IllegalArgumentException(
                " Cannot to use "
                    + "\""
                    + methodString
                    + "\" as reference method"
                    + " because the number of parameters does not"
                    + " match. Exactly one parameter must be"
                    + " provided.");
          }

          if (customReferenceMethod.getReturnType() == void.class
              || customReferenceMethod.getReturnType().isPrimitive()) {
            throw new IllegalArgumentException(
                " Cannot to use "
                    + "\""
                    + methodString
                    + "\" as reference method"
                    + " because it does not return an object."
                    + " Returning primitives or void is not"
                    + " allowed.");
          }

          customReferenceMethod.setMethodType(MethodType.CUSTOM_REFERENCE);

          result.addMethod(customReferenceMethod);
        } //
        // TODO: at the moment method id is always 0 and will only be
        //      set from corresponding method representations
        //
        //      is it necessary to change that?
        else if (modifierString.contains("public")
            && (methodInfo == null || !methodInfo.ignore())) {
          result.addMethod(
              new MethodDescription(
                  objID,
                  0,
                  methodString,
                  methodTitle,
                  null,
                  parameterTypes,
                  parameterNames,
                  parameterAnnotations,
                  parameterGroupAnnotations,
                  returnType,
                  returnValueName,
                  interactive,
                  methodInfo,
                  outputInfo));
        }
      } // end for i

      // Object name
      if (objectInfo != null && !objectInfo.name().equals("")) {
        result.setName(objectInfo.name());
      }
    } // end else if (o instanceof ProxyObject)

    if (!hasCustomReferenceMethod) {
      result.addMethod(MethodDescription.createReferenceMethod(objID, o.getClass()));
    }

    return result;
  }