Esempio n. 1
0
  public void actionPerformed(ActionEvent e) {
    note.requestFocus();

    String s = e.getActionCommand();
    if (s.equals(com.floreantpos.POSConstants.OK)) {
      // canceled = false;
      // dispose();
    } else if (s.equals(com.floreantpos.POSConstants.CANCEL)) {
      // canceled = true;
      // dispose();
    } else if (s.equals(com.floreantpos.POSConstants.CLEAR)) {
      String str = note.getText();
      if (str.length() > 0) {
        str = str.substring(0, str.length() - 1);
      }
      note.setText(str);
    } else if (s.equals(com.floreantpos.POSConstants.CLEAR_ALL)) {
      note.setText(""); // $NON-NLS-1$
    } else if (s.equals(Messages.getString("NoteView.43"))) { // $NON-NLS-1$
      String str = note.getText();
      if (str == null) {
        str = ""; // $NON-NLS-1$
      }
      note.setText(str + " "); // $NON-NLS-1$
    } else {
      String str = note.getText();
      if (str == null) {
        str = ""; // $NON-NLS-1$
      }
      note.setText(str + s);
    }
  }
 /** Disposes of the focusable tip currently displayed, if any. */
 public void possiblyDisposeOfTipWindow() {
   if (tipWindow != null) {
     tipWindow.dispose();
     tipWindow = null;
     textAreaListener.uninstall();
     tipVisibleBounds.setBounds(-1, -1, 0, 0);
     lastText = null;
     textArea.requestFocus();
   }
 }
Esempio n. 3
0
  private void setupTab() {

    // The chat area
    BorderLayout chatLayout = new BorderLayout();
    JPanel chatWrapper = new JPanel(chatLayout);

    chatLog = new JTextPane();
    chatLog.setEditable(false);
    chatLog.setDocument(new ChatDocument());
    chatLogScrollPane = new JScrollPane(chatLog);
    chatLogScrollPane.addMouseListener(this);

    chatWrapper.add(chatLogScrollPane, BorderLayout.CENTER);

    // The send message panel
    message = new JTextArea();
    message.addMouseListener(this);
    message.addKeyListener(this);
    messageScrollPane = new JScrollPane(message);
    message.setLineWrap(true);
    message.setWrapStyleWord(true);
    message.requestFocus();
    message.setDocument(new JTextFieldLimit(512));

    sendMessage = new JButton("Send", frame.getGui().getUtil().getImage("sendmessage"));
    sendMessage.addMouseListener(this);
    sendMessage.addActionListener(this);

    chatMessagePanel = new JPanel();
    chatMessagePanel.setLayout(new BoxLayout(chatMessagePanel, BoxLayout.X_AXIS));
    chatMessagePanel.add(messageScrollPane);
    chatMessagePanel.add(sendMessage);

    chatWrapper.add(chatMessagePanel, BorderLayout.PAGE_END);

    // Setup the avatars
    avatarTable = new JTable(new AvatarTableModel(indexNode));
    avatarTable.addMouseListener(this);
    avatarTable.setTableHeader(null);
    avatarTable.setDefaultRenderer(Object.class, new AvatarRenderer(frame));
    avatarTable.setRowHeight(70);
    avatarScrollPane = new JScrollPane(avatarTable);
    avatarScrollPane.setMaximumSize(new Dimension(200, -1));
    avatarScrollPane.setPreferredSize(new Dimension(200, -1));

    // Add all to parent
    BorderLayout pageLayout = new BorderLayout();

    this.setLayout(pageLayout);
    this.add(avatarScrollPane, BorderLayout.LINE_END);
    this.add(chatWrapper, BorderLayout.CENTER);

    // Set the status
    active = true;
  }
