📄 storeconfigdialog.java
字号:
else storeList_ = new JList( nameList ); storeList_.addListSelectionListener( new IListSelectionListener() ); storeList_.setToolTipText( ICEMail.getBundle().getString( "StoreConfig.List.tip" ) ); JScrollPane scroller = new JScrollPane(); scroller.getViewport().add( storeList_ ); AWTUtilities.constrain( listPan, scroller, GridBagConstraints.BOTH, GridBagConstraints.CENTER, 0, 0, 1, 1, 1.0, 1.0 ); JPanel fieldPan = new JPanel(); fieldPan.setLayout( new GridBagLayout() ); fieldPan.setBorder( new EmptyBorder( 4, 4, 4, 4 ) ); AWTUtilities.constrain( cont, fieldPan, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH, 1, 0, 1, 1, 0.7, 0.0 ); int subRow = 0; JLabel lbl; lbl = ComponentFactory.getLabel( ICEMail.getBundle(), "StoreConfig.StoreName" ); lbl.setHorizontalAlignment( JLabel.RIGHT ); AWTUtilities.constrain( fieldPan, lbl, GridBagConstraints.NONE, GridBagConstraints.WEST, 0, subRow, 1, 1, 0.0, 0.0 ); nameField_ = ComponentFactory.getTextField( ICEMail.getBundle(), "StoreConfig.StoreName", null ); AWTUtilities.constrain( fieldPan, nameField_, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1, subRow++, 1, 1, 1.0, 0.0 ); lbl = ComponentFactory.getLabel( ICEMail.getBundle(), "StoreConfig.StoreProtocol" ); lbl.setHorizontalAlignment( JLabel.RIGHT ); AWTUtilities.constrain( fieldPan, lbl, GridBagConstraints.NONE, GridBagConstraints.WEST, 0, subRow, 1, 1, 0.0, 0.0 ); // add all STORE providers to a combo box providerCombo_ = new JComboBox(); Provider[] prov = ICEMail.getDefaultSession().getProviders(); for ( int i = 0 ; i < prov.length ; ++i ) { if ( prov[i].getType() == Provider.Type.STORE ) { providers_.addElement( prov[i] ); providerCombo_.addItem( prov[i].getProtocol() + " (" + prov[i].getVendor() + ')' ); } } providerCombo_.setEditable( false ); providerCombo_.setToolTipText( ICEMail.getBundle().getString( "StoreConfig.StoreProtocol.combo.tip" ) ); providerCombo_.addItemListener( new IItemListener() ); AWTUtilities.constrain( fieldPan, providerCombo_, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1, subRow++, 1, 1, 1.0, 0.0 ); lbl = ComponentFactory.getLabel( ICEMail.getBundle(), "StoreConfig.Hostname" ); lbl.setHorizontalAlignment( JLabel.RIGHT ); AWTUtilities.constrain( fieldPan, lbl, GridBagConstraints.NONE, GridBagConstraints.WEST, 0, subRow, 1, 1, 0.0, 0.0 ); hostField_ = ComponentFactory.getTextField( ICEMail.getBundle(), "StoreConfig.Hostname", null ); hostField_.getDocument().addDocumentListener( new IDocumentListener() ); AWTUtilities.constrain( fieldPan, hostField_, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1, subRow++, 1, 1, 1.0, 0.0 ); lbl = ComponentFactory.getLabel( ICEMail.getBundle(), "StoreConfig.HostAccount" ); lbl.setHorizontalAlignment( JLabel.RIGHT ); AWTUtilities.constrain( fieldPan, lbl, GridBagConstraints.NONE, GridBagConstraints.WEST, 0, subRow, 1, 1, 0.0, 0.0 ); userField_ = ComponentFactory.getTextField( ICEMail.getBundle(), "StoreConfig.HostAccount", null ); userField_.getDocument().addDocumentListener( new IDocumentListener() ); AWTUtilities.constrain( fieldPan, userField_, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1, subRow++, 1, 1, 1.0, 0.0 ); lbl = ComponentFactory.getLabel( ICEMail.getBundle(), "StoreConfig.HostPassword" ); lbl.setHorizontalAlignment( JLabel.RIGHT ); AWTUtilities.constrain( fieldPan, lbl, GridBagConstraints.NONE, GridBagConstraints.WEST, 0, subRow, 1, 1, 0.0, 0.0 ); passField_ = ComponentFactory.getPasswordField( ICEMail.getBundle(), "StoreConfig.HostPassword", null ); passField_.getDocument().addDocumentListener( new IDocumentListener() ); AWTUtilities.constrain( fieldPan, passField_, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1, subRow++, 1, 1, 1.0, 0.0 ); lbl = ComponentFactory.getLabel( ICEMail.getBundle(), "StoreConfig.FilePath" ); lbl.setHorizontalAlignment( JLabel.RIGHT ); AWTUtilities.constrain( fieldPan, lbl, GridBagConstraints.NONE, GridBagConstraints.WEST, 0, subRow, 1, 1, 0.0, 0.0 ); fileField_ = ComponentFactory.getTextField( ICEMail.getBundle(), "StoreConfig.FilePath", null ); fileField_.getDocument().addDocumentListener( new IDocumentListener() ); AWTUtilities.constrain( fieldPan, fileField_, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1, subRow++, 1, 1, 1.0, 0.0 ); lbl = ComponentFactory.getLabel( ICEMail.getBundle(), "StoreConfig.NameSpace" ); lbl.setHorizontalAlignment( JLabel.RIGHT ); AWTUtilities.constrain( fieldPan, lbl, GridBagConstraints.NONE, GridBagConstraints.WEST, 0, subRow, 1, 1, 0.0, 0.0 ); String[] nmSpcTypes = UserProperties.getStringArray( "nameSpaceComboList", NAMESPC_COMBO_DEFAULT ); nameSpaceCombo_ = new JComboBox( nmSpcTypes ); nameSpaceCombo_.setEditable( true ); nameSpaceCombo_.setToolTipText( ICEMail.getBundle().getString( "StoreConfig.NameSpace.combo.tip" ) ); AWTUtilities.constrain( fieldPan, nameSpaceCombo_, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1, subRow++, 1, 1, 1.0, 0.0 ); lbl = ComponentFactory.getLabel( ICEMail.getBundle(), "StoreConfig.StoreURL" ); lbl.setHorizontalAlignment( JLabel.LEFT ); AWTUtilities.constrain( fieldPan, lbl, GridBagConstraints.NONE, GridBagConstraints.WEST, 0, subRow++, 1, 1, 0.0, 0.0 ); urlField_ = ComponentFactory.getTextField( ICEMail.getBundle(), "StoreConfig.StoreURL", null ); urlField_.setEditable( false ); AWTUtilities.constrain( fieldPan, urlField_, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 0, subRow++, 2, 1, 1.0, 0.0 ); JPanel btnPan = new JPanel(); btnPan.setLayout( new GridLayout( 2, 2, 10, 10) ); btnPan.setBorder( JFCUtilities.StandardBorder ); AWTUtilities.constrain( cont, btnPan, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH, 1, 1, 1, 1, 0.7, 0.0 ); JButton btn; btn = ComponentFactory.getButton( ICEMail.getBundle(), "StoreConfig.Save", xlistener, null ); btnPan.add( btn ); btn = ComponentFactory.getButton( ICEMail.getBundle(), "StoreConfig.Clear", xlistener, null ); btnPan.add( btn ); btn = ComponentFactory.getButton( ICEMail.getBundle(), "StoreConfig.Delete", xlistener, null ); btnPan.add( btn ); btn = ComponentFactory.getButton( ICEMail.getBundle(), "StoreConfig.Close", xlistener, null ); btnPan.add( btn ); }//............................................................ private class IActionListener implements ActionListener { /** * Invoked when an action occurs. * <p> * Implementation of java.awt.event.ActionListener.actionPerformed() * * @param event the action event that occured */ public void actionPerformed( ActionEvent event ) { String command = event.getActionCommand(); if ( command.equals( "SAVE" ) ) { saveStore(); } else if ( command.equals( "DELETE" ) ) { removeStore(); } else if ( command.equals( "CLEAR" ) ) { clearFields(); } else if ( command.equals( "CLOSE" ) ) { if ( hasChanged_ ) { FolderTreePanel.getInstance().loadRootStores(); } dispose(); } } }//............................................................ private class IListSelectionListener implements ListSelectionListener { public void valueChanged( ListSelectionEvent event ) { if ( ! event.getValueIsAdjusting() ) { String xstoreName = (String) storeList_.getSelectedValue(); if ( xstoreName != null ) { nameField_.setText( xstoreName ); String xurlStr = UserProperties.getProperty( Configuration.PP_STORE_URL + xstoreName, "" ); String xstoreNmSpcStr = UserProperties.getProperty( Configuration.PP_STORE_NMSPC + xstoreName, "" ); nameField_.setText( xstoreName ); nameSpaceCombo_.setSelectedItem( xstoreNmSpcStr ); URLName xurl = new URLName( xurlStr ); for ( int i = 0; i < providers_.size(); i++ ) { Provider xprovider = (Provider)providers_.elementAt( i ); if ( xurl.getProtocol().equals( xprovider.getProtocol() ) ) { providerCombo_.setSelectedIndex( i ); break; } } userField_.setText( xurl.getUsername() ); passField_.setText( xurl.getPassword() ); hostField_.setText( xurl.getHost() ); fileField_.setText( xurl.getFile() ); urlField_.setText( getStoreURL( true ) ); providerCombo_.repaint( 50 ); nameSpaceCombo_.repaint( 50 ); } } } }//............................................................ private class IDocumentListener implements DocumentListener { public void insertUpdate( DocumentEvent event ) { urlField_.setText( getStoreURL( true ) ); } public void removeUpdate( DocumentEvent event ) { urlField_.setText( getStoreURL( true ) ); } public void changedUpdate( DocumentEvent event ) { } }//............................................................ private class IItemListener implements ItemListener { public void itemStateChanged( ItemEvent event ) { if ( event.getStateChange() == ItemEvent.SELECTED ) { urlField_.setText( getStoreURL( true ) ); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -