*/
public Connector(String id, Properties props) {
assert id != null;
- if (!id.matches("[A-Za-z0-9]+")) {
- throw new IllegalArgumentException("illegal id : " + id);
+ if (!id.matches("[A-Za-z0-9]+")) { // XXX move to new public method isValid
+ throw new IllegalArgumentException(ResourceManager.Default.get("e.id-can-only-contain-alphanum", id));
}
Properties p = new Properties();
p.putAll(props);
e.dir-not-exists=Directory[{0}] does not exist.
e.fatal=Fatal Error: {0}
e.file-not-exists=File[{0}] does not exist.
+e.id-can-only-contain-alphanum=ID can only contain alphanumeric characters: ID=[{0}]
e.no-connector=Connector [{0}] does not exist.
e.not-connect=Not connected.
e.not-found=Error: Command [{0}] was not found.
e.dir-not-exists=ディレクトリ[{0}]は存在しません。
e.fatal=致命的なエラー: {0}
e.file-not-exists=ファイル[{0}]は存在しません。
+e.id-can-only-contain-alphanum=IDには英数字のみ使用できます: ID=[{0}]
e.no-connector=コネクタ [{0}] はありません。
e.not-connect=接続されていません。
e.not-found=エラー: コマンド [{0}] は見つかりませんでした。
final String message = res.get("e.id-already-exists", id);
showMessageDialog(this, message, null, ERROR_MESSAGE);
} else {
- openConnectorEditDialog(new Connector(id, new Properties()));
+ Connector connector;
+ try {
+ connector = new Connector(id, new Properties());
+ } catch (IllegalArgumentException ex) {
+ showMessageDialog(this, ex.getMessage(), null, ERROR_MESSAGE);
+ return;
+ }
+ openConnectorEditDialog(connector);
}
} else if (ev.isAnyOf(modify)) {
ConnectorEntry entry = (ConnectorEntry)idList.getSelectedValue();
connectorMap.remove(entry);
connectorMap.put(newId, entry.getConnector());
DefaultListModel m = (DefaultListModel)idList.getModel();
- Connector newConnector = new Connector(newId, entry.getConnector());
+ Connector newConnector;
+ try {
+ newConnector = new Connector(newId, entry.getConnector());
+ } catch (IllegalArgumentException ex) {
+ showMessageDialog(this, ex.getMessage(), null, ERROR_MESSAGE);
+ return;
+ }
m.set(m.indexOf(entry), new ConnectorEntry(newId, newConnector));
idList.repaint();
} else if (ev.isAnyOf(remove)) {