Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2013-2014 Erwin Müller <erwin.mueller@deventm.org>
   *
   * This file is part of prefdialog-misc-swing.
   *
   * prefdialog-misc-swing is free software: you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as published by the
   * Free Software Foundation, either version 3 of the License, or (at your
   * option) any later version.
  *
  * prefdialog-misc-swing is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public License
  * along with prefdialog-misc-swing. If not, see <http://www.gnu.org/licenses/>.
  */
 package com.anrisoftware.prefdialog.miscswing.logpane;
 
 import java.util.List;
 
 
 
Uses a tree table to display messages ordered in categories.
 pane.setColumns(columnNames);
 
 errors = new CategoryNode();
 errors.setName("Errors");
 pane.addCategory(errors);
 
 info = new CategoryNode();
 info.setName("Info");
 pane.addCategory(info);
 
 message = new MessageNode(errors);
 message.setValueAt(DateTime.now(), 0);
 message.setValueAt("Exception", 1);
 message.setValueAt("Some message", 2);
 message.setValueAt(ex, 3);
 pane.addMessage(message);
 

Author(s):
Erwin Mueller, erwin.mueller@deventm.org
Since:
3.0
 
 public class LogPane {

    
Creates the problems pane.

Returns:
the LogPane.
 
     public static LogPane createLogPane() {
         return Guice.createInjector().getInstance(LogPane.class);
     }
 
     private final UiPane pane;
 
     private final RootNode root;
 
     private DefaultTreeTableModel model;
 
     private Texts texts;
 
     private List<ObjectcolumnNames;
 
     private List<StringcolumnNamesResources;
 
     private final List<CategoryNodecategories;
 
     private final List<MessageNodemessages;
 
     @Inject
     @OnAwt
     LogPane(UiPane paneRootNode rootNode) {
         this. = pane;
         this. = rootNode;
         this. = new ArrayList<CategoryNode>();
         this. = new ArrayList<MessageNode>();
     }

    
Sets the columns of the problems pane.

AWT Thread

Should be called in the AWT thread.

Parameters:
columnNames the column names.
    @OnAwt
    public void setColumns(List<ObjectcolumnNames) {
        .setName("root");
        .setColumnCount(columnNames.size());
        this. = columnNames;
        this. = new ArrayList<String>(columnNames.size());
        for (Object object : columnNames) {
            .add(object.toString());
        }
        this. = new DefaultTreeTableModel(columnNames);
    }

    
Sets the texts resources for the category. The name is looked up in the resources.

AWT Thread

Should be called in the AWT thread.

    @OnAwt
    public void setTexts(Texts texts) {
        this. = texts;
        updateTextsResource();
        for (CategoryNode node : ) {
            node.setTexts(texts);
        }
        for (MessageNode node : ) {
            node.setTexts(texts);
        }
    }
    private void updateTextsResource() {
        if ( == null) {
            return;
        }
        for (int i = 0; i < .size(); i++) {
            try {
                String name = .get(i);
                name = .getResource(name).getText();
                .set(iname);
            } catch (ResourcesException e) {
            }
        }
        this. = new DefaultTreeTableModel();
    }

    
Returns the pane component to be added in the container.

Returns:
the java.awt.Component.
    public Component getComponent() {
        return ;
    }

    
Adds a new category to the problems pane.

AWT Thread

Should be called in the AWT thread.

Parameters:
category the CategoryNode.
    @OnAwt
    public void addCategory(CategoryNode category) {
        .add(category);
        category.setColumnCount(.getColumnCount());
        .insertNodeInto(category, 0);
    }

    
Adds the message to the list of problems.

AWT Thread

Should be called in the AWT thread.

Parameters:
message the MessageNode.
    @OnAwt
    public void addMessage(MessageNode message) {
        .add(message);
        .insertNodeInto(messagemessage.getCategory(), 0);
        .getProblemsTable().expandAll();
    }
New to GrepCode? Check out our FAQ X