예제 #1
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()
  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());
  }
 private void onCloseTab(ObjectResultTabController toClose) {
   for (int i = 0; i < _objectResultTabbedPane.getTabCount(); i++) {
     if (_objectResultTabbedPane.getComponentAt(i) == toClose.getPanel()) {
       _objectResultTabbedPane.removeTabAt(i);
       break;
     }
   }
 }
예제 #4
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;
 }
예제 #5
0
 int indexOf(String strThreadID) {
   int iMonitorCount = pnlThread.getComponentCount();
   for (int iMonitorIndex = 0; iMonitorIndex < iMonitorCount; iMonitorIndex++) {
     PanelThreadMonitor mntTemp = ((PanelThreadMonitor) pnlThread.getComponentAt(iMonitorIndex));
     if (mntTemp.mstrThreadID.equals(strThreadID)) return iMonitorIndex;
   }
   return -1;
 }
예제 #6
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;
     }
   }
 }
 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);
 }
예제 #8
0
 /**
  * Spawns a new tab. called when the user clicks twice on a tab.
  *
  * @param tab the index of the clicked tab
  */
 public void myDoubleClick(int tab) {
   // TODO: should fire its own event and ProjectBrowser
   // should register a listener
   LOG.log(Level.FINE, "double: {0}", topLevelTabbedPane.getComponentAt(tab).toString());
   //        JPanel t = (JPanel) tabPanelList.elementAt(tab);
   // Currently this feature is disabled for ArgoUML.
   //        if (t instanceof AbstractArgoJPanel)
   //	    ((AbstractArgoJPanel) t).spawn();
 }
 /** Creates new form FindAndReplaceDialog */
 public FindAndReplaceDialog(java.awt.Frame parent, boolean modal, JTabbedPane tab) {
   super(parent, modal);
   initComponents();
   setLocationRelativeTo(null);
   RTextScrollPane t = (RTextScrollPane) tab.getComponentAt(tab.getSelectedIndex());
   selectedArea = (RSyntaxTextArea) t.getTextArea();
   findDocListener();
   replaceDocListener();
 }
예제 #10
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);
      }
    }
  }
 private ArrayList<Component> getAllTabs() {
   ArrayList<Component> allTabs = new ArrayList<Component>();
   for (int i = 0; i < _tabbedExecutionsPanel.getTabCount(); i++) {
     Component component = _tabbedExecutionsPanel.getComponentAt(i);
     if (false == component instanceof CancelPanel) {
       allTabs.add(component);
     }
   }
   return allTabs;
 }
  private void checkResultTabLimit() {
    SessionProperties props = _session.getProperties();

    while (props.getLimitSQLResultTabs()
        && props.getSqlResultTabLimit() < _tabbedExecutionsPanel.getTabCount()) {
      if (_tabbedExecutionsPanel.getComponentAt(0) instanceof CancelPanel) {
        break;
      }
      closeTabAt(0);
    }
  }
  private Component getTab(@NotNull Content content, String displayName) {
    //        Component[] comps = (content.getComponent()).getComponents();
    //        JTabbedPane tabbedPane = (JTabbedPane) comps[1];
    JTabbedPane tabbedPane = getTabComponent(content);
    int index = tabbedPane.indexOfTab(displayName);
    if (index == -1) {
      return null;
    }

    return tabbedPane.getComponentAt(index);
  }
예제 #14
0
 public static int getIndexOf(JTabbedPane tabbedPane, Component component) {
   int result = -1;
   for (int i = 0; i < tabbedPane.getComponentCount(); i++) {
     Component comp = tabbedPane.getComponentAt(i);
     if (comp == component) {
       result = i;
       break;
     }
   }
   return result;
 }
 public void propertyChange(PropertyChangeEvent evt) {
   if (evt.getPropertyName().equals(TagConflictResolverModel.NUM_CONFLICTS_PROP)) {
     TagConflictResolverModel model = (TagConflictResolverModel) evt.getSource();
     for (int i = 0; i < tpResolvers.getTabCount(); i++) {
       TagConflictResolver resolver = (TagConflictResolver) tpResolvers.getComponentAt(i);
       if (model == resolver.getModel()) {
         tpResolvers.setIconAt(i, (Boolean) evt.getNewValue() ? iconResolved : iconUnresolved);
       }
     }
   }
 }
  private QueryResultPanel getSelectedTab(@NotNull Content content) {
    //        Component[] comps = (content.getComponent()).getComponents();
    //        JTabbedPane tabbedPane = (JTabbedPane) comps[1];
    JTabbedPane tabbedPane = getTabComponent(content);
    int index = tabbedPane.getSelectedIndex();
    if (index == -1) {
      return null;
    }

    return (QueryResultPanel) tabbedPane.getComponentAt(index);
  }
예제 #17
0
파일: ChatFrame.java 프로젝트: TingXqt/iqq
  /**
   * 安装皮肤
   *
   * @param skinService
   */
  @Override
  public void installSkin(SkinService skinService) {
    super.installSkin(skinService);
    this.contentPane.installSkin(skinService);
    setIconImage(skinService.getIconByKey("window/titleWIcon").getImage());

    // 更新每个tab中panel的皮肤
    for (int i = 0; i < tabbedPane.getTabCount(); i++) {
      BasicPanel entityPanel = (BasicPanel) tabbedPane.getComponentAt(i);
      entityPanel.installSkin(skinService);
    }
  }
  private int getIndexOfTab(JComponent tab) {
    if (null == tab) {
      return -1;
    }

    for (int i = 0; i < _tabbedExecutionsPanel.getTabCount(); i++) {
      if (tab == _tabbedExecutionsPanel.getComponentAt(i)) {
        return i;
      }
    }
    return -1;
  }
예제 #19
0
  /* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    Object o = e.getSource();
    if (o instanceof JMenuItem) {
      JMenuItem sender = (JMenuItem) o;
      String name = sender.getText();
      if (name.equals("close")) {
        tabbedPane.removeTabAt(tabbedPane.getSelectedIndex());
      } else if (name.equals("save")) {
        int index = tabbedPane.getSelectedIndex();
        Component c = tabbedPane.getComponent(index);
        Point p = c.getLocation();
        Component t = tabbedPane.getComponentAt(new Point(p.x + 20, p.y + 30));
        if (t instanceof TextView) {
          TextView text = (TextView) t;
          // String code = text.getText();
          // save the code
          // saveTab(code);
        }
        if (t instanceof HTMLTextView) {
          HTMLTextView text = (HTMLTextView) t;
          fileChooser.setSelectedFile(new File(text.node.getName()));
          int returnVal = fileChooser.showSaveDialog(this);

          if (returnVal == JFileChooser.APPROVE_OPTION) {
            File f = fileChooser.getSelectedFile();

            // save the code
            String fileType =
                f.getName().substring(f.getName().lastIndexOf("."), f.getName().length());
            if (fileType.indexOf("htm") != -1) {
              // save as html
              String code = text.getText();
              saveTab(code, f);
            } else if (fileType.indexOf("java") != -1) {
              // save as java
              String code = text.getUnModyfiedContent();
              saveTab(code, f);
            } else if (text.node.fileType.indexOf(FileTypes.MANIFEST) != -1
                || text.node.fileType.indexOf(FileTypes.MANIFEST2) != -1) {
              String code = text.getUnModyfiedContent();
              saveTab(code, f);
              System.out.println("Saved manifest");
            } else {
              System.out.println("FILETYPE UNKNOWN:" + text.node.fileType);
            }
          }
        }
      } else if (name.equals("close all")) {
        tabbedPane.removeAll();
      }
    }
  }
예제 #20
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();
  }
  private void removeErrorPanels() {
    ArrayList<ErrorPanel> toRemove = new ArrayList<ErrorPanel>();

    for (int i = 0; i < _tabbedExecutionsPanel.getTabCount(); i++) {
      Component tab = _tabbedExecutionsPanel.getComponentAt(i);
      if (tab instanceof ErrorPanel) {
        toRemove.add((ErrorPanel) tab);
      }
    }

    for (ErrorPanel errorPanel : toRemove) {
      closeTab(errorPanel);
    }
  }
예제 #22
0
  private void rebuildTabs() {

    rebuildingTabs = true;
    for (int i = 0; i < tabbedPane.getTabCount(); i++) {
      SheetPanel sheetPanel = (SheetPanel) tabbedPane.getComponentAt(i);
      sheetPanel.dispose();
    }
    tabbedPane.removeAll();
    Workbook workbook = manager.getWorkbook();
    for (Sheet sheet : workbook.getSheets()) {
      if (!sheet.isHidden()) {
        SheetPanel sheetPanel = new SheetPanel(manager, sheet);
        tabbedPane.add(sheet.getName(), sheetPanel);
      }
    }
    rebuildingTabs = false;
  }
예제 #23
0
  public int getOpenCount() {
    int num = tabbedToolPanel.getComponentCount();
    if (num != 1) return num;
    Component comp = tabbedToolPanel.getComponent(0);
    if (comp instanceof JTabbedPane) {
      JTabbedPane tp = (JTabbedPane) comp;
      num = tp.getTabCount();
      if (num != 1) return num;
      comp = tp.getComponentAt(0);
    }
    if (comp instanceof VToolPanel) num = ((VToolPanel) comp).getOpenCount();
    else if (comp instanceof PushpinIF) {
      if (!((PushpinIF) comp).isOpen()) num = 0;
    }

    return num;
  }
  /*
   *	Tab has changed. Focus on saved component for the given tab.
   *  When there is no saved component, focus on the first component.
   */
  public void stateChanged(ChangeEvent e) {
    Component key = tabbedPane.getComponentAt(tabbedPane.getSelectedIndex());

    if (key == null) return;

    Component value = tabFocus.get(key);

    //  First time selecting this tab or focus policy is RESET_FOCUS

    if (value == null) {
      key.transferFocus();
      tabFocus.put(key, value);
    } else //  Use the saved component for focusing
    {
      value.requestFocusInWindow();
    }
  }