Esempio n. 4
0
  @Override
  public void actionPerformed(ActionEvent e) {
    String prefix = "";
    String userName = settingsPane.returnSetting("IRC_nick");
    String input = "<b><font color=blue>[" + userName + "]:</font></b> " + chatInput.getText();

    if (e.getSource() == g_start) {

      substarterBegin(prefix, userName, input);
    }

    if (e.getSource() == g_end) {
      substarterEnd(prefix, userName, input);
    }

    if (e.getSource() == sendButton) {

      if (!chatInput.getText().equals("")) {

        // toChatScreen(input);

        // chatScreen.append(input + "\n");
        if (chatInput.getText().startsWith("/")) {
          if (chatInput.getText().equals("/substart")) {
            substarterBegin(prefix, userName, input);
          }
          if (chatInput.getText().equals("/substartend")) {
            substarterEnd(prefix, userName, input);
          }
        } else {
          sock.outputToChannel(chatInput.getText(), channelName);

          try {
            // chatter.printScreen();

            toChatScreen(prefix + input, false);
          } catch (IOException | BadLocationException ex) {
            Logger.getLogger(IRCBOT.class.getName()).log(Level.SEVERE, null, ex);
          }
        }
        chatInput.setText("");
        // chatter.addTo(input);

      } else {
        chatInput.setText("");
      }
      chatInput.requestFocus();
    }

    if (e.getSource() == settings) {
      // makeNewWindow("Window " + frameCounter, JFrame.DISPOSE_ON_CLOSE, 800, 500, 2);
      settingsPane.showPane();
    }
  }
Esempio n. 5
0
  /** Send the message to the index node */
  @Override
  public void actionPerformed(ActionEvent e) {
    String messageToSend = message.getText();
    messageToSend = messageToSend.replace("\n", "");

    // send the message
    indexNode.sendMessage(messageToSend);

    // Clear the message from the textbox
    message.setText("");
    message.requestFocus();
  }
Esempio n. 6
0
 private void breakpointHit(char pc) {
   registersModel.fireUpdate();
   memoryModel.fireUpdate(0, RAM_SIZE - 1); // TODO optimize
   Integer srcline = asmMap.bin2src(pc);
   if (srcline != null) {
     try {
       sourceTextarea.requestFocus();
       sourceTextarea.setCaretPosition(sourceTextarea.getLineStartOffset(srcline - 1));
     } catch (BadLocationException e) {
       e.printStackTrace();
     }
   }
 }
Esempio n. 7
0
  public void reactivate() {
    // Need to re-register incase the index node has been rebooted
    indexNode.registerChatListener(this);

    message.setEnabled(true);
    message.setText("");
    message.requestFocus();
    sendMessage.setEnabled(true);
    avatarTable.setEnabled(true);
    chatLog.setBackground(Color.white);

    // Set status
    active = true;
  }
  private void showHelp(String help[]) {

    txtCommand.setText(help[0]);

    bHelp = true;

    pResult.removeAll();
    pResult.add(txtResultScroll, BorderLayout.CENTER);
    pResult.doLayout();
    txtResult.setText(help[1]);
    pResult.repaint();
    txtCommand.requestFocus();
    txtCommand.setCaretPosition(help[0].length());
  }
Esempio n. 9
0
  // Updates input and output text areas.
  private void updateWindowComponents() {
    //  Insets      frameInsets = m_Frame.getInsets();
    ///  Dimension   dim = m_Frame.getSize();

    //  dim.height -= (frameInsets.bottom + frameInsets.top);
    //  dim.width -= (frameInsets.right + frameInsets.left);

    // m_TextInput.setSize(dim.width, dim.height / 2);
    // m_TextInput.setLocation(frameInsets.left, frameInsets.top + dim.height / 2);

    // m_TextOutput.setSize(dim.width, dim.height / 2);
    // m_TextOutput.setLocation(frameInsets.left, frameInsets.top);

    m_TextOutput.requestFocus();
  }
