Beispiel #1
0
  @Test
  public void testShowingPopupMenu() {
    MouseEvent event =
        new MouseEvent(
            manif1,
            MouseEvent.MOUSE_CLICKED,
            WHEN,
            MODS,
            X_LOC,
            Y_LOC,
            ONE_CLICK,
            false,
            MouseEvent.BUTTON3);

    // Assertion that the number of Frames has not changed
    Frame[] framesBefore = Frame.getFrames();
    secondPopupOpener.mousePressed(event);
    Frame[] framesAfter = Frame.getFrames();
    Assert.assertTrue(framesBefore.length == framesAfter.length);

    // Assertion that the count of open Frames has increased by one
    framesBefore = Frame.getFrames();
    firstPopupOpener.mousePressed(event);
    framesAfter = Frame.getFrames();
    Assert.assertTrue(framesBefore.length + 1 == framesAfter.length);
  }
  public static void prepare() {
    // If there's no user to worry about, we're done now.

    String userName = KoLCharacter.getUserName();

    if (userName == null || userName.equals("")) {
      return;
    }

    // If you need to allow for another login, create a login frame
    // to ensure that there is an active frame to display messages.

    if (StaticEntity.getClient() instanceof KoLmafiaGUI) {
      KoLmafiaGUI.constructFrame(LoginFrame.class);
    }

    // Shut down main frame

    if (KoLDesktop.instanceExists()) {
      KoLDesktop.getInstance().dispose();
    }

    // Close down any other active frames.	Since
    // there is at least one active, logout will
    // not be called again.

    Frame[] frames = Frame.getFrames();

    for (int i = 0; i < frames.length; ++i) {
      if (frames[i].getClass() != LoginFrame.class) {
        frames[i].dispose();
      }
    }
  }
  /**
   * Updates LAF of all windows. The method also updates font of components as it's configured in
   * <code>UISettings</code>.
   */
  @Override
  public void updateUI() {
    final UIDefaults uiDefaults = UIManager.getLookAndFeelDefaults();

    fixPopupWeight();

    fixGtkPopupStyle();

    fixTreeWideSelection(uiDefaults);

    fixMenuIssues(uiDefaults);

    if (UIUtil.isUnderAquaLookAndFeel()) {
      uiDefaults.put("Panel.opaque", Boolean.TRUE);
    } else if (UIUtil.isWinLafOnVista()) {
      uiDefaults.put("ComboBox.border", null);
    }

    initInputMapDefaults(uiDefaults);

    uiDefaults.put("Button.defaultButtonFollowsFocus", Boolean.FALSE);

    patchFileChooserStrings(uiDefaults);

    patchLafFonts(uiDefaults);

    patchOptionPaneIcons(uiDefaults);

    fixSeparatorColor(uiDefaults);

    for (Frame frame : Frame.getFrames()) {
      updateUI(frame);
    }
    fireLookAndFeelChanged();
  }
 // TODO maybe something more elegant?
 private void restoreDefaultCursor() {
   Cursor defaultCursor = Cursor.getDefaultCursor();
   Frame[] frames = Frame.getFrames();
   for (int i = frames.length; i-- > 0; ) {
     frames[i].setCursor(defaultCursor);
   }
 }