예제 #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;
  }
예제 #26
0
 @Override
 public void locationChanged(WebBrowserNavigationEvent e) {
   JWebBrowser webBrowser = e.getWebBrowser();
   JTabbedPane panel = (JTabbedPane) e.getWebBrowser().getParent();
   if (panel != null) {
     int index = 0;
     for (int i = 0; i < panel.getTabCount(); i++) {
       if (webBrowser == panel.getComponentAt(i)) {
         index = i;
         break;
       }
     }
     panel.setTitleAt(index, webBrowser.getPageTitle());
     if (panel.getSelectedComponent() == webBrowser) {
       updateNavigateButtons(webBrowser);
       updateLocation(webBrowser);
     }
   }
 }
  private synchronized void doShowSalesReport() {

    BackOfficeWindow window = BackOfficeWindow.getInstance();
    JTabbedPane tabbedPane = window.getTabbedPane();

    ReportViewer viewer = null;
    //        int index = tabbedPane.indexOfTab(com.floreantpos.POSConstants.SALES_REPORT);
    int index = tabbedPane.indexOfTab("Transaksi Harian");
    if (index == -1) {
      //            viewer = new ReportViewer(new SalesReport());
      viewer = new ReportViewer(new DailyTxnReport());
      //            tabbedPane.addTab(POSConstants.SALES_REPORT, viewer);
      tabbedPane.addTab("Transaksi Harian", viewer);
    } else {
      viewer = (ReportViewer) tabbedPane.getComponentAt(index);
    }
    tabbedPane.setSelectedComponent(viewer);

    window.setVisible(true);
  }