Esempio n. 10
0
  private void highlightError(int index) {
    String message = (String) messages.elementAt(index);
    int i = message.indexOf(":");

    if ((i != -1) && (i < 10)) {
      try {
        int lineNumber = Integer.parseInt(message.substring(0, i).trim()) - 1;
        if (lineNumber < sourceArea.getLineCount()) {
          int start = sourceArea.getLineStartOffset(lineNumber);
          int end = sourceArea.getLineEndOffset(lineNumber);

          sourceArea.requestFocus();
          sourceArea.setSelectionStart(start);
          sourceArea.setSelectionEnd(end - 1);
        }
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }
  private void updateResult() {

    if (iResult == 0) {

      // in case 'help' has removed the grid
      if (bHelp) {
        pResult.removeAll();
        pResult.add(gScrollPane, BorderLayout.CENTER);
        pResult.doLayout();
        gResult.fireTableChanged(null);
        pResult.repaint();

        bHelp = false;
      }
    } else {
      showResultInText();
    }

    txtCommand.selectAll();
    txtCommand.requestFocus();
  }
Esempio n. 12
0
  @Override
  public void keyReleased(KeyEvent e) {

    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
      String prefix = "";
      if (!chatInput.getText().equals("")) {
        String userName = settingsPane.returnSetting("IRC_nick");
        String input = "<b><font color=blue>[" + userName + "]:</font></b> " + chatInput.getText();

        // toChatScreen(input);

        // chatScreen.append(input + "\n");
        if (chatInput.getText().startsWith("/")) {
          if (chatInput.getText().equals("/substart")) {
            substarterBegin(prefix, userName, input);
          }
          if (chatInput.getText().equals("/substartend")) {
            substarterEnd(prefix, userName, input);
          }
        } else {

          try {
            // chatter.printScreen();

            toChatScreen(prefix + input, false);
          } catch (IOException | BadLocationException ex) {
            Logger.getLogger(IRCBOT.class.getName()).log(Level.SEVERE, null, ex);
          }
          sock.outputToChannel(chatInput.getText(), channelName);
        }
        chatInput.setText("");
        // chatter.addTo(input);

      } else {
        chatInput.setText("");
      }
      chatInput.requestFocus();
    }
  }
Esempio n. 13
0
    /**
     * Sets the HTML content to be displayed.
     *
     * @param content an HTML document
     */
    private void setDocumentContent(String content) {

      HTMLDocument doc = new HTMLDocument();
      try {
        doc.remove(0, doc.getLength());
      } catch (BadLocationException e) {
        e.printStackTrace();
      }
      doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);

      try {
        htmlPane.read(new ByteArrayInputStream(content.getBytes()), doc);
      } catch (IOException e) {
        e.printStackTrace();
      }

      htmlPane.setDocument(doc);
      htmlPane.setCaretPosition(0);

      taTextResponse.setText(content);
      taTextResponse.setCaretPosition(0);
      taTextResponse.requestFocus();
    }
Esempio n. 14
0
 public void ready() {
   textArea.setText("@" + evm.event.getAuthor() + " ");
   textArea.setCaretPosition(textArea.getText().length());
   textArea.requestFocus();
 }
