Пример #1
0
  /**
   * Create the given ViewManager
   *
   * @param viewDescriptor Identifies the VM
   * @param properties Property string to pass
   * @return The new one
   */
  public ViewManager createViewManager(ViewDescriptor viewDescriptor, String properties) {
    synchronized (viewManagers) {
      try {
        ViewManager viewManager = null;
        if (viewDescriptor == null) {
          viewDescriptor = new ViewDescriptor();
        }
        if (viewDescriptor.getClassNames().size() > 0) {
          Class viewManagerClass = Misc.findClass((String) viewDescriptor.getClassNames().get(0));
          Constructor ctor =
              Misc.findConstructor(
                  viewManagerClass,
                  new Class[] {IntegratedDataViewer.class, ViewDescriptor.class, String.class});

          if (ctor == null) {
            throw new IllegalArgumentException(
                "cannot create ViewManager:" + viewManagerClass.getName());
          }

          viewManager =
              (ViewManager) ctor.newInstance(new Object[] {getIdv(), viewDescriptor, properties});
        } else {
          viewManager = new MapViewManager(getIdv(), viewDescriptor, properties);
        }

        addViewManager(viewManager);
        return viewManager;
      } catch (Throwable e) {
        logException("In getViewManager", e);
        return null;
      }
    }
  }
Пример #2
0
 /**
  * Return a String representation of the object
  *
  * @return a String representation of the object
  */
 public String toString() {
   return paramType.getName()
       + " "
       + name
       + " "
       + ((reader == null) ? "-" : "R")
       + ((writer == null) ? "-" : "W");
 }
Пример #3
0
  public void stateChanged(ChangeEvent ce) {
    Object ob = ce.getSource();
    Class<?> cl = ob.getClass();

    if (Debug) {
      System.out.println("MyChangeListener: got stateChanged: Object: " + ob.toString() + "\n");
      System.out.println("MyChangeListener: got stateChanged: Class: " + cl.getName() + "\n");
    }

    if (cl.getName().equals("javax.swing.JTabbedPane")) {
      if (pane == ce.getSource()) {
        int index = pane.getSelectedIndex();
        mLook.stateChanged(index);
      } else {
        System.out.println("The source does NOT equal pane\n");
      }
    }
  }
Пример #4
0
  public XTextField(
      Object value,
      Class<?> expectedClass,
      int colWidth,
      boolean isCallable,
      JButton button,
      XOperations operation) {
    super(new BorderLayout());
    this.button = button;
    this.operation = operation;
    add(textField = new JTextField(value.toString(), colWidth), BorderLayout.CENTER);
    if (isCallable) textField.addActionListener(this);

    boolean fieldEditable = Utils.isEditableType(expectedClass.getName());
    if (fieldEditable && isCallable) {
      textField.setEditable(true);
    } else {
      textField.setEditable(false);
    }
  }
Пример #5
0
  protected void init(Object value, Class<?> expectedClass) {
    boolean fieldEditable = Utils.isEditableType(expectedClass.getName());
    clearObject();
    if (value != null) {
      textField.setText(value.toString());
    } else {
      // null String value for the moment
      textField.setText("");
    }
    textField.setToolTipText(null);
    if (fieldEditable) {
      if (!textField.isEditable()) {
        textField.setEditable(true);
      }

    } else {
      if (textField.isEditable()) {
        textField.setEditable(false);
      }
    }
  }
Пример #6
0
 static {
   // compute primitives/primitiveMap/primitiveToWrapper
   for (Class<?> c : primitiveWrappers) {
     try {
       Field f = c.getField("TYPE");
       Class<?> p = (Class<?>) f.get(null);
       primitives.add(p);
       primitiveMap.put(p.getName(), p);
       primitiveToWrapper.put(p.getName(), c);
     } catch (Exception e) {
       throw new AssertionError(e);
     }
   }
   // compute editableTypes
   for (Class<?> c : primitives) {
     editableTypes.add(c.getName());
   }
   for (Class<?> c : primitiveWrappers) {
     editableTypes.add(c.getName());
   }
   for (Class<?> c : extraEditableClasses) {
     editableTypes.add(c.getName());
   }
   // compute numericalTypes
   for (Class<?> c : primitives) {
     String name = c.getName();
     if (!name.equals(Boolean.TYPE.getName())) {
       numericalTypes.add(name);
     }
   }
   for (Class<?> c : primitiveWrappers) {
     String name = c.getName();
     if (!name.equals(Boolean.class.getName())) {
       numericalTypes.add(name);
     }
   }
 }
Пример #7
0
  /** Determine JDK level of an applet. */
  private void findAppletJDKLevel(Applet applet) {
    // To determine the JDK level of an applet, the
    // most reliable way is to check the major version
    // of the applet class file.

    // synchronized on applet class object, so calling from
    // different instances of the same applet will be
    // serialized.
    Class<?> appletClass = applet.getClass();

    synchronized (appletClass) {
      // Determine if the JDK level of an applet has been
      // checked before.
      Boolean jdk11Target = loader.isJDK11Target(appletClass);
      Boolean jdk12Target = loader.isJDK12Target(appletClass);

      // if applet JDK level has been checked before, retrieve
      // value and return.
      if (jdk11Target != null || jdk12Target != null) {
        jdk11Applet = (jdk11Target == null) ? false : jdk11Target.booleanValue();
        jdk12Applet = (jdk12Target == null) ? false : jdk12Target.booleanValue();
        return;
      }

      String name = appletClass.getName();

      // first convert any '.' to '/'
      name = name.replace('.', '/');

      // append .class
      final String resourceName = name + ".class";

      byte[] classHeader = new byte[8];

      try (InputStream is =
          AccessController.doPrivileged(
              (PrivilegedAction<InputStream>) () -> loader.getResourceAsStream(resourceName))) {

        // Read the first 8 bytes of the class file
        int byteRead = is.read(classHeader, 0, 8);

        // return if the header is not read in entirely
        // for some reasons.
        if (byteRead != 8) return;
      } catch (IOException e) {
        return;
      }

      // Check major version in class file header
      int major_version = readShort(classHeader, 6);

      // Major version in class file is as follows:
      //   45 - JDK 1.1
      //   46 - JDK 1.2
      //   47 - JDK 1.3
      //   48 - JDK 1.4
      //   49 - JDK 1.5
      if (major_version < 46) jdk11Applet = true;
      else if (major_version == 46) jdk12Applet = true;

      // Store applet JDK level in AppContext for later lookup,
      // e.g. page switch.
      loader.setJDK11Target(appletClass, jdk11Applet);
      loader.setJDK12Target(appletClass, jdk12Applet);
    }
  }
Пример #8
0
 public static <T extends Enum<T>> String getPropertyID(T algo) {
   Class<T> clazz = algo.getDeclaringClass();
   return "net.java.sip.communicator." + clazz.getName().replace('$', '_');
 }