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);
  }
 /** Eine Seite, die sich im RAM befindet, anhand der pteRAMlist auswählen und zurückgeben */
 public PageTableEntry selectNextRAMpteAndReplace(PageTableEntry newPte) {
   if (os.getReplacementAlgorithm() == OperatingSystem.ImplementedReplacementAlgorithms.CLOCK) {
     return clockAlgorithm(newPte);
   } else {
     if (os.getReplacementAlgorithm() == OperatingSystem.ImplementedReplacementAlgorithms.FIFO) {
       return fifoAlgorithm(newPte);
     } else {
       return randomAlgorithm(newPte);
     }
   }
 }
    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;
    }
  /**
   * FIFO-Algorithmus: Auswahl = Listenkopf (1. Element) Anschließend Listenkopf löschen, neue Seite
   * (newPte) an Liste anhängen
   */
  private PageTableEntry fifoAlgorithm(PageTableEntry newPte) {
    PageTableEntry pte; // Auswahl

    pte = (PageTableEntry) pteRAMlist.getFirst();
    os.testOut("Prozess " + pid + ": FIFO-Algorithmus hat pte ausgewählt: " + pte.virtPageNum);
    pteRAMlist.removeFirst();
    pteRAMlist.add(newPte);
    return pte;
  }
  /** RANDOM-Algorithmus: Zufällige Auswahl */
  private PageTableEntry randomAlgorithm(PageTableEntry newPte) {
    /* TODO:RANDOM Algorithmus */

    PageTableEntry pte; // Auswahl

    final int randomIndex = new Random().nextInt(pteRAMlist.size());
    pte = (PageTableEntry) pteRAMlist.get(randomIndex);
    os.testOut("Prozess " + pid + ": Random-Algorithmus hat pte ausgewählt: " + pte.virtPageNum);
    pteRAMlist.remove(randomIndex);
    pteRAMlist.add(newPte);
    return pte;
  }
  /**
   * CLOCK-Algorithmus (Second-Chance): Nächstes Listenelement, ausgehend vom aktuellen Index, mit
   * Referenced-Bit = 0 (false) auswählen Sonst R-Bit auf 0 setzen und nächstes Element in der
   * pteRAMlist untersuchen. Anschließend die ausgewählte Seite durch die neue Seite (newPte) am
   * selben Listenplatz ersetzen
   */
  private PageTableEntry clockAlgorithm(PageTableEntry newPte) {
    PageTableEntry pte; // Aktuell untersuchter Seitentabelleneintrag

    // Immer ab altem "Uhrzeigerstand" weitersuchen
    pte = (PageTableEntry) pteRAMlist.get(pteRAMlistIndex);

    // Suche den nächsten Eintrag mit referenced == false (R-Bit = 0)
    while (pte.referenced == true) {
      // Seite wurde referenziert, also nicht auswählen, sondern R-Bit
      // zurücksetzen
      os.testOut(
          "Prozess "
              + pid
              + ": CLOCK-Algorithmus! --- pte.vpn: "
              + pte.virtPageNum
              + " ref: "
              + pte.referenced);
      pte.referenced = false;
      incrementPteRAMlistIndex();
      pte = (PageTableEntry) pteRAMlist.get(pteRAMlistIndex);
    }

    // Seite ausgewählt! (--> pteRAMlistIndex)
    // Alte Seite gegen neue in pteRAMlist austauschen
    pteRAMlist.remove(pteRAMlistIndex);
    pteRAMlist.add(pteRAMlistIndex, newPte);
    // Index auf Nachfolger setzen
    incrementPteRAMlistIndex();
    os.testOut(
        "Prozess "
            + pid
            + ": CLOCK-Algorithmus hat pte ausgewählt: "
            + pte.virtPageNum
            + "  Neuer pteRAMlistIndex ist "
            + pteRAMlistIndex);

    return pte;
  }
    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);
    }
 /** Pte in pteRAMlist eintragen, wenn sich die Zahl der RAM-Seiten des Prozesses erhöht hat. */
 public void pteRAMlistInsert(PageTableEntry pte) {
   os.testOut(
       "pteRAMlistInsert in Prozess " + pid + ": pte mit vpn " + pte.virtPageNum + " angefügt!");
   pteRAMlist.add(pte);
 }
Exemple #9
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());
  } // }}}