private void editCurrent() { GenericEditor editor = tableModel.getEditor(); editor.edit(tableModel.getRowData(objectTable.getSelectedRow())); MainFrame w = (MainFrame) this.getTopLevelAncestor(); w.addToDesktop(editor); editor.show(); }
private static void main2(String[] args) { Config.cmdline(args); try { javabughack(); } catch (InterruptedException e) { return; } setupres(); MainFrame f = new MainFrame(null); if (Utils.getprefb("fullscreen", false)) f.setfs(); f.mt.start(); try { f.mt.join(); } catch (InterruptedException e) { f.g.interrupt(); return; } dumplist(Resource.remote().loadwaited(), Config.loadwaited); dumplist(Resource.remote().cached(), Config.allused); if (ResCache.global != null) { try { Writer w = new OutputStreamWriter(ResCache.global.store("tmp/allused"), "UTF-8"); try { Resource.dumplist(Resource.remote().used(), w); } finally { w.close(); } } catch (IOException e) { } } System.exit(0); }
void addButton_actionPerformed(ActionEvent e) { GenericEditor editor = tableModel.getEditor(); editor.editNew(); MainFrame w = (MainFrame) this.getTopLevelAncestor(); w.addToDesktop(editor); editor.show(); }
private String getTextFor(OpenDefinitionsDocument doc) { DefinitionsPane pane = _frame.getDefPaneGivenODD(doc); String endl = "\n"; // was StringOps.EOL; but Swing uses '\n' for newLine int loc = pane.getCaretPosition(); int start = loc; int end = loc; String text; text = doc.getText(); /* get the starting point of 2 lines up... */ for (int i = 0; i < 4; i++) { if (start > 0) start = text.lastIndexOf(endl, start - endl.length()); } if (start == -1) start = 0; // skip the end line, if we're at one // if (doc.getLength() >= endl.length() && text.substring(start, start+endl.length()) == // endl) // start += endl.length(); if (doc.getLength() >= endl.length() && text.substring(start, start + endl.length()).equals(endl)) start += endl.length(); /* get the ending point 2 lines down */ int index; for (int i = 0; i < 4; i++) { if (end < doc.getLength()) { index = text.indexOf(endl, end + endl.length()); if (index != -1) end = index; } } if (end < start) end = start; text = text.substring(start, end); return text; }
/** * Creates a call to the given list of contacts. * * @param contacts the list of contacts to call to */ public void createCall(Vector contacts) { CallPanel callPanel = new CallPanel(this, contacts); mainFrame.addCallPanel(callPanel); new CreateCallThread(contacts, callPanel).start(); }
/** Save the settings of this panel */ private void saveSettings() { settings.setValue( SettingsClass.FCP2_DEFAULT_PRIO_MESSAGE_UPLOAD, uploadPrioTextField.getText()); settings.setValue( SettingsClass.FCP2_DEFAULT_PRIO_MESSAGE_DOWNLOAD, downloadPrioTextField.getText()); settings.setValue( SettingsClass.FCP2_USE_ONE_CONNECTION_FOR_MESSAGES, useOneConnectionForMessagesCheckBox.isSelected()); settings.setValue(SettingsClass.MAX_MESSAGE_DISPLAY, displayDaysTextField.getText()); settings.setValue(SettingsClass.MAX_MESSAGE_DOWNLOAD, downloadDaysTextField.getText()); settings.setValue( SettingsClass.MESSAGE_BASE, messageBaseTextField.getText().trim().toLowerCase()); settings.setValue( SettingsClass.ALWAYS_DOWNLOAD_MESSAGES_BACKLOAD, alwaysDownloadBackloadCheckBox.isSelected()); settings.setValue( SettingsClass.BOARD_AUTOUPDATE_CONCURRENT_UPDATES, concurrentUpdatesTextField.getText()); settings.setValue( SettingsClass.BOARD_AUTOUPDATE_MIN_INTERVAL, minimumIntervalTextField.getText()); // settings.setValue(SettingsClass.BOARD_AUTOUPDATE_ENABLED, // automaticBoardUpdateCheckBox.isSelected()); // we change setting in MainFrame, this is auto-saved during frostSettings.save() MainFrame.getInstance() .setAutomaticBoardUpdateEnabled(automaticBoardUpdateCheckBox.isSelected()); settings.setValue( SettingsClass.STORAGE_STORE_SENT_MESSAGES, storeSentMessagesCheckBox.isSelected()); settings.setValue(SettingsClass.SILENTLY_RETRY_MESSAGES, silentlyRetryCheckBox.isSelected()); settings.setValue(SettingsClass.ALTERNATE_EDITOR_ENABLED, altEditCheckBox.isSelected()); settings.setValue(SettingsClass.ALTERNATE_EDITOR_COMMAND, altEditTextField.getText()); }
/** Load the settings of this panel */ private void loadSettings() { uploadPrioTextField.setText(settings.getValue(SettingsClass.FCP2_DEFAULT_PRIO_MESSAGE_UPLOAD)); downloadPrioTextField.setText( settings.getValue(SettingsClass.FCP2_DEFAULT_PRIO_MESSAGE_DOWNLOAD)); useOneConnectionForMessagesCheckBox.setSelected( settings.getBoolValue(SettingsClass.FCP2_USE_ONE_CONNECTION_FOR_MESSAGES)); displayDaysTextField.setText(settings.getValue(SettingsClass.MAX_MESSAGE_DISPLAY)); downloadDaysTextField.setText(settings.getValue(SettingsClass.MAX_MESSAGE_DOWNLOAD)); messageBaseTextField.setText(settings.getValue(SettingsClass.MESSAGE_BASE)); alwaysDownloadBackloadCheckBox.setSelected( settings.getBoolValue(SettingsClass.ALWAYS_DOWNLOAD_MESSAGES_BACKLOAD)); minimumIntervalTextField.setText( settings.getValue(SettingsClass.BOARD_AUTOUPDATE_MIN_INTERVAL)); concurrentUpdatesTextField.setText( settings.getValue(SettingsClass.BOARD_AUTOUPDATE_CONCURRENT_UPDATES)); // this setting is in MainFrame automaticBoardUpdateCheckBox.setSelected( MainFrame.getInstance().isAutomaticBoardUpdateEnabled()); refreshUpdateState(); storeSentMessagesCheckBox.setSelected( settings.getBoolValue(SettingsClass.STORAGE_STORE_SENT_MESSAGES)); silentlyRetryCheckBox.setSelected(settings.getBoolValue(SettingsClass.SILENTLY_RETRY_MESSAGES)); altEditCheckBox.setSelected(settings.getBoolValue(SettingsClass.ALTERNATE_EDITOR_ENABLED)); altEditTextField.setEnabled(altEditCheckBox.isSelected()); altEditTextField.setText(settings.getValue(SettingsClass.ALTERNATE_EDITOR_COMMAND)); }
/** * Creates a call to the contact represented by the given string. * * @param contact the contact to call to */ public void createCall(String contact) { CallPanel callPanel = new CallPanel(this, contact); mainFrame.addCallPanel(callPanel); new CreateCallThread(contact, callPanel).start(); }
/** Updates call and hangup buttons' states aa */ private void updateButtonsStateAccordingToSelectedPanel() { Component selectedPanel = mainFrame.getSelectedTab(); if (selectedPanel != null && selectedPanel instanceof CallPanel) { this.hangupButton.setEnabled(true); } else { this.hangupButton.setEnabled(false); } }
public void switchToOriginalColor() { MainFrame.printLog("swiching back to original color", Color.white); Appearance ap = new Appearance(); for (int z = 0; z < CanvasActionListener.colorCubeArrayList.size(); z++) { DNAColorCube pickedCube = CanvasActionListener.colorCubeArrayList.get(z).canvasDNAColorCube; pickedCube.setAppearance(ap); } }
/** * Removes the given call panel tab. * * @param callPanel the CallPanel to remove */ private void removeCallPanel(CallPanel callPanel) { if (callPanel.getCall() != null && activeCalls.contains(callPanel.getCall())) { this.activeCalls.remove(callPanel.getCall()); } mainFrame.removeCallPanel(callPanel); updateButtonsStateAccordingToSelectedPanel(); }
private void loadWindowState() { // load size, location and state of window int lastHeight = Core.frostSettings.getIntValue("helpBrowser.lastFrameHeight"); int lastWidth = Core.frostSettings.getIntValue("helpBrowser.lastFrameWidth"); final int lastPosX = Core.frostSettings.getIntValue("helpBrowser.lastFramePosX"); final int lastPosY = Core.frostSettings.getIntValue("helpBrowser.lastFramePosY"); final boolean lastMaximized = Core.frostSettings.getBoolValue("helpBrowser.lastFrameMaximized"); if (lastHeight <= 0 || lastWidth <= 0) { // first call setSize(780, 550); setLocationRelativeTo(MainFrame.getInstance()); return; } final Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize(); if (lastWidth < 100) { lastWidth = 780; } if (lastHeight < 100) { lastHeight = 550; } if ((lastPosX + lastWidth) > scrSize.width) { setSize(780, 550); setLocationRelativeTo(MainFrame.getInstance()); return; } if ((lastPosY + lastHeight) > scrSize.height) { setSize(780, 550); setLocationRelativeTo(MainFrame.getInstance()); return; } setBounds(lastPosX, lastPosY, lastWidth, lastHeight); if (lastMaximized) { setExtendedState(getExtendedState() | Frame.MAXIMIZED_BOTH); } }
@Override public void actionPerformed(ActionEvent e) { try { if (e.getSource() == ok_button) { if (mainFrame != null) { Client client = new Client(serverAddress.getText(), Integer.parseInt(serverPort.getText()), 0); if (client.getClientThread().getClientSocket().isConnected()) mainFrame.setClient(client); } this.setVisible(false); this.dispose(); } else if (e.getSource() == cancel_button) { mainFrame.setClient(null); this.setVisible(false); this.dispose(); } } catch (NumberFormatException exception) { JOptionPane.showMessageDialog(this, "Invalid value: " + exception.getMessage()); } }
/** * Implements CallListener.incomingCallReceived. When a call is received creates a call panel and * adds it to the main tabbed pane and plays the ring phone sound to the user. */ public void incomingCallReceived(CallEvent event) { Call sourceCall = event.getSourceCall(); CallPanel callPanel = new CallPanel(this, sourceCall, GuiCallParticipantRecord.INCOMING_CALL); mainFrame.addCallPanel(callPanel); if (mainFrame.getState() == JFrame.ICONIFIED) mainFrame.setState(JFrame.NORMAL); if (!mainFrame.isVisible()) mainFrame.setVisible(true); mainFrame.toFront(); this.callButton.setEnabled(true); this.hangupButton.setEnabled(true); NotificationManager.fireNotification( NotificationManager.INCOMING_CALL, null, "Incoming call recived from: " + sourceCall.getCallParticipants().next()); activeCalls.put(sourceCall, callPanel); this.setCallPanelVisible(true); }
/** Creates the text area. */ private void initTextArea() { textArea.setOpaque(false); textArea.setEditable(false); StyledDocument doc = textArea.getStyledDocument(); MutableAttributeSet standard = new SimpleAttributeSet(); StyleConstants.setAlignment(standard, StyleConstants.ALIGN_CENTER); StyleConstants.setFontFamily(standard, textArea.getFont().getFamily()); StyleConstants.setFontSize(standard, 12); doc.setParagraphAttributes(0, 0, standard, true); parentWindow.addSearchFieldListener(this); }
/** * Implements ChangeListener.stateChanged. Enables the hangup button if ones selects a tab in the * main tabbed pane that contains a call panel. */ public void stateChanged(ChangeEvent e) { this.updateButtonsStateAccordingToSelectedPanel(); Component selectedPanel = mainFrame.getSelectedTab(); if (selectedPanel == null || !(selectedPanel instanceof CallPanel)) { Iterator callPanels = activeCalls.values().iterator(); while (callPanels.hasNext()) { CallPanel callPanel = (CallPanel) callPanels.next(); callPanel.removeDialogs(); } } }
public static Map[] showOpenMapDialog(final JFrame owner) throws IOException { final JFileChooser ch = new JFileChooser(); if (config.getFile("mapLastOpenDir") != null) { ch.setCurrentDirectory(config.getFile("mapLastOpenDir")); } ch.setDialogType(JFileChooser.OPEN_DIALOG); ch.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (ch.showOpenDialog(MainFrame.getInstance()) != JFileChooser.APPROVE_OPTION) { return null; } final File dir = ch.getSelectedFile(); config.set("mapLastOpenDir", dir); final String[] maps = dir.list(FILTER_TILES); for (int i = 0; i < maps.length; ++i) { maps[i] = maps[i].substring(0, maps[i].length() - MapIO.EXT_TILE.length()); } final JDialog dialog = new JDialog(owner, Lang.getMsg("gui.chooser")); dialog.setModal(true); dialog.setLocationRelativeTo(null); dialog.setLayout(new BorderLayout()); final JList list = new JList(maps); final JButton btn = new JButton(Lang.getMsg("gui.chooser.Ok")); btn.addActionListener( new AbstractAction() { @Override public void actionPerformed(final ActionEvent e) { if (list.getSelectedValue() != null) { dialog.setVisible(false); } } }); dialog.add(new JScrollPane(list), BorderLayout.CENTER); dialog.add(btn, BorderLayout.SOUTH); dialog.pack(); dialog.setVisible(true); dialog.dispose(); Map[] loadedMaps = new Map[list.getSelectedIndices().length]; for (int i = 0; i < list.getSelectedIndices().length; i++) { loadedMaps[i] = MapIO.loadMap(dir.getPath(), (String) list.getSelectedValues()[i]); } return loadedMaps; }
/** Initializes the call button. */ private void initSMSButton() { if (!parentWindow.hasOperationSet(OperationSetSmsMessaging.class)) return; smsButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.SEND_SMS")); smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON")); buttonPanel.add(smsButton); smsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String searchText = parentWindow.getCurrentSearchText(); if (searchText == null) return; SMSManager.sendSMS(smsButton, searchText); } }); }
public void actionPerformed(ActionEvent e) { // Ask user to confirm exit. int reply = JOptionPane.showConfirmDialog( main, bundle.getString("Exit_application_?"), bundle.getString("Exit"), JOptionPane.YES_NO_OPTION); if (reply != JOptionPane.YES_OPTION) return; // Save MainFrame's bounds Rectangle r = main.getBounds(); Main.setProperty("window.bounds.width", Integer.toString(r.width)); Main.setProperty("window.bounds.height", Integer.toString(r.height)); Main.setProperty("window.bounds.x", Integer.toString(r.x)); Main.setProperty("window.bounds.y", Integer.toString(r.y)); // System Exit Main.saveProperties(); Main.exit(0); }
/** * Creates the <tt>UnknownContactPanel</tt> by specifying the parent window. * * @param window the parent window */ public UnknownContactPanel(MainFrame window) { super(new BorderLayout()); this.parentWindow = window; TransparentPanel mainPanel = new TransparentPanel(new BorderLayout()); this.add(mainPanel, BorderLayout.NORTH); if (!ConfigurationUtils.isAddContactDisabled()) { initAddContactButton(); } initCallButton(); initSMSButton(); initTextArea(); mainPanel.add(textArea, BorderLayout.CENTER); if (callButton.getParent() != null) { textArea.setText( GuiActivator.getResources() .getI18NString( "service.gui.NO_CONTACTS_FOUND", new String[] {'"' + parentWindow.getCurrentSearchText() + '"'})); } else { textArea.setText( GuiActivator.getResources().getI18NString("service.gui.NO_CONTACTS_FOUND_SHORT")); } if (buttonPanel.getComponentCount() > 0) { TransparentPanel southPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER)); southPanel.add(buttonPanel); mainPanel.add(southPanel, BorderLayout.SOUTH); } loadSkin(); }
/** * Implements ListSelectionListener.valueChanged. Enables or disables call and hangup buttons * depending on the selection in the contactlist. */ public void valueChanged(ListSelectionEvent e) { Object o = mainFrame.getContactListPanel().getContactList().getSelectedValue(); if ((e.getFirstIndex() != -1 || e.getLastIndex() != -1) && (o instanceof MetaContact)) { setCallMetaContact(true); // Switch automatically to the appropriate pps in account selector // box and enable callButton if telephony is supported. Contact contact = ((MetaContact) o).getDefaultContact(OperationSetBasicTelephony.class); if (contact != null) { callButton.setEnabled(true); if (contact.getProtocolProvider().isRegistered()) getAccountSelectorBox().setSelected(contact.getProtocolProvider()); } else { callButton.setEnabled(false); } } else if (phoneNumberCombo.isComboFieldEmpty()) { callButton.setEnabled(false); } }
/** Hides the panel containing call and hangup buttons. */ public void setCallPanelVisible(boolean isVisible) { if (isVisible) { this.add(comboPanel, BorderLayout.NORTH); this.add(buttonsPanel, BorderLayout.CENTER); this.minimizeButtonPanel.removeAll(); this.minimizeButtonPanel.add(minimizeButton); } else { this.remove(comboPanel); this.remove(buttonsPanel); this.minimizeButtonPanel.removeAll(); this.minimizeButtonPanel.add(restoreButton); if (mainFrame.isVisible()) this.mainFrame.getContactListPanel().getContactList().requestFocus(); } if (ConfigurationManager.isCallPanelShown() != isVisible) ConfigurationManager.setShowCallPanel(isVisible); this.mainFrame.validate(); }
private void removeCurrent() { LogicItem l = (LogicItem) tableModel.getRowData(objectTable.getSelectedRow()); tableModel.remove(objectTable.getSelectedRow()); MainFrame mf = (MainFrame) this.getTopLevelAncestor(); mf.refreshLists(l, transport.client.tablemodel.GenericTableModel.REFRESH_DELETE); }
/** Invoked when any text is removed from the search field. */ public void textRemoved() { updateTextArea(parentWindow.getCurrentSearchText()); }
/** Shows the "about OLS" dialog on screen. the parent window to use, can be <code>null</code>. */ public void showAboutBox() { MainFrame.showAboutBox(this.host.getVersion()); }
/** @param args */ public static void main(String[] args) { // TODO Auto-generated method stub MainFrame mFrm = new MainFrame(); mFrm.setVisible(true); }
public static void main(String[] args) { MainFrame frame = new MainFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
/** * This class extends a Swing view class. Hence it should only be accessed from the event-handling * thread. */ public class RecentDocFrame extends JWindow { // MainFrame MainFrame _frame; // The manager that gives filenames and icons DisplayManager<OpenDefinitionsDocument> _displayManager = MainFrame.getOddDisplayManager30(); // the label that shows the icon and filename JLabel _label; // the panel that holds the label and textpane JPanel _panel; // the pane that holds the sample of source JTextPane _textpane; // the scroller that holds the text JScrollPane _scroller; // the currently selected document int _current = 0; int _padding = 4; LinkedList<OpenDefinitionsDocument> _docs = new LinkedList<OpenDefinitionsDocument>(); private OptionListener<Color> _colorListener = new OptionListener<Color>() { public void optionChanged(OptionEvent<Color> oce) { updateFontColor(); } }; private OptionListener<Font> _fontListener = new OptionListener<Font>() { public void optionChanged(OptionEvent<Font> oce) { updateFontColor(); } }; private OptionListener<Boolean> _antialiasListener = new OptionListener<Boolean>() { public void optionChanged(OptionEvent<Boolean> oce) { updateFontColor(); } }; private OptionListener<Boolean> _showSourceListener = new OptionListener<Boolean>() { public void optionChanged(OptionEvent<Boolean> oce) { _showSource = oce.value; } }; /* if the pane should antialias itself */ boolean _antiAliasText = false; /* if we should show source code when switching */ boolean _showSource; public RecentDocFrame(MainFrame f) { super(); _frame = f; _current = 0; _label = new JLabel("...") { // Enable anti-aliased text by overriding paintComponent. protected void paintComponent(Graphics g) { if (_antiAliasText && g instanceof Graphics2D) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } super.paintComponent(g); } }; _panel = new JPanel(); _scroller = new JScrollPane(); _textpane = new JTextPane() { // Enable anti-aliased text by overriding paintComponent. protected void paintComponent(Graphics g) { if (_antiAliasText && g instanceof Graphics2D) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } super.paintComponent(g); } }; _textpane.setText("..."); _scroller.getViewport().add(_textpane); _scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); _scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); _scroller.setMaximumSize(new Dimension(300, 200)); _panel.setLayout(new BorderLayout()); _panel.add(_label, BorderLayout.NORTH); _panel.add(_scroller, BorderLayout.SOUTH); getContentPane().add(_panel); pack(); updateFontColor(); _showSource = DrJava.getConfig().getSetting(OptionConstants.SHOW_SOURCE_WHEN_SWITCHING); DrJava.getConfig() .addOptionListener(OptionConstants.DEFINITIONS_BACKGROUND_COLOR, _colorListener); DrJava.getConfig().addOptionListener(OptionConstants.DEFINITIONS_NORMAL_COLOR, _colorListener); DrJava.getConfig().addOptionListener(OptionConstants.FONT_MAIN, _fontListener); DrJava.getConfig().addOptionListener(OptionConstants.TEXT_ANTIALIAS, _antialiasListener); DrJava.getConfig() .addOptionListener(OptionConstants.SHOW_SOURCE_WHEN_SWITCHING, _showSourceListener); } private void updateFontColor() { Font mainFont = DrJava.getConfig().getSetting(OptionConstants.FONT_MAIN); Color backColor = DrJava.getConfig().getSetting(OptionConstants.DEFINITIONS_BACKGROUND_COLOR); Color fontColor = DrJava.getConfig().getSetting(OptionConstants.DEFINITIONS_NORMAL_COLOR); /* make it bigger */ Font titleFont = mainFont.deriveFont((float) (mainFont.getSize() + 3)); _antiAliasText = DrJava.getConfig().getSetting(OptionConstants.TEXT_ANTIALIAS).booleanValue(); _label.setForeground(fontColor); _panel.setBackground(backColor); _label.setFont(titleFont); _textpane.setForeground(fontColor); _textpane.setFont(mainFont); ; _textpane.setBackground(backColor); _scroller.setBackground(backColor); _scroller.setBorder(new EmptyBorder(0, 0, 0, 0)); _panel.setBorder(new LineBorder(fontColor, 1)); } /** * Moves the document d to the beginning of the list if it's already in the list, or it adds it to * the beginning if its not already in the list. */ public void pokeDocument(OpenDefinitionsDocument d) { if (_docs.contains(d)) { _current = _docs.indexOf(d); reset(); } else _docs.addFirst(d); } /** Removes the document from the list. */ public void closeDocument(OpenDefinitionsDocument d) { _docs.remove(d); } private void show(int _current) { OpenDefinitionsDocument doc = _docs.get(_current); String text = getTextFor(doc); _label.setText(_displayManager.getName(doc)); _label.setIcon(_displayManager.getIcon(doc)); if (text.length() > 0) { // as wide as the text area wants, but only 200px high _textpane.setText(text); _scroller.setPreferredSize(_textpane.getPreferredScrollableViewportSize()); if (_scroller.getPreferredSize().getHeight() > 200) _scroller.setPreferredSize( new Dimension((int) _scroller.getPreferredSize().getWidth(), 200)); _scroller.setVisible(_showSource); } else _scroller.setVisible(false); Dimension d = _label.getMinimumSize(); d.setSize(d.getWidth() + _padding * 2, d.getHeight() + _padding * 2); _label.setPreferredSize(d); _label.setHorizontalAlignment(SwingConstants.CENTER); _label.setVerticalAlignment(SwingConstants.CENTER); pack(); centerH(); } /** Sets the current document to be the next document in the list. */ public void next() { if (_docs.size() > 0) { _current++; if (_current >= _docs.size()) _current = 0; show(_current); } } /** Sets the current document to be the previous document in the list. */ public void prev() { if (_docs.size() > 0) { _current--; if (_current < 0) _current = _docs.size() - 1; show(_current); } } private String getTextFor(OpenDefinitionsDocument doc) { DefinitionsPane pane = _frame.getDefPaneGivenODD(doc); String endl = "\n"; // was StringOps.EOL; but Swing uses '\n' for newLine int loc = pane.getCaretPosition(); int start = loc; int end = loc; String text; text = doc.getText(); /* get the starting point of 2 lines up... */ for (int i = 0; i < 4; i++) { if (start > 0) start = text.lastIndexOf(endl, start - endl.length()); } if (start == -1) start = 0; // skip the end line, if we're at one // if (doc.getLength() >= endl.length() && text.substring(start, start+endl.length()) == // endl) // start += endl.length(); if (doc.getLength() >= endl.length() && text.substring(start, start + endl.length()).equals(endl)) start += endl.length(); /* get the ending point 2 lines down */ int index; for (int i = 0; i < 4; i++) { if (end < doc.getLength()) { index = text.indexOf(endl, end + endl.length()); if (index != -1) end = index; } } if (end < start) end = start; text = text.substring(start, end); return text; } /** Resets the frame to point to the first document in the list. */ public void first() { _current = 0; next(); } public void refreshColor() {} /** Sets this frame as visible only if _docs is non empty. Also resets the frame accordingly */ public void setVisible(boolean v) { centerH(); if (_docs.size() > 0) { if (v) { centerV(); refreshColor(); first(); } else reset(); super.setVisible(v); } } /** Centers the frame in the screen. */ private void centerH() { Utilities.setPopupLoc(this, _frame); } /** Centers the frame in the screen. */ private void centerV() { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); setLocation((int) getLocation().getX(), (screenSize.height - frameSize.height) / 2); } /** Moves the selected document to the front of the list. */ public void reset() { if (_current < _docs.size()) _docs.addFirst(_docs.remove(_current)); } /** Returns null if the list is empty, or the currently prefered OpenDefinitionsDocument. */ public OpenDefinitionsDocument getDocument() { if (_docs.size() > 0) return _docs.getFirst(); return null; } // private ImageIcon _getIconResource(String name) { // URL url = RecentDocFrame.class.getResource("icons/" + name); // if (url != null) return new ImageIcon(url); // return null; // } }
/** * 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); } }
public static void main(String[] arg) { final MainFrame frame = new MainFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setVisible(true); }