private void addButton(TreeNode parentNode, AppTopButtonVo value, boolean autoSelect) { if(parentNode != null && value != null && value.getAction() != null) { if(value.getAction().equals(TopButtonAction.BUILTIN)) { addPredefinedButton(parentNode, value, autoSelect); } else if(value.getAction().equals(TopButtonAction.FORM)) { addForm(parentNode, value, autoSelect); } else if(value.getAction().equals(TopButtonAction.URL)) { addUrl(parentNode, value, autoSelect); } } }
private boolean canRenameSelectedItem() { if(form.getMode() == FormMode.VIEW) return false; if(!isItemSelected()) return false; Object value = form.treItems().getSelectedNode().getValue(); if(value != null) { if(value instanceof AppTopButtonSectionVo) return true; else if(value instanceof AppTopButtonVo) { return ((AppTopButtonVo)value).getAction() != null && (((AppTopButtonVo)value).getAction().equals(TopButtonAction.URL) || ((AppTopButtonVo)value).getAction().equals(TopButtonAction.FORM)); } } return false; }
private void addUrl(TreeNode parentNode, AppTopButtonVo value, boolean autoSelect) { if(parentNode != null && value != null) { String nodeText = value.getText(); if(nodeText == null) nodeText = " "; TreeNode node = parentNode.getNodes().add(value, nodeText, autoSelect, BUTTON_DRAGDROP_TYPE, new int[] { BUTTONS_DRAGDROP_TYPE, SECTION_DRAGDROP_TYPE }); node.setSelectedImage(form.getImages().Core.Web); node.setCollapsedImage(form.getImages().Core.Web); node.setExpandedImage(form.getImages().Core.Web); node.setTooltip(value.getURL()); } }
private void processNodeMove(TreeNode node) { if(node != null) { Object value = node.getValue(); if(value != null) { if(value instanceof AppTopButtonSectionVo) { ((AppTopButtonSectionVo)value).setID_AppTopButtonSection(null); } else if(value instanceof AppTopButtonVo) { ((AppTopButtonVo)value).setID_AppTopButton(null); } } } }
private void resetButtonToDefault() { if(form.treItems().getSelectedNode() != null && form.treItems().getSelectedNode().getParent() != null && form.treItems().getSelectedNode().getValue() != null) { if (form.treItems().getSelectedNode().getValue() instanceof AppTopButtonVo) { AppTopButtonVo topbutton = (AppTopButtonVo) form.treItems().getSelectedNode().getValue(); topbutton.setContextDependent(false); topbutton.setPatientMustBeSelected(null); form.treItems().getSelectedNode().setValue(topbutton); } } }
private void disableButtonIfPatientSelected() { if(form.treItems().getSelectedNode() != null && form.treItems().getSelectedNode().getParent() != null && form.treItems().getSelectedNode().getValue() != null) { if (form.treItems().getSelectedNode().getValue() instanceof AppTopButtonVo) { AppTopButtonVo topbutton = (AppTopButtonVo) form.treItems().getSelectedNode().getValue(); topbutton.setContextDependent(true); topbutton.setPatientMustBeSelected(false); form.treItems().getSelectedNode().setValue(topbutton); } } }
private void addButton(AppTopButtonVo value, boolean select) { if(value != null) { addButton(form.treItems().getSelectedNode(), value, select); updateControlsState(); if(value.getAction() != null && value.getAction().equals(TopButtonAction.FORM)) form.treItems().beginEditSelectedNode(); } }
private void addSection(TreeNode parentNode, AppTopButtonSectionVo value, boolean autoSelect) { if(parentNode != null && value != null) { String text = value.getText(); if(text == null) text = " "; TreeNode node = parentNode.getNodes().add(value, text, autoSelect, SECTION_DRAGDROP_TYPE, new int[] { SECTIONS_DRAGDROP_TYPE }, true); node.setSelectedImage(form.getImages().Core.Organizer); node.setCollapsedImage(form.getImages().Core.Organizer); node.setExpandedImage(form.getImages().Core.Organizer); if(value.getButtons() != null) { AppTopButtonVoCollection buttons = value.getButtons(); if(buttons != null) { for(int x = 0; x < buttons.size(); x++) { AppTopButtonVo button = buttons.get(x); if(button != null) { addButton(node, button, autoSelect); } } } } } }
private void updateContextMenuState() { form.getContextMenus().getTopButtonAdminADD_BUTTONItem().setVisible(canAddButtonItem()); form.getContextMenus().getTopButtonAdminADD_FORMItem().setVisible(canAddButtonItem()); form.getContextMenus().getTopButtonAdminADD_URLItem().setVisible(canAddButtonItem()); form.getContextMenus().getTopButtonAdminADD_SECTIONItem().setVisible(canAddSectionItem()); form.getContextMenus().getTopButtonAdminRENAMEItem().setVisible(canRenameSelectedItem()); form.getContextMenus().getTopButtonAdminREMOVEItem().setVisible(canRemoveSelectedItem()); form.getContextMenus().getTopButtonAdminDISABLE_IF_PATIENT_SELECTEDItem().setVisible(false); form.getContextMenus().getTopButtonAdminRESET_TOP_BUTTON_TO_DEFAULTItem().setVisible(false); // if(form.treItems().getSelectedNode() != null && form.treItems().getSelectedNode().getParent() != null && form.treItems().getSelectedNode().getValue() != null) { if (form.treItems().getSelectedNode().getValue() instanceof AppTopButtonVo && //Is not BuildIn TopButton (!((AppTopButtonVo)form.treItems().getSelectedNode().getValue()).getBuildInIsNotNull())) { if (((AppTopButtonVo)form.treItems().getSelectedNode().getValue()).getPatientMustBeSelectedIsNotNull()) { form.getContextMenus().getTopButtonAdminDISABLE_IF_PATIENT_SELECTEDItem().setVisible(true); form.getContextMenus().getTopButtonAdminDISABLE_IF_PATIENT_SELECTEDItem().setEnabled(false); form.getContextMenus().getTopButtonAdminRESET_TOP_BUTTON_TO_DEFAULTItem().setVisible(true); form.getContextMenus().getTopButtonAdminRESET_TOP_BUTTON_TO_DEFAULTItem().setEnabled(true); } else { form.getContextMenus().getTopButtonAdminDISABLE_IF_PATIENT_SELECTEDItem().setVisible(true); form.getContextMenus().getTopButtonAdminDISABLE_IF_PATIENT_SELECTEDItem().setEnabled(true); form.getContextMenus().getTopButtonAdminRESET_TOP_BUTTON_TO_DEFAULTItem().setVisible(false); form.getContextMenus().getTopButtonAdminRESET_TOP_BUTTON_TO_DEFAULTItem().setEnabled(false); } } } }
private void addPredefinedButton(TreeNode parentNode, AppTopButtonVo value, boolean autoSelect) { if(parentNode != null && value != null) { String nodeText = value.getText(); if(nodeText == null) nodeText = " "; TreeNode node = parentNode.getNodes().add(value, nodeText, autoSelect, BUTTON_DRAGDROP_TYPE, new int[] { BUTTONS_DRAGDROP_TYPE, SECTION_DRAGDROP_TYPE }); node.setSelectedImage(form.getImages().Core.HelpButton); node.setCollapsedImage(form.getImages().Core.HelpButton); node.setExpandedImage(form.getImages().Core.HelpButton); } }
private void addForm(TreeNode parentNode, AppTopButtonVo value, boolean autoSelect) { String nodeText = value.getText(); if(nodeText == null) nodeText = " "; if(parentNode != null && value != null) { TreeNode node = parentNode.getNodes().add(value, nodeText, autoSelect, BUTTON_DRAGDROP_TYPE, new int[] { BUTTONS_DRAGDROP_TYPE, SECTION_DRAGDROP_TYPE }); node.setSelectedImage(form.getImages().Core.Form); node.setCollapsedImage(form.getImages().Core.Form); node.setExpandedImage(form.getImages().Core.Form); node.setTooltip(buildFormTooltip(value)); if (engine.getRegisteredForm(value.getForm()).isDialog()) { //Display maximise button if available on dialog open by top button TreeNode nodeChild = node.getNodes().add(value, "Show maximize button", false); nodeChild.setIdentifier(DIALOG_MAXIMISE_BUTTON_TAG); nodeChild.setCheckBoxVisible(true); nodeChild.setChecked(value != null ? (value.getDisplayMaximiseButton() == null ? false : value.getDisplayMaximiseButton()) : false); //Display close button if available on dialog open by top button nodeChild = node.getNodes().add(value, "Enable close button if available", false); nodeChild.setIdentifier(DIALOG_CLOSE_BUTTON_TAG); nodeChild.setCheckBoxVisible(true); nodeChild.setChecked(value != null ? (value.getDisplayCloseButton() == null ? false : value.getDisplayCloseButton()) : false); } } }
private String buildFormTooltip(AppTopButtonVo value) { if(value != null && value.getForm() != null) { IAppForm selectedForm = null; IAppForm[] forms = engine.getRegisteredForms(); for(int x = 0; x < forms.length; x++) { if(forms[x].getFormId() == value.getForm().getID()) { selectedForm = forms[x]; break; } } if(selectedForm == null) return ""; String formName = selectedForm.getName(); if(selectedForm.isAlias()) formName += " (" + selectedForm.getAliasName() + ")"; return formName; } return ""; }
private TopButton getTopButton(AppTopButtonVo value) { TopButtonCollection topButtons = engine.getBuiltInTopButtons(); for(int x = 0; x < topButtons.size(); x++) { if(topButtons.get(x).getID() == value.getBuildIn().intValue()) return topButtons.get(x); } return null; }
private void processNodeRename(TreeNode node) { if(node != null) { String nodeText = node.getText(); Object value = node.getValue(); if(value != null) { if(value instanceof AppTopButtonSectionVo) { if(nodeText == null || nodeText.length() == 0) nodeText = " "; ((AppTopButtonSectionVo)value).setText(nodeText); } else if(value instanceof AppTopButtonVo) { if(nodeText == null || nodeText.length() == 0) { nodeText = "Untitled"; node.setText(nodeText); } ((AppTopButtonVo)value).setText(nodeText); } } } }