예제 #28
0
 public void updateLanguage() {
   //////////////////////////////////////////////////////////////
   mdic = MonitorDictionary.getChildDictionary("ThreadManager");
   MonitorDictionary.applyButton(btnKick, "Kick");
   MonitorDictionary.applyButton(btnRefresh, "Refresh");
   MonitorDictionary.applyButton(btnSend, "Send");
   tblUser.setColumnNameEx(mdic.getString("LoginName"), 1);
   tblUser.setColumnNameEx(mdic.getString("LoginTime"), 2);
   tblUser.setColumnNameEx(mdic.getString("Host"), 3);
   //////////////////////////////////////////////////////////////
   MonitorDictionary.applyButton(mnuSelectAll, "jmenu.Edit.SelectAll");
   MonitorDictionary.applyButton(mnuClearAll, "jmenu.Edit.ClearAll");
   MonitorDictionary.applyButton(mnuClearSelected, "jmenu.Edit.ClearSelected");
   //////////////////////////////////////////////////////////////
   MonitorDictionary.applyButton(mnuSystem, "jmenu.System");
   MonitorDictionary.applyButton(mnuSystem_ChangePassword, "jmenu.System.ChangePassword");
   MonitorDictionary.applyButton(mnuSystem_StopServer, "jmenu.System.Shutdown");
   MonitorDictionary.applyButton(mnuSystem_EnableThreads, "jmenu.System.ThreadManager");
   MonitorDictionary.applyButton(mnuHelp, "jmenu.Help");
   MonitorDictionary.applyButton(mnuHelp_About, "jmenu.Help.About");
   //////////////////////////////////////////////////////////////
   MonitorDictionary.applyButton(mnuUI, "jmenu.UI");
   //////////////////////////////////////////////////////////////
   if (isOpen()) {
     lblStatus.setText(
         "  " + MonitorDictionary.getString("LoggedUser") + ": " + channel.getUserName());
     MonitorDictionary.applyButton(mnuSystem_Login, "jmenu.System.Logout");
     mnuSystem_ChangePassword.setEnabled(true);
     mnuSystem_StopServer.setEnabled(true);
     mnuSystem_EnableThreads.setEnabled(true);
   } else {
     lblStatus.setText("");
     MonitorDictionary.applyButton(mnuSystem_Login, "jmenu.System.Login");
     mnuSystem_ChangePassword.setEnabled(false);
     mnuSystem_StopServer.setEnabled(false);
     mnuSystem_EnableThreads.setEnabled(false);
   }
   //////////////////////////////////////////////////////////////
   for (int iIndex = 0; iIndex < pnlThread.getTabCount(); iIndex++)
     ((PanelThreadMonitor) pnlThread.getComponentAt(iIndex)).updateLanguage();
 }
  /**
   * Exports currently selected table to file
   *
   * @param tabbedPane - Currently loaded tabbedPane
   */
  public void exportCSVToFile(JTabbedPane tabbedPane) {

    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle("Select where you'd like to save the CSV file");
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    String tabName = tabbedPane.getTitleAt(tabbedPane.getSelectedIndex());
    chooser.setSelectedFile(new File(tabName.replaceAll("/", "-")));
    chooser.setAcceptAllFileFilterUsed(true);

    // If user chooses valid directory then saves CSV there
    if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
      String filepath = chooser.getSelectedFile() + ".csv";
      try {
        // Uses a file choo
        FileWriter writer = new FileWriter(filepath);
        JScrollPane currentScrollPane =
            (JScrollPane) tabbedPane.getComponentAt(tabbedPane.getSelectedIndex());
        JViewport viewport = currentScrollPane.getViewport();
        JTable currentTable = (JTable) viewport.getView();

        // Goes through column headings and adds to CSV file
        for (int i = 0; i < currentTable.getColumnCount(); i++) {
          writer.write(currentTable.getColumnName(i) + ",");
        }
        writer.write("\n");
        // Goes through rows and adds to CSV file
        for (int i = 0; i < currentTable.getRowCount(); i++) {
          for (int j = 0; j < currentTable.getColumnCount(); j++) {
            writer.write(currentTable.getValueAt(i, j).toString() + ",");
          }
          writer.write("\n");
        }
        writer.close();
        JOptionPane.showMessageDialog(null, "Table data successfully exported as CSV file");
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
예제 #30
0
  private boolean containTool(JComponent obj) {
    int k, num;

    if (obj == null) return false;
    Component src = (Component) obj;
    Component comp;
    if (tabbedPane != null) {
      num = tabbedPane.getTabCount();
      for (k = 0; k < num; k++) {
        comp = tabbedPane.getComponentAt(k);
        if (src == comp) return true;
      }
    }
    if (tabbedToolPanel != null) {
      num = tabbedToolPanel.getComponentCount();
      for (k = 0; k < num; k++) {
        comp = tabbedToolPanel.getComponent(k);
        if (src == comp) return true;
      }
    }
    return false;
  }