⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jrempropertyeditorview.java

📁 JRemoteControl is a simple Java&#8482 driven bluetooth remote control.It allows you to initiate virt
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
										setupBasePath();				}			});						jTextBasePath.addFocusListener(new FocusListener() {				public void focusGained(FocusEvent e) {				}				public void focusLost(FocusEvent e) {					setupBasePath();				}							});					}		return jTextBasePath;	}	/**	 * This method initializes jComboDefView		 * 		 * @return javax.swing.JComboBox		 */	private JComboBox getJComboDefView() {		if (jComboDefView == null) {						jComboDefView = new JComboBox();			jComboDefView.setPreferredSize(new Dimension(90, 17));			jComboDefView.setMaximumSize(new Dimension(90, 23));			jComboDefView.setMinimumSize(new Dimension(90, 23));			jComboDefView.setFont(new Font("Dialog", Font.PLAIN, 12));			jComboDefView.setForeground(Color.BLACK);			jComboDefView.addActionListener(new java.awt.event.ActionListener() {				public void actionPerformed(java.awt.event.ActionEvent e) {										if (updating)						return;					pm.setPropertyValue(JRemProperties.PROP_DEF_VIEW, 							new Short( (short) jComboDefView.getSelectedIndex()));				}			});		}		return jComboDefView;	}	/**	 * This method initializes jComboKey		 * 		 * @return javax.swing.JComboBox		 */	private JComboBox getJComboKey() {		if (jComboKey == null) {			jComboKey = new JComboBox();			jComboKey.setMaximumSize(new Dimension(90, 23));			jComboKey.setPreferredSize(new Dimension(90, 23));			jComboKey.setMinimumSize(new Dimension(90, 23));			jComboKey.setForeground(Color.BLACK);			jComboKey.setFont(new Font("Dialog", Font.PLAIN, 12));			jComboKey.setRenderer(new MobileKeysComboRenderer());			jComboKey.addActionListener(new java.awt.event.ActionListener() {				public void actionPerformed(java.awt.event.ActionEvent e) {					if (updating)						return;					KeyComboItem ci = (KeyComboItem) jComboKey.getSelectedItem();									JRemCommandDoc cmd = (JRemCommandDoc) doc;					if (cmd.getKey().equals(ci.getKey()))						return;										boolean assign = true;										if (ci.isUsed()) {												int res = 							SwingUtils.askYN(JRemPropertyEditorView.this, env, 									"The key " + ci.getValue() + " has already been assigned.\n" +									"Forcing the assignment the key will be removed from\n" +									"current owner command and assigned to new one.\n" +									"Do you want to continue?");						if (res == JOptionPane.YES_OPTION) {														JRemContextDoc ctx = (JRemContextDoc) cmd.getContext();							cmd = ctx.findCommandByKey( (String) ci.getKey());							if (cmd != null)								cmd.setKey(JRemMobileKeys.KEY_NONE);														assign = true;						} else {							JRemServerUtils.setSelectDomainCombo(									jComboKey, JRemProperties.PROP_MOBILE_KEY, pm);							assign = false;						}													}										if (assign)						pm.setPropertyValue(JRemProperties.PROP_MOBILE_KEY, ci.getKey());				}			});		}		return jComboKey;	}	/**	 * This method initializes jTextCmdPath		 * 		 * @return javax.swing.JTextField		 */	private JTextField getJTextCmdPath() {		if (jTextCmdPath == null) {			jTextCmdPath = new JTextField();			jTextCmdPath.setForeground(Color.BLACK);			jTextCmdPath.addActionListener(new java.awt.event.ActionListener() {				public void actionPerformed(java.awt.event.ActionEvent e) {					setupExePath();				}			});						jTextCmdPath.addFocusListener(new FocusListener() {				public void focusGained(FocusEvent e) {				}				public void focusLost(FocusEvent e) {					setupExePath();				}							});								}		return jTextCmdPath;	}	/**	 * This method initializes jButtonBrowseCmdPath		 * 		 * @return javax.swing.JButton		 */	private JButton getJButtonBrowseCmdPath() {		if (jButtonBrowseCmdPath == null) {			jButtonBrowseCmdPath = new JButton();			jButtonBrowseCmdPath.setMaximumSize(new Dimension(25, 20));			jButtonBrowseCmdPath.setPreferredSize(new Dimension(25, 20));			jButtonBrowseCmdPath.setText("...");			jButtonBrowseCmdPath.setMinimumSize(new Dimension(25, 20));			jButtonBrowseCmdPath.addActionListener(new java.awt.event.ActionListener() {				public void actionPerformed(java.awt.event.ActionEvent e) {						File f = SwingUtils.showOpenDialog(env, JRemPropertyEditorView.this);						if (f != null) {														String path = f.getAbsolutePath();							pm.setPropertyValue(JRemProperties.PROP_EXE_PATH, path);						}					}			});		}		return jButtonBrowseCmdPath;	}			private JRemPropertyManager pm;  //  @jve:decl-index=0:	private AbstractDocument doc;  //  @jve:decl-index=0:	private JLabel jLabel221 = null;	private JTextField jTextQuestion = null;	private JLabel jLabel3 = null;	private DocumentListener listener = new DocumentListener() {		public void actionPerformed(DocumentEvent event) {			updateView(event);  //  @jve:decl-index=0:		}	};	public void setDocument(AbstractDocument doc) {		if (this.doc != null) {			commitPendings();			this.doc.removeActionListener(listener);		}		this.doc = (AbstractDocument) doc;		this.pm = (JRemPropertyManager) doc;				if (this.doc != null)			this.doc.addActionListener(listener);	}		private void commitPendings() {				setupDescription();		setupBasePath();		setupExePath();		setupQuestion();	}		private void updateView(DocumentEvent event) {		try {						updating = true;						SwingUtils.showWaitCursor(this, false);							if (event instanceof DocumentModifiedEvent) {								update();												} else {								if (event instanceof DocumentAttachedEvent) {						init();					update();								} else {					disableAll();				}							}					} finally {			updating = false;						SwingUtils.showWaitCursor(this, false);		}	}		private void disableAll() {				getJTextId().setText("");		getJTextId().setEnabled(false);		getJTextId().setEditable(false);				getJTextDescription().setText("");		getJTextDescription().setEnabled(false);		getJTextDescription().setEditable(false);				getJTextBasePath().setText("");		getJTextBasePath().setEnabled(false);		getJTextBasePath().setEditable(false);		getJTextCmdPath().setText("");		getJTextCmdPath().setEnabled(false);		getJTextCmdPath().setEditable(false);				getJComboDefView().setEnabled(false);		getJComboDefView().removeAllItems();				getJComboKey().removeAllItems();		getJComboKey().setEnabled(false);				getJButtonBrowseBaseDir().setEnabled(false);		getJButtonBrowseCmdPath().setEnabled(false);				getJTextQuestion().setText("");		getJTextQuestion().setEnabled(false);		getJTextQuestion().setEditable(false);	}					private void setupComboMobileKeys() {		getJComboKey().removeAllItems();		if (!pm.isManageProperty(JRemProperties.PROP_MOBILE_KEY))			return;		Collection c = pm.getPropertyDomainValues(				JRemProperties.PROP_MOBILE_KEY);				for (Iterator i = c.iterator(); i.hasNext(); ) {						JRemPropertyDomainValue domainValue = 				(JRemPropertyDomainValue) i.next();						KeyComboItem item = new KeyComboItem(					(String) domainValue.getKey(),					(String) domainValue.getValue());						getJComboKey().addItem(item);		}	}		private void init() {		disableAll();						getJTextId().setEnabled(pm.isPropertyEnabled(JRemProperties.PROP_ID));		getJTextId().setEnabled(pm.isPropertyEditable(JRemProperties.PROP_ID));				getJTextDescription().setEnabled(pm.isPropertyEnabled(JRemProperties.PROP_DESCRIPTION));		getJTextDescription().setEditable(pm.isPropertyEditable(JRemProperties.PROP_DESCRIPTION));				getJTextBasePath().setEnabled(pm.isPropertyEnabled(JRemProperties.PROP_BASE_DIR));		getJTextBasePath().setEditable(pm.isPropertyEditable(JRemProperties.PROP_BASE_DIR));				getJTextCmdPath().setEnabled(pm.isPropertyEnabled(JRemProperties.PROP_EXE_PATH));		getJTextCmdPath().setEditable(pm.isPropertyEnabled(JRemProperties.PROP_EXE_PATH));		getJComboDefView().setEnabled(pm.isPropertyEnabled(JRemProperties.PROP_DEF_VIEW));		JRemServerUtils.addComboItemsFromDomain(getJComboDefView(), JRemProperties.PROP_DEF_VIEW, pm);		getJComboKey().setEnabled(pm.isPropertyEnabled(JRemProperties.PROP_MOBILE_KEY));		setupComboMobileKeys();				getJButtonBrowseCmdPath().setEnabled(pm.isPropertyEnabled(JRemProperties.PROP_EXE_PATH));		getJButtonBrowseBaseDir().setEnabled(pm.isPropertyEnabled(JRemProperties.PROP_BASE_DIR));				getJTextQuestion().setEnabled(pm.isPropertyEnabled(JRemProperties.PROP_QUESTION));		getJTextQuestion().setEditable(pm.isPropertyEnabled(JRemProperties.PROP_QUESTION));	}	private void update() {		getJTextId().setText(JRemProperties.getString(pm, JRemProperties.PROP_ID));		getJTextDescription().setText(JRemProperties.getString(pm, JRemProperties.PROP_DESCRIPTION));		getJTextBasePath().setText(JRemProperties.getString(pm, JRemProperties.PROP_BASE_DIR));				if (pm.isManageProperty(JRemProperties.PROP_DEF_VIEW))			JRemServerUtils.setSelectDomainCombo(					getJComboDefView(), JRemProperties.PROP_DEF_VIEW, pm);				updateMobileKeyList();		getJTextCmdPath().setText(JRemProperties.getString(pm, JRemProperties.PROP_EXE_PATH));		getJTextQuestion().setText(JRemProperties.getString(pm, JRemProperties.PROP_QUESTION));	}	private void updateMobileKeyList() {		if (!pm.isManageProperty(JRemProperties.PROP_MOBILE_KEY))			return;		JRemCommandDoc cmd = (JRemCommandDoc) doc;		JRemContextDoc ctx = (JRemContextDoc) cmd.getContext();		Object[] usedKeys = ctx.getUsedKeys();				ComboBoxModel cbm = getJComboKey().getModel();				Map keysMap = new Hashtable();				for (int index = 0; index < cbm.getSize(); ++index) {						KeyComboItem ci = (KeyComboItem) cbm.getElementAt(index);			ci.setUsed(false);						keysMap.put(ci.getKey(), ci);		}				for (int index = 0; index < usedKeys.length; ++index) {						String key = (String) usedKeys[index];						KeyComboItem ci = (KeyComboItem) keysMap.get(key);			if (ci != null)				ci.setUsed(true);					}				JRemServerUtils.setSelectDomainCombo(				getJComboKey(), JRemProperties.PROP_MOBILE_KEY, pm);	}	private void setupBasePath() {		if (updating)			return;		pm.setPropertyValue(JRemProperties.PROP_BASE_DIR, 				jTextBasePath.getText());	}	private void setupDescription() {		if (updating)			return;				pm.setPropertyValue(JRemProperties.PROP_DESCRIPTION, 				jTextDescription.getText());	}	private void setupExePath() {		if (updating)			return;				pm.setPropertyValue(JRemProperties.PROP_EXE_PATH, 				jTextCmdPath.getText());	}	private void setupQuestion() {		if (updating)			return;				pm.setPropertyValue(JRemProperties.PROP_QUESTION, 				jTextQuestion.getText());	}		/**	 * This method initializes jTextQuestion		 * 		 * @return javax.swing.JTextField		 */	private JTextField getJTextQuestion() {		if (jTextQuestion == null) {			jTextQuestion = new JTextField();			jTextQuestion.setForeground(Color.BLACK);			jTextQuestion.setPreferredSize(new Dimension(150, 20));			jTextQuestion.setMinimumSize(new Dimension(30, 23));		}				jTextQuestion.addFocusListener(new FocusListener() {			public void focusGained(FocusEvent e) {								}			public void focusLost(FocusEvent e) {				setupQuestion();			}					});		return jTextQuestion;	}	}  //  @jve:decl-index=0:visual-constraint="0,0"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -