예제 #1
0
  public SwingInstall() {
    installer = new Install();
    osTasks = OperatingSystem.getOperatingSystem().getOSTasks(installer);

    appName = installer.getProperty("app.name");

    setTitle(appName + " installer");

    JPanel content = new JPanel(new WizardLayout());
    setContentPane(content);

    caption = new JLabel();
    caption.setFont(new Font("SansSerif", Font.BOLD, 18));

    ActionHandler actionHandler = new ActionHandler();

    cancelButton = new JButton("Cancel");
    cancelButton.setRequestFocusEnabled(false);
    cancelButton.addActionListener(actionHandler);
    prevButton = new JButton("Previous");
    prevButton.setRequestFocusEnabled(false);
    prevButton.addActionListener(actionHandler);
    nextButton = new JButton();
    nextButton.setRequestFocusEnabled(false);
    nextButton.addActionListener(actionHandler);

    content.add(caption);
    content.add(cancelButton);
    content.add(prevButton);
    content.add(nextButton);

    String clazz = OperatingSystem.getOperatingSystem().getClass().getName();
    String completedInfo = "done-" + clazz.substring(clazz.indexOf('$') + 1) + ".html";

    pages =
        new Component[] {
          chooseDirectory = new ChooseDirectory(),
          progress = new SwingProgress(),
          new TextPanel(completedInfo)
        };

    selectComponents = new SelectComponents();

    for (int i = 0; i < pages.length; i++) content.add(pages[i]);

    pageChanged();

    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowHandler());

    Dimension screen = getToolkit().getScreenSize();
    pack();
    setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2);
    setVisible(true);
  }
예제 #2
0
    private JPanel createCompPanel() {
      filesets = new Vector();

      int count = installer.getIntegerProperty("comp.count");
      JPanel panel = new JPanel(new GridLayout(count, 1));

      String osClass = OperatingSystem.getOperatingSystem().getClass().getName();
      osClass = osClass.substring(osClass.indexOf('$') + 1);

      for (int i = 0; i < count; i++) {
        String os = installer.getProperty("comp." + i + ".os");

        if (os != null && !osClass.equals(os)) continue;

        JCheckBox checkBox =
            new JCheckBox(
                installer.getProperty("comp." + i + ".name")
                    + " ("
                    + installer.getProperty("comp." + i + ".disk-size")
                    + "Mb)");
        checkBox.getModel().setSelected(true);
        checkBox.addActionListener(this);
        checkBox.setRequestFocusEnabled(false);

        filesets.addElement(new Integer(i));

        panel.add(checkBox);
      }

      Dimension dim = panel.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      panel.setMaximumSize(dim);

      return panel;
    }
예제 #3
0
  // {{{ EditServer constructor
  EditServer(String portFile) {
    super("jEdit server daemon [" + portFile + "]");
    setDaemon(true);
    this.portFile = portFile;
    try {
      // On Unix, set permissions of port file to rw-------,
      // so that on broken Unices which give everyone read
      // access to user home dirs, people can't see your
      // port file (and hence send arbitriary BeanShell code
      // your way. Nasty.)
      if (OperatingSystem.isUnix()) {
        new File(portFile).createNewFile();
        FileVFS.setPermissions(portFile, 0600);
      }

      // Bind to any port on localhost; accept 2 simultaneous
      // connection attempts before rejecting connections
      socket = new ServerSocket(0, 2, InetAddress.getByName("127.0.0.1"));
      authKey = new Random().nextInt(Integer.MAX_VALUE);
      int port = socket.getLocalPort();

      FileWriter out = new FileWriter(portFile);

      try {
        out.write("b\n");
        out.write(String.valueOf(port));
        out.write("\n");
        out.write(String.valueOf(authKey));
        out.write("\n");
      } finally {
        out.close();
      }

      ok = true;

      Log.log(Log.DEBUG, this, "jEdit server started on port " + socket.getLocalPort());
      Log.log(Log.DEBUG, this, "Authorization key is " + authKey);
    } catch (IOException io) {
      /* on some Windows versions, connections to localhost
       * fail if the network is not running. To avoid
       * confusing newbies with weird error messages, log
       * errors that occur while starting the server
       * as NOTICE, not ERROR */
      Log.log(Log.NOTICE, this, io);
    }
  } // }}}
예제 #4
0
    ChooseDirectory() {
      super(new BorderLayout());

      osTaskDirs = new HashMap();

      JPanel directoryPanel =
          new JPanel(new VariableGridLayout(VariableGridLayout.FIXED_NUM_COLUMNS, 3, 12, 12));

      installDir =
          addField(
              directoryPanel,
              "Install program in:",
              OperatingSystem.getOperatingSystem().getInstallDirectory(appName));

      for (int i = 0; i < osTasks.length; i++) {
        OperatingSystem.OSTask osTask = osTasks[i];
        String label = osTask.getLabel();
        if (label != null) {
          JTextField field = addField(directoryPanel, label, osTask.getDirectory());
          osTaskDirs.put(osTask, field);
        }
      }
      ChooseDirectory.this.add(BorderLayout.NORTH, directoryPanel);
    }
예제 #5
0
  // {{{ HyperSearchResults constructor
  public HyperSearchResults(View view) {
    super(new BorderLayout());

    this.view = view;

    caption = new JLabel();

    Box toolBar = new Box(BoxLayout.X_AXIS);
    toolBar.add(caption);
    toolBar.add(Box.createGlue());

    ActionHandler ah = new ActionHandler();

    highlight = new RolloverButton();
    highlight.setToolTipText(jEdit.getProperty("hypersearch-results.highlight.label"));
    highlight.addActionListener(ah);
    toolBar.add(highlight);

    clear =
        new RolloverButton(
            GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.clear.icon")));
    clear.setToolTipText(jEdit.getProperty("hypersearch-results.clear.label"));
    clear.addActionListener(ah);
    toolBar.add(clear);

    multi = new RolloverButton();
    multi.setToolTipText(jEdit.getProperty("hypersearch-results.multi.label"));
    multi.addActionListener(ah);
    toolBar.add(multi);

    stop =
        new RolloverButton(
            GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.stop.icon")));
    stop.setToolTipText(jEdit.getProperty("hypersearch-results.stop.label"));
    stop.addActionListener(ah);
    toolBar.add(stop);
    stop.setEnabled(false);

    add(BorderLayout.NORTH, toolBar);

    resultTreeRoot = new DefaultMutableTreeNode();
    resultTreeModel = new DefaultTreeModel(resultTreeRoot);
    resultTree = new HighlightingTree(resultTreeModel);
    resultTree.setToolTipText(null);
    resultTree.setCellRenderer(new ResultCellRenderer());
    resultTree.setVisibleRowCount(16);
    resultTree.setRootVisible(false);
    resultTree.setShowsRootHandles(true);
    // the ESCAPE keystroke is assigned to hideTip action by swing
    // it breaks the action usually assigned to close-docking-area by jEdit,
    // so we remove this keystroke binding bug #1955140
    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    resultTree.getInputMap().remove(keyStroke);
    // looks bad with the OS X L&F, apparently...
    if (!OperatingSystem.isMacOSLF()) resultTree.putClientProperty("JTree.lineStyle", "Angled");

    resultTree.setEditable(false);

    resultTree.addKeyListener(new KeyHandler());
    resultTree.addMouseListener(new MouseHandler());

    JScrollPane scrollPane = new JScrollPane(resultTree);
    Dimension dim = scrollPane.getPreferredSize();
    dim.width = 400;
    scrollPane.setPreferredSize(dim);
    add(BorderLayout.CENTER, scrollPane);
    resultTree.setTransferHandler(new ResultTreeTransferHandler());
  } // }}}