Esempio n. 15
0
  public IRCBOT(boolean uList, String channel, int chatNum) {

    // chatter = new ChatDisplay("<html><body bgcolor='black'><table border=0pt width=100%>");
    winNum = chatNum;
    URL iconURL = getClass().getResource("P_300x300.png");
    ImageIcon icon = new ImageIcon(iconURL);
    setIconImage(icon.getImage());

    Action doNothing =
        new AbstractAction() {

          @Override
          public void actionPerformed(ActionEvent e) {}
        };

    channelName = channel;
    standardWindow = uList;

    chatInput = new JTextArea(4, 55);
    chatInput.setWrapStyleWord(true);
    chatInput.setLineWrap(true);
    chatInput.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "doNothing");
    chatScreen = new JTextPane();
    chatScreen.setContentType("text/html");
    chatScreen.setEditorKit(kit);
    chatScreen.setDocument(doc);
    userList = new JTextPane();
    registeredUserList = new JTextPane();
    sendButton = new JButton("SEND");
    g_start = new JButton("START");
    g_end = new JButton("END");
    g_reroll = new JButton("secret");

    JLabel l_giveaway = new JLabel("Giveaway", JLabel.CENTER);
    JLabel l_chat = new JLabel("Chat", JLabel.CENTER);
    JLabel l_uList = new JLabel("User List", JLabel.CENTER);

    sendButton.addActionListener(this);
    g_start.addActionListener(this);
    g_end.addActionListener(this);
    g_reroll.addActionListener(this);

    g_start.setEnabled(false); // disabled for basic irc client
    g_end.setEnabled(false);
    g_reroll.setEnabled(false);

    // String start = "<html><body>";

    Dimension min = new Dimension(100, 1);
    Dimension pref = new Dimension(150, 1);
    Dimension max = new Dimension(600, 600);
    // chatScreen.setMinimumSize(min);
    // userList.setMinimumSize(min);
    // chatInput.addKeyListener(KeyBoardListener);

    JPanel mainPanel = new JPanel(new BorderLayout(5, 5));
    JPanel left = new JPanel(new BorderLayout(5, 5));
    JPanel mid = new JPanel(new BorderLayout(5, 5));
    JPanel right = new JPanel(new BorderLayout(5, 5));
    JPanel giveaway_buttons = new JPanel(new BorderLayout(5, 5));

    JPanel sendBar = new JPanel();
    scrollChat = new JScrollPane(chatScreen);
    JScrollPane scrollChatInput = new JScrollPane(chatInput);
    userListScroll = new JScrollPane(userList);
    JScrollPane regUserListScroll = new JScrollPane(registeredUserList);

    userListScroll.setMinimumSize(min);
    // userListScroll.setPreferredSize(pref);
    // userListScroll.setMaximumSize(new Dimension(800,600));
    // userListScroll.setPreferredSize(new Dimension(100,100));
    // scrollChat.setPreferredSize(pref);
    scrollChat.setMinimumSize(min);
    // scrollChat.setMaximumSize(new Dimension(500,500));
    regUserListScroll.setPreferredSize(pref);

    mid.add(l_chat, BorderLayout.NORTH);
    mid.add(scrollChat, BorderLayout.CENTER);

    right.add(l_uList, BorderLayout.NORTH);
    right.add(userListScroll, BorderLayout.CENTER);

    giveaway_buttons.add(g_start, BorderLayout.WEST);
    giveaway_buttons.add(g_end, BorderLayout.CENTER);
    giveaway_buttons.add(g_reroll, BorderLayout.PAGE_END);

    left.add(giveaway_buttons, BorderLayout.PAGE_END);

    JSplitPane chat_userList = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mid, right);
    chat_userList.setOneTouchExpandable(true);
    chat_userList.setDividerLocation(500);
    chat_userList.setResizeWeight(0.5);
    chat_userList.setContinuousLayout(true);
    // chat_userList.setPreferredSize(new Dimension(100,100));
    chat_userList.setMinimumSize(min);
    // chat_userList.setMaximumSize(max);

    userListScroll.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER);
    // scroll.add(chatScreen);

    sendBar.add(scrollChatInput);
    sendBar.add(sendButton);

    if (standardWindow) {

      mainPanel.add(chat_userList, BorderLayout.CENTER);
      mainPanel.add(sendBar, BorderLayout.PAGE_END);

      JMenuBar menuBar = new JMenuBar();
      JMenu fileMenu = new JMenu("File");
      settings = new JMenuItem("Settings");

      settings.addActionListener(this);

      fileMenu.add(settings);
      menuBar.add(fileMenu);

      left.add(l_giveaway, BorderLayout.NORTH);
      left.add(regUserListScroll, BorderLayout.CENTER);
      // left.setBorder(new EmptyBorder(0,5,0,0));
      // chat_userList.setBorder(new EtchedBorder(0,0,0,5));
      mainPanel.add(left, BorderLayout.WEST);
      mainPanel.add(menuBar, BorderLayout.PAGE_START);
      // mainPanel.setBorder(new EmptyBorder(0,10,10,10));
    } else {
      mainPanel.add(scrollChat, BorderLayout.CENTER);
    }
    registeredUserList.setEditable(false);
    userList.setEditable(false);
    chatScreen.setEditable(false);

    registeredUserList.setFont(new Font("Courier New", Font.PLAIN, 12));
    chatScreen.setFont(new Font("Courier New", Font.PLAIN, 12));
    chatInput.setFont(new Font("Courier New", Font.PLAIN, 12));

    getContentPane().add(mainPanel);
    setSize(800, 500);
    setVisible(true);
    setResizable(true);
    setLocationRelativeTo(null);
    setTitle("IRC Chatter");
    setMinimumSize(new Dimension(500, 200));

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            // System.out.println("\n\n\n\n\n\\n\nCLOSEDWINDOW\n\n\n\n\n\n\n\n");
            if (sock.isSafe() == true) sock.outputText("PART " + channelName + "\r\n");
            // System.out.println("\n\n\n\n\n\\n\nCLOSEDWINDOW\n\n\n\n\n\n\n\n");
          }
        });
    chatInput.addKeyListener(this);
    chatInput.requestFocus();
  }
 public void clearCard() {
   question.setText("");
   answer.setText("");
   question.requestFocus();
 }
  void main() {

    CommonSwing.setDefaultColor();

    fMain = new JFrame("HSQL Database Manager");

    // (ulrivo): An actual icon.
    fMain.getContentPane().add(createToolBar(), "North");
    fMain.setIconImage(CommonSwing.getIcon());
    fMain.addWindowListener(this);

    JMenuBar bar = new JMenuBar();

    // used shortcuts: CERGTSIUDOLM
    String fitems[] = {
      "-Connect...", "--", "-Open Script...", "-Save Script...", "-Save Result...", "--", "-Exit"
    };

    addMenu(bar, "File", fitems);

    String vitems[] = {"RRefresh Tree", "--", "GResults in Grid", "TResults in Text"};

    addMenu(bar, "View", vitems);

    String sitems[] = {
      "SSELECT",
      "IINSERT",
      "UUPDATE",
      "DDELETE",
      "---",
      "-CREATE TABLE",
      "-DROP TABLE",
      "-CREATE INDEX",
      "-DROP INDEX",
      "--",
      "-CHECKPOINT",
      "-SCRIPT",
      "-SET",
      "-SHUTDOWN",
      "--",
      "-Test Script"
    };

    addMenu(bar, "Command", sitems);

    mRecent = new JMenu("Recent");

    bar.add(mRecent);

    String soptions[] = {
      "-AutoCommit on",
      "-AutoCommit off",
      "OCommit",
      "LRollback",
      "--",
      "-Disable MaxRows",
      "-Set MaxRows to 100",
      "--",
      "-Logging on",
      "-Logging off",
      "--",
      "-Insert test data"
    };

    addMenu(bar, "Options", soptions);

    String stools[] = {"-Dump", "-Restore", "-Transfer"};

    addMenu(bar, "Tools", stools);
    fMain.setJMenuBar(bar);
    initGUI();

    sRecent = new String[iMaxRecent];

    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = fMain.getSize();

    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
      fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else {
      fMain.setLocation(0, 0);
      fMain.setSize(d);
    }

    fMain.show();

    // (ulrivo): load query from command line
    if (defScript != null) {
      if (defDirectory != null) {
        defScript = defDirectory + File.separator + defScript;
      }

      // if insert stmet is thousands of records...skip showing it
      // as text.  Too huge.
      StringBuffer buf = new StringBuffer();

      ifHuge = DatabaseManagerCommon.readFile(defScript);

      if (4096 <= ifHuge.length()) {
        buf.append("This huge file cannot be edited. Please execute\n");
        txtCommand.setText(buf.toString());
      } else {
        txtCommand.setText(ifHuge);
      }
    }

    txtCommand.requestFocus();
  }