public void unregisterKeyStroke(KeyStroke ks, JComponent c) { // component may have already been removed from the hierarchy, we // need to look up the container using the componentKeyStrokeMap. ComponentKeyStrokePair ckp = new ComponentKeyStrokePair(c, ks); Container topContainer = componentKeyStrokeMap.get(ckp); if (topContainer == null) { // never heard of this pairing, so bail return; } Hashtable keyMap = containerMap.get(topContainer); if (keyMap == null) { // this should never happen, but I'm being safe Thread.dumpStack(); return; } Object tmp = keyMap.get(ks); if (tmp == null) { // this should never happen, but I'm being safe Thread.dumpStack(); return; } if (tmp instanceof JComponent && tmp == c) { keyMap.remove(ks); // remove the KeyStroke from the Map // System.out.println("removed a stroke" + ks); } else if (tmp instanceof Vector) { // this means there is more than one component reg for this key Vector v = (Vector) tmp; v.removeElement(c); if (v.isEmpty()) { keyMap.remove(ks); // remove the KeyStroke from the Map // System.out.println("removed a ks vector"); } } if (keyMap.isEmpty()) { // if no more bindings in this table containerMap.remove(topContainer); // remove table to enable GC // System.out.println("removed a container"); } componentKeyStrokeMap.remove(ckp); // Check for EmbeddedFrame case, they know how to process accelerators even // when focus is not in Java if (topContainer instanceof EmbeddedFrame) { ((EmbeddedFrame) topContainer).unregisterAccelerator(ks); } }
/** * creates a new channel, if the channel exists it is removed (this method doubles as a * removeChannel) * * @param name the name of the channel */ public void newChannel(String name, boolean pass) { if (channels.containsKey(name)) { channels.remove(name); cboChannels.removeItem(name); } else { channels.put(name, new Boolean(pass)); cboChannels.addItem(name); } }
public void unregisterMenuBar(JMenuBar mb) { Container topContainer = getTopAncestor(mb); if (topContainer == null) { return; } Hashtable keyMap = containerMap.get(topContainer); if (keyMap != null) { Vector v = (Vector) keyMap.get(JMenuBar.class); if (v != null) { v.removeElement(mb); if (v.isEmpty()) { keyMap.remove(JMenuBar.class); if (keyMap.isEmpty()) { // remove table to enable GC containerMap.remove(topContainer); } } } } }
public void delete(String name) { table.remove(name); save(); }
/** * Handles the <tt>ActionEvent</tt> generated when user presses one of the buttons in this panel. */ public void actionPerformed(ActionEvent evt) { JButton button = (JButton) evt.getSource(); String buttonName = button.getName(); if (buttonName.equals("call")) { Component selectedPanel = mainFrame.getSelectedTab(); // call button is pressed over an already open call panel if (selectedPanel != null && selectedPanel instanceof CallPanel && ((CallPanel) selectedPanel).getCall().getCallState() == CallState.CALL_INITIALIZATION) { NotificationManager.stopSound(NotificationManager.BUSY_CALL); NotificationManager.stopSound(NotificationManager.INCOMING_CALL); CallPanel callPanel = (CallPanel) selectedPanel; Iterator participantPanels = callPanel.getParticipantsPanels(); while (participantPanels.hasNext()) { CallParticipantPanel panel = (CallParticipantPanel) participantPanels.next(); panel.setState("Connecting"); } Call call = callPanel.getCall(); answerCall(call); } // call button is pressed over the call list else if (selectedPanel != null && selectedPanel instanceof CallListPanel && ((CallListPanel) selectedPanel).getCallList().getSelectedIndex() != -1) { CallListPanel callListPanel = (CallListPanel) selectedPanel; GuiCallParticipantRecord callRecord = (GuiCallParticipantRecord) callListPanel.getCallList().getSelectedValue(); String stringContact = callRecord.getParticipantName(); createCall(stringContact); } // call button is pressed over the contact list else if (selectedPanel != null && selectedPanel instanceof ContactListPanel) { // call button is pressed when a meta contact is selected if (isCallMetaContact) { Object[] selectedContacts = mainFrame.getContactListPanel().getContactList().getSelectedValues(); Vector telephonyContacts = new Vector(); for (int i = 0; i < selectedContacts.length; i++) { Object o = selectedContacts[i]; if (o instanceof MetaContact) { Contact contact = ((MetaContact) o).getDefaultContact(OperationSetBasicTelephony.class); if (contact != null) telephonyContacts.add(contact); else { new ErrorDialog( this.mainFrame, Messages.getI18NString("warning").getText(), Messages.getI18NString( "contactNotSupportingTelephony", new String[] {((MetaContact) o).getDisplayName()}) .getText()) .showDialog(); } } } if (telephonyContacts.size() > 0) createCall(telephonyContacts); } else if (!phoneNumberCombo.isComboFieldEmpty()) { // if no contact is selected checks if the user has chosen // or has // writen something in the phone combo box String stringContact = phoneNumberCombo.getEditor().getItem().toString(); createCall(stringContact); } } else if (selectedPanel != null && selectedPanel instanceof DialPanel) { String stringContact = phoneNumberCombo.getEditor().getItem().toString(); createCall(stringContact); } } else if (buttonName.equalsIgnoreCase("hangup")) { Component selectedPanel = this.mainFrame.getSelectedTab(); if (selectedPanel != null && selectedPanel instanceof CallPanel) { NotificationManager.stopSound(NotificationManager.BUSY_CALL); NotificationManager.stopSound(NotificationManager.INCOMING_CALL); NotificationManager.stopSound(NotificationManager.OUTGOING_CALL); CallPanel callPanel = (CallPanel) selectedPanel; Call call = callPanel.getCall(); if (removeCallTimers.containsKey(callPanel)) { ((Timer) removeCallTimers.get(callPanel)).stop(); removeCallTimers.remove(callPanel); } removeCallPanel(callPanel); if (call != null) { ProtocolProviderService pps = call.getProtocolProvider(); OperationSetBasicTelephony telephony = mainFrame.getTelephonyOpSet(pps); Iterator participants = call.getCallParticipants(); while (participants.hasNext()) { try { // now we hang up the first call participant in the // call telephony.hangupCallParticipant((CallParticipant) participants.next()); } catch (OperationFailedException e) { logger.error("Hang up was not successful: " + e); } } } } } else if (buttonName.equalsIgnoreCase("minimize")) { JCheckBoxMenuItem hideCallPanelItem = mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem(); if (!hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(true); this.setCallPanelVisible(false); } else if (buttonName.equalsIgnoreCase("restore")) { JCheckBoxMenuItem hideCallPanelItem = mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem(); if (hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(false); this.setCallPanelVisible(true); } }