Package clips.delegate.directory.complex

Examples of clips.delegate.directory.complex.DirectoryVidalAtcItem


    public ArrayList<DirectoryVidalAtcItem> read() throws IOException, ClipsException {
    DirectoryVidalAtc dir = (DirectoryVidalAtc) DirectoryLocator.getDirectory(DirectoryVidalAtc.class, false);

        ArrayList<DirectoryVidalAtcItem> res = new ArrayList<DirectoryVidalAtcItem>();
        DirectoryVidalAtcItem stack[] = new DirectoryVidalAtcItem[10];
        int stackPos = -1;

        String line = input.readLine();
        while (line != null) {
            if (!line.trim().isEmpty()) {
                int pos = line.indexOf('\t');
                String code = line.substring(0, pos);
                line = line.substring(pos + 1);
                int lvl = 0;
                while (line.charAt(lvl) == ' ') {                   
                    lvl += 1;
                }
                line = line.substring(lvl);
                lvl = lvl/3;
                DirectoryVidalAtcItem parent;
                if (lvl-1 >= 0) {
                    parent = stack[lvl-1];
                } else {
                    parent = null;
                }
                if (lvl > stackPos + 1) {
                    System.err.println("Ошибка структуры файла");
                    break;
                }
                ClassificationAtcDetails details = new ClassificationAtcDetails();
                details.title = line;
                if (parent != null) {
                    details.groupCode = code.substring(parent.getGroupCode().length());
                    parent.getGroupCode();
                } else {
                    details.groupCode = code;
                }
                DirectoryVidalAtcItem newItem = new DirectoryVidalAtcItem(details);
               
                System.out.println("["+code+"][" + line + "]" + lvl);
                if (parent != null) {
                    System.out.println(parent+"->>>>>"+newItem);
                    parent.getItems().append(newItem);
View Full Code Here


    public int getChildCount(Object parent) {
      //  try {
            if(parent instanceof DefaultMutableTreeNode) {
                return items.size();
            } else {
                DirectoryVidalAtcItem item = (DirectoryVidalAtcItem)parent;
                return item.getItems().size();
            }
       /* } catch (ClipsException ex) {
            ex.printStackTrace();
        }
        return 0;*/
 
View Full Code Here

    public Object getChild(Object parent, int index) {
      //  try {
            if(parent instanceof DefaultMutableTreeNode) {
              return items.get(index);
            } else {
                DirectoryVidalAtcItem item = (DirectoryVidalAtcItem)parent;
                return item.getItems().get(index);
            }
      /*  } catch (ClipsException ex) {
            ex.printStackTrace();
        }
        return null;*/
 
View Full Code Here

   
    @Override
    public int getIndexOfChild(Object parent, Object child) {
        if (parent instanceof TreeNode) return super.getIndexOfChild(parent, child);
        if (parent instanceof DirectoryVidalAtcItem){
            DirectoryVidalAtcItem p = (DirectoryVidalAtcItem) parent;
            DirectoryVidalAtcItem c = (DirectoryVidalAtcItem) child;
           // try {
                for (int i = 0; i< p.getItems().size(); i++){
                    if (c.getID() == p.getItems().get(i).getID()){
                        return i;
                    }
                }
               
           /* } catch (ClipsException ex) {
View Full Code Here

private void treeVidalAtcValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_treeVidalAtcValueChanged
    Object value = treeVidalAtc.getLastSelectedPathComponent();
    vidalItems = new ArrayList<DirectoryVidalItem>();
    if (value instanceof DirectoryVidalAtcItem){
        try {
            DirectoryVidalAtcItem item = (DirectoryVidalAtcItem) value;
            SelectorEditableExceptional<DirectoryVidalItem> s = directoryVidal.getFilteredItems(item);
            if (s != null){
                if (s.size() > 0){
                    for (int i=0;i<s.size();i++){
                        vidalItems.add(s.get(i));
View Full Code Here

}//GEN-LAST:event_btDeleteVidalActionPerformed

private void btAddAtcNodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddAtcNodeActionPerformed
    try {
        Object value = treeVidalAtc.getLastSelectedPathComponent();
        DirectoryVidalAtcItem newItem = null;
        if (value instanceof DirectoryVidalAtcItem) {
            DirectoryVidalAtcItem selected = (DirectoryVidalAtcItem) value;
            tfGroupCodePref.setText(selected.getGroupCode());
            tfName.setText("");
            tfGroupCode.setText("");
            int res = JOptionPane.showConfirmDialog(null, pnlNewNode, "Заполните поля", JOptionPane.OK_CANCEL_OPTION, -1);
            if (res == JOptionPane.OK_OPTION) {
                if (tfName.getText().isEmpty() || tfGroupCode.getText().isEmpty()) {
                    MessageBox.showWarning(MessageBox.W_INCORRECT_DATA);
                    return;
                } else {
                    ClassificationAtcDetails details = new ClassificationAtcDetails();
                    details.title = tfName.getText();
                    details.groupCode = tfGroupCode.getText();
                    details.parentItem = selected.getID();
                    newItem = new DirectoryVidalAtcItem(details);
                    selected.getItems().append(newItem);
                }
            }
        } else {
            tfGroupCodePref.setText("");
            tfName.setText("");
            tfGroupCode.setText("");
            int res = JOptionPane.showConfirmDialog(null, pnlNewNode, "Заполните поля", JOptionPane.OK_CANCEL_OPTION, -1);
            if (res == JOptionPane.OK_OPTION) {
                if (tfName.getText().isEmpty() || tfGroupCode.getText().isEmpty()) {
                    MessageBox.showWarning(MessageBox.W_INCORRECT_DATA);
                    return;
                } else {
                    ClassificationAtcDetails details = new ClassificationAtcDetails();
                    details.title = tfName.getText();
                    details.groupCode = tfGroupCode.getText();
                    newItem = new DirectoryVidalAtcItem(details);
                    directoryVidalAtc.getItems().append(newItem);
                }
            }
        }
        updateTree();
View Full Code Here

    if (treeVidalAtc.getSelectionCount() > 0 && selectedAtc != null) {
        try {
            if (selectedAtc.getItems().size() > 0) {
                MessageBox.showWarning(MessageBox.W_CANT_DEL_HAVE_CHILDREN);
            } else {
                DirectoryVidalAtcItem parent = selectedAtc.getParent();
                SelectorEditableExceptional<DirectoryVidalItem> s = directoryVidal.getFilteredItems(selectedAtc);
                while (s.size() > 0) {
                    s.remove(0);
                }
                if (selectedAtc.getParent() != null) {
View Full Code Here

     */
    private void rename() {
        Object value = treeVidalAtc.getLastSelectedPathComponent();
        try {
            if (value instanceof DirectoryVidalAtcItem) {
                DirectoryVidalAtcItem selected = (DirectoryVidalAtcItem) value;
                tfGroupCodePref.setText(selected.getParent() != null?
                                    selected.getParent().getGroupCode(): "");
                tfName.setText(selected.getTitle());
                tfGroupCode.setText(selected.getIndividualCode());
                int res = JOptionPane.showConfirmDialog(
                        null, pnlNewNode, "Переименовать", JOptionPane.OK_CANCEL_OPTION, -1);
                if (res == JOptionPane.OK_OPTION) {
                    if (tfName.getText().isEmpty() || tfGroupCode.getText().isEmpty()) {
                        MessageBox.showError(MessageBox.E_MAKE_FUCKING_EXCEPTION, "Данные некорректны");
                        return;
                    } else {
                        selected.rename(tfGroupCode.getText(), tfName.getText());
                    }
                }
            }
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
View Full Code Here

            ArrayList path = new ArrayList();
            path.add(item);
            return path;
        }
        if (item instanceof DirectoryVidalAtcItem) {
            DirectoryVidalAtcItem parent = (DirectoryVidalAtcItem) item;
            Selector ii = parent.getItems();
            for (int i = 0; i < ii.size(); i++) {
                DirectoryItem child = (DirectoryItem) ii.get(i);
                List path = findMatch(child, pattern);
                if (path != null) {
                    path.add(parent);
View Full Code Here

    @Override
    public void print() {
        try {
            if (readyForPrint()) {
                String group = "";
                DirectoryVidalAtcItem parent = selectedAtc;
                ArrayList<String> titles = new ArrayList<String>();
                while (parent != null) {
                    titles.add(parent.getTitle() + "(" + parent.getGroupCode() + ")" + "\n");               
                    parent = parent.getParent();
                }               
                String title = "АТХ классификация лекарственных средств группы: ";
                int k = titles.size() - 1;
                for (int i = k; i > -1; i--) {
                    String iS  = titles.get(i);
View Full Code Here

TOP

Related Classes of clips.delegate.directory.complex.DirectoryVidalAtcItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.