Exemplo n.º 1
0
 /**
  * Insert a new tab\graph in the editor and selects it.
  *
  * @param tabName
  * @param graph
  * @return PetriNetGraph
  */
 public PetriNetGraph insertGraph(String tabName, PetriNetGraph graph) {
   tabs.add(tabName, new GraphViewContainer(graph));
   tabs.setTabComponentAt(tabs.getTabCount() - 1, new ButtonTabComponent(tabs, tabName));
   tabs.setSelectedIndex(tabs.getTabCount() - 1);
   indexOpenedGraphs++;
   return graph;
 }
 protected void addPage(String _typeOfPage, String _name, String _code, boolean _enabled) {
   cardLayout.show(finalPanel, "TabbedPanel");
   _name = getUniqueName(_name);
   Editor page = createPage(_typeOfPage, _name, _code);
   page.setFont(myFont);
   page.setColor(myColor);
   int index = tabbedPanel.getSelectedIndex();
   if (index == -1) {
     pageList.addElement(page);
     if (tabbedPanel.getTabCount() == 0) {
       tabbedPanel.addTab(
           page.getName(),
           null,
           page.getComponent(),
           tooltip); // This causes an exception sometimes
     } else {
       tabbedPanel.insertTab(
           page.getName(), null, page.getComponent(), tooltip, tabbedPanel.getTabCount());
     }
     index = 0;
   } else {
     index++;
     pageList.insertElementAt(page, index);
     tabbedPanel.insertTab(page.getName(), null, page.getComponent(), tooltip, index);
   }
   tabbedPanel.setSelectedComponent(page.getComponent());
   page.setActive(_enabled);
   if (!_enabled) tabbedPanel.setTitleAt(index, page.getName() + " (D)");
   updatePageCounterField(pageList.size());
   // tabbedPanel.validate(); This hangs the computer when reading a file at start-up !!!???
   tabbedPanel.repaint();
   changed = true;
 }
Exemplo n.º 3
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.º 4
0
  private void createTab(String title, String adress) {
    System.out.println("create tab");
    if (tab.getTabCount() > 0) tab.remove(tab.getTabCount() - 1);
    MyEditorPane pane = new MyEditorPane(adress);
    JScrollPane scPane = new JScrollPane(pane);
    pane.addHyperlinkListener(HYHandler);

    tab.addTab(title, scPane);
    addCloseButton(tab.getTabCount() - 1, title);
    pane.setEditable(false);
    tabAccess.add(new Tab(pane, new JTextField(adress)));
    if (adress != "") loadPage(pane, adress);
    tab.addTab("", new ImageIcon(iconDir + "newTab.png"), null);
  }
Exemplo n.º 5
0
 private void setSelectedTab(int id, String name) {
   if (tabbedPane == null) return;
   int selectId = id;
   if (name != null) {
     for (int k = 0; k < tabbedPane.getTabCount(); k++) {
       String tabName = tabbedPane.getTitleAt(k);
       if (name.equals(tabName)) {
         selectId = k;
         break;
       }
     }
   }
   if (selectId >= 0 && selectId < tabbedPane.getTabCount()) tabbedPane.setSelectedIndex(selectId);
 }
 protected void showFirstPage() {
   if (tabbedPanel.getTabCount() <= 0) cardLayout.show(finalPanel, "FirstPanel");
   else {
     cardLayout.show(finalPanel, "TabbedPanel");
     tabbedPanel.setSelectedIndex(0);
   }
 }
  private void onListRead(QueryListCreator queryListCreator) {

    for (int i = 0; i < _objectResultTabbedPane.getTabCount(); i++) {
      if (_objectResultTabbedPane.getComponentAt(i) == queryListCreator.getWaitPanel()) {
        _objectResultTabbedPane.removeTabAt(i);
        break;
      }
    }

    List list = queryListCreator.getList();

    if (null == list) {
      return;
    }

    ObjectResultTabControllerListener l =
        new ObjectResultTabControllerListener() {
          @Override
          public void closeTab(ObjectResultTabController toClose) {
            onCloseTab(toClose);
          }
        };

    String hqlQuery = queryListCreator.getHqlQuery();
    int maxNumResults = queryListCreator.getMaxNumResults();
    HibernateConnection con = queryListCreator.getConnection();

    ObjectResultTabController ortc =
        new ObjectResultTabController(list, maxNumResults, con, hqlQuery, _resource, l, _session);
    int titelLen = Math.min(hqlQuery.length(), 14);
    String title = hqlQuery.trim().substring(0, titelLen).replaceAll("\n", " ");
    _objectResultTabbedPane.addTab(title, ortc.getPanel());
    _objectResultTabbedPane.setSelectedComponent(ortc.getPanel());
  }
Exemplo n.º 8
0
  /** Update tab title to each tab page. */
  public void updateTabTitle() {
    for (int i = 0; i < tabbedPane.getTabCount(); i++) {
      final SessionPane session = (SessionPane) model.getSessions().elementAt(i);

      tabbedPane.setTitleAt(i, session.getSite().getName());
    }
  }
Exemplo n.º 9
0
  /**
   * Change current session showed on the screen.
   *
   * @param index the index of session to be showed on the screen.
   */
  public void changeSession(final int index) {
    if ((0 <= index) && (index < tabbedPane.getTabCount())) {

      // 取得焦點的工作
      final Runnable sessionFocuser =
          new Runnable() {
            public void run() {
              final SessionPane session = (SessionPane) sessions.get(index);
              session.requestFocusInWindow();
            }
          };

      // 切換分頁的工作 (包含取得焦點的工作)
      final Runnable tabbedSwitcher =
          new Runnable() {
            public void run() {
              tabbedPane.setSelectedIndex(index);
              SwingUtilities.invokeLater(sessionFocuser);
            }
          };

      // 啟動切換分頁的工作
      SwingUtilities.invokeLater(tabbedSwitcher);
    }
  }
Exemplo n.º 10
0
  public ChatPane createChatPane(String userName) {
    JTextPane chatPane = new JTextPane();
    chatPane.setEditable(false);
    Font font = chatPane.getFont();
    float size = Main.pref.getInteger("geochat.fontsize", -1);
    if (size < 6) size += font.getSize2D();
    chatPane.setFont(font.deriveFont(size));
    //        DefaultCaret caret = (DefaultCaret)chatPane.getCaret(); // does not work
    //        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    JScrollPane scrollPane =
        new JScrollPane(
            chatPane,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    chatPane.addMouseListener(new GeoChatPopupAdapter(panel));

    ChatPane entry = new ChatPane();
    entry.pane = chatPane;
    entry.component = scrollPane;
    entry.notify = 0;
    entry.userName = userName;
    entry.isPublic = userName == null;
    chatPanes.put(userName == null ? PUBLIC_PANE : userName, entry);

    tabs.addTab(null, scrollPane);
    tabs.setTabComponentAt(tabs.getTabCount() - 1, new ChatTabTitleComponent(entry));
    tabs.setSelectedComponent(scrollPane);
    return entry;
  }
  private void assertTabCount(Content content) {
    //        PluginSettingsBean bean = (PluginSettingsBean)
    // SharedObjectPool.getUserData(SharedConstants.PLUGIN_SETTINGS);
    PluginSettingsBean bean = PluginKeys.PLUGIN_SETTINGS.getData();

    if (bean == null) {
      bean = new PluginSettingsBean();
    }

    int max = bean.getNumberOfTabs();

    if (max <= getTabComponent(content).getTabCount()) {
      // remove the oldest tab
      JTabbedPane tabbedPane = getTabComponent(content);
      long lastMin = Long.MAX_VALUE;
      int index = 0;
      for (int i = 0; i < tabbedPane.getTabCount(); i++) {
        JComponent tab = (JComponent) tabbedPane.getTabComponentAt(i);
        Long time = (Long) tab.getClientProperty(CREATE_TIME);
        if (time != null && lastMin < time) {
          lastMin = time;
          index = i;
        }
      }

      tabbedPane.remove(index);
    }
  }
Exemplo n.º 12
0
  /** Handle OK/Cancel selections */
  @Override
  public void close(String actionCommand) {
    super.close(actionCommand);

    if (isOKorAccept(actionCommand)) {
      World world = clientFrame.getWorld();

      // this isn't really the way to do it
      GamePanel gp = (GamePanel) tabPane.getComponentAt(0);
      GameMetadata gmd = new GameMetadata();
      gp.write(gmd);
      world.setGameMetadata(gmd);

      // assume panels 1-n are all player panels
      for (int i = 1; i < tabPane.getTabCount(); i++) {
        PlayerPanel pp = (PlayerPanel) tabPane.getComponentAt(i);
        PlayerMetadata pmd = new PlayerMetadata();
        pp.write(pmd);
        world.setPlayerMetadata(pp.getPower(), pmd);
      }

      // set data-changed flag
      clientFrame.fireStateModified();
    }

    if (propertyListener != null) {
      clientFrame.removePropertyChangeListener(propertyListener);
    }
  } // close()
Exemplo n.º 13
0
  private void secureAddTab(ExplainTab tab) {
    SessionProperties props = _session.getProperties();

    if (s_log.isDebugEnabled()) {
      s_log.debug("secureAddTab - TabCount: " + _tabbedExecutionsPanel.getTabCount());
      s_log.debug("secureAddTab - Limited?: " + props.getLimitSQLResultTabs());
      s_log.debug("secureAddTab - TabLimit: " + props.getSqlResultTabLimit());
    }

    if (props.getLimitSQLResultTabs()
        && props.getSqlResultTabLimit() <= _tabbedExecutionsPanel.getTabCount()) {
      closeTabAt(0);
    }
    _tabbedExecutionsPanel.addTab(tab.getTitle(), null, tab, tab.getToolTip());
    _tabbedExecutionsPanel.setSelectedComponent(tab);
  }
Exemplo n.º 14
0
  /** Add a new tab with the given name. */
  private void addTab(String name, int rows, int cols) {
    String rowString = "";
    for (int i = 0; i < rows; i++) {
      rowString += "pref:grow";
      if (i < rows - 1) rowString += ",";
    }

    String colString = "";
    for (int i = 0; i < cols; i++) {
      colString += "pref:grow";
      if (i < cols - 1) colString += ",";
    }

    FormLayout layout = new FormLayout(colString, rowString);

    Hashtable[] tmp = icons;
    icons = new Hashtable[tmp.length + 1];
    System.arraycopy(tmp, 0, icons, 0, tmp.length);
    icons[icons.length - 1] = new Hashtable();

    tmp = fields;
    fields = new Hashtable[tmp.length + 1];
    System.arraycopy(tmp, 0, fields, 0, tmp.length);
    fields[fields.length - 1] = new Hashtable();

    JPanel panel = new JPanel(layout);

    for (int x = 0; x < rows; x++) {
      for (int y = 0; y < cols; y++) {
        addIcon(panel, x, y, tabPane.getTabCount());
      }
    }

    tabPane.addTab(name, panel);
  }
Exemplo n.º 15
0
 /**
  * Adds a tab to the gui.
  *
  * @param tab tab that will be added to the gui.
  */
 public void addTab(JNotepadPPTab tab) {
   int index = tabPane.getTabCount();
   tabPane.insertTab("", null, new JScrollPane(tab.getEditor()), "", index);
   tab.getTitle().setVisible(true);
   tabPane.setTabComponentAt(index, tab.getTitle());
   setTab(index);
 }
Exemplo n.º 16
0
 public void addView(View view) {
   container.addTab("", null, view.getContent());
   JPanel panel = new JPanel();
   panel.add(new JLabel("My Title"));
   panel.add(createXButton());
   container.setTabComponentAt(container.getTabCount() - 1, panel);
 }
Exemplo n.º 17
0
  public static void main(String[] args)
      throws BadLocationException, FileNotFoundException, UnsupportedEncodingException,
          IOException {
    m_form = new MainForm();
    m_form.setVisible(true);
    JTabbedPane j = m_form.getTabbedPane();

    if (!IO.loadFile(j)) {
      IO.setStatus("Welcome to ZeroVal.");
      SyntaxBox b = new SyntaxBox();
      b.setHighlightText("//New Tab Name\n//Press Alt + Enter to evaluate");
      j.insertTab("New Tab", null, b, "Blank Tab", 0);
    } else {
      IO.setStatus("Loaded tabs successfully.");
    }

    m_timer =
        new Timer(
            60,
            new java.awt.event.ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                try {
                  ((SyntaxBox) m_form.getTabbedPane().getSelectedComponent())
                      .getPatternHandler()
                      .renderSyntaxHighlighting();
                } catch (BadLocationException ex) {
                  Logger.getLogger(Base.class.getName()).log(Level.SEVERE, null, ex);
                }
              }
            });
    m_timer.start();
    j.insertTab("+", null, null, "Create New Tab", j.getTabCount());
  }
