示例#1
0
  /** Install Add and Remove Buttons into the toolbar */
  private void installAddRemovePointButtons() {
    URL imgURL = ClassLoader.getSystemResource("ch/tbe/pics/plus.gif");
    ImageIcon plus = new ImageIcon(imgURL);
    imgURL = ClassLoader.getSystemResource("ch/tbe/pics/minus.gif");
    ImageIcon minus = new ImageIcon(imgURL);
    add = new JButton(plus);
    rem = new JButton(minus);
    add.setToolTipText(workingViewLabels.getString("plus"));
    rem.setToolTipText(workingViewLabels.getString("minus"));
    add.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            WorkingView.this.addRemovePoint(true);
          }
        });
    rem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            WorkingView.this.addRemovePoint(false);
          }
        });

    add.setContentAreaFilled(false);
    add.setBorderPainted(false);
    rem.setContentAreaFilled(false);
    rem.setBorderPainted(false);
    toolbar.add(add);
    toolbar.add(rem);
  }
示例#2
0
 public void init() {
   vlog.debug("init called");
   setBackground(Color.white);
   ClassLoader cl = this.getClass().getClassLoader();
   ImageIcon icon = new ImageIcon(cl.getResource("com/tigervnc/vncviewer/tigervnc.png"));
   logo = icon.getImage();
 }
示例#3
0
  /** @param frameName title name for frame */
  public ShowSavedResults(String frameName) {
    super(frameName);
    aboutRes =
        new JTextArea(
            "Select a result set from"
                + "\nthose listed and details"
                + "\nof that analysis will be"
                + "\nshown here. Then you can"
                + "\neither delete or view those"
                + "\nresults using the buttons below.");
    aboutScroll = new JScrollPane(aboutRes);
    ss = new JScrollPane(sp);
    ss.getViewport().setBackground(Color.white);

    //  resMenu.setLayout(new FlowLayout(FlowLayout.LEFT,10,1));
    ClassLoader cl = getClass().getClassLoader();
    rfii = new ImageIcon(cl.getResource("images/Refresh_button.gif"));

    // results status
    resButtonStatus = new JPanel(new BorderLayout());
    Border loweredbevel = BorderFactory.createLoweredBevelBorder();
    Border raisedbevel = BorderFactory.createRaisedBevelBorder();
    Border compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    statusField = new JTextField();
    statusField.setBorder(compound);
    statusField.setEditable(false);
  }
示例#4
0
 public void start() {
   vlog.debug("start called");
   if (version == null || build == null) {
     ClassLoader cl = this.getClass().getClassLoader();
     InputStream stream = cl.getResourceAsStream("com/tigervnc/vncviewer/timestamp");
     try {
       Manifest manifest = new Manifest(stream);
       Attributes attributes = manifest.getMainAttributes();
       version = attributes.getValue("Version");
       build = attributes.getValue("Build");
     } catch (java.io.IOException e) {
     }
   }
   nViewers++;
   if (firstApplet) {
     alwaysShowServerDialog.setParam(true);
     Configuration.readAppletParams(this);
     String host = getCodeBase().getHost();
     if (vncServerName.getValue() == null && vncServerPort.getValue() != 0) {
       int port = vncServerPort.getValue();
       vncServerName.setParam(
           host + ((port >= 5900 && port <= 5999) ? (":" + (port - 5900)) : ("::" + port)));
     }
   }
   thread = new Thread(this);
   thread.start();
 }
示例#5
0
  public String readFileFromJAR(String filepath) {

    String out = "";

    try {

      // setup input buffer
      ClassLoader cl = this.getClass().getClassLoader();
      InputStream instream = cl.getResourceAsStream(filepath);
      BufferedReader filereader = new BufferedReader(new InputStreamReader(instream));

      // read lines
      String line = filereader.readLine();
      while (line != null) {
        out += "\n" + line;
        line = filereader.readLine();
      }

      filereader.close();

    } catch (Exception e) {
      // e.printStackTrace();
    }

    return out;
  }