Beispiel #5
0
  public void setBankInProphet(boolean inBankInProphet) {
    if (inBankInProphet) {
      this.statusLabel.setText(kInProphetStatus);
      this.statusLabel.setForeground(Color.blue);

      // now clear the flags of the other bank windows
      Frame[] frames = Frame.getFrames();

      for (int i = 0; i < frames.length; i++) {
        if (frames[i].isVisible() && frames[i] instanceof BankWindow) {
          BankWindow bankWindow = (BankWindow) frames[i];

          if (bankWindow != this) {
            // this bank isn't in the Prophet
            // because *our* bank is in the Prophet!
            bankWindow.setBankInProphet(false);
          }
        }
      }
    } else {
      this.statusLabel.setText(kNotInProphetStatus);
      this.statusLabel.setForeground(Color.red);
    }

    this.bankInProphet = inBankInProphet;
  }
  /**
   * A method used to open a new <code>RequestFrame</code> which displays the given location,
   * relative to the KoL home directory for the current session. This should be called whenever
   * <code>RequestFrame</code>s need to be created in order to keep code modular.
   */
  public static final void openRequestFrame(final String location) {
    GenericRequest request = RequestEditorKit.extractRequest(location);

    if (location.startsWith("search")
        || location.startsWith("desc")
        || location.startsWith("static")
        || location.startsWith("show")) {
      DescriptionFrame.showRequest(request);
      return;
    }

    Frame[] frames = Frame.getFrames();
    RequestFrame requestHolder = null;

    for (int i = frames.length - 1; i >= 0; --i) {
      if (frames[i].getClass() == RequestFrame.class && ((RequestFrame) frames[i]).hasSideBar()) {
        requestHolder = (RequestFrame) frames[i];
      }
    }

    if (requestHolder == null) {
      RequestSynchFrame.showRequest(request);
      return;
    }

    if (!location.equals("main.php")) {
      requestHolder.refresh(request);
    }
  }
 /** Repaints all displayable window. */
 @Override
 public void repaintUI() {
   Frame[] frames = Frame.getFrames();
   for (Frame frame : frames) {
     repaintUI(frame);
   }
 }
Beispiel #8
0
 /**
  * Finds opened frame by the class type.
  *
  * @param formClass The class of the frame to find.
  */
 public static Frame findOpenedFrameByClassName(Class formClass) {
   Frame[] frames = Frame.getFrames();
   for (int i = 0; i < frames.length; i++) {
     if (frames[i].getClass().getName().equals(formClass.getName())) {
       return frames[i];
     }
   }
   return null;
 }
 /** Updates the UIs of all the known Frames. */
 private static void updateAllUIs() {
   // Check if the current UI is WindowsLookAndfeel and flush the XP style map.
   // Note: Change the package test if this class is moved to a different package.
   Class uiClass = UIManager.getLookAndFeel().getClass();
   if (uiClass.getPackage().equals(DesktopProperty.class.getPackage())) {
     XPStyle.invalidateStyle();
   }
   Frame appFrames[] = Frame.getFrames();
   for (int j = 0; j < appFrames.length; j++) {
     updateWindowUI(appFrames[j]);
   }
 }
Beispiel #10
0
 /** Returns the top visible frame. */
 public static Frame getTopFrame() {
   Frame[] frames = Frame.getFrames();
   for (int i = 0; i < frames.length; i++) {
     if (frames[i].getFocusOwner() != null) {
       return frames[i];
     }
   }
   if (frames.length > 0) {
     return frames[0];
   }
   return null;
 }
