Exemplo n.º 1
0
  @Override
  public void setPressed(boolean b) {
    if ((isPressed() == b) || !isEnabled()) {
      return;
    }

    if (!b && isArmed()) {
      updateState();
    }

    if (b) {
      stateMask |= PRESSED;
    } else {
      stateMask &= ~PRESSED;
    }

    fireStateChanged();

    if (!isPressed() && isArmed()) {
      int modifiers = 0;
      AWTEvent currentEvent = EventQueue.getCurrentEvent();
      if (currentEvent instanceof InputEvent) {
        modifiers = ((InputEvent) currentEvent).getModifiers();
      } else if (currentEvent instanceof ActionEvent) {
        modifiers = ((ActionEvent) currentEvent).getModifiers();
      }
      fireActionPerformed(
          new ActionEvent(
              this,
              ActionEvent.ACTION_PERFORMED,
              getActionCommand(),
              EventQueue.getMostRecentEventTime(),
              modifiers));
    }
  }
Exemplo n.º 2
0
  /** Initializes the core phone objects. */
  private void initializePhone() {
    // Load Preferences
    loadPreferences();

    if (preferences == null) {
      return;
    }

    guiManager = new GuiManager();
    guiManager.addUserActionListener(this);
    logManager = new LogManagerImpl(this);

    this.getLogManager().setRemoteLogging(true);

    try {
      EventQueue.invokeAndWait(
          new Runnable() {
            @Override
            public void run() {
              registerMenu = new JCheckBoxMenuItem(PhoneRes.getIString("phone.enabled"));
            }
          });
    } catch (Exception e) {
      Log.error(e);
    }

    registerMenu.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            if (getStatus() == SipRegisterStatus.Unregistered
                || getStatus() == SipRegisterStatus.RegistrationFailed) {

              register();
            } else {
              handleUnregisterRequest();
            }
          }
        });

    SIPConfig.setPreferredNetworkAddress(preferences.getPreferredAddress());
    NetworkAddressManager.start();

    try {
      EventQueue.invokeAndWait(
          new Runnable() {
            @Override
            public void run() {
              // Initialize Missed calls
              missedCalls = new MissedCalls();
            }
          });
    } catch (Exception e) {
      Log.error(e);
    }

    final JMenu actionsMenu =
        SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.actions"));
    actionsMenu.add(registerMenu);
  }
Exemplo n.º 3
0
  @Override
  public ActionCallback show() {
    LOG.assertTrue(
        EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
    if (myTypeAheadCallback != null) {
      IdeFocusManager.getInstance(myProject).typeAheadUntil(myTypeAheadCallback);
    }
    LOG.assertTrue(
        EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
    final ActionCallback result = new ActionCallback();

    final AnCancelAction anCancelAction = new AnCancelAction();
    final JRootPane rootPane = getRootPane();
    anCancelAction.registerCustomShortcutSet(
        new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)), rootPane);
    myDisposeActions.add(
        new Runnable() {
          @Override
          public void run() {
            anCancelAction.unregisterCustomShortcutSet(rootPane);
          }
        });

    if (!myCanBeParent && myWindowManager != null) {
      myWindowManager.doNotSuggestAsParent(myDialog.getWindow());
    }

    final CommandProcessorEx commandProcessor =
        ApplicationManager.getApplication() != null
            ? (CommandProcessorEx) CommandProcessor.getInstance()
            : null;
    final boolean appStarted = commandProcessor != null;

    if (myDialog.isModal() && !isProgressDialog()) {
      if (appStarted) {
        commandProcessor.enterModal();
        LaterInvocator.enterModal(myDialog);
      }
    }

    if (appStarted) {
      hidePopupsIfNeeded();
    }

    try {
      myDialog.show();
    } finally {
      if (myDialog.isModal() && !isProgressDialog()) {
        if (appStarted) {
          commandProcessor.leaveModal();
          LaterInvocator.leaveModal(myDialog);
        }
      }

      myDialog.getFocusManager().doWhenFocusSettlesDown(result.createSetDoneRunnable());
    }

    return result;
  }
 @TestOnly
 public static void dispatchAllInvocationEventsInIdeEventQueue() throws InterruptedException {
   assert SwingUtilities.isEventDispatchThread() : Thread.currentThread();
   final EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
   while (true) {
     AWTEvent event = eventQueue.peekEvent();
     if (event == null) break;
     AWTEvent event1 = eventQueue.getNextEvent();
     if (event1 instanceof InvocationEvent) {
       IdeEventQueue.getInstance().dispatchEvent(event1);
     }
   }
 }