示例#6
0
文件: About.java 项目: annsofi/kalken
  public About() {
    cl = ClassLoader.getSystemClassLoader();

    // ----------------------------------------CENTER--------------------------------//
    imgAbout = new ImageIcon(cl.getResource("om.png"));

    lblAbout = new JLabel(imgAbout);

    lblAbout.setBounds(0, 0, 450, 263);

    JPanel pnlCenter = new JPanel();
    pnlCenter.setLayout(null);
    pnlCenter.add(lblAbout);

    btnOk = new JButton(new ImageIcon(cl.getResource("ok.png")));
    btnOk.setBounds(390, 215, 40, 30);
    pnlCenter.add(btnOk);
    btnOk.addActionListener(this);

    // -----------------------------------CONTAINER----------------------------------//
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    c.add(pnlCenter, BorderLayout.CENTER);
    setSize(450, 280);
    setVisible(true);
    setResizable(false);
    setLocation(580, 280);
    // setDefaultCloseOperation(EXIT_ON_CLOSE);

  }
示例#7
0
 public static Icon getIcon(String iconName) {
   ClassLoader cl = Thread.currentThread().getContextClassLoader();
   URL url = cl.getResource("test/check/icons/" + iconName + ".gif");
   if (url != null) return new ImageIcon(url);
   url = cl.getResource("test/check/icons/" + iconName + ".png");
   if (url != null) return new ImageIcon(url);
   return null;
 }
示例#8
0
 public ViewportRenderer() {
   ClassLoader loader = getClass().getClassLoader();
   surfaceIcon =
       new ImageIcon(loader.getResource(IMAGE_BASE + "/vrjuggler-surface-viewport.png"));
   simIcon = new ImageIcon(loader.getResource(IMAGE_BASE + "/vrjuggler-sim-viewport.png"));
   scaledSurfaceIcon = new ImageIcon();
   scaledSimIcon = new ImageIcon();
 }
 /**
  * Load image with current class loader.
  *
  * @param fileName image resource file name
  * @return image
  */
 public static Image loadSwtImage(String fileName) {
   Image result = null;
   try {
     ClassLoader classloader = DavGatewayTray.class.getClassLoader();
     URL imageUrl = classloader.getResource(fileName);
     result = new Image(display, imageUrl.openStream());
   } catch (IOException e) {
     DavGatewayTray.warn(new BundleMessage("LOG_UNABLE_TO_LOAD_IMAGE"), e);
   }
   return result;
 }
示例#10
0
 /**
  * Gets the URL of the icon file denoted by the specified file name.
  *
  * @param fileName The file name. May be {@code null}.
  * @return The URL of the specified file name, or {@code null} if {@code fileName} is {@code
  *     null}, or {@code null} if there is not file with the specified file name in the bundle
  *     class path.
  */
 private static URL getIconURL(String fileName) {
   if (fileName == null) {
     return null;
   }
   ClassLoader loader = OWLIcons.class.getClassLoader();
   URL url = loader.getResource(fileName);
   if (url == null && !isFileNameAbsolute(fileName)) {
     url = loader.getResource(ALTERNATIVE_ICONS_DIRECTORY + fileName);
   }
   return url;
 }
示例#11
0
 private static Clip getClip(String wavFile) {
   String soundName = "sound\\" + wavFile + ".wav";
   InputStream sound = null;
   Clip clip = null;
   try {
     sound = new FileInputStream(soundName);
   } catch (FileNotFoundException ex) {
     sound = ClassLoader.getSystemResourceAsStream(soundName);
     if (sound == null) {
       System.out.println("Cant open file " + soundName);
       return null;
     }
   }
   try {
     AudioInputStream audioIn = AudioSystem.getAudioInputStream(sound);
     clip = AudioSystem.getClip();
     clip.open(audioIn);
   } catch (Exception ex) {
     System.out.println("Error in sound " + wavFile);
     System.out.println(ex.getMessage());
     if (clip != null) {
       clip.close();
       return null;
     }
     try {
       sound.close();
     } catch (IOException e) {
     }
   }
   return clip;
 }
  // initialize data hash table servers
  // read server addresses from file and initialize the servers
  private void initServers() {

    try {
      java.net.URL path = ClassLoader.getSystemResource(clientSettingFile);
      FileReader fr = new FileReader(path.getFile());
      BufferedReader br = new BufferedReader(fr);
      try {
        String[] portMap = br.readLine().split(",");
        mServerCount = portMap.length;
        mPortMap = new int[mServerCount];
        for (int i = 0; i < mServerCount; i++) {
          mPortMap[i] = Integer.parseInt(portMap[i]);
        }
      } catch (IOException e) {
        e.printStackTrace();
        System.exit(-1);
      }
    } catch (FileNotFoundException e2) {
      e2.printStackTrace();
      System.exit(-1);
    }

    mDhtServerArray = new IDistributedHashTable[mServerCount];
    for (int i = 0; i < mServerCount; i++) {
      try {
        mDhtServerArray[i] =
            (IDistributedHashTable)
                Naming.lookup("rmi://localhost:" + mPortMap[i] + "/DistributedHashTable");
        appendOutput("server: " + (i + 1) + " is connected");
      } catch (Exception e) {
        appendOutput("initServers: " + (i + 1) + " " + e.getMessage());
      }
    }
  }
