private void styleNameChange(DialogAccess dlg) { if (nCurrentFamily > -1) { updateStyleMaps(dlg); short nStyleNameItem = dlg.getListBoxSelectedItem("StyleName"); if (nStyleNameItem >= 0) { sCurrentStyleName = dlg.getListBoxStringItemList("StyleName")[nStyleNameItem]; setControls(dlg, styleMap[nCurrentFamily].get(sCurrentStyleName)); } else { sCurrentStyleName = null; clearControls(dlg); } } }
// Methods to handle user controlled lists protected boolean deleteCurrentItem(DialogAccess dlg, String sListName) { String[] sItems = dlg.getListBoxStringItemList(sListName); short nSelected = dlg.getListBoxSelectedItem(sListName); if (nSelected >= 0 && deleteItem(sItems[nSelected])) { int nOldLen = sItems.length; String[] sNewItems = new String[nOldLen - 1]; if (nSelected > 0) { System.arraycopy(sItems, 0, sNewItems, 0, nSelected); } if (nSelected < nOldLen - 1) { System.arraycopy(sItems, nSelected + 1, sNewItems, nSelected, nOldLen - 1 - nSelected); } dlg.setListBoxStringItemList(sListName, sNewItems); short nNewSelected = nSelected < nOldLen - 1 ? nSelected : (short) (nSelected - 1); dlg.setListBoxSelectedItem(sListName, nNewSelected); return true; } return false; }
protected String appendItem(DialogAccess dlg, String sListName, Set<String> suggestions) { String[] sItems = dlg.getListBoxStringItemList(sListName); String sNewItem = newItem(suggestions); if (sNewItem != null) { int nOldLen = sItems.length; for (short i = 0; i < nOldLen; i++) { if (sNewItem.equals(sItems[i])) { // Item already exists, select the existing one dlg.setListBoxSelectedItem(sListName, i); return null; } } String[] sNewItems = new String[nOldLen + 1]; System.arraycopy(sItems, 0, sNewItems, 0, nOldLen); sNewItems[nOldLen] = sNewItem; dlg.setListBoxStringItemList(sListName, sNewItems); dlg.setListBoxSelectedItem(sListName, (short) nOldLen); } return sNewItem; }
private void updateStyleControls(DialogAccess dlg) { boolean bHasMappings = dlg.getListBoxStringItemList("StyleName").length > 0; dlg.setControlEnabled("DeleteStyleButton", bHasMappings); prepareControls(dlg, bHasMappings); }