void showPasswordDialog(boolean wasWrong) { WebPanel passPanel = new WebPanel(); WebLabel passLabel = new WebLabel(Tr.tr("Please enter your key password:"******"Wrong password")); wrongLabel.setForeground(Color.RED); passPanel.add(wrongLabel, BorderLayout.SOUTH); } WebOptionPane passPane = new WebOptionPane( passPanel, WebOptionPane.QUESTION_MESSAGE, WebOptionPane.OK_CANCEL_OPTION); JDialog dialog = passPane.createDialog(mMainFrame, Tr.tr("Enter password")); dialog.setModal(true); dialog.addWindowFocusListener( new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { passField.requestFocusInWindow(); } }); // blocking dialog.setVisible(true); Object value = passPane.getValue(); if (value != null && value.equals(WebOptionPane.OK_OPTION)) mControl.connect(passField.getPassword()); }
public static Optional<View> create(final ViewControl control) { Optional<View> optView = invokeAndWait( new Callable<View>() { @Override public View call() throws Exception { return new View(control); } }); if (!optView.isPresent()) { LOGGER.log(Level.SEVERE, "can't start view"); return optView; } control.addObserver(optView.get()); return optView; }
private void statusChanged() { Control.Status status = mControl.getCurrentStatus(); switch (status) { case CONNECTING: mStatusBarLabel.setText(Tr.tr("Connecting...")); break; case CONNECTED: mChatView.setColor(Color.WHITE); mStatusBarLabel.setText(Tr.tr("Connected")); NotificationManager.hideAllNotifications(); break; case DISCONNECTING: mStatusBarLabel.setText(Tr.tr("Disconnecting...")); break; case DISCONNECTED: mChatView.setColor(Color.LIGHT_GRAY); mStatusBarLabel.setText(Tr.tr("Not connected")); // if (mTrayIcon != null) // trayIcon.setImage(updatedImage); break; case SHUTTING_DOWN: mMainFrame.save(); mChatListView.save(); mTrayManager.removeTray(); mMainFrame.setVisible(false); mMainFrame.dispose(); break; case FAILED: mStatusBarLabel.setText(Tr.tr("Connecting failed")); break; case ERROR: mChatView.setColor(Color.lightGray); mStatusBarLabel.setText(Tr.tr("Connection error")); break; } mMainFrame.onStatusChanged(status); }
void callCreateNewChat(Set<Contact> contact) { Chat chat = mControl.createNewChat(contact); this.selectChat(chat); }
void callShutDown() { // trigger save if contact details are shown mContent.showNothing(); mControl.shutDown(); }
Control.Status getCurrentStatus() { return mControl.getCurrentStatus(); }