Exemplo n.º 5
0
 @Override
 public void actionPerformed(AnActionEvent anActionEvent) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           final TableCellEditor editor = table.getCellEditor();
           if (editor != null) {
             editor.stopCellEditing();
           }
           final ListSelectionModel selectionModel = table.getSelectionModel();
           final int minIndex = selectionModel.getMinSelectionIndex();
           final int maxIndex = selectionModel.getMaxSelectionIndex();
           if (minIndex == -1 || maxIndex == -1) {
             return;
           }
           final ListWrappingTableModel tableModel = table.getModel();
           for (int i = minIndex; i <= maxIndex; i++) {
             if (selectionModel.isSelectedIndex(i)) {
               tableModel.removeRow(i);
             }
           }
           final int count = tableModel.getRowCount();
           if (count <= minIndex) {
             selectionModel.setSelectionInterval(count - 1, count - 1);
           } else if (minIndex <= 0) {
             if (count > 0) {
               selectionModel.setSelectionInterval(0, 0);
             }
           } else {
             selectionModel.setSelectionInterval(minIndex - 1, minIndex - 1);
           }
         }
       });
 }
Exemplo n.º 6
0
    @Override
    public void keyPressed(KeyEvent evt) {
      switch (evt.getKeyCode()) {
        case KeyEvent.VK_SPACE:
          goToSelectedNode(M_OPEN);

          // f**k me dead
          EventQueue.invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  resultTree.requestFocus();
                }
              });

          evt.consume();
          break;
        case KeyEvent.VK_ENTER:
          goToSelectedNode(M_OPEN);
          evt.consume();
          break;
        case KeyEvent.VK_DELETE:
          removeSelectedNode();
          evt.consume();
          break;
        default:
          break;
      }
    }
Exemplo n.º 7
0
 /* (non-Javadoc)
  * @see java.awt.Component#doLayout()
  */
 public void doLayout() {
   if (EventQueue.isDispatchThread()) {
     Dimension size = this.getSize();
     this.rblock.setBounds(0, 0, size.width, size.height);
     this.removeAll();
     this.rblock.layout(size.width, size.height);
     this.rblock.updateWidgetBounds();
   } else {
     EventQueue.invokeLater(
         new Runnable() {
           public void run() {
             HtmlBlock.this.doLayout();
           }
         });
   }
 }
  public static void main(String[] args) {

    StringBuffer result = new StringBuffer("<html><body><h1>Fibonacci Sequence</h1><ol>");

    long f1 = 0;
    long f2 = 1;

    for (int i = 0; i < 50; i++) {
      result.append("<li>");
      result.append(f1);
      long temp = f2;
      f2 = f1 + f2;
      f1 = temp;
    }

    result.append("</ol></body></html>");

    JEditorPane jep = new JEditorPane("text/html", result.toString());
    jep.setEditable(false);

    //  new FibonocciRectangles().execute();
    JScrollPane scrollPane = new JScrollPane(jep);
    JFrame f = new JFrame("Fibonacci Sequence");
    f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    f.setContentPane(scrollPane);
    f.setSize(512, 342);
    EventQueue.invokeLater(new FrameShower(f));
  }
 public void insertUpdate(final DocumentEvent e) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           try {
             String inserted = e.getDocument().getText(e.getOffset(), e.getLength());
             int i = inserted.indexOf('\n');
             if (i >= 0) {
               int offset = e.getOffset() + i;
               if (offset + 1 == e.getDocument().getLength()) {
                 returnResponse();
               } else {
                 // remove the '\n' and put it at the end
                 e.getDocument().remove(offset, 1);
                 e.getDocument().insertString(e.getDocument().getLength(), "\n", null);
                 // insertUpdate will be called again, since we have inserted the '\n' at
                 // the end
               }
             } else if (maxLen >= 0
                 && e.getDocument().getLength() - initialPos >= maxLen) {
               returnResponse();
             }
           } catch (BadLocationException ex) {
             returnResponse();
           }
         }
       });
 }