Exemplo n.º 18
0
 private JPanel addResultPane() {
   JPanel resultPane = new JPanel(new BorderLayout());
   resultPane.setOpaque(false);
   int componentCount = southPanel.getComponentCount();
   if (componentCount == 0) {
     southPanel.add(resultPane, BorderLayout.CENTER);
     southPanel.revalidate();
     southPanel.repaint();
   } else {
     JTabbedPane tabbedPane;
     Component component0 = southPanel.getComponent(0);
     if (component0 instanceof JTabbedPane) {
       tabbedPane = (JTabbedPane) component0;
     } else {
       JPanel query1Panel = (JPanel) component0;
       southPanel.remove(0);
       tabbedPane = new JTabbedPane();
       tabbedPane.addTab("Query 1", query1Panel);
       southPanel.add(tabbedPane, BorderLayout.CENTER);
       southPanel.revalidate();
       southPanel.repaint();
     }
     tabbedPane.addTab("Query " + (tabbedPane.getTabCount() + 1), resultPane);
   }
   return resultPane;
 }
Exemplo n.º 19
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.º 20
0
 /**
  * remove tab
  *
  * @param i
  */
 protected void removeTab(int i) {
   if (i == 0) System.exit(1);
   tab.remove(i - 1);
   tabcreate = false;
   tab.setSelectedIndex(tab.getTabCount() - 2);
   tabAccess.remove(i - 1);
 }
