private void moveUpAndDownPage(boolean _up) {
   int index = tabbedPanel.getSelectedIndex();
   if (index < 0) return;
   Editor page = pageList.get(index);
   if (page == null) return;
   if (_up) {
     if (index == 0) return;
     pageList.removeElementAt(index);
     pageList.insertElementAt(page, index - 1);
     tabbedPanel.removeTabAt(index);
     tabbedPanel.insertTab(
         page.isActive() ? page.getName() : page.getName() + " (D)",
         null,
         page.getComponent(),
         tooltip,
         index - 1);
   } else {
     if (index == (pageList.size() - 1)) return;
     pageList.removeElementAt(index);
     pageList.insertElementAt(page, index + 1);
     tabbedPanel.removeTabAt(index);
     tabbedPanel.insertTab(
         page.isActive() ? page.getName() : page.getName() + " (D)",
         null,
         page.getComponent(),
         tooltip,
         index + 1);
   }
   tabbedPanel.setSelectedComponent(page.getComponent());
   changed = true;
 }
 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;
 }
 private void toggleCurrentPage() {
   int index = tabbedPanel.getSelectedIndex();
   if (index < 0) return;
   Editor page = pageList.get(index);
   if (page.isActive()) {
     page.setActive(false);
     tabbedPanel.setTitleAt(index, page.getName() + " (D)");
   } else {
     page.setActive(true);
     tabbedPanel.setTitleAt(index, page.getName());
   }
   changed = true;
   ejs.getModelEditor().getVariablesEditor().updateControlValues(false);
 }
 public StringBuffer saveStringBuffer() {
   StringBuffer save = new StringBuffer();
   for (java.util.Enumeration<Editor> e = pageList.elements(); e.hasMoreElements(); ) {
     Editor page = e.nextElement();
     save.append(
         "<"
             + name
             + ".Page>\n"
             + "<Type>"
             + typeOfPage(page)
             + "</Type>\n"
             + "<Name>"
             + page.getName()
             + "</Name>\n"
             + "<Active>"
             + page.isActive()
             + "</Active>\n"
             + "<"
             + contentDelim
             + ">\n");
     save.append(page.saveStringBuffer());
     save.append("</" + contentDelim + ">\n" + "</" + name + ".Page>\n");
   }
   return save;
 }
 private void renameCurrentPage(String _name) {
   int index = tabbedPanel.getSelectedIndex();
   if (index < 0) return;
   _name = getUniqueName(_name); // Gonzalo 070128
   tabbedPanel.setTitleAt(index, _name);
   Editor page = pageList.get(index);
   page.setName(_name);
   if (!page.isActive()) tabbedPanel.setTitleAt(index, page.getName() + " (D)");
   changed = true;
 }
 public void showPage(Editor anEditor) {
   for (int i = 0, n = tabbedPanel.getComponentCount(); i < n; i++) {
     if (tabbedPanel.getComponent(i) == anEditor.getComponent()) {
       //        System.out.println ("Found editor "+anEditor.getName()+ " at i="+i);
       ejs.showPanel(defaultHeader);
       cardLayout.show(finalPanel, anEditor.getName());
       tabbedPanel.setSelectedComponent(anEditor.getComponent());
       return;
     }
   }
 }
 private void copyPage() {
   int index = tabbedPanel.getSelectedIndex();
   if (index < 0) return;
   Editor page = pageList.get(index);
   if (page == null) return;
   addPage(
       typeOfPage(page),
       this.getUniqueName(page.getName()),
       page.saveStringBuffer().toString(),
       true);
   changed = true;
 }