コード例 #1
0
ファイル: CorpusEditor.java プロジェクト: kzn/gate
 public void actionPerformed(ActionEvent e) {
   List<Resource> loadedDocuments;
   try {
     // get all the documents loaded in the system
     loadedDocuments = Gate.getCreoleRegister().getAllInstances("gate.Document");
   } catch (GateException ge) {
     // gate.Document is not registered in creole.xml....what is!?
     throw new GateRuntimeException(
         "gate.Document is not registered in the creole register!\n"
             + "Something must be terribly wrong...take a vacation!");
   }
   Vector<String> docNames = new Vector<String>();
   for (Resource loadedDocument : new ArrayList<Resource>(loadedDocuments)) {
     if (corpus.contains(loadedDocument)) {
       loadedDocuments.remove(loadedDocument);
     } else {
       docNames.add(loadedDocument.getName());
     }
   }
   JList docList = new JList(docNames);
   docList.getSelectionModel().setSelectionInterval(0, docNames.size() - 1);
   docList.setCellRenderer(renderer);
   final JOptionPane optionPane =
       new JOptionPane(
           new JScrollPane(docList), JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
   final JDialog dialog =
       optionPane.createDialog(CorpusEditor.this, "Add document(s) to this corpus");
   docList.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() == 2) {
             optionPane.setValue(JOptionPane.OK_OPTION);
             dialog.dispose();
           }
         }
       });
   dialog.setVisible(true);
   if (optionPane.getValue().equals(JOptionPane.OK_OPTION)) {
     int[] selectedIndices = docList.getSelectedIndices();
     for (int selectedIndice : selectedIndices) {
       corpus.add((Document) loadedDocuments.get(selectedIndice));
     }
   }
   changeMessage();
 }
コード例 #2
0
ファイル: SimulationGui.java プロジェクト: kyrrelm/OS
  /** Creates an places the components used by the GUI. */
  private void placeComponents() {
    memory = new Resource("Memory");
    cpu = new Resource("CPU");
    io = new Resource("I/O");
    loadImages();

    backgroundPanel = new PicturePanel(background);
    getContentPane().setLayout(null);
    getContentPane().add(backgroundPanel);
    backgroundPanel.setBounds(0, 0, 494, 374);
    backgroundPanel.setLayout(null);
    backgroundPanel.add(memoryQueue);
    backgroundPanel.add(cpuQueue);
    backgroundPanel.add(ioQueue);
    backgroundPanel.add(memory);
    backgroundPanel.add(cpu);
    backgroundPanel.add(io);
    memoryQueue.setBounds(110, 20, 200, 50);
    memory.setBounds(310, 10, 90, 90);
    cpuQueue.setBounds(200, 120, 200, 50);
    cpu.setBounds(110, 110, 90, 90);
    ioQueue.setBounds(110, 220, 200, 50);
    io.setBounds(310, 210, 90, 90);

    JPanel lowerPanel = new JPanel();
    lowerPanel.setLayout(null);
    getContentPane().add(lowerPanel);
    lowerPanel.setBounds(0, 374, 494, 100);
    simulationSpeedSlider = new JSlider(0, 10000, 8000);
    lowerPanel.add(simulationSpeedSlider);
    addSliderLabels(lowerPanel, 10, 10, 474, 20, "Slow", "Fast", "Simulation speed");
    simulationSpeedSlider.setBounds(10, 30, 474, 20);
    timeElapsedLabel = new JLabel("Simulated time elapsed: " + timeElapsed + " ms.");
    lowerPanel.add(timeElapsedLabel);
    timeElapsedLabel.setBounds(10, 60, 300, 20);
    startButton = new JButton("Start simulation");
    lowerPanel.add(startButton);
    startButton.setBounds(320, 60, 154, 20);
    startButton.addActionListener(this);
  }
コード例 #3
0
ファイル: ResourceIcon.java プロジェクト: jasonchaffee/VUE
  synchronized void loadResource(Resource r) {

    if (DEBUG.RESOURCE || DEBUG.IMAGE) out("loadResource: " + Util.tag(r) + " " + r);

    mResource = r;
    if (r != null) mPreviewData = r.getPreview();
    else mPreviewData = null;
    mImage = null;

    // URLResource decides this
    // if (mPreviewData == null && mResource.isImage())
    //    mPreviewData = mResource;

    loadPreview(mPreviewData);
  }
コード例 #4
0
ファイル: SimulationGui.java プロジェクト: kyrrelm/OS
 /**
  * Controls which process is being shown as the process active in the I/O device.
  *
  * @param p The process that is currently active, or null if the I/O device is idle.
  */
 public void setIoActive(Process p) {
   io.setActiveProcess(p);
 }
コード例 #5
0
ファイル: SimulationGui.java プロジェクト: kyrrelm/OS
 /**
  * Controls which process is being shown as the process active in the CPU.
  *
  * @param p The process that is currently active, or null if the CPU is idle.
  */
 public void setCpuActive(Process p) {
   cpu.setActiveProcess(p);
 }