Beispiel #11
0
  public void setVisible(boolean inVisible) {
    if (inVisible) {
      super.setVisible(inVisible);
    } else {
      boolean closeWindow = true;

      // see if any child windows are open
      Frame[] frames = Frame.getFrames();

      for (int i = 0; i < frames.length; i++) {
        if (frames[i].isVisible() && frames[i] instanceof PatchWindow) {
          PatchWindow patchWindow = (PatchWindow) frames[i];

          if (patchWindow.getBankWindow() == this) {
            // this will confirm saves etc
            patchWindow.setVisible(false);

            if (patchWindow.isVisible()) {
              closeWindow = false;
              break;
            }
          }
        }
      }

      if (closeWindow) {
        if (this.bank.isModified()) {
          StringBuffer buffer = new StringBuffer();

          buffer.append("Save \"");
          buffer.append(getTitle());
          buffer.append(" before closing?");

          int response =
              JOptionPane.showConfirmDialog(
                  this, buffer.toString(), "Confirm", JOptionPane.YES_NO_CANCEL_OPTION);

          if (response == JOptionPane.YES_OPTION) {
            saveBank(false);
          } else if (response == JOptionPane.CANCEL_OPTION) {
            closeWindow = false;
          }
        }
      }

      if (closeWindow) {
        super.setVisible(false);

        // do NOT dispose() here
      }
    }
  }
  String getNewCollection(Collection<AbstractComponent> sourceComponents) {
    Frame frame = null;
    for (Frame f : Frame.getFrames()) {
      if (f.isActive() || f.isFocused()) {
        frame = f;
      }
    }

    assert frame != null : "Active frame cannot be null.";

    PlaceObjectsInCollectionDialog dialog =
        new PlaceObjectsInCollectionDialog(frame, getSelectedComponentNames(sourceComponents));
    return dialog.getConfirmedTelemetryGroupName();
  }
  /**
   * Updates LAF of all windows. The method also updates font of components as it's configured in
   * <code>UISettings</code>.
   */
  @Override
  public void updateUI() {
    final UIDefaults uiDefaults = UIManager.getLookAndFeelDefaults();

    fixPopupWeight();

    fixGtkPopupStyle();

    fixTreeWideSelection(uiDefaults);

    fixMenuIssues(uiDefaults);

    if (UIUtil.isUnderAquaLookAndFeel()) {
      uiDefaults.put("Panel.opaque", Boolean.TRUE);
    } else if (UIUtil.isWinLafOnVista()) {
      uiDefaults.put("ComboBox.border", null);
    }

    initInputMapDefaults(uiDefaults);

    uiDefaults.put("Button.defaultButtonFollowsFocus", Boolean.FALSE);

    patchFileChooserStrings(uiDefaults);

    patchLafFonts(uiDefaults);

    patchHiDPI(uiDefaults);

    patchGtkDefaults(uiDefaults);

    fixSeparatorColor(uiDefaults);

    updateToolWindows();

    for (Frame frame : Frame.getFrames()) {
      // OSX/Aqua fix: Some image caching components like ToolWindowHeader use
      // com.apple.laf.AquaNativeResources$CColorPaintUIResource
      // a Java wrapper for ObjC MagicBackgroundColor class (Java RGB values ignored).
      // MagicBackgroundColor always reports current Frame background.
      // So we need to set frames background to exact and correct value.
      if (SystemInfo.isMac) {
        //noinspection UseJBColor
        frame.setBackground(new Color(UIUtil.getPanelBackground().getRGB()));
      }

      updateUI(frame);
    }
    fireLookAndFeelChanged();
  }
 private static IdeFrame tryToFindTheOnlyFrame() {
   IdeFrame candidate = null;
   final Frame[] all = Frame.getFrames();
   for (Frame each : all) {
     if (each instanceof IdeFrame) {
       if (candidate == null) {
         candidate = (IdeFrame) each;
       } else {
         candidate = null;
         break;
       }
     }
   }
   return candidate;
 }
  public IdeFrame getIdeFrame(@Nullable final Project project) {
    if (project != null) {
      return getFrame(project);
    }
    final Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
    final Component parent = UIUtil.findUltimateParent(window);
    if (parent instanceof IdeFrame) return (IdeFrame) parent;

    final Frame[] frames = Frame.getFrames();
    for (Frame each : frames) {
      if (each instanceof IdeFrame) {
        return (IdeFrame) each;
      }
    }

    return null;
  }
  void nuevo() {
    Insertar dialogoContacto = new Insertar(Frame.getFrames()[0], true);
    // Asignar el contacto obtenido a la ventana de diálogo
    dialogoContacto.nuevo();
    if (editar == true) {
      salidaSeleccionada = arrayListSalidas.get(jTable1.getSelectedRow());
      Salidas salidaEditar =
          new Salidas(
              salidaSeleccionada.getCod_salida(),
              coordinador.getCod_Coordinador(),
              voluntario.getCod_voluntario(),
              salidaSeleccionada.getObservaciones());

      dialogoContacto.setSalida(salidaEditar);
    }
    dialogoContacto.setVisible(true);
    // Liberar la memoria de pantalla ocupada por la ventana de detalle
    dialogoContacto.dispose();
  }
