public void setOrg(long _orgID, D_Organization org) throws P2PDDSQLException { if (DEBUG) System.out.println("ConstituentsTest:setOrg: id=" + _orgID); organization = org; if (tree != null) { tree.clean(); } organizationID = _orgID; constituentID = net.ddp2p.common.config.Identity.getDefaultConstituentIDForOrg(organizationID); global_constituentID = D_Constituent.getGIDFromLID(constituentID); if (global_constituentID == null) { constituentID = -1; MainFrame.status.setMeConstituent(null); } else { MainFrame.status.setMeConstituent(D_Constituent.getConstByLID(constituentID, true, false)); } ConstituentsModel cm = new ConstituentsModel( Application.db, organizationID, constituentID, global_constituentID, org, this); tree = new ConstituentsTree(cm); long cID = cm.getConstituentIDMyself(); cm.expandConstituentID(tree, ((cID <= 0) ? null : ("" + cID)), true); JScrollPane scrollPane = new JScrollPane(tree); scrollPane.setPreferredSize(new Dimension(200, 200)); this.removeAll(); if (org_label != null) { org_label.setText(getLabelText()); add(getNorthComponent(), BorderLayout.NORTH); disableRefresh(); this.refresh_button.addActionListener(this); // add(org_label, BorderLayout.NORTH); } add(scrollPane, BorderLayout.CENTER); }
private String getLabelText() { String result; if (organization == null) return __("No current organization!"); if (organization.getName() == null) return __("Incomplete organization data!"); result = __("Current Organization:") + " \"" + organization.getName() + "\""; result += " || " + __("I am :") + " " + tree.getModel().getConstituentMyselfName(); return result; }
@Override public void actionPerformed(ActionEvent e) { if (DEBUG) System.out.println("ConstituentsPanel:action Refresh \n" + e); if (e.getSource() == this.refresh_button) { if (!this.refresh_button.isEnabled()) return; // disableRefresh(); if (tree == null) return; ConstituentsModel model = tree.getModel(); if (model == null) return; try { model.doRefreshAll(); /* Object oldRoot = model.getRoot(); model.init(model.getOrganizationID(), model.getConstituentIDMyself(), model.getConstituentGIDMyself(), model.getOrganization()); model.fireTreeStructureChanged(new TreeModelEvent(tree,new Object[]{model.root})); model.refresh(new JTree[]{tree}, oldRoot); model.runCensus(); */ } catch (P2PDDSQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }