Esempio n. 1
0
  /** Creates a new Main object. */
  public Main() {
    super("ssh-keygen");

    /* try {
    ConfigurationLoader.setLogfile(ConfigurationLoader.getHomeDirectory()
     + "logs/ssh-keygen.log");
    } catch (IOException ex) {
    }*/
    try {
      ConfigurationLoader.initialize(false);
    } catch (ConfigurationException ex) {
    }

    //  Set the frame icon
    setIconImage(new ResourceIcon(ICON).getImage());

    //
    keygen = new KeygenPanel();

    //  Create the center banner panel
    IconWrapperPanel centerPanel = new IconWrapperPanel(new ResourceIcon(ICON), keygen);
    centerPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    //  Button panel
    JPanel buttonPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(6, 6, 0, 0);
    gbc.weighty = 1.0;
    generate = new JButton("Generate");
    generate.addActionListener(this);
    generate.setMnemonic('g');
    this.getRootPane().setDefaultButton(generate);
    UIUtil.jGridBagAdd(buttonPanel, generate, gbc, GridBagConstraints.RELATIVE);
    close = new JButton("Close");
    close.addActionListener(this);
    close.setMnemonic('c');
    UIUtil.jGridBagAdd(buttonPanel, close, gbc, GridBagConstraints.REMAINDER);

    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    southPanel.add(buttonPanel);

    //  Wrap the whole thing in an empty border
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPanel.add(centerPanel, BorderLayout.CENTER);
    mainPanel.add(southPanel, BorderLayout.SOUTH);

    //  Build the main panel
    getContentPane().setLayout(new GridLayout(1, 1));
    getContentPane().add(mainPanel);
  }
Esempio n. 2
0
  public static final void main(String[] args) {
    try {

      /**
       * We use log4j as our logging implementation as it rules but lets not fail if it aint around
       * so we !
       */
      if (System.getProperty("log4j.properties") != null) {

        try {
          Properties properties = new Properties();
          properties.load(ConfigurationLoader.loadFile(System.getProperty("log4j.properties")));

          try {
            Class cls = Class.forName("org.apache.log4j.PropertyConfigurator");
            Object obj = cls.newInstance();
            Method method = cls.getMethod("configure", new Class[] {Properties.class});
            method.invoke(obj, new Object[] {properties});
            System.out.println(System.getProperty("log4j.properties"));
          } catch (Throwable ex) {
          }
        } catch (IOException ex) {
          configureBasicLogging();
        }
      } else {
        configureBasicLogging();
      }

      XmlConfigurationContext context = new XmlConfigurationContext();

      context.setAutomationConfigurationResource("automation.xml");
      context.setFailOnError(false);

      ConfigurationLoader.initialize(false, context);

      SshTerm term = new SshTerm();

      term.init(args);
      term.newContainer();
    } catch (Exception e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
      System.exit(0);
    }
  }