Package org.jboss.bpm.console.client

Source Code of org.jboss.bpm.console.client.Workspace$WrapperPanel

/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This 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 2.1 of
* the License, or (at your option) any later version.
*
* This software 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.bpm.console.client;

import com.gwtext.client.widgets.Component;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.TabPanel;

/**
* Maintains {@link org.jboss.bpm.console.client.Workspace}'s
*
* @author Heiko.Braun <heiko.braun@jboss.com>
*/
public class Workspace extends TabPanel
{
  protected ApplicationContext view;
  private Menu menu;
 
  public Workspace(Menu menu)
  {
    super();
    this.menu = menu;

    this.setResizeTabs(true);
    this.setMinTabWidth(115);
    this.setTabWidth(135);
    this.setEnableTabScroll(true);
    this.setAutoScroll(true);
    this.setActiveTab(0);
  }

  private Panel createTab(Editor editor, boolean closeable)
  {
    Panel tab = new WrapperPanel(editor.getId() + ".tab");
    tab.setTitle(editor.getTitle());
    tab.setIconCls(editor.getIconCSS());
    tab.setClosable(closeable);
    tab.setAutoScroll(true);
    tab.setBorder(false);
    tab.setFrame(false);
    tab.setHideBorders(true);
    return tab;
  }

  public void addEditor(Editor editor, boolean closeable)
  {
    // Menu
    menu.addSection(editor.provideMenuSection());

    // Editor pane
    Panel tab = createTab(editor, closeable);
    tab.add(editor);
    this.add(tab);
    this.setActiveTab(tab.getId());
    this.doLayout();
  }

  public boolean hasEditor(String id)
  {
    boolean b = false;
    final String tabId = id + ".tab";

    Component[] tabs = this.getItems();
    for (int i = 0; i < tabs.length; i++)
    {
      Component tab = tabs[i];
      if (tab.getId().equals(tabId))
      {
        b = true;
        break;
      }
    }

    return b;
  }

  public void showEditor(String id)
  {
    final String tabId = id + ".tab";
    this.setActiveTab(tabId);
  }

  class WrapperPanel extends Panel
  {
    public WrapperPanel(String id)
    {
      super();
      setId(id);
    }
  }
}
TOP

Related Classes of org.jboss.bpm.console.client.Workspace$WrapperPanel

TOP
Copyright © 2018 www.massapi.com. 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.