Package de.kopis.jusenet.nntp

Examples of de.kopis.jusenet.nntp.Group


        updateTimer = new Timer(Integer.parseInt(Application.getInstance().getProperty("updateinterval", "" + UPDATE_INTERVAL)),
                new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                GroupListModel model = (GroupListModel) subscribedGroupList.getModel();
                for (int i = 0; i < model.getSize(); i++) {
                    Group g = (Group) model.getElementAt(i);
                    try {
                        NNTPUtils.getInstance().getArticles(g, g.getLastUpdate());
                    } catch (NntpNotConnectedException e1) {
                        GuiUtils.showError(e1);
                    }
                }
                //TODO use Logger to log this messages
View Full Code Here


        GroupListModel newgroupmodel = new GroupListModel();
        GroupListModel subscribedgroupmodel = new GroupListModel();
        // popuplate models
        try {
            Iterator<Group> it = HibernateUtils.listGroups().iterator();
            Group g;
            while(it.hasNext()) {
                g = it.next();
                allgroupmodel.addElement(g);
                if(g.isSubscribed()) {
                    subscribedgroupmodel.addElement(g);
                }
            }
        } catch (JDBCConnectionException e) {
            System.err.println("Cannot open connection to database.");
            System.err.println("Maybe you restarted to fast? Let HSQLDB recover from last session.");
            Application.getInstance().quit(Application.ERROR_CONNECTION_NOT_READY);
        }
        //TODO check if deserialization is really useful! Maybe it's slower then reading from database
//        GroupListModel allgroupmodel = deserializeAllGroups();
//        GroupListModel subscribedgroupmodel = deserializeSubscribedGroups();
//        GroupListModel newgroupmodel = new GroupListModel();
        // register listeners for group events
        //TODO check if it is correct to let both groupmodels implement GroupListener
        NNTPUtils.getInstance().addGroupListener(newgroupmodel);
        NNTPUtils.getInstance().addGroupListener(allgroupmodel);
       
        allGroupList = new JList(allgroupmodel);
        allGroupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        allGroupList.setCellRenderer(new GroupCellRenderer());
        allGroupList.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                   if(e.getValueIsAdjusting()) return;
                  
                   Group g = (Group) allGroupList.getSelectedValue();
                   if(g == null) return;
                  
                   displayArticles(g.getId());
            }});
        allGroupList.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                if(SwingUtilities.isRightMouseButton(e)) {
                    if(allGroupList.getSelectedValue() != null) {
//                        GuiUtils.showError("show group popup");
                        //TODO select value under mouse
                        GroupPopupMenu popup = new GroupPopupMenu();
                        popup.setLocation(e.getPoint());
                        popup.show((Component) e.getSource(), e.getX(), e.getY());
                    }
//                    else {
//                        GuiUtils.showError("no selection!");
//                    }
                }
            }
            });
        groupTabs.addTab("All", new JScrollPane(allGroupList));

        newGroupList = new JList(newgroupmodel);
        newGroupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        newGroupList.setCellRenderer(new GroupCellRenderer());
        newGroupList.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                   if(e.getValueIsAdjusting()) return;
                  
                   Group g = (Group) newGroupList.getSelectedValue();
                   if(g == null) return;
                  
                   displayArticles(g.getId());
            }});
        newGroupList.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                if(SwingUtilities.isRightMouseButton(e)) {
                    if(newGroupList.getSelectedValue() != null) {
//                        GuiUtils.showError("show group popup");
                        //TODO select value under mouse
                        GroupPopupMenu popup = new GroupPopupMenu();
                        popup.setLocation(e.getPoint());
                        popup.show((Component) e.getSource(), e.getX(), e.getY());
                    }
//                    else {
//                        GuiUtils.showError("no selection!");
//                    }
                }
            }
            });
        groupTabs.addTab("New", new JScrollPane(newGroupList));

        subscribedGroupList = new JList(subscribedgroupmodel);
        subscribedGroupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        subscribedGroupList.setCellRenderer(new GroupCellRenderer());
        subscribedGroupList.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                   if(e.getValueIsAdjusting()) return;

                   final Group g = (Group) subscribedGroupList.getSelectedValue();
                   if(g == null) return;
                  
                   displayArticles(g.getId());
            }});
        subscribedGroupList.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                if(SwingUtilities.isRightMouseButton(e)) {
                    if(subscribedGroupList.getSelectedValue() != null) {
View Full Code Here

            public void run() {
                Session session = HibernateUtils.getSessionFactory().getCurrentSession();
                session.beginTransaction();
                // reload Group from session, because lazy fetching of inner Set<Article>
                // won't work otherwise
                Group g = (Group) session.load(Group.class, gid);

                statusbar.setAction("Entering " + g + "...");
                ArticleListModel model = (ArticleListModel)articleList.getModel();
                model.clear();
                Iterator it = g.getArticles().iterator();
                while(it.hasNext()) {
                    model.addElement(it.next());
                    try {
                        Thread.sleep(5);
                    } catch (InterruptedException e) {
View Full Code Here

    return subject;
  }

  public void composeMessage() {
    ComposeMessageWindow cmw;
    Group g = (Group) allGroupList.getSelectedValue();
    if(g != null) {
      cmw = new ComposeMessageWindow(g);
    } else {
      cmw = new ComposeMessageWindow();
    }
View Full Code Here

    /**
     * Gets new articles for currently selected group.
     *
     */
    public void getNewArticles() {
        Group g = (Group) allGroupList.getSelectedValue();
        statusbar.setAction("Updating " + g);
        System.out.println("Getting new articles for " + g);
        try {
            NNTPUtils.getInstance().getArticles(g, g.getLastUpdate());
        } catch (NntpNotConnectedException e) {
            GuiUtils.showError(e);
        }
    }
View Full Code Here

        SelectServerWindow window = new SelectServerWindow(this);
        window.setVisible(true);
    }

    public void subscribe() {
        Group g = null;
        if(allGroupList.isShowing()) {
            g = (Group) allGroupList.getSelectedValue();
        } else if(newGroupList.isShowing()) {
            g = (Group) newGroupList.getSelectedValue();
        } else if(subscribedGroupList.isShowing()) {
View Full Code Here

            ((GroupListModel)subscribedGroupList.getModel()).addElement(g);
        }
    }

    public void unsubscribe() {
        Group g = null;
        if(allGroupList.isShowing()) {
            g = (Group) allGroupList.getSelectedValue();
        } else if(newGroupList.isShowing()) {
            g = (Group) newGroupList.getSelectedValue();
        } else if(subscribedGroupList.isShowing()) {
View Full Code Here

    public static void remove(Article a) {
        Session session = getSessionFactory().getCurrentSession();
       
        session.beginTransaction();
        Iterator<Group> it = a.getGroups().iterator();
        Group g;
        while(it.hasNext()) {
            g = it.next();
            g.getArticles().remove(a);
            session.saveOrUpdate(g);
        }
        session.delete(a);
        session.getTransaction().commit();
    }
View Full Code Here

TOP

Related Classes of de.kopis.jusenet.nntp.Group

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.