Beispiel #17
0
  public TestHTML() {
    int d = (Frame.getFrames().length == 0) ? JFrame.EXIT_ON_CLOSE : JFrame.DISPOSE_ON_CLOSE;

    JPanel pan = new JPanel();
    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COL);
    pan.setFont(font);
    lab = new JLabel(MSG); // , SwingConstants.CENTER);
    lab.setName("title");
    lab.setFont(new Font("Serif", 3, 16));
    // lab.setForeground(Color.black);
    pan.add(lab, "North");

    text = new JTextArea("JTextArea\n");
    text.setName("area");
    text.setLineWrap(true);
    text.setFont(font);
    JScrollPane scr1 = new JScrollPane(text);
    scr1.setPreferredSize(new Dimension(300, 500));
    pan.add(scr1, "Center");

    html = new JEditorPane();
    html.setContentType("text/html");
    html.setEditable(false);
    html.addMouseListener(this);
    html.addMouseMotionListener(this);
    JScrollPane scr2 = new JScrollPane(html);
    scr2.setPreferredSize(new Dimension(350, 500));
    pan.add(scr2, "East");

    but = new JButton("Copy text from JTextArea to JEditorPane");
    but.addActionListener(this);
    pan.add(but, "South");

    frm = new JFrame(MSG);
    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(d);
    frm.setLocation(100, 150);
    frm.pack();
    frm.setVisible(true);
  }
  public EditorFont(
      Font systemFont,
      byte[] truetypeFont,
      String lookupFont,
      boolean includesBitmap,
      Object bitmapAntialiasing,
      String bitmapCharset) {
    this.systemFallback = systemFont;
    this.truetypeFont = truetypeFont;
    this.includesBitmap = includesBitmap;
    this.bitmapAntialiasing = bitmapAntialiasing;
    this.bitmapCharset = bitmapCharset;
    this.lookupFont = lookupFont;
    if (truetypeFont != null) {
      try {
        java.awt.Font internal =
            java.awt.Font.createFont(
                java.awt.Font.TRUETYPE_FONT, new ByteArrayInputStream(truetypeFont));
        bestFont = new Font(internal);
        return;
      } catch (Exception err) {
        err.printStackTrace();
        JOptionPane.showMessageDialog(
            java.awt.Frame.getFrames()[0],
            "Error creating font: " + err,
            "TTF Error",
            JOptionPane.ERROR_MESSAGE);
      }
    }

    if (lookupFont != null) {
      bestFont = Font.create(lookupFont.split(";")[0]);
      if (bestFont != null) {
        return;
      }
    }

    bestFont = systemFont;
  }
Beispiel #19
0
  @Override
  public void run() {
    this.emuRunning = true;
    while (this.emuRunning) {
      try {

        /*
         * Pruefen, ob ein Programm geladen oder der Emulator
         * tatsaechlich zurueckgesetzt werden soll
         */
        LoadData loadData = null;
        synchronized (this.monitor) {
          loadData = this.loadData;
          if (loadData != null) {
            this.loadData = null;
          } else {
            if (this.resetLevel == ResetLevel.POWER_ON) {
              Arrays.fill(this.ram, (byte) 0);
            }
          }
        }
        if (loadData != null) {
          loadData.loadIntoMemory(this);
          this.z80cpu.setRegPC(loadData.getStartAddr());
          if (this.emuSys != null) {
            int spInitValue = this.emuSys.getAppStartStackInitValue();
            if (spInitValue > 0) {
              this.z80cpu.setRegSP(spInitValue);
            }
          }
        } else {
          if ((this.resetLevel == ResetLevel.COLD_RESET)
              || (this.resetLevel == ResetLevel.POWER_ON)) {
            this.z80cpu.resetCPU(true);
          } else {
            this.z80cpu.resetCPU(false);
          }
          if (this.emuSys != null) {
            this.emuSys.reset(this.resetLevel, Main.getProperties());
            this.z80cpu.setRegPC(this.emuSys.getResetStartAddress(this.resetLevel));
          }
        }

        // RAM-Floppies und Druckmanager zuruecksetzen
        this.printMngr.reset();
        this.ramFloppy1.reset();
        this.ramFloppy2.reset();
        if ((this.emuSys != null)
            && (this.resetLevel == ResetLevel.POWER_ON)
            && Main.getBooleanProperty("jkcemu.ramfloppy.clear_on_power_on", false)) {
          if (this.emuSys.supportsRAMFloppy1() && (this.ramFloppy1.getUsedSize() > 0)) {
            this.ramFloppy1.clear();
          }
          if (this.emuSys.supportsRAMFloppy2() && (this.ramFloppy2.getUsedSize() > 0)) {
            this.ramFloppy2.clear();
          }
        }

        // Fenster informieren
        final Frame[] frms = Frame.getFrames();
        if (frms != null) {
          EventQueue.invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  for (Frame f : frms) {
                    if (f instanceof BasicFrm) {
                      ((BasicFrm) f).resetFired();
                    }
                  }
                }
              });
        }

        // in die Z80-Emulation verzweigen
        this.resetLevel = ResetLevel.NO_RESET;
        this.z80cpu.run();
      } catch (Z80ExternalException ex) {
      } catch (Exception ex) {
        this.emuRunning = false;
        EventQueue.invokeLater(new ErrorMsg(this.screenFrm, ex));
      }
    }
  }
 /** Updates the UIs of all the known Frames. */
 private static void updateAllUIs() {
   Frame appFrames[] = Frame.getFrames();
   for (Frame frame : appFrames) {
     updateWindowUI(frame);
   }
 }