Exemplo n.º 10
0
  /**
   * Create a splash screen (borderless graphic for display while other operations are taking
   * place).
   *
   * @param filename a class-relative path to the splash graphic
   * @param callingClass the class to which the graphic filename location is relative
   */
  public SplashScreen(String filename, Class callingClass) {
    super(new Frame());
    URL imageURL = callingClass.getResource(filename);
    image = Toolkit.getDefaultToolkit().createImage(imageURL);
    // Load the image
    MediaTracker mt = new MediaTracker(this);
    mt.addImage(image, 0);
    try {
      mt.waitForID(0);
    } catch (InterruptedException ie) {
    }

    // Center the window on the screen
    int imgWidth = image.getWidth(this);
    int imgHeight = image.getHeight(this);
    setSize(imgWidth, imgHeight);
    Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation((screenDim.width - imgWidth) / 2, (screenDim.height - imgHeight) / 2);

    setVisible(true);
    repaint();
    // if on a single processor machine, wait for painting (see Fast Java Splash Screen.pdf)
    if (!EventQueue.isDispatchThread()) {
      synchronized (this) {
        while (!this.paintCalled) {
          try {
            this.wait();
          } catch (InterruptedException e) {
          }
        }
      }
    }
  }
Exemplo n.º 11
0
 public static void main(String[] args) {
   EventQueue.invokeLater(
       () -> {
         Main m = new Main();
         m.setVisible(true);
       });
 }
 public void dispose() {
   LOG.assertTrue(EventQueue.isDispatchThread(), Thread.currentThread().getName());
   myAbstractTreeBuilder = null;
   // this will also dispose wrapped TreeModel
   myTreeModelWrapper.dispose();
   myFileEditor = null;
 }
Exemplo n.º 13
0
  /**
   * Main method. Begins the GUI, and the rest of the program.
   *
   * @param args the command line arguments
   */
  public static void main(String args[]) {
    // playSound();
    try {
      for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (ClassNotFoundException
        | InstantiationException
        | IllegalAccessException
        | UnsupportedLookAndFeelException ex) {
      Logger.getLogger(mainForm.class.getName()).log(Level.SEVERE, null, ex);
    }
    // </editor-fold>

    /* Create and display the form */
    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            new mainForm().setVisible(true);
          }
        });
  }
Exemplo n.º 14
0
 synchronized void append(String val) {
   values.add(val);
   if (queue) {
     queue = false;
     EventQueue.invokeLater(this);
   }
 }