示例#13
0
  /** Creates new form display window */
  public PZWindow(
      final PZManager manager,
      int screenX,
      int screenY,
      int width,
      int height,
      int drawX,
      int drawY) {
    this.manager = manager;
    java.net.URL url = ClassLoader.getSystemClassLoader().getResource("images/dgu.gif");
    if (url != null) setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage(url));

    setBounds(screenX, screenY, width, height);
    setMySize(width, height, 1.0f);

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    // setup the canvas for the window to draw
    final Container cp = getContentPane();
    cp.setLayout(null);
    cp.add(lblCanvas);
    lblCanvas.setBorder(BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    lblCanvas.setDoubleBuffered(true);
    lblCanvas.setFocusable(true);

    initEventListeners();
    drawOffset.set(drawX, drawY);
  }
示例#14
0
  public NodeSettingsPanel() {
    try {
      jbInit();
    } catch (Exception e) {
      e.printStackTrace();
    }
    // Try to get icons for the toolbar buttons
    try {
      ClassLoader loader = getClass().getClassLoader();
      mClusterIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/ClusterIcon.png"));

      mIconLabel.setIcon(mClusterIcon);
    } catch (Exception e) {
      // Ack! No icons. Use text labels instead
      mIconLabel.setText("");
    }
  }
示例#15
0
  @Nullable
  public static Icon findIcon(@NotNull String path, @NotNull ClassLoader classLoader) {
    path = undeprecate(path);
    if (isReflectivePath(path)) return getReflectiveIcon(path, classLoader);
    if (!StringUtil.startsWithChar(path, '/')) return null;

    final URL url = classLoader.getResource(path.substring(1));
    return findIcon(url);
  }
示例#16
0
 private MultiMap<String, ProjectTemplate> loadLocalTemplates() {
   ConcurrentMultiMap<String, ProjectTemplate> map =
       new ConcurrentMultiMap<String, ProjectTemplate>();
   ProjectTemplateEP[] extensions = ProjectTemplateEP.EP_NAME.getExtensions();
   for (ProjectTemplateEP ep : extensions) {
     ClassLoader classLoader = ep.getLoaderForClass();
     URL url = classLoader.getResource(ep.templatePath);
     if (url != null) {
       LocalArchivedTemplate template = new LocalArchivedTemplate(url, classLoader);
       if (ep.category) {
         TemplateBasedCategory category = new TemplateBasedCategory(template, ep.projectType);
         myTemplatesMap.putValue(new TemplatesGroup(category), template);
       } else {
         map.putValue(ep.projectType, template);
       }
     }
   }
   return map;
 }
    public SidebarOption(String labelTxt, String rsc) {
      label = new JLabel(labelTxt);
      label.setForeground(Color.WHITE);
      label.setFont(font);
      add(label);
      setOpaque(false);
      setMaximumSize(new Dimension(1000, label.getPreferredSize().height + 5));

      this.rsc = ClassLoader.getSystemClassLoader().getResource(rsc);
    }
  // todo[r.sh] drop after migration on Java 7
  private static void loadSnappyForJRockit() throws Exception {
    String vmName = System.getProperty("java.vm.name");
    if (vmName == null || !vmName.toLowerCase().contains("jrockit")) {
      return;
    }

    byte[] bytes;
    InputStream in =
        StartupUtil.class.getResourceAsStream("/org/xerial/snappy/SnappyNativeLoader.bytecode");
    try {
      bytes = FileUtil.loadBytes(in);
    } finally {
      in.close();
    }

    ClassLoader classLoader = StartupUtil.class.getClassLoader();

    Method defineClass =
        ClassLoader.class.getDeclaredMethod(
            "defineClass", String.class, byte[].class, int.class, int.class);
    defineClass.setAccessible(true);
    Class<?> loaderClass =
        (Class<?>)
            defineClass.invoke(
                classLoader, "org.xerial.snappy.SnappyNativeLoader", bytes, 0, bytes.length);
    loaderClass = classLoader.loadClass(loaderClass.getName());

    String[] classes = {
      "org.xerial.snappy.SnappyNativeAPI",
      "org.xerial.snappy.SnappyNative",
      "org.xerial.snappy.SnappyErrorCode"
    };
    for (String aClass : classes) {
      classLoader.loadClass(aClass);
    }

    Method loadNativeLibrary =
        SnappyLoader.class.getDeclaredMethod("loadNativeLibrary", Class.class);
    loadNativeLibrary.setAccessible(true);
    loadNativeLibrary.invoke(null, loaderClass);
  }
示例#19
0
文件: GUI.java 项目: sametkaya/BLM305
 boolean tryDir(String d) {
   ClassLoader L = getClass().getClassLoader();
   File p = new File(d, PACKAGE);
   // System.out.println("Try "+p);
   if (!p.exists() || !p.isDirectory()) return false;
   for (File f : p.listFiles()) {
     String s = f.getName();
     if (!s.endsWith(".class")) continue;
     String name = s.substring(0, s.length() - 6);
     try {
       Class<?> c = L.loadClass(PACKAGE + "." + name);
       if (!Quotation.class.isAssignableFrom(c)) continue;
       Q.put(name, (Quotation) c.newInstance());
       System.out.println("  " + name);
       // ClassNotFoundException InstantiationException IllegalAccessException
     } catch (Exception e) {
       continue;
     }
   }
   return Q.size() > 0;
 }
 public Toolbar() {
   button = new JButton[20];
   for (int i = 0; i < imageName24.length; i++) {
     if (i == 6 || i == 10 || i == 11 || i == 14 || i == 16)
       // for adding separator to the toolBar
       addSeparator();
     // for adding the buttons to toolBar
     add(button[i] = new JButton(new ImageIcon(ClassLoader.getSystemResource(imageName24[i]))));
     // for setting the ToolTipText to the button
     button[i].setToolTipText(tipText[i]);
   }
 }
