SystemReportsDisplayComponent.java :  » Content-Management-System » harmonise » org » openharmonise » him » displaycomponents » Java Open Source

Java Open Source » Content Management System » harmonise 
harmonise » org » openharmonise » him » displaycomponents » SystemReportsDisplayComponent.java
/*
 * The contents of this file are subject to the 
 * Mozilla Public License Version 1.1 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
 * See the License for the specific language governing rights and 
 * limitations under the License.
 *
 * The Initial Developer of the Original Code is Simulacra Media Ltd.
 * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
 *
 * All Rights Reserved.
 *
 * Contributor(s):
 */

package org.openharmonise.him.displaycomponents;

import org.openharmonise.him.context.StateHandler;
import org.openharmonise.him.displaycomponents.table.*;
import org.openharmonise.him.window.*;
import org.openharmonise.vfs.*;
import org.openharmonise.vfs.context.*;
import org.openharmonise.vfs.servers.*;


/**
 * Display component for managing system reports.
 * 
 * @author Matthew Large
 * @version $Revision: 1.1 $
 *
 */
public class SystemReportsDisplayComponent extends AbstractTreeTableDisplayComponent
implements ContextListener {

  /**
   * Virtual file system for the selected file.
   */
  private AbstractVirtualFileSystem m_SelectedFileVFS = null;
  
  /**
   * Full path to the selected file.
   */
  private String m_sSelectedFilePath = null;

  /**
   * Virtual file system for the selected collection.
   */
  private AbstractVirtualFileSystem m_SelectedDirVFS = null;
  
  /**
   * Full path to the selected collection.
   */
  private String m_sSelectedDirPath = null;

  /**
   * Constructs a new system reports display component.
   * 
   * @param displayManager Display manager
   */
  public SystemReportsDisplayComponent(DisplayManager displayManager) {
    super(displayManager);
    ContextHandler.getInstance().addListener(ContextType.CONTEXT_TABS, this);
  }
  
  /**
   * Constructs a new system reports display compoment.
   * 
   * @param displayManager Display manager
   * @param server Server
   * @param sPath Full path to system reports collection
   */
  public SystemReportsDisplayComponent(DisplayManager displayManager, Server server, String sPath) {
    super(displayManager, server, sPath);
    ContextHandler.getInstance().addListener(ContextType.CONTEXT_TABS, this);
  }
  
  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.displaycomponents.tree.TreeViewListener#directorySelected(com.simulacramedia.vfs.servers.Server, java.lang.String)
   */
  public void virtualFileSelected(AbstractVirtualFileSystem vfs, String sPath) {
    StateHandler.getInstance().addWait("REPORTS-DIR-SELECTION");
    try {
      this.m_SelectedDirVFS = vfs;
      this.m_sSelectedDirPath = sPath;
      this.m_SelectedFileVFS=null;
      this.m_sSelectedFilePath=null;
      this.m_tableView.setPath(vfs, sPath);
      this.m_displayManager.hideMetadata();
      ContextEvent ce = new ContextEvent(ContextType.CONTEXT_DIRS, "", vfs, sPath);
      ContextHandler.getInstance().fireContextEvent(ce);
    } catch (Exception e) {
      e.printStackTrace(System.err);
    } finally {
      StateHandler.getInstance().removeWait("REPORTS-DIR-SELECTION");
    }
  }
  
  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.displaycomponents.table.TableListener#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.TableEntry)
   */
  public void fileSelection(TableEntry entry) {
    StateHandler.getInstance().addWait("REPORTS-FILE-SELECTION");
    try {
      ContextEvent ce = new ContextEvent(ContextType.CONTEXT_FILES, null, entry.getVFS(), entry.getPath());
      this.m_SelectedFileVFS = entry.getVFS();
      this.m_sSelectedFilePath = entry.getPath();
      ContextHandler.getInstance().fireContextEvent(ce);
      this.m_displayManager.openMetadata();
      this.m_displayManager.scrollTableTo( entry.getLocation().x );
    } catch (Exception e) {
      e.printStackTrace(System.err);
    } finally {
      StateHandler.getInstance().removeWait("REPORTS-FILE-SELECTION");
    }
  }
  
  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.displaycomponents.table.TableListener#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.TableEntry)
   */
  public void fileSelection(VersionEntry entry) {
    StateHandler.getInstance().addWait("REPORTS-FILE-SELECTION");
    try {
      ContextEvent ce = new ContextEvent(ContextType.CONTEXT_FILES, null, entry.getVFS(), entry.getPath());
      this.m_SelectedFileVFS = entry.getVFS();
      this.m_sSelectedFilePath = entry.getPath();
      ContextHandler.getInstance().fireContextEvent(ce);
      this.m_displayManager.openMetadata();
      this.m_displayManager.scrollTableTo( entry.getParentTableEntry().getLocation().x );
    } catch (Exception e) {
      e.printStackTrace(System.err);
    } finally {
      StateHandler.getInstance().removeWait("REPORTS-FILE-SELECTION");
    }
  }
  
  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getTitle()
   */
  public String getTitle() {
    return "System Reports";
  }
  
  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getIcon()
   */
  public String getIcon() {
    return "16-report.gif";
  }
  
  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
   */
  public void contextMessage(ContextEvent ce) {
    if(ce.CONTEXT_TYPE==ContextType.CONTEXT_TABS && ce.getMessage().equalsIgnoreCase(this.getTitle())) {
      if(this.m_SelectedDirVFS!=null && this.m_sSelectedDirPath!=null) {
        ContextEvent ce2 = new ContextEvent(ContextType.CONTEXT_DIRS, null, this.m_SelectedDirVFS, this.m_sSelectedDirPath);
        ContextHandler.getInstance().fireContextEvent(ce2);
      }
      if(this.m_SelectedFileVFS!=null && this.m_sSelectedFilePath!=null) {
        ContextEvent ce2 = new ContextEvent(ContextType.CONTEXT_FILES, null, this.m_SelectedFileVFS, this.m_sSelectedFilePath);
        ContextHandler.getInstance().fireContextEvent(ce2);
        this.m_displayManager.openMetadata();
      } else {
        this.m_displayManager.hideMetadata();
      }
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.