Exemplo n.º 15
0
  // {{{ BrowserView constructor
  BrowserView(final VFSBrowser browser) {
    this.browser = browser;

    tmpExpanded = new HashSet<String>();
    DockableWindowManager dwm = jEdit.getActiveView().getDockableWindowManager();
    KeyListener keyListener = dwm.closeListener(VFSBrowser.NAME);

    parentDirectories = new ParentDirectoryList();
    parentDirectories.addKeyListener(keyListener);
    parentDirectories.setName("parent");

    parentDirectories.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    parentDirectories.setCellRenderer(new ParentDirectoryRenderer());
    parentDirectories.setVisibleRowCount(5);
    parentDirectories.addMouseListener(new ParentMouseHandler());

    final JScrollPane parentScroller = new JScrollPane(parentDirectories);
    parentScroller.setMinimumSize(new Dimension(0, 0));

    table = new VFSDirectoryEntryTable(this);
    table.addMouseListener(new TableMouseHandler());
    table.addKeyListener(new TableKeyListener());
    table.setName("file");
    JScrollPane tableScroller = new JScrollPane(table);
    tableScroller.setMinimumSize(new Dimension(0, 0));
    tableScroller.getViewport().setBackground(table.getBackground());
    tableScroller.getViewport().addMouseListener(new TableMouseHandler());
    splitPane =
        new JSplitPane(
            browser.isHorizontalLayout() ? JSplitPane.HORIZONTAL_SPLIT : JSplitPane.VERTICAL_SPLIT,
            parentScroller,
            tableScroller);
    splitPane.setOneTouchExpandable(true);

    EventQueue.invokeLater(
        new Runnable() {
          public void run() {
            String prop =
                browser.isHorizontalLayout()
                    ? "vfs.browser.horizontalSplitter"
                    : "vfs.browser.splitter";
            int loc = jEdit.getIntegerProperty(prop, -1);
            if (loc == -1) loc = parentScroller.getPreferredSize().height;

            splitPane.setDividerLocation(loc);
            parentDirectories.ensureIndexIsVisible(parentDirectories.getModel().getSize());
          }
        });

    if (browser.isMultipleSelectionEnabled())
      table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    else table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    setLayout(new BorderLayout());

    add(BorderLayout.CENTER, splitPane);

    propertiesChanged();
  } // }}}
Exemplo n.º 16
0
 public static void main(String[] args) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           new Server();
         }
       });
 }
 public static void main(String[] args) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           new AllThoseTerritories();
         }
       });
 }
 public void setDisplayedComponent(final Component comp) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           LodEntryDisplayPanel.this.setComp(comp);
         }
       });
 }
Exemplo n.º 19
0
 public static void main(String args[]) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           new FrontPanel().setComponentAnimation(new Fade(25, 20, 400)).setVisible(true);
         }
       });
 }
Exemplo n.º 20
0
 /** @param args command line arguments */
 public static void main(String[] args) {
   EventQueue.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           new Main();
         }
       });
 }
Exemplo n.º 21
0
 public static void main(String... args) {
   EventQueue.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           createAndShowGUI();
         }
       });
 }
Exemplo n.º 22
0
 @NotNull
 public ModalityState getDefaultModalityState() {
   if (EventQueue.isDispatchThread()) {
     return getCurrentModalityState();
   } else {
     ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
     return progress == null ? getNoneModalityState() : progress.getModalityState();
   }
 }
Exemplo n.º 23
0
 /** @param args the command line arguments */
 public static void main(String args[]) {
   // Build the UI on the Swing thread
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           new LibraryUI();
         }
       });
 }
Exemplo n.º 24
0
 public static void main(String[] sa) {
   Debug.println("main()");
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           new DialTest();
         }
       });
 }
Exemplo n.º 25
0
 public static void main(String[] args) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           JFrame frame = new PostTestFrame();
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setVisible(true);
         }
       });
 }
 String response() {
   EventQueue.invokeLater(this);
   try {
     return resultQueue.take();
   } catch (InterruptedException ex) {
     return null;
   } finally {
     cleanup();
   }
 }
Exemplo n.º 27
0
  public static void main(String[] args) {
    EventQueue.invokeLater(
        new Runnable() {

          @Override
          public void run() {
            new SplitPaneTest().create();
          }
        });
  }
Exemplo n.º 28
0
 synchronized void clear() {
   clear = true;
   curLength = 0;
   lengths.clear();
   values.clear();
   if (queue) {
     queue = false;
     EventQueue.invokeLater(this);
   }
 }
Exemplo n.º 29
0
 public static void main(String[] args) {
   EventQueue.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           Spaceships ex = new Spaceships();
           ex.setVisible(true);
         }
       });
 }
Exemplo n.º 30
0
 @Override
 public void actionPerformed(ActionEvent e) {
   EventQueue.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           fireEditingStopped();
         }
       });
 }