@Action private void keyTyped(java.awt.event.KeyEvent evt) { // {{{ switch (evt.getKeyCode()) { case KeyEvent.VK_ENTER: // sendAsyncTweet(); btnTweet.doClick(); // sendTweetClicked().execute(); break; case KeyEvent.VK_M: if (evt.isControlDown()) view.showMiniMode(); break; case KeyEvent.VK_ESCAPE: view.getMainApp().toggleWindowView("down"); break; // default: // int c = txtTweet.getDocument().getLength(); // lblChars.setText((140 - c)+""); // if((c > 0) && (c < 141)) { // btnTweet.setEnabled(true); // lblChars.setForeground(getResourceMap().getColor("lblChars.foreground")); // } // else if(c > 140) { // lblChars.setForeground(Color.RED); // btnTweet.setEnabled(false); // } // else // { // btnTweet.setEnabled(false); // } } } // }}}
public void update(boolean force) { logger.debug("update() run force = " + force); if (firstrun && view.isConnected() || force) { // Load userlists view Map map = Collections.synchronizedMap(new TreeMap()); map.put("async", true); map.put("caller", this); ArrayList args = new ArrayList(); args.add(view.getAuthenticatedUser().getId()); // screenName args.add(-1L); map.put("arguments", args); fireTwitzEvent( new TwitzEvent(this, TwitzEventType.USER_LISTS, new java.util.Date().getTime(), map)); firstrun = false; } }
public void addUserList(final PagableResponseList userLists) // {{{ { if (userLists != null) { // Clear out the current lists try { SwingUtilities.invokeAndWait( new Runnable() { public void run() { removeAllUserList(); } }); } catch (Exception ie) { logger.error(ie); } SwingWorker<List<UserList>, UserList> worker = new SwingWorker<List<UserList>, UserList>() { int total = -1, count = 1; @Override public List<UserList> doInBackground() { total = userLists.size(); firePropertyChange("started", null, "processing UserLists"); for (Object o : userLists) { if (isUserList(o)) { publish((UserList) o); } } return null; } @Override protected void done() { btnNext.setEnabled(userLists.hasNext()); btnPrev.setEnabled(userLists.hasPrevious()); } @Override protected void process(List<UserList> part) { for (UserList u : part) { firePropertyChange( "message", null, String.format("Processing %d of %d UserLists. Please wait...", count, total)); addUserList(u); count++; } } }; worker.addPropertyChangeListener(view.getStatusListener()); worker.execute(); nextPage = userLists.getNextCursor(); prevPage = userLists.getPreviousCursor(); } } // }}}
@Action public void getPrevious() // {{{ { Map map = Collections.synchronizedMap(new TreeMap()); map.put("async", true); map.put("caller", this); ArrayList args = new ArrayList(); args.add(view.getAuthenticatedUser().getId()); // screenName args.add(prevPage); map.put("arguments", args); fireTwitzEvent( new TwitzEvent(this, TwitzEventType.USER_LISTS, new java.util.Date().getTime(), map)); } // }}}
@Action private void keyReleased(java.awt.event.KeyEvent evt) { // {{{ int c = txtTweet.getDocument().getLength(); lblChars.setText((140 - c) + ""); if ((c > 0) && (c < 141)) { btnTweet.setEnabled(true); lblChars.setForeground(TwitzMainView.getResourceMap().getColor("lblChars.foreground")); } else if (c > 140) { lblChars.setForeground(Color.RED); btnTweet.setEnabled(false); } else { btnTweet.setEnabled(false); } } // }}}
private void initLayout() { // {{{ layout = new javax.swing.GroupLayout(listPanel); super.setLayout(blayout); layout.setHonorsVisibility(true); // layout.setAutoCreateContainerGaps(true); layout.setAutoCreateGaps(true); ParallelGroup pg = layout.createParallelGroup(Alignment.LEADING); SequentialGroup sg = layout.createSequentialGroup(); pg = pg.addGroup(sg); // add components to this one. vgroup = layout.createParallelGroup(Alignment.LEADING); sg.addGroup(vgroup); layout.setHorizontalGroup(pg); // Add out components to this one. hgroup = layout.createSequentialGroup(); ParallelGroup pg1 = layout.createParallelGroup(Alignment.LEADING).addGroup(hgroup); layout.setVerticalGroup(pg1); // Add the listPanel to our layout listPanel.setLayout(layout); add(userListPane, BorderLayout.CENTER); setupToolBar(); add(toolbar, BorderLayout.NORTH); btnNext.setEnabled(false); btnPrev.setEnabled(false); userListPane.setHorizontalScrollBarPolicy( javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); userListPane.setVerticalScrollBarPolicy( javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); userListPane.setAutoscrolls(true); userListPane.setName("userListPane"); // NOI18N userListPane.setViewportView(listPanel); javax.swing.JScrollBar bar = userListPane.getVerticalScrollBar(); bar.setUnitIncrement(50); TwitzMainView.fixJScrollPaneBarsSize(userListPane); } // }}}
@Action public void showMiniMode() { view.showMiniMode(); }