Exemplo n.º 21
0
 protected Component getTab(String name) {
   for (int i = 0; i < tabPane.getTabCount(); i++) {
     if (tabPane.getTitleAt(i).equals(name)) {
       return tabPane.getComponentAt(i);
     }
   }
   return null;
 }
 private void onCloseTab(ObjectResultTabController toClose) {
   for (int i = 0; i < _objectResultTabbedPane.getTabCount(); i++) {
     if (_objectResultTabbedPane.getComponentAt(i) == toClose.getPanel()) {
       _objectResultTabbedPane.removeTabAt(i);
       break;
     }
   }
 }
Exemplo n.º 23
0
 public void selectFirstTabWithConflicts() {
   for (int i = 0; i < tabbedPane.getTabCount(); i++) {
     if (tabbedPane.isEnabledAt(i) && mergeIncomplete.equals(tabbedPane.getIconAt(i))) {
       tabbedPane.setSelectedIndex(i);
       break;
     }
   }
 }
Exemplo n.º 24
0
 public void setSelectedSheet(Sheet sheet) {
   for (int i = 0; i < tabbedPane.getTabCount(); i++) {
     SheetPanel sheetPanel = (SheetPanel) tabbedPane.getComponentAt(i);
     if (sheetPanel.getSheet().getName().equals(sheet.getName())) {
       tabbedPane.setSelectedIndex(i);
       break;
     }
   }
 }
Exemplo n.º 25
0
  private Component getSelectedObj() {
    if (tabbedToolPanel.getComponentCount() < 1) return null;
    Component comp = tabbedToolPanel.getComponent(0);
    if (comp instanceof JTabbedPane) {
      JTabbedPane tp = (JTabbedPane) comp;
      if (tp.getTabCount() == 1) {
        comp = tp.getComponentAt(0);
      } else if (tp.getTabCount() > 1) {
        comp = tp.getSelectedComponent();
      }
    }
    if (comp instanceof VToolPanel) return comp;

    if (!(comp instanceof XMLToolPanel)) {
      if (comp instanceof PushpinIF) comp = ((PushpinIF) comp).getPinObj();
    }
    return comp;
  }
Exemplo n.º 26
0
  public void toolMenuItem(ActionEvent evt) {
    JTabbedPane tp = GMGenSystemView.getTabPane();

    for (int i = 0; i < tp.getTabCount(); i++) {
      if (tp.getComponentAt(i) instanceof PCGTrackerView) {
        tp.setSelectedIndex(i);
      }
    }
  }
Exemplo n.º 27
0
  /**
   * Sets the selected index on the CytoPanel.
   *
   * @param index The desired index.
   */
  @Override
  public void setSelectedIndex(final int index) {
    // set selected index
    if (tabbedPane.getTabCount() <= index) return;

    tabbedPane.setSelectedIndex(index);
    resizeSelectedComponent();
    // do not have to sent out notification - the tabbedPane will let us know.
  }
Exemplo n.º 28
0
  public void addPanel(String name, JPanel panel) {

    if (tabbedPane.getTabCount() == 0) {
      preffered = panel.getPreferredSize();
    }

    panel.setPreferredSize(preffered);
    tabbedPane.add(name, panel);
  }
 public void testTabbedPane() throws Exception {
   JTabbedPane tabbedPane =
       (JTabbedPane) getInstrumentedRootComponent("TestTabbedPane.form", "BindingTest");
   assertEquals(2, tabbedPane.getTabCount());
   assertEquals("First", tabbedPane.getTitleAt(0));
   assertEquals("Test Value", tabbedPane.getTitleAt(1));
   assertTrue(tabbedPane.getComponentAt(0) instanceof JLabel);
   assertTrue(tabbedPane.getComponentAt(1) instanceof JButton);
 }
Exemplo n.º 30
0
  private void clearChats() {
    // 在管理器中清除当然所有对话
    ChatManager.clearChats();

    int count = tabbedPane.getTabCount();
    for (int i = 0; i < count; i++) {
      tabbedPane.removeTabAt(0);
    }
  }