Beispiel #21
0
    @Override
    public void actionPerformed(ActionEvent arg0) {
      for (Frame f : Frame.getFrames()) if (f.isActive()) parent_frame = (JFrame) f;
      if (arg0.getActionCommand().equalsIgnoreCase("Exit")) {
        parent_frame.dispatchEvent(new WindowEvent(parent_frame, WindowEvent.WINDOW_CLOSING));
      } else if (arg0.getActionCommand().equalsIgnoreCase("NEWUSER")) {
        showNewUserDialog(parent_frame);
      } else if (arg0.getActionCommand().equals("START")) {
        TableUI this_game = games.get("MainGame");
        if (this_game != null) {
          this_game.start();
          game_start_menu.setEnabled(false);
        }
      } else if (arg0.getActionCommand().equals("HOST")) {
        game_host_menu.setEnabled(false);
        game_join_menu.setEnabled(false);
        game_start_menu.setEnabled(true);
        GUITable.this.hostGame("MainGame");
      } else if (arg0.getActionCommand().equals("JOIN")) {
        Matcher m = null;
        Object options[] = {"Connect", "Cancel"};
        String host_str = null;
        JOptionPane jp =
            new JOptionPane(
                "Enter host information",
                JOptionPane.QUESTION_MESSAGE,
                JOptionPane.OK_CANCEL_OPTION,
                null,
                options,
                options[0]);
        jp.setWantsInput(true);
        JDialog jd = jp.createDialog(parent_frame.getContentPane(), "Join Game");
        do {
          jd.setVisible(true);
          Object selection = jp.getValue();
          if ((selection == null) || (selection == options[1])) break;

          host_str = (String) jp.getInputValue();
          for (int i = 0; i < connect_str.length; i++) {
            m = connect_str[i].matcher(host_str);
            if (m.matches()) break;
          }

          if ((m != null) && m.matches()) break;
          JOptionPane.showConfirmDialog(
              parent_frame.getContentPane(),
              "Enter valid format for host information",
              "Error",
              JOptionPane.OK_OPTION,
              JOptionPane.ERROR_MESSAGE);
          m = null;
        } while (m == null);

        if (m != null) {
          game_host_menu.setEnabled(false);
          game_join_menu.setEnabled(false);
          game_start_menu.setEnabled(true);
          GUITable.this.joinGame(host_str, "MainGame");
        }
      }
    }
 private static void changeTablesFont(Font f) {
   Frame[] frames = Frame.getFrames();
   for (Frame frame : frames) {
     changeTablesFont(frame, f);
   }
 }