serviceMap = new HashMap<String, DirectoryServiceItem>();
serviceList = new ArrayList<DirectoryServiceItem>();
SelectorEditableExceptional<DirectoryServiceItem> servItems = dirService.getItems();
for (int i = 0; i < servItems.size(); i++) {
DirectoryServiceItem item = servItems.get(i);
if (item.getID() != 0 && !item.getCode().trim().isEmpty()
&& item.getGroup().getID() == ServiceGroup.SERVICE_GROUP_VISIT) {
serviceMap.put(item.getCode().trim(), item);
serviceList.add(item);
}
}
modelService = new DelegateComboboxModel(jComboService, false) {
@Override
public boolean isSelectionVisible(){
return true;
}
@Override
public Object getElementAtImp(int index) throws ClipsException {
return serviceList.get(index);
}
@Override
public int getSizeImp() throws ClipsException {
return serviceList.size();
}
@Override
public Object getSelectedItemImp() throws ClipsException {
return selectedService;
}
@Override
public void setSelectedItemImp(Object anItem) throws ClipsException {
selectedService = (DirectoryServiceItem) anItem;
if (selectedService == null || tfServiceCode.getText().equals(selectedService.getCode())) {
return;
}
inputedServCode = selectedService.getCode();
tfServiceCode.setText(inputedServCode);
}
};
modelServiceCode = new TextFieldModel(tfServiceCode) {
@Override
protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
selectedService = serviceMap.get(text);
jComboService.setSelectedItem(selectedService);
}
@Override
protected String getModelTextChecked() throws ClipsException {
return inputedServCode;
}
};
modelServiceCode.setModelText("");
//Код типа приема
resetCollFuncList(selectedColl);
modelCollFunc = new DelegateComboboxModel(jComboSpec, false) {
@Override
public boolean isSelectionVisible(){
return true;
}
@Override
public boolean isEnabled() {
return collFuncList.size() > 1;
}
@Override
public Object getElementAtImp(int index) throws ClipsException {
return collFuncList.get(index);
}
@Override
public int getSizeImp() throws ClipsException {
return collFuncList.size();
}
@Override
public Object getSelectedItemImp() throws ClipsException {
return selectedCollFunc;
}
@Override
public void setSelectedItemImp(Object anItem) throws ClipsException {
selectedCollFunc = (DCFI) anItem;
if (selectedCollFunc == null) {
jPanel2.remove(panUet);
tfUet.setText("1");
return;
}
inputedSpecCode = selectedCollFunc.getItem().getReceptionType().getExtKey();
if (!tfSpecCode.getText().equals(inputedSpecCode)) {
tfSpecCode.setText(inputedSpecCode);
}
if (inputedSpecCode.contains("29")) {
jPanel2.add(panUet, BorderLayout.SOUTH);
}
else {
jPanel2.remove(panUet);
tfUet.setText("1");
}
DialogQuickInput.this.validate();
DialogQuickInput.this.pack();
DialogQuickInput.this.repaint();
}
};
modelSpecCode = new TextFieldModel(tfSpecCode) {
@Override
protected boolean isEnabled() {
return collFuncList.size() > 1;
}
@Override
protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
selectedCollFunc = collFuncMap.get(text);
modelCollFunc.setSelectedItemImp(selectedCollFunc);
modelCollFunc.contentStateChanged();
}
@Override
protected String getModelTextChecked() throws ClipsException {
return inputedSpecCode;
}
};
tfSpecCode.setDocument(modelSpecCode);
tfSpecCode.setText(inputedSpecCode);
for (int i = 0; i < dirPlace.getItems().size(); i++) {
DirectoryServicingPlaceItem item = dirPlace.getItems().get(i);
if (item.getTitle().trim().toUpperCase().startsWith("ПОЛИ")) {
selectedPlace = item;
break;
}
}
modelPlace = new DelegateComboboxModel(jComboPlace, false) {