示例#21
0
  /**
   * Creates a new FlowClient
   *
   * @throws IOException
   */
  private FlowClient() {
    // loads things
    super("Flow");

    // sets the icon in the task bar
    try {
      this.setIconImage(ImageIO.read(ClassLoader.getSystemResource("images/icon.png")));
    } catch (IOException e) {
      JOptionPane.showConfirmDialog(
          this,
          "Window icon not found",
          "Missing Image",
          JOptionPane.DEFAULT_OPTION,
          JOptionPane.ERROR_MESSAGE);
    }

    // Sets up communications with the server
    Communicator.initComms(JOptionPane.showInputDialog(null, "TEMP: ENTER IP", "127.0.0.1"));

    // Creates a new PanelManager
    manager = PanelManager.createNewInstance(this);
    this.add(manager);

    // JFrame setup
    this.setResizable(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // Logs off the client when the "big red X" is pressed
    Runtime.getRuntime()
        .addShutdownHook(
            new Thread(
                new Runnable() {

                  @Override
                  public void run() {
                    // Generates a new data packet and sends to server
                    Data logOff = new Data("end_session");
                    UUID sessionID = Communicator.getSessionID();
                    if (sessionID == null) return;
                    Communicator.killAsync();
                    Communicator.communicate(logOff);
                  }
                }));
    this.setSize(
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() * 0.8),
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() * 0.8));
    this.setLocation(
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() * 0.1),
        (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() * 0.1));
    this.setVisible(true);
  }
    Sidebar() {
      super(BoxLayout.Y_AXIS);

      try {
        back =
            ImageIO.read(
                ClassLoader.getSystemClassLoader()
                    .getResource("org/madeirahs/editor/ui/help_sidebar.png"));
        scaleImage();
        setPreferredSize(new Dimension(back.getWidth(), back.getHeight()));
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
示例#23
0
  public WalletSumPanel(BigInteger balance) {

    this.setBackground(Color.WHITE);
    double width = this.getSize().getWidth();
    this.setPreferredSize(new Dimension(500, 50));
    Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
    Border empty = new EmptyBorder(5, 8, 5, 8);
    CompoundBorder border = new CompoundBorder(line, empty);

    JLabel addressField = new JLabel();
    addressField.setPreferredSize(new Dimension(300, 35));
    this.add(addressField);

    JTextField amount = new JTextField();
    amount.setBorder(border);
    amount.setEnabled(true);
    amount.setEditable(false);
    amount.setText(Utils.getValueShortString(balance));

    amount.setPreferredSize(new Dimension(100, 35));
    amount.setForeground(new Color(143, 170, 220));
    amount.setHorizontalAlignment(SwingConstants.RIGHT);
    amount.setFont(new Font("Monospaced", 0, 13));
    amount.setBackground(Color.WHITE);
    this.add(amount);

    URL payoutIconURL = ClassLoader.getSystemResource("buttons/wallet-pay.png");
    ImageIcon payOutIcon = new ImageIcon(payoutIconURL);
    JLabel payOutLabel = new JLabel(payOutIcon);
    payOutLabel.setToolTipText("Payout for all address list");
    payOutLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    payOutLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            JOptionPane.showMessageDialog(null, "Under construction");
          }
        });

    this.add(payOutLabel);
  }
示例#24
0
  /**
   * Constructor del juego que inicializa los valores.
   *
   * @param juga
   * @param jugadorActual
   */
  public Juego(ArrayList<Jugador> juga, Jugador jugadorActual) {
    jugadores = new ArrayList<>();
    this.jugadores = juga;
    this.jugador = jugadorActual;
    loader = Juego.class.getClassLoader();
    utilidades = new Util();
    claseTime = new Time();
    ventana = new JFrame("Concéntrese - Juan S.");
    ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ventana.setSize(520, 475);
    ventana.setLayout(null);
    ventana.setResizable(false);
    contadorJugadas = 0;
    cartaPorDefecto = new ImageIcon(loader.getResource("recursos/carta8.gif"));
    panel = new JPanel();
    panel.setSize(300, 450);
    panel.setLayout(new GridLayout(4, 4));
    intentos = new JLabel("Intento : 0");
    etiquetaTiempoPartida = new JLabel("Tiempo: ");
    tiempoPartida = new JLabel("00.00.000");
    etiquetaTiempoPartida.setFont(etiquetaTiempoPartida.getFont().deriveFont(20.0f));
    tiempoPartida.setFont(tiempoPartida.getFont().deriveFont(20.0f));
    intentos.setFont(intentos.getFont().deriveFont(20.0f));
    intentos.setBounds(320, 50, 200, 30);
    tiempoPartida.setBounds(420, 5, 200, 30);
    etiquetaTiempoPartida.setBounds(320, 5, 200, 30);
    ventana.add(tiempoPartida);
    ventana.add(etiquetaTiempoPartida);
    ventana.add(intentos);
    ventana.add(panel);

    crearMenuSuperior();
    crearMatrizIconos();
    crearArrayBotones();
    crearTemporizador();

    ventana.setLocationRelativeTo(null);
    ventana.setVisible(true);
  }
示例#25
0
 /** Éste método crea una matriz con íconos y los asigna a cada botón. */
 private void crearMatrizIconos() {
   ImageIcon[][] miMatrizIconos = new ImageIcon[4][4];
   iconos = new ArrayList<>();
   int indice = 0;
   for (int i = 0; i < 4; ++i) {
     for (int j = 0; j < 4; j++) {
       if (indice >= nombreCartas.length) {
         indice = 0;
       }
       miMatrizIconos[i][j] =
           new ImageIcon(loader.getResource("recursos/" + nombreCartas[indice]));
       miMatrizIconos[i][j].setDescription(
           nombreCartas[
               indice]); // set description sirve para dar al usuario una breve explicacion textual
                         // de la imagen.
       iconos.add(miMatrizIconos[i][j]);
       ++indice;
     }
   }
   Collections.shuffle(
       iconos); // el metodo shuffle de la clase collections sirve para bajarar las cartas, es un
                // randomizador de arraylist.
 }
  /** Look on disk for an editor with the class name 'ocName'. */
  PluggableEditor loadEditorFromDisk(String ocName) {
    // if here, we need to look on disk for a pluggable editor class...
    log.finer("looking for ocName: " + ocName);
    try {
      Class c = myLoader.loadClass(ocName);
      Constructor constructor = c.getConstructor(new Class[0]);

      // XXX If the pluggable editor has an error in the constructor, under some
      // XXX circumstances it can fail so badly that this call never returns, and
      // XXX the thread hangs!  It doesn't even get to the exception handler below...
      // XXX but sometimes if the constructor fails everything works as expected.  Wierd.
      PluggableEditor editor = (PluggableEditor) constructor.newInstance(new Object[0]);

      editors.put(ocName, editor); // add the new editor to our list
      return editor;
    } catch (Exception e) // expected condition - just means no pluggable editor available
    {
      if (e
          instanceof
          InvocationTargetException) // rare exception - an error was encountered in the plugin's
                                     // constructor.
      {
        log.warning("unable to load special editor for: '" + ocName + "' " + e);
        if (JXConfig.debugLevel >= 1) {
          log.warning("Error loading plugin class: ");
          ((InvocationTargetException) e).getTargetException().printStackTrace();
        }
      }

      log.log(Level.FINEST, "'Expected' Error loading " + ocName, e);
      editors.put(ocName, NONE); // add a blank place holder - we can't load
      // an editor for this, and there's no point looking again. (change if want dynamic loading,
      // i.e. look *every* time)
    }
    return null; // only here if an error has occured.
  }
示例#27
0
  public static MetaDataLoader getV2ResourceMetaDataLoader(String resourceFile) {
    if (resourceFile == null) resourceFile = "";
    else resourceFile = resourceFile.trim();

    // if (v2Loader == null) System.out.println("CCC v3 meta loader (1) : " + resourceFile);
    // else System.out.println("CCC v3 meta loader (2) : " + v2Loader.getPath() + ", " +
    // resourceFile);
    if (resourceFile.equalsIgnoreCase("null")) resourceFile = "";
    if (!resourceFile.equals("")) {
      MetaDataLoader loader = null;

      File ff = new File(resourceFile);
      if (!ff.exists()) {
        System.out.println(
            "HL7MessageTreeException00 : This is not a valid file or directory path => "
                + resourceFile);
        return null;
      }
      if (ff.isFile()) {
        try {
          loader =
              new MetaDataLoader(
                  resourceFile, edu.knu.medinfo.hl7.v2tree.util.Config.DEFAULT_VERSION);
        } catch (HL7MessageTreeException he) {
          System.out.println("HL7MessageTreeException01 : " + he.getMessage());
          // he.printStackTrace();
          try {
            loader =
                new MetaDataLoader(
                    resourceFile, null, edu.knu.medinfo.hl7.v2tree.util.Config.DEFAULT_VERSION);
          } catch (HL7MessageTreeException he1) {
            System.out.println("HL7MessageTreeException02 : " + he1.getMessage());
            return null;
          }
        }
      } else {
        try {
          loader =
              new MetaDataLoader(
                  resourceFile, null, edu.knu.medinfo.hl7.v2tree.util.Config.DEFAULT_VERSION);
        } catch (HL7MessageTreeException he1) {
          System.out.println("HL7MessageTreeException03 : " + he1.getMessage());
          return null;
        }
      }
      if (loader != null) {
        v2Loader = loader;
        return loader;
      }
    }

    if (v2Loader == null) {
      MetaDataLoader loader = null;
      try {
        loader = new MetaDataLoader();
      } catch (HL7MessageTreeException he) {
        loader = null;
      }
      if (loader != null) {
        v2Loader = loader;
        return loader;
      }

      String name = "v2Meta/version2.4/MessageStructure/ADT_A01.dat";

      Enumeration<URL> fileURLs = null;
      try {
        fileURLs = ClassLoader.getSystemResources(name);
      } catch (IOException ie) {
        System.out.println("IOException #1 : " + ie.getMessage());
      }
      if (fileURLs == null) {
        System.out.println("ClassLoader Result : " + name + " : Not Found");
        return null;
      }
      // System.out.println("Number of Result : " + fileURLs.toString());
      boolean found = false;
      while (fileURLs.hasMoreElements()) {
        URL fileURL = fileURLs.nextElement();

        String url = fileURL.toString();

        if ((url.toLowerCase().startsWith("jar:")) || (url.toLowerCase().startsWith("zip:"))) {
          int idx = url.indexOf("!");
          if (idx < 0) {
            System.err.println("Invalid jar file url : " + url);
            continue;
          }
          String jarFileName = url.substring(4, idx);
          try {
            v2Loader = new MetaDataLoader(jarFileName);
            found = true;
          } catch (HL7MessageTreeException he) {
            continue;
          }
        }
        if ((found) && (v2Loader != null)) return v2Loader;
      }

      v2Loader = null;
      return null;
    } else return v2Loader;
  }
示例#28
0
  private void jbInit() throws Exception {
    titledBorder1 = new TitledBorder("");
    this.setLayout(baseLayout);

    double[][] lower_size = {
      {TableLayout.PREFERRED, TableLayout.FILL, 25}, {25, 25, TableLayout.FILL}
    };
    mLowerPanelLayout = new TableLayout(lower_size);

    mLowerPanel.setLayout(mLowerPanelLayout);

    double[][] dir_size = {
      {TableLayout.FILL, TableLayout.PREFERRED}, {TableLayout.PREFERRED, TableLayout.FILL}
    };
    mDirectionsPanelLayout = new TableLayout(dir_size);
    mDirectionsPanel.setLayout(mDirectionsPanelLayout);

    // Try to get icons for the toolbar buttons
    try {
      ClassLoader loader = getClass().getClassLoader();
      mAddIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/add.gif"));
      mRemoveIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove.gif"));
      mDisabledRemoveIcon =
          new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove_disabled.gif"));

      mAddNodeBtn.setIcon(mAddIcon);
      mRemoveNodeBtn.setIcon(mRemoveIcon);
      mRemoveNodeBtn.setDisabledIcon(mDisabledRemoveIcon);
    } catch (Exception e) {
      // Ack! No icons. Use text labels instead
      mAddNodeBtn.setText("Add");
      mRemoveNodeBtn.setText("Remove");
    }

    /*
    mAddNodeBtn.setMaximumSize(new Dimension(130, 33));
    mAddNodeBtn.setMinimumSize(new Dimension(130, 33));
    mAddNodeBtn.setPreferredSize(new Dimension(130, 33));
    mAddNodeBtn.setText("Add Node");
    */
    mAddNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    /*
    mRemoveNodeBtn.setMaximumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setMinimumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setPreferredSize(new Dimension(130, 33));
    mRemoveNodeBtn.setText("Remove Node");
    */
    mRemoveNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mRemoveNode();
          }
        });
    mHostnameLabel.setHorizontalAlignment(SwingConstants.TRAILING);
    mHostnameLabel.setLabelFor(mHostnameField);
    mHostnameLabel.setText("Hostname:");

    mHostnameField.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    mDirectionsPanel.setBorder(BorderFactory.createEtchedBorder());
    mTitleLabel.setFont(new java.awt.Font("Serif", 1, 20));
    mTitleLabel.setHorizontalAlignment(SwingConstants.CENTER);
    mTitleLabel.setText("Add Cluster Nodes");
    mDirectionsLabel.setText("Click on the add button to add nodes to your cluster configuration.");
    mDirectionsLabel.setLineWrap(true);
    mDirectionsLabel.setEditable(false);
    mDirectionsLabel.setBackground(mTitleLabel.getBackground());

    baseLayout.setHgap(5);
    baseLayout.setVgap(5);
    mLowerPanel.add(
        mHostnameLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mHostnameField, new TableLayoutConstraints(1, 0, 1, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mListScrollPane1,
        new TableLayoutConstraints(0, 1, 1, 2, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mAddNodeBtn, new TableLayoutConstraints(2, 0, 2, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mRemoveNodeBtn, new TableLayoutConstraints(2, 1, 2, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mLowerPanel, BorderLayout.CENTER);
    mListScrollPane1.getViewport().add(lstNodes, null);
    mDirectionsPanel.add(
        mTitleLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mDirectionsLabel,
        new TableLayoutConstraints(0, 1, 0, 1, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mIconLabel, new TableLayoutConstraints(1, 0, 1, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mDirectionsPanel, BorderLayout.NORTH);
  }
  /**
   * ERROR (exceptions) WARN (when something happens that's not supposed to) INFO (wire output)
   * DEBUG (test/displaying intermediate values), TRACE (start/end method)
   */
  public ConnectionConsoleWindow(ToolBar toolBar) {
    final ConnectionConsoleWindow thisConsole = this;
    this.toolBar = toolBar;

    java.net.URL url = ClassLoader.getSystemResource("ethereum-icon.png");
    Toolkit kit = Toolkit.getDefaultToolkit();
    Image img = kit.createImage(url);
    this.setIconImage(img);
    addCloseAction();

    JPanel cp = new JPanel(new BorderLayout());

    AbstractTokenMakerFactory atmf =
        (AbstractTokenMakerFactory) TokenMakerFactory.getDefaultInstance();
    atmf.putMapping("text/console", "org.ethereum.gui.ConsoleTokenMaker");

    textArea = new RSyntaxTextArea(16, 44);
    textArea.setSyntaxEditingStyle("text/console");
    //        textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_LISP);
    textArea.setCodeFoldingEnabled(true);
    textArea.setAntiAliasingEnabled(true);

    changeStyleProgrammatically();
    RTextScrollPane sp = new RTextScrollPane(textArea);

    cp.add(sp);

    setContentPane(cp);
    setTitle("Connection Console");
    //        setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    setLocation(802, 460);

    if (CONFIG.peerDiscovery()) UIEthereumManager.ethereum.startPeerDiscovery();

    Thread t =
        new Thread() {
          public void run() {

            UIEthereumManager.ethereum.connect(
                SystemProperties.CONFIG.activePeerIP(), SystemProperties.CONFIG.activePeerPort());
          }
        };

    UIEthereumManager.ethereum.addListener(
        new EthereumListenerAdapter() {
          @Override
          public void trace(final String output) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    textArea.append(output);
                    textArea.append("\n");

                    if (autoScroll) textArea.setCaretPosition(textArea.getText().length());
                  }
                });
          }
        });
    t.start();
  }
示例#30
0
  public static void main(final String[] args) {
    final JFrame frame = new JFrame();
    frame.setTitle(Globals.getLocalizedString("programName"));
    frame.setBackground(VComponentGlobals.BACKGROUND_COLOR);

    try {
      frame.setIconImage(
          ICODecoder.read(ClassLoader.getSystemResourceAsStream("Art Assets/Icons/Frame_Icon.ico"))
              .get(0));
    } catch (final IOException e) {
      Logger.writeLog(
          Globals.getLocalizedString("DC_error_UnableToLoadIcon"), Logger.LOG_TYPE_ERROR);
    }

    frame.addWindowListener(
        new WindowListener() {
          @Override
          public void windowOpened(WindowEvent e) {}

          @Override
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }

          @Override
          public void windowClosed(WindowEvent e) {
            System.exit(0);
          }

          @Override
          public void windowIconified(WindowEvent e) {}

          @Override
          public void windowDeiconified(WindowEvent e) {}

          @Override
          public void windowActivated(WindowEvent e) {}

          @Override
          public void windowDeactivated(WindowEvent e) {}
        });

    frame.addComponentListener(
        new ComponentAdapter() {
          public void componentResized(ComponentEvent e) {
            final Dimension currentDimensions = frame.getSize();
            final Dimension minimumDimensions = frame.getMinimumSize();

            if (currentDimensions.width < minimumDimensions.width) {
              currentDimensions.width = minimumDimensions.width;
            }

            if (currentDimensions.height < minimumDimensions.height) {
              currentDimensions.height = minimumDimensions.height;
            }

            frame.setSize(currentDimensions);
          }
        });

    frame.add(new ConnectionScreenController(frame).getView());
    frame.setResizable(false);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }