protected AbstractAuthorizationUI getCurrentAuthorisationUI() { switch ((AuthorizationProcedure) cbAuthorisationProcedure.getSelectedItem()) { case FULLY_AUTOMATIC: return pnlFullyAutomaticAuthorisationUI; case MANUALLY: return pnlManualAuthorisationUI; case SEMI_AUTOMATIC: return pnlSemiAutomaticAuthorisationUI; default: return null; } }
/** * Builds the panel with general information in the header * * @return panel woth information display */ protected JPanel buildHeaderInfoPanel() { JPanel pnl = new JPanel(new GridBagLayout()); pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); GridBagConstraints gc = new GridBagConstraints(); // the oauth logo in the header gc.anchor = GridBagConstraints.NORTHWEST; gc.fill = GridBagConstraints.HORIZONTAL; gc.weightx = 1.0; gc.gridwidth = 2; JLabel lbl = new JLabel(); lbl.setIcon(ImageProvider.get("oauth", "oauth-logo")); lbl.setOpaque(true); pnl.add(lbl, gc); // OAuth in a nutshell ... gc.gridy = 1; gc.insets = new Insets(5, 0, 0, 5); HtmlPanel pnlMessage = new HtmlPanel(); pnlMessage.setText( "<html><body>" + tr( "With OAuth you grant JOSM the right to upload map data and GPS tracks " + "on your behalf (<a href=\"{0}\">more info...</a>).", "http://oauth.net/") + "</body></html>"); pnlMessage.getEditorPane().addHyperlinkListener(new ExternalBrowserLauncher()); pnl.add(pnlMessage, gc); // the authorisation procedure gc.gridy = 2; gc.gridwidth = 1; gc.weightx = 0.0; lbl = new JLabel(tr("Please select an authorization procedure: ")); lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN)); pnl.add(lbl, gc); gc.gridx = 1; gc.gridwidth = 1; gc.weightx = 1.0; pnl.add(cbAuthorisationProcedure = new AuthorizationProcedureComboBox(), gc); cbAuthorisationProcedure.addItemListener(new AuthorisationProcedureChangeListener()); return pnl; }
/** * Refreshes the view of the authorisation panel, depending on the authorisation procedure * currently selected */ protected void refreshAuthorisationProcedurePanel() { AuthorizationProcedure procedure = (AuthorizationProcedure) cbAuthorisationProcedure.getSelectedItem(); switch (procedure) { case FULLY_AUTOMATIC: spAuthorisationProcedureUI.getViewport().setView(pnlFullyAutomaticAuthorisationUI); pnlFullyAutomaticAuthorisationUI.revalidate(); break; case SEMI_AUTOMATIC: spAuthorisationProcedureUI.getViewport().setView(pnlSemiAutomaticAuthorisationUI); pnlSemiAutomaticAuthorisationUI.revalidate(); break; case MANUALLY: spAuthorisationProcedureUI.getViewport().setView(pnlManualAuthorisationUI); pnlManualAuthorisationUI.revalidate(); break; } validate(); repaint(); }