Exemplo n.º 1
0
  public void switchLayout(int newId, boolean bLayout) {

    if (layoutId == newId) return;
    if (newId >= nviews) updateVpInfo(newId + 1);

    if (bSwitching) {
      return;
    }

    bSwitching = true;
    int oldId = layoutId;
    vpId = newId;
    layoutId = newId;

    recordCurrentLayout();
    VpLayoutInfo vInfo = Util.getViewArea().getLayoutInfo(oldId);
    if (vInfo != null) { // save current layout info
      vInfo.tp_selectedTab = tp_selectedTab;
      vInfo.setVerticalTabName(selectedTabName);
      // copyCurrentLayout(vInfo);
    }

    vInfo = Util.getViewArea().getLayoutInfo(newId);

    putHsLayout(oldId);
    if (bLayout) getHsLayout(vpId);

    for (int i = 0; i < toolList.size(); i++)
      ((VToolPanel) toolList.get(i)).switchLayout(newId, bLayout);

    if (bLayout) setCurrentLayout();
    /*
    if(comparePanelLayout(oldId, newId)) {
    setCurrentLayout();
           }
           if ((vInfo != null) && vInfo.bAvailable &&
    compareCurrentLayout(vInfo)) {
                  setCurrentLayout(vInfo);
           }

    for(int i=0; i< toolList.size(); i++)
        ((VToolPanel) toolList.get(i)).switchLayout(newId);
           */

    // setViewPort(newId);

    if (bLayout) setCurrentLayout(vInfo);

    updateValue();

    if (bLayout) {
      if (pinPanel.isOpen()) {
        if (!pinPanel.isVisible()) pinPanel.setVisible(true);
      } else pinPanel.setVisible(false);
    }
    validate();
    repaint();

    bSwitching = false;
  }
Exemplo n.º 2
0
 public boolean popdnTool(String name) {
   JComponent obj = searchTool(name);
   if (obj == null) return false;
   if (obj instanceof VToolPanel) {
     if (!((VToolPanel) obj).popdnTool(name)) return false;
   } else {
     if (obj instanceof PushpinIF) {
       PushpinIF pobj = (PushpinIF) obj;
       pobj.pinPopup(false);
     }
     boolean bContain = containTool(obj);
     if (!bContain) return false;
   }
   bChangeTool = true;
   setCurrentLayout();
   if (previous_selectedTab >= 1 && tabbedPane != null) {
     if (tabbedPane.getTabCount() > previous_selectedTab)
       tabbedPane.setSelectedIndex(previous_selectedTab);
   }
   VnmrjIF vif = Util.getVjIF();
   if (vif != null) vif.raiseToolPanel(false);
   if (!pinPanel.isOpen()) pinPanel.setVisible(false);
   bChangeTool = false;
   updateSelectedObj();
   repaint();
   return true;
 }
Exemplo n.º 3
0
 public boolean popupTool(String name) {
   JComponent obj = searchTool(name);
   if (obj == null) return false;
   if (obj instanceof VToolPanel) {
     if (!((VToolPanel) obj).popupTool(name)) return false;
   } else {
     if (obj instanceof PushpinIF) {
       PushpinIF pobj = (PushpinIF) obj;
       if (!pobj.isOpen()) pobj.pinPopup(true);
     }
   }
   bChangeTool = true;
   setCurrentLayout();
   if (!pinPanel.isOpen()) {
     pinPanel.setVisible(false);
     bChangeTool = false;
     return false;
   }
   displayTool((Component) obj);
   VnmrjIF vif = Util.getVjIF();
   if (vif != null) vif.raiseToolPanel(true);
   bChangeTool = false;
   validate();
   repaint();
   return true;
 }
Exemplo n.º 4
0
  public boolean openTool(String name, boolean bOpen, boolean bShowOnly) {
    if (!bOpen) return closeTool(name);

    JComponent obj = searchTool(name);
    if (obj == null) return false;
    if (obj instanceof VToolPanel) {
      if (!((VToolPanel) obj).openTool(name, bOpen, bShowOnly)) return false;
    } else {
      if (obj instanceof PushpinIF) {
        PushpinIF pobj = (PushpinIF) obj;
        if (bShowOnly) {
          if (!pobj.isClose()) return false; // no change
        }
        pobj.setStatus("open");
      }
    }
    recordCurrentLayout();
    bChangeTool = true;
    setCurrentLayout();
    if (!pinPanel.isOpen()) {
      pinPanel.setVisible(false);
      bChangeTool = false;
      return false;
    }
    if (!bShowOnly) displayTool((Component) obj);
    bChangeTool = false;
    if (!pinPanel.isVisible()) pinPanel.setVisible(true);
    if (bShowOnly) setSelectedTab(tp_selectedTab, selectedTabName);
    validate();
    repaint();

    return true;
  }
Exemplo n.º 5
0
  public void setCurrentLayout(int newId) {

    if (newId >= nviews) return;

    tabbedPane.removeAll();
    tabbedToolPanel.removeAll();
    String key;
    String currValue;
    JComponent obj;
    PushpinIF pobj;
    clearPushpinComp();
    for (int i = 0; i < keys.size(); i++) {
      key = (String) keys.get(i);
      currValue = (String) tp_paneInfo[newId].get(key);
      obj = (JComponent) panes.get(key);
      pobj = null;
      if (currValue.equals("yes") && obj != null) {
        if (obj instanceof PushpinIF) {
          pobj = (PushpinIF) obj;
          pobj.setAvailable(true);
          if (!pobj.isOpen()) {
            if (!pobj.isPopup()) obj = null;
          }
        }
        if (obj != null) {
          if (key.equals("Locator")) key = getLocatorName();
          tabbedPane.addTab(key, null, obj, "");
        }
        // tabbedPane.addTab(key, null, (JComponent)panes.get(key), "");
      }
    }

    if (tabbedPane.getTabCount() < 1) {
      pinPanel.setAvailable(false);
      pinPanel.setStatus("close");
      // setVisible(false);
      return;
    }

    pinPanel.setAvailable(true);
    pinPanel.setStatus("open");
    if (tabbedPane.getTabCount() == 1) {
      tabbedToolPanel.add(tabbedPane.getComponentAt(0));
      // tabbedToolPanel.add(tabbedPane);
    } else {
      tabbedToolPanel.add(tabbedPane);
    }
    setSelectedTab(tp_selectedTab, selectedTabName);

    tabbedToolPanel.validate();
    // repaint();
  }
Exemplo n.º 6
0
  public boolean hideTool(String name) {
    JComponent obj = searchTool(name);
    if (obj == null) return false;
    if (obj instanceof VToolPanel) {
      if (!((VToolPanel) obj).hideTool(name)) return false;
    } else {
      if (obj instanceof PushpinIF) {
        PushpinIF pobj = (PushpinIF) obj;
        pobj.setStatus("hide");
      }
    }
    setCurrentLayout();
    if (!pinPanel.isOpen()) {
      pinPanel.setVisible(false);
    }

    validate();
    repaint();

    return true;
  }
Exemplo n.º 7
0
  /**
   * public void setCurrentLayout(int newId) {
   *
   * <p>if(newId >= nviews || vpId >= nviews) return;
   *
   * <p>String key; String newValue; String currValue;
   *
   * <p>for(int i=0; i<keys.size(); i++) { key = (String)keys.get(i); newValue =
   * (String)tp_paneInfo[newId].get(key); currValue = (String)tp_paneInfo[vpId].get(key); JComponent
   * obj = (JComponent)panes.get(key); if(newValue.equals("yes")) { if
   * (tabbedPane.indexOfComponent((Component)obj) < 0) tabbedPane.addTab(key, null, obj, ""); if
   * (obj instanceof PushpinIF) ((PushpinIF) obj).setAvailable(true); } else
   * if(newValue.equals("no")) { if (tabbedPane.indexOfComponent((Component)obj) >= 0)
   * tabbedPane.remove(obj); if (obj instanceof PushpinIF) ((PushpinIF) obj).setAvailable(false); }
   * }
   *
   * <p>tabbedToolPanel.removeAll(); if(tabbedPane.getTabCount() > 0) { if(tabbedPane.getTabCount()
   * == 1) { tabbedToolPanel.add(tabbedPane.getComponentAt(0)); } else if(tabbedPane.getTabCount() >
   * 1) { tabbedToolPanel.add(tabbedPane); } pinPanel.setStatus("open"); } else {
   * pinPanel.setStatus("close"); setVisible(false); } validate(); repaint(); }
   */
  public void initPanel() {

    if (panes == null || panes.size() <= 0) return;

    setCurrentLayout();
    String key;
    for (Enumeration e = panes.keys(); e.hasMoreElements(); ) {
      key = (String) e.nextElement();
      JComponent comp = (JComponent) panes.get(key);
      if (comp instanceof VToolPanel) ((VToolPanel) comp).initPanel();
      else {
        if (comp instanceof PushpinIF) comp = ((PushpinIF) comp).getPinObj();
        if (comp instanceof XMLToolPanel) ((XMLToolPanel) comp).buildPanel();
      }
      /**
       * ** if(comp instanceof XMLToolPanel) { ((XMLToolPanel)comp).buildPanel(); } else if(comp
       * instanceof VToolPanel) { ((VToolPanel)comp).initPanel(); } **
       */
    }
    if (pinPanel.isOpen()) {
      if (!pinPanel.isVisible()) pinPanel.setVisible(true);
    } else pinPanel.setVisible(false);
  }
Exemplo n.º 8
0
  public void showPinObj(PushpinIF pobj, boolean on) {
    Component comp = (Component) pobj;
    if (comp == null) return;
    Container p = comp.getParent();
    if (!on) {
      pobj.setPopup(false, true);
      if (p != null && p != tabbedPane) {
        p.remove(comp);
        p.validate();
        p.repaint();
      }
      if (popupComp == comp) popupComp = null;
      return;
    }

    if (popupComp != null) {
      if (popupComp != comp) {
        ((PushpinIF) popupComp).setPopup(false, true);
        p = popupComp.getParent();
        if (p != null && p != tabbedPane) {
          p.remove(popupComp);
        }
      }
      popupComp = null;
    }
    /*
    if (!isShowing()) {
        return;
    }
     */
    if (comp.isShowing()) {
      return;
    }
    Container p2 = null;
    p = pinPanel.getParent();
    while (p != null) {
      if (p instanceof JLayeredPane) p2 = p;
      p = p.getParent();
    }
    if (p2 == null) return;
    if (!isShowing()) {
      VnmrjIF vif = Util.getVjIF();
      vif.raiseToolPanel(on);
      setVisible(true);
    }

    popupComp = comp;
    p = p2;
    pobj.setPopup(true, true);
    /*
    Point pt0 = p.getLocationOnScreen();
    Point pt1 = getLocationOnScreen();
     */
    Point pt1 = getLocation();
    Dimension dim = getSize();
    int y0 = (int) ((float) dim.height * pobj.getRefY());
    int h = (int) ((float) dim.height * pobj.getRefH());
    int x = pt1.x + 2;
    int y = pt1.y + y0;
    p.add(comp, JLayeredPane.MODAL_LAYER);
    comp.setBounds(x, y, dim.width, dim.height - y0);
    ((JComponent) p).validate();
    /*
    p.repaint();
     */
  }