Example #1
0
  public void refreshOutput() {
    Command command = cmdEditor.getModel();

    if (cmdTable.getSelectedRow() == -1) {
      cmdTabs.setSelectedIndex(0);
      cmdTabs.setEnabledAt(1, false);
      cmdTabs.setEnabledAt(2, false);
    } else {
      cmdTabs.setEnabledAt(1, true);
      cmdTabs.setEnabledAt(2, true);
    }

    if (command != null) {
      JTextArea text = stdOutput.isShowing() ? stdOutput : errOutput.isShowing() ? errOutput : null;
      if (text != null) {
        try {
          text.setText(cmdEditor.getProcess().getTraces(command, text == stdOutput));
          return;
        } catch (ConnectException e) {
          setStatus(e);
        }
      }
    }
    // else
    stdOutput.setText("");
    errOutput.setText("");
  }
Example #2
0
 public void enableTab(TabView view, String toolTip) {
   int index = tabbedView.indexOfComponent(view);
   if (index != -1) {
     tabbedView.setEnabledAt(index, true);
     tabbedView.setToolTipTextAt(index, toolTip);
   }
 }
Example #3
0
  /**
   * Enables/disables the tabs on the tabbed card. Also selects the tab to show.
   *
   * @param target the target object
   */
  private void enableTabs(Object target) {

    // TODO: Quick return here for target == null? - tfm

    // iterate through the tabbed panels to determine whether they
    // should be enabled.
    for (int i = 0; i < tabPanelList.size(); i++) {
      JPanel tab = tabPanelList.get(i);
      boolean shouldEnable = false;
      if (!(tab instanceof TabToDoTarget) && !(tab instanceof TabProps)) {
        // TODO: Bob says - tabs that listen for target changes
        // should register themselves not expect DetailsPane to
        // listen and pass on the event. Otherwise these tabs
        // always rely on DetailsPane. TabToDoTarget and TabProps
        // currently listen directly.
        if (tab instanceof TargetListener) {
          if (tab instanceof TabTarget) {
            shouldEnable = ((TabTarget) tab).shouldBeEnabled(target);
          } else {
            if (tab instanceof TabToDoTarget) {
              shouldEnable = true;
            }
          }
          // TODO: Do we want all enabled tabs to listen or
          // only the one that is selected/visible? - tfm
          removeTargetListener((TargetListener) tab);
          if (shouldEnable) {
            addTargetListener((TargetListener) tab);
          }

          topLevelTabbedPane.setEnabledAt(i, shouldEnable);
        }
      }
    }
  }
  private void CreateWindow() {
    fm = new Param(new File("graph.pref"));
    FilePath = fm.getDefaultPath(new File("Graph.ini"));

    JMenuBar menubar = new JMenuBar();

    JMenu MenuFile = new JMenu("File");

    menubar.add(MenuFile);

    JMenuItem MenuNew = new JMenuItem(Param.Label_File_New);
    JMenuItem MenuOpen = new JMenuItem(Param.Label_File_Open);
    JMenuItem MenuSave = new JMenuItem(Param.Label_File_Save);
    JMenuItem MenuQuit = new JMenuItem(Param.Label_File_Quit);

    MenuFile.add(MenuNew);
    MenuFile.add(MenuOpen);
    MenuFile.add(MenuSave);
    MenuFile.add(MenuQuit);

    MenuNew.addActionListener(this);
    MenuOpen.addActionListener(this);
    MenuSave.addActionListener(this);
    MenuQuit.addActionListener(this);

    initParam();

    tabCom = new ComSetting();
    tabSubGHz = new SubghzSetting();

    SettingFrame = new JTabbedPane();
    SettingFrame.addTab("COM", tabCom);
    SettingFrame.addTab("SubGHz", tabSubGHz);
    SettingFrame.setBounds(0, 0, 600, 200);
    SettingFrame.setEnabledAt(1, Param.Subghz_Tab_Enb);

    graphSetting = new GraphSetting();

    graphStart = new JButton(Param.Label_Start);
    graphStart.addActionListener(this);

    setLayout(null);

    graphSetting.setBounds(0, 0, 600, 200);
    graphStart.setBounds(240, 210, 100, 30);
    SettingFrame.setBounds(0, 240, 600, 200);

    add(SettingFrame);
    add(graphSetting);
    add(graphStart);

    setTitle("Setting Window");
    setJMenuBar(menubar);
    setBounds(100, 100, 600, 480);

    ImageIcon icon = new ImageIcon(Param.App_Icon);
    setIconImage(icon.getImage());
  }
Example #5
0
  /**
   * populates the conflict resolver with the conflicts between my and their
   *
   * @param conflict the conflict data set
   */
  public void populate(Conflict<? extends OsmPrimitive> conflict) {
    setMy(conflict.getMy());
    setTheir(conflict.getTheir());
    this.conflict = conflict;
    propertiesMerger.populate(conflict);

    tabbedPane.setEnabledAt(0, true);
    tagMerger.populate(conflict);
    tabbedPane.setEnabledAt(1, true);

    if (my instanceof Node) {
      tabbedPane.setEnabledAt(2, false);
      tabbedPane.setEnabledAt(3, false);
    } else if (my instanceof Way) {
      nodeListMerger.populate(conflict);
      tabbedPane.setEnabledAt(2, true);
      tabbedPane.setEnabledAt(3, false);
      tabbedPane.setTitleAt(3, tr("Members"));
      tabbedPane.setIconAt(3, null);
    } else if (my instanceof Relation) {
      relationMemberMerger.populate(conflict);
      tabbedPane.setEnabledAt(2, false);
      tabbedPane.setTitleAt(2, tr("Nodes"));
      tabbedPane.setIconAt(2, null);
      tabbedPane.setEnabledAt(3, true);
    }
    updateResolvedCompletely();
    selectFirstTabWithConflicts();
  }
Example #6
0
 /** Enables all items that are disabled upon launching */
 private void enableObjects() {
   tabbedPane.setEnabledAt(0, true);
   setNewsIcon();
   tabbedPane.setEnabledAt(1, true);
   tabbedPane.setEnabledAt(2, true);
   tabbedPane.setEnabledAt(3, true);
   //		tabbedPane.setEnabledAt(4, true);
   tabbedPane.getSelectedComponent().setEnabled(true);
   updateFooter();
   mapInstall.setEnabled(true);
   mapInstallLocation.setEnabled(true);
   serverMap.setEnabled(true);
   tpInstall.setEnabled(true);
   launch.setEnabled(true);
   users.setEnabled(true);
   serverbutton.setEnabled(true);
   tpInstallLocation.setEnabled(true);
 }
Example #7
0
  public MainFrame(String title, UserFrontEnd ptheApp) {
    super(title);
    theApp = ptheApp;
    // identify the OS

    if (theApp.runningOSX()) initForOSX(); // OSX specific inits
    else if (theApp.runningWindows()) { // Windows specific inits
      initForWindows();
    } else if (theApp.runningLinux()) {
      initForLinux();
    } else {
      JOptionPane.showMessageDialog(
          this,
          "Phylontal doesn't recognize your operating system (yet!)",
          "Operating System unknown",
          JOptionPane.WARNING_MESSAGE);
    }

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    // add tabbed pane
    tabbedView = new JTabbedPane(JTabbedPane.TOP);
    tabbedView.addChangeListener(this);

    tabbedView.addTab("Project", projectTab = new ProjectTab(theApp));
    tabbedView.addTab("Matcher", matcherTab = new MatcherTab(theApp));

    int matchIndex = tabbedView.indexOfComponent(matcherTab);
    tabbedView.setToolTipTextAt(matchIndex, "Disabled until a project is specified");
    tabbedView.setEnabledAt(matchIndex, false);

    int projectIndex = tabbedView.indexOfComponent(projectTab);
    tabbedView.setToolTipTextAt(projectIndex, "Create or Load a project; specify components");

    currentTabComponent = tabbedView.getSelectedComponent();
    if (currentTabComponent instanceof TabView) {
      resetMenuBar();
      JMenuBar tmpBar = ((TabView) currentTabComponent).initializeMenus();
      if (tmpBar != null) {
        menuBar = tmpBar;
        setJMenuBar(menuBar);
      }
    }

    Container content = getContentPane(); // get content pane
    content.setLayout(new BorderLayout());
    content.add(tabbedView, BorderLayout.CENTER);

    // add icons

    // add preferences Dialog

    preferencesDialog = new PreferencesDialog(this);
  }
  private static void setupTabbedPane(JTabbedPane tabbedPane) {
    // Simple tab
    tabbedPane.addTab("Normal 1", new WebLabel());

    // Disabled tab
    tabbedPane.addTab("Disabled 2", new WebLabel());
    tabbedPane.setEnabledAt(1, false);

    // Selected tab
    tabbedPane.addTab("Selected 3", new WebLabel());
    tabbedPane.setSelectedIndex(2);

    // Colored tab
    tabbedPane.addTab("Colored 4", new WebLabel());
    tabbedPane.setBackgroundAt(3, new Color(255, 212, 161));
  }
  @Override
  public void setEnabledAt(int index, boolean enabled) {
    super.setEnabledAt(index, enabled);
    // update tab label to show enabled state
    getTabComponentAt(index).setEnabled(enabled);

    // disable current selected tab, select another enable tab if possible
    if (enabled == false && index == getSelectedIndex()) {
      // looking first enable tab and select it.
      for (int i = 0; i < getTabCount(); i++) {
        if (getComponentAt(i).isEnabled()) {
          setSelectedIndex(i);
          break;
        }
      }
    }
  }
Example #10
0
  /** Creates the experiment environment gui with no initial experiment */
  public Experimenter(boolean classFirst) {

    System.out.println(
        "[DEBUGGER] ---- "
            + Messages.getInstance().getString("Experimenter_TabbedPane_Setup_Key_Text"));

    m_SetupPanel = new SetupModePanel();
    m_ResultsPanel = new ResultsPanel();
    m_RunPanel = new RunPanel();
    m_RunPanel.setResultsPanel(m_ResultsPanel);

    m_ClassFirst = classFirst;

    m_TabbedPane.addTab(
        Messages.getInstance().getString("Experimenter_TabbedPane_Setup_Key_Text"),
        null,
        m_SetupPanel,
        Messages.getInstance().getString("Experimenter_TabbedPane_Setup_Value_Text"));
    m_TabbedPane.addTab(
        Messages.getInstance().getString("Experimenter_TabbedPane_Run_Key_Text"),
        null,
        m_RunPanel,
        Messages.getInstance().getString("Experimenter_TabbedPane_Run_Value_Text"));
    m_TabbedPane.addTab(
        Messages.getInstance().getString("Experimenter_TabbedPane_Analyse_Key_Text"),
        null,
        m_ResultsPanel,
        Messages.getInstance().getString("Experimenter_TabbedPane_Analyse_Value_Text"));
    m_TabbedPane.setSelectedIndex(0);
    m_TabbedPane.setEnabledAt(1, false);
    m_SetupPanel.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            // System.err.println("Updated experiment");
            Experiment exp = m_SetupPanel.getExperiment();
            exp.classFirst(m_ClassFirst);
            m_RunPanel.setExperiment(exp);
            // m_ResultsPanel.setExperiment(exp);
            m_TabbedPane.setEnabledAt(1, true);
          }
        });
    setLayout(new BorderLayout());
    add(m_TabbedPane, BorderLayout.CENTER);
  }
Example #11
0
  private void getByModifiedProduct() {
    try {
      if (this.jtblProduct.getSelectedRowCount() != 0) {
        Product rc = recoveryProduct();
        valForm.editableTextFields(jpnAddProduct, true);
        this.jtxtId_Product.setEnabled(false);
        this.jtxtId_Product.setText("" + rc.getId_product());
        this.jtxtProduct.setText("" + rc.getProduct());
        this.jtxtDescripcion.setText("" + rc.getDescripcion());
        this.jtxtPrecioCompra.setText("" + rc.getP_compra());
        this.jtxtPrecioVenta.setText("" + rc.getP_venta());
        this.jtxtCantidad.setText("" + rc.getCantidad());

        if (null != myCategory) {
          for (Category c : myCategory) {
            if (c.getId_category().equals(rc.getId_category())) {
              jcmbCategoria.setSelectedItem(c.getCategory());
            }
          }
        }
        /*
         * Validamos si el Articulo esta activo
         */
        if (rc.getActivo() == 1) {
          this.jchkActivo.setSelected(true);
        } else {
          this.jchkActivo.setSelected(false);
        }
        /*
         * Cambia el estatus del boton Guardar a Actualizar
         */
        this.jbtnOperacion.setText("Actualizar");
        jbtnOperacion.setIcon(new ImageIcon(pathImage + "update.gif"));
        // Seleccionamos la Pestaña 1 para modificar el Articulo seleccionado
        frmProduct.jtbpProduct.setSelectedIndex(0);
        jtbpProduct.setEnabledAt(1, false);
      } else {
        valForm.msjWarn("No se ha seleccionado ningun Articulo...");
      }
    } catch (Exception ex) {
      System.out.println("getByModifiedProduct. Error: " + ex.getMessage());
    }
  }
 public void disableTab(int tabIndex) {
   if (tabIndex != 0 && tabIndex != 1)
     throw new IllegalArgumentException("The tab index is not correct.");
   tabbedPane.setEnabledAt(tabIndex, false);
   tabbedPane.setSelectedIndex(tabIndex == 0 ? 1 : 0);
 }
Example #13
0
 private void setCacheTabsStatus(boolean enabled) {
   int numTabs = mainPane.getTabCount();
   for (int i = 1; i < numTabs; i++) mainPane.setEnabledAt(i, enabled);
   panel1.repaint();
 }
Example #14
0
  /**
   * Constructor to initialize the GUI. This should only be invoked from the Swing event thread.
   * Properties must be initialized first. In particular, {@link Survivor#currentColourScheme} must
   * be set.
   *
   * @param survivor The Survivor object associated with this object
   */
  public RootPanel(final Survivor survivor) {
    this.backgroundColourableComponents = new HashSet<Component>();
    this.complementaryAmenableForegroundColourableComponents = new HashSet<Component>();
    this.colourSchemeButtons = new HashSet<AbstractButton>();

    this.survivor = survivor;

    // Do nothing on close to allow close to be handles identically to File>Quit.
    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    /*
     * This is added as an anonymous inner class to
     * prevent having to extend WindowAdapter or implement WindowListener.
     */
    this.addWindowListener(
        new WindowAdapter() {
          /* (non-Javadoc)
           * @see java.awt.event.WindowAdapter#windowClosing(java.awt.event.WindowEvent)
           */
          @Override
          public void windowClosing(WindowEvent e) {
            exit();
          }
        });

    this.setTitle(application.ProjectInfo.TITLE);
    this.setSize(size);
    this.setMinimumSize(size);
    this.setLayout(new BorderLayout());

    /*
     * Attempts to set the Look and Feel to Nimbus.
     * Note that a modicum of backwards compatibility is present if Nimbus cannot be found.
     * It is ideal that it is available, since it severely reduces colour schemes.
     */
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          this.nimbus = info.getClassName();
          UIManager.setLookAndFeel(this.nimbus);
          break;
        }
      }
    } catch (Exception e) {
    }

    tabbedPane = new JTabbedPane();

    ContestantManagementTab contestantManagementTab = new ContestantManagementTab(survivor);
    tabbedPane.addTab(
        ContestantManagementTab.TITLE,
        ContestantManagementTab.ICON,
        contestantManagementTab,
        ContestantManagementTab.TOOLTIP);
    tabbedPane.setMnemonicAt(tabbedPane.getTabCount() - 1, KeyEvent.VK_C);

    PlayerManagementTab playerManagementTab = new PlayerManagementTab(survivor);
    tabbedPane.addTab(
        PlayerManagementTab.TITLE,
        PlayerManagementTab.ICON,
        playerManagementTab,
        PlayerManagementTab.TOOLTIP);
    tabbedPane.setMnemonicAt(tabbedPane.getTabCount() - 1, KeyEvent.VK_P);

    tabbedPane.addTab(
        BonusQuestionTab.TITLE,
        BonusQuestionTab.ICON,
        new BonusQuestionTab(survivor),
        BonusQuestionTab.TOOLTIP);
    tabbedPane.setMnemonicAt(tabbedPane.getTabCount() - 1, KeyEvent.VK_B);

    tabbedPane.addTab(
        StandingsTab.TITLE, StandingsTab.ICON, new StandingsTab(), StandingsTab.TOOLTIP);
    tabbedPane.setMnemonicAt(tabbedPane.getTabCount() - 1, KeyEvent.VK_S);

    JButton startGame = new JButton(START_GAME);
    startGame.addActionListener(this);
    startGame.addActionListener(contestantManagementTab);
    startGame.addActionListener(playerManagementTab);
    startGame.setFont(Constants.BOLD_FONT);
    startGame.setMnemonic(KeyEvent.VK_G);
    colourSchemeButtons.add(startGame);
    tabbedPane.add(new JPanel(new GridLayout(1, 1)));
    this.startGameTabIndex = tabbedPane.getComponentCount() - 1;
    tabbedPane.setTabComponentAt(this.startGameTabIndex, startGame);
    tabbedPane.setEnabledAt(this.startGameTabIndex, false);
    backgroundColourableComponents.add(tabbedPane);

    for (Component c : tabbedPane.getComponents()) {
      backgroundColourableComponents.add(c);
    }

    this.add(tabbedPane);
    io.io.readProperties();

    JMenuBar menuBar = new JMenuBar();
    backgroundColourableComponents.add(menuBar);

    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    this.backgroundColourableComponents.add(file);
    this.complementaryAmenableForegroundColourableComponents.add(file);
    menuBar.add(file);

    JMenuItem menuItem = new JMenuItem(CLEAR_DATA, RESET_ICON);
    menuItem.setMnemonic(KeyEvent.VK_C);
    menuItem.addActionListener(this);
    this.backgroundColourableComponents.add(menuItem);
    file.add(menuItem);

    file.addSeparator();

    JLabel label = new JLabel("Colour Scheme");
    file.add(label);

    ButtonGroup group = new ButtonGroup();

    JRadioButtonMenuItem rbMenuItemDefault = new JRadioButtonMenuItem(DEFAULT);
    rbMenuItemDefault.addActionListener(this);
    this.colourSchemeButtons.add(rbMenuItemDefault);
    this.backgroundColourableComponents.add(rbMenuItemDefault);
    group.add(rbMenuItemDefault);
    file.add(rbMenuItemDefault);

    JRadioButtonMenuItem rbMenuItemSunset = new JRadioButtonMenuItem(SUNSET);
    rbMenuItemSunset.addActionListener(this);
    this.colourSchemeButtons.add(rbMenuItemSunset);
    this.backgroundColourableComponents.add(rbMenuItemSunset);
    group.add(rbMenuItemSunset);
    file.add(rbMenuItemSunset);

    JRadioButtonMenuItem rbMenuItemDawn = new JRadioButtonMenuItem(DAWN);
    rbMenuItemDawn.addActionListener(this);
    this.colourSchemeButtons.add(rbMenuItemDawn);
    this.backgroundColourableComponents.add(rbMenuItemDawn);
    group.add(rbMenuItemDawn);
    file.add(rbMenuItemDawn);

    /*
     * Set both the colour scheme and the corresponding selection
     * of the radio button in the file menu.
     * This data is read from the configuration file, if available.
     */
    setCurrentColourSchemeSelected();
    setColourScheme(survivor.getCurrentColourScheme());

    menuItem = new JMenuItem(QUIT, QUIT_ICON);
    menuItem.setMnemonic(KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK));
    menuItem.addActionListener(this);
    this.backgroundColourableComponents.add(menuItem);
    file.add(menuItem);
    file.addSeparator();

    JMenu help = new JMenu("Help");
    help.setMnemonic(KeyEvent.VK_H);
    this.backgroundColourableComponents.add(help);
    this.complementaryAmenableForegroundColourableComponents.add(help);
    menuBar.add(help);

    menuItem = new JMenuItem(ABOUT, ABOUT_ICON);
    menuItem.setMnemonic(KeyEvent.VK_A);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    menuItem.addActionListener(this);
    this.backgroundColourableComponents.add(menuItem);
    help.add(menuItem);
    help.addSeparator();

    this.add(menuBar, BorderLayout.PAGE_START);

    this.setVisible(true);
  }
Example #15
0
  public ControlPane(Controller pCore) {
    super(JSplitPane.HORIZONTAL_SPLIT);
    core = pCore;
    mainTable = new MoveableTable(this);

    commands = new CommandTable(this);
    cmdEditor = new CommandEditor(this);
    cmdTable = new JTable(commands);

    // Build graphic
    wrappers = new WrapperList(core);

    wrapper = new WrapperHeader(this);
    newWrapper =
        new WrapperHeader(this) {
          protected void update() {
            super.update();
            connectB.setAction(getActionMap().get("connect"));
            connectB.setEnabled(false);
          }
        };

    SwingHelper h = new SwingHelper(this);
    h.add(LEFT, new JScrollPane(new JList(wrappers)));
    h.with(RIGHT, switchPane)
        .with("global", new BorderLayout())
        .add("new", newWrapper, BorderLayout.PAGE_START)
        .add("table", mainTable, BorderLayout.CENTER)
        .back()
        .with("process", new BorderLayout())
        .add("id", wrapper, BorderLayout.PAGE_START)
        .with("center", new BorderLayout(), BorderLayout.CENTER)
        .vsplit("cmds")
        .add(JSplitPane.TOP, new JScrollPane(cmdTable))
        .with(JSplitPane.BOTTOM, cmdTabs)
        .with("editor", new BorderLayout())
        .add("cmd", cmdEditor, BorderLayout.PAGE_START)
        .back()
        .scroll("std", stdOutput)
        .scroll("err", errOutput)
        .back()
        .back()
        .back()
        .back()
        .back();

    JList list = h.get("left?view");
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // list.setSelectionInterval(0, 0);
    list.setCellRenderer(wrapperRenderer);

    cmdTable.setRowSelectionAllowed(true);
    cmdTable.setColumnSelectionAllowed(false);
    cmdTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // Refresh outputs on
    cmdTabs.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            refreshOutput();
          }
        });

    switchPane.setEnabledAt(1, list.getSelectedValue() != null);

    ListEventListenener lel = new ListEventListenener(list);
    list.getSelectionModel().addListSelectionListener(lel);
    // list.addMouseListener(this); // deselection in wrapper list
    cmdTable.getSelectionModel().addListSelectionListener(lel);
    cmdTable.addMouseListener(lel); // deselection in process list

    pCore.addControlListener(this);
  }
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame();
    frame.setResizable(false);
    frame.setBounds(100, 100, 505, 467);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);
    frame.setLocationRelativeTo(null);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setBounds(0, 0, 500, 442);

    /*Camera Report Panel*/
    CameraReportPanel = new JPanel();
    tabbedPane.add("Camera Report", CameraReportPanel);
    tabbedPane.setEnabledAt(0, true);
    CameraReportPanel.setLayout(null);

    JLabel label = new JLabel("Insert First Part of IP (xxx.xxx.xxx):");
    label.setFont(new Font("Tahoma", Font.PLAIN, 14));
    label.setBounds(36, 40, 232, 25);
    CameraReportPanel.add(label);

    JLabel label_1 = new JLabel("Insert Starting Host Number:");
    label_1.setFont(new Font("Tahoma", Font.PLAIN, 14));
    label_1.setBounds(36, 72, 181, 17);
    CameraReportPanel.add(label_1);

    JLabel label_2 = new JLabel("Insert Ending Host Number:");
    label_2.setFont(new Font("Tahoma", Font.PLAIN, 14));
    label_2.setBounds(36, 112, 181, 17);
    CameraReportPanel.add(label_2);

    sOctet = new JTextField();
    sOctet.setFont(new Font("Dialog", Font.PLAIN, 20));
    sOctet.addFocusListener(this);
    sOctet.setColumns(10);
    sOctet.setBounds(278, 70, 40, 25);
    CameraReportPanel.add(sOctet);

    eOctet = new JTextField();
    eOctet.setFont(new Font("Dialog", Font.PLAIN, 20));
    eOctet.addFocusListener(this);
    eOctet.setColumns(10);
    eOctet.setBounds(278, 110, 40, 25);
    CameraReportPanel.add(eOctet);

    JLabel label_3 = new JLabel("Enter Username:"******"Tahoma", Font.PLAIN, 14));
    label_3.setBounds(36, 205, 106, 14);
    CameraReportPanel.add(label_3);

    JLabel label_4 = new JLabel("Enter Password:"******"Tahoma", Font.PLAIN, 14));
    label_4.setBounds(36, 249, 106, 14);
    CameraReportPanel.add(label_4);

    uName = new JTextField();
    uName.setFont(new Font("Tahoma", Font.PLAIN, 19));
    uName.addFocusListener(this);
    uName.setText("root");
    uName.setColumns(10);
    uName.setBounds(143, 195, 149, 32);
    CameraReportPanel.add(uName);

    passwordField = new JPasswordField();
    passwordField.setFont(new Font("Tahoma", Font.PLAIN, 19));
    passwordField.addFocusListener(this);
    passwordField.setText("p@ssw0rd");
    passwordField.setBounds(143, 239, 149, 32);
    CameraReportPanel.add(passwordField);

    checkBoxPing = new JCheckBox("Ping Address");
    checkBoxPing.setFont(new Font("Tahoma", Font.PLAIN, 14));
    checkBoxPing.setSelected(true);
    checkBoxPing.setBounds(36, 144, 125, 23);
    CameraReportPanel.add(checkBoxPing);

    progressBar = new JProgressBar();
    progressBar.setString("");
    progressBar.setStringPainted(true);
    progressBar.setBounds(68, 331, 374, 32);
    CameraReportPanel.add(progressBar);

    CamReportBtn = new JButton("Run");
    CamReportBtn.addActionListener(this);
    CamReportBtn.setBounds(201, 282, 104, 38);
    CameraReportPanel.add(CamReportBtn);

    firstOctet = new JTextField();
    firstOctet.addFocusListener(this);
    firstOctet.setFont(new Font("Tahoma", Font.PLAIN, 20));
    firstOctet.setText("10");
    firstOctet.setColumns(3);
    firstOctet.setBounds(278, 38, 40, 25);
    CameraReportPanel.add(firstOctet);

    secondOctet = new JTextField();
    secondOctet.addFocusListener(this);
    secondOctet.setFont(new Font("Dialog", Font.PLAIN, 20));
    secondOctet.setColumns(3);
    secondOctet.setBounds(328, 37, 40, 25);
    CameraReportPanel.add(secondOctet);

    thirdOctet = new JTextField();
    thirdOctet.addFocusListener(this);
    thirdOctet.setFont(new Font("Dialog", Font.PLAIN, 20));
    thirdOctet.setColumns(3);
    thirdOctet.setBounds(378, 37, 40, 25);
    CameraReportPanel.add(thirdOctet);

    JLabel label_5 = new JLabel(".");
    label_5.setFont(new Font("Dialog", Font.BOLD, 17));
    label_5.setBounds(320, 50, 4, 14);
    CameraReportPanel.add(label_5);

    JLabel label_6 = new JLabel(".");
    label_6.setFont(new Font("Dialog", Font.BOLD, 17));
    label_6.setBounds(370, 50, 4, 14);
    CameraReportPanel.add(label_6);

    /*Host Uploader Panel*/
    frame.getContentPane().add(tabbedPane);
    JComponent HostUploaderPanel = new JPanel();
    tabbedPane.add("Host Uploader", HostUploaderPanel);
    tabbedPane.setEnabledAt(1, true);
    HostUploaderPanel.setLayout(null);

    hostUploaderBrowseBtn = new JButton("Browse");
    hostUploaderBrowseBtn.addActionListener(this);
    hostUploaderBrowseBtn.setBounds(23, 82, 117, 29);
    HostUploaderPanel.add(hostUploaderBrowseBtn);

    filePath = new JTextField();
    filePath.addFocusListener(this);
    filePath.setFont(new Font("Tahoma", Font.PLAIN, 10));
    filePath.setBounds(150, 86, 318, 20);
    HostUploaderPanel.add(filePath);
    filePath.setColumns(10);

    hostUploaderRunBtn = new JButton("Run");
    hostUploaderRunBtn.setFont(new Font("Tahoma", Font.PLAIN, 15));
    hostUploaderRunBtn.addActionListener(this);
    hostUploaderRunBtn.setBounds(157, 334, 186, 60);
    hostUploaderRunBtn.setEnabled(false);
    HostUploaderPanel.add(hostUploaderRunBtn);

    JLabel label_7 = new JLabel("Insert First Part of IP (xxx.xxx.xxx):");
    label_7.setFont(new Font("Tahoma", Font.PLAIN, 14));
    label_7.setBounds(23, 125, 232, 25);
    HostUploaderPanel.add(label_7);

    textField_7 = new JTextField();
    textField_7.addFocusListener(this);
    textField_7.setText("10");
    textField_7.setFont(new Font("Tahoma", Font.PLAIN, 20));
    textField_7.setColumns(3);
    textField_7.setBounds(265, 123, 40, 25);
    HostUploaderPanel.add(textField_7);

    textField_8 = new JTextField();
    textField_8.addFocusListener(this);
    textField_8.setFont(new Font("Dialog", Font.PLAIN, 20));
    textField_8.setColumns(3);
    textField_8.setBounds(315, 122, 40, 25);
    HostUploaderPanel.add(textField_8);

    textField_9 = new JTextField();
    textField_9.addFocusListener(this);
    textField_9.setFont(new Font("Dialog", Font.PLAIN, 20));
    textField_9.setColumns(3);
    textField_9.setBounds(365, 122, 40, 25);
    HostUploaderPanel.add(textField_9);

    JLabel label_8 = new JLabel("Insert Starting Host Number:");
    label_8.setFont(new Font("Tahoma", Font.PLAIN, 14));
    label_8.setBounds(23, 157, 181, 17);
    HostUploaderPanel.add(label_8);

    textField_10 = new JTextField();
    textField_10.addFocusListener(this);
    textField_10.setFont(new Font("Dialog", Font.PLAIN, 20));
    textField_10.setColumns(10);
    textField_10.setBounds(265, 155, 40, 25);
    HostUploaderPanel.add(textField_10);

    JLabel label_9 = new JLabel("Insert Ending Host Number:");
    label_9.setFont(new Font("Tahoma", Font.PLAIN, 14));
    label_9.setBounds(23, 197, 181, 17);
    HostUploaderPanel.add(label_9);

    textField_11 = new JTextField();
    textField_11.addFocusListener(this);
    textField_11.setFont(new Font("Dialog", Font.PLAIN, 20));
    textField_11.setColumns(10);
    textField_11.setBounds(265, 195, 40, 25);
    HostUploaderPanel.add(textField_11);

    JLabel label_10 = new JLabel("Enter Username:"******"Tahoma", Font.PLAIN, 14));
    label_10.setBounds(23, 265, 106, 14);
    HostUploaderPanel.add(label_10);

    textField_12 = new JTextField();
    textField_12.addFocusListener(this);
    textField_12.setText("root");
    textField_12.setFont(new Font("Tahoma", Font.PLAIN, 19));
    textField_12.setColumns(10);
    textField_12.setBounds(130, 255, 149, 32);
    HostUploaderPanel.add(textField_12);

    JLabel label_11 = new JLabel("Enter Password:"******"Tahoma", Font.PLAIN, 14));
    label_11.setBounds(23, 309, 106, 14);
    HostUploaderPanel.add(label_11);

    passwordField_1 = new JPasswordField();
    passwordField_1.addFocusListener(this);
    passwordField_1.setText("p@ssw0rd");
    passwordField_1.setFont(new Font("Tahoma", Font.PLAIN, 19));
    passwordField_1.setBounds(130, 291, 149, 32);
    HostUploaderPanel.add(passwordField_1);

    JLabel lblNewLabel = new JLabel("NOTE: Running this program REBOOTS the Camera(s)");
    lblNewLabel.setForeground(Color.RED);
    lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 18));
    lblNewLabel.setBounds(23, 17, 445, 54);
    HostUploaderPanel.add(lblNewLabel);

    JLabel label_12 = new JLabel(".");
    label_12.setFont(new Font("Dialog", Font.BOLD, 17));
    label_12.setBounds(308, 132, 4, 14);
    HostUploaderPanel.add(label_12);

    JLabel label_13 = new JLabel(".");
    label_13.setFont(new Font("Dialog", Font.BOLD, 17));
    label_13.setBounds(358, 132, 4, 14);
    HostUploaderPanel.add(label_13);
    JComponent snmpReportPanel = new JPanel();
    tabbedPane.add("SNMP Report", snmpReportPanel);
    tabbedPane.setEnabledAt(2, true);
  }
Example #17
0
  /** Initialize the GUI. */
  private void initGUI() {
    setLayout(new BorderLayout());

    // init tabs
    defaultsPanel = new OptionsDefaults(app);
    euclidianPanel = new OptionsEuclidian(app, app.getEuclidianView());
    spreadsheetPanel =
        new OptionsSpreadsheet(app, (SpreadsheetView) app.getGuiManager().getSpreadsheetView());
    casPanel = new OptionsCAS(app);
    advancedPanel = new OptionsAdvanced(app);

    // init scroll panes for tabs (show no extra borders)
    JScrollPane euclidianPanelScroll = new JScrollPane(euclidianPanel);
    euclidianPanelScroll.setBorder(BorderFactory.createEmptyBorder());

    // init tabbing pane
    tabbedPane = new OptionsTabbedPane();

    // defaults
    tabbedPane.addTab("", app.getToolBarImage("mode_delete_32.gif", Color.RED), defaultsPanel);

    // euclidian properties
    tabbedPane.addTab(
        "", app.getToolBarImage("mode_delete_32.gif", Color.RED), euclidianPanelScroll);

    // spreadsheet properties
    tabbedPane.addTab("", app.getToolBarImage("mode_delete_32.gif", Color.RED), spreadsheetPanel);

    // CAS properties
    tabbedPane.addTab("", app.getToolBarImage("mode_delete_32.gif", Color.RED), casPanel);

    // advanced
    tabbedPane.addTab("", app.getToolBarImage("mode_delete_32.gif", Color.RED), advancedPanel);

    // disable some tabs for applets
    if (app.isApplet()) {
      tabbedPane.setEnabledAt(TAB_DEFAULTS, false);
    }

    add(tabbedPane, BorderLayout.CENTER);

    // init close button
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, SystemColor.controlDkShadow));
    buttonPanel.setBackground(Color.white);

    saveButton = new JButton();
    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            GeoGebraPreferences.getPref().saveXMLPreferences(app);
          }
        });
    buttonPanel.add(saveButton);
    closeButton = new JButton();
    closeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            closeDialog();
          }
        });
    buttonPanel.add(closeButton);

    add(buttonPanel, BorderLayout.SOUTH);

    setLabels(); // update all labels

    setPreferredSize(new Dimension(640, 480));
    pack();

    setLocationRelativeTo(null);
  }
Example #18
0
  /** call this to login */
  private void doLogin(final String username, String password) {
    if (password.isEmpty()) {
      PasswordDialog p = new PasswordDialog(this, true);
      p.setVisible(true);
      if (tempPass.isEmpty()) {
        enableObjects();
        return;
      }
      password = tempPass;
    }

    Logger.logInfo("Logging in...");

    tabbedPane.setEnabledAt(0, false);
    tabbedPane.setIconAt(0, new ImageIcon(this.getClass().getResource("/image/tabs/news.png")));
    tabbedPane.setEnabledAt(1, false);
    tabbedPane.setEnabledAt(2, false);
    tabbedPane.setEnabledAt(3, false);
    tabbedPane.setEnabledAt(4, false);
    tabbedPane.getSelectedComponent().setEnabled(false);

    launch.setEnabled(false);
    users.setEnabled(false);
    edit.setEnabled(false);
    serverbutton.setEnabled(false);
    mapInstall.setEnabled(false);
    mapInstallLocation.setEnabled(false);
    serverMap.setEnabled(false);
    tpInstall.setEnabled(false);
    tpInstallLocation.setEnabled(false);

    LoginWorker loginWorker =
        new LoginWorker(username, password) {
          @Override
          public void done() {
            String responseStr;
            try {
              responseStr = get();
            } catch (InterruptedException err) {
              Logger.logError(err.getMessage(), err);
              enableObjects();
              return;
            } catch (ExecutionException err) {
              if (err.getCause() instanceof IOException
                  || err.getCause() instanceof MalformedURLException) {
                Logger.logError(err.getMessage(), err);
                PlayOfflineDialog d = new PlayOfflineDialog("mcDown", username);
                d.setVisible(true);
              }
              enableObjects();
              return;
            }

            try {
              RESPONSE = new LoginResponse(responseStr);
            } catch (IllegalArgumentException e) {
              if (responseStr.contains(":")) {
                Logger.logError("Received invalid response from server.");
              } else {
                if (responseStr.equalsIgnoreCase("bad login")) {
                  ErrorUtils.tossError("Invalid username or password.");
                } else if (responseStr.equalsIgnoreCase("old version")) {
                  ErrorUtils.tossError("Outdated launcher.");
                } else {
                  ErrorUtils.tossError("Login failed: " + responseStr);
                  PlayOfflineDialog d = new PlayOfflineDialog("mcDown", username);
                  d.setVisible(true);
                }
              }
              enableObjects();
              return;
            }
            Logger.logInfo("Login complete.");
            runGameUpdater(RESPONSE);
          }
        };
    loginWorker.execute();
  }
Example #19
0
  /** Create the frame. */
  public MainFrame() {
    setTitle("\u90AE\u4EF6\u670D\u52A1\u5668");
    setResizable(false);
    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowOpened(WindowEvent e) {
            // 读取配置文件
            loadProp();
          }
        });
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 634, 561);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new GridLayout(1, 0, 0, 0));

    final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    contentPane.add(tabbedPane);

    JPanel tap1 = new JPanel();
    tabbedPane.addTab("\u57FA\u672C\u8BBE\u7F6E", null, tap1, null);
    GridBagLayout gbl_tap1 = new GridBagLayout();
    gbl_tap1.columnWidths = new int[] {343, 0};
    gbl_tap1.rowHeights = new int[] {100, 100, 100, 100, 56, 0};
    gbl_tap1.columnWeights = new double[] {1.0, Double.MIN_VALUE};
    gbl_tap1.rowWeights = new double[] {0.0, 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE};
    tap1.setLayout(gbl_tap1);

    JPanel setPort = new JPanel();
    setPort.setBorder(
        new TitledBorder(
            null, "\u7AEF\u53E3\u8BBE\u7F6E", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_setPort = new GridBagConstraints();
    gbc_setPort.fill = GridBagConstraints.BOTH;
    gbc_setPort.insets = new Insets(0, 0, 5, 0);
    gbc_setPort.gridx = 0;
    gbc_setPort.gridy = 0;
    tap1.add(setPort, gbc_setPort);
    GridBagLayout gbl_setPort = new GridBagLayout();
    gbl_setPort.columnWidths = new int[] {80, 293, 0};
    gbl_setPort.rowHeights = new int[] {41, 0, 0};
    gbl_setPort.columnWeights = new double[] {0.0, 1.0, Double.MIN_VALUE};
    gbl_setPort.rowWeights = new double[] {0.0, 1.0, Double.MIN_VALUE};
    setPort.setLayout(gbl_setPort);

    JLabel lblSmtp = new JLabel("SMTP\u7AEF\u53E3");
    GridBagConstraints gbc_lblSmtp = new GridBagConstraints();
    gbc_lblSmtp.insets = new Insets(0, 0, 5, 5);
    gbc_lblSmtp.gridx = 0;
    gbc_lblSmtp.gridy = 0;
    setPort.add(lblSmtp, gbc_lblSmtp);

    smtpPortText = new JTextField();
    GridBagConstraints gbc_smtpPortText = new GridBagConstraints();
    gbc_smtpPortText.fill = GridBagConstraints.HORIZONTAL;
    gbc_smtpPortText.insets = new Insets(0, 0, 5, 0);
    gbc_smtpPortText.gridx = 1;
    gbc_smtpPortText.gridy = 0;
    setPort.add(smtpPortText, gbc_smtpPortText);
    smtpPortText.setColumns(10);

    JLabel lblPop = new JLabel("POP3\u7AEF\u53E3");
    GridBagConstraints gbc_lblPop = new GridBagConstraints();
    gbc_lblPop.insets = new Insets(0, 0, 0, 5);
    gbc_lblPop.gridx = 0;
    gbc_lblPop.gridy = 1;
    setPort.add(lblPop, gbc_lblPop);

    pop3PortText = new JTextField();
    GridBagConstraints gbc_pop3PortText = new GridBagConstraints();
    gbc_pop3PortText.fill = GridBagConstraints.HORIZONTAL;
    gbc_pop3PortText.gridx = 1;
    gbc_pop3PortText.gridy = 1;
    setPort.add(pop3PortText, gbc_pop3PortText);
    pop3PortText.setColumns(10);

    JPanel setDomain = new JPanel();
    setDomain.setBorder(
        new TitledBorder(
            null, "\u57DF\u540D\u8BBE\u7F6E", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_setDomain = new GridBagConstraints();
    gbc_setDomain.fill = GridBagConstraints.BOTH;
    gbc_setDomain.insets = new Insets(0, 0, 5, 0);
    gbc_setDomain.gridx = 0;
    gbc_setDomain.gridy = 1;
    tap1.add(setDomain, gbc_setDomain);
    GridBagLayout gbl_setDomain = new GridBagLayout();
    gbl_setDomain.columnWidths = new int[] {79, 0, 0};
    gbl_setDomain.rowHeights = new int[] {41, 0, 0};
    gbl_setDomain.columnWeights = new double[] {0.0, 1.0, Double.MIN_VALUE};
    gbl_setDomain.rowWeights = new double[] {0.0, 1.0, Double.MIN_VALUE};
    setDomain.setLayout(gbl_setDomain);

    JLabel lblNewLabel = new JLabel("\u670D\u52A1\u5668\u57DF\u540D");
    GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
    gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
    gbc_lblNewLabel.gridx = 0;
    gbc_lblNewLabel.gridy = 0;
    setDomain.add(lblNewLabel, gbc_lblNewLabel);

    localDomainText = new JTextField();
    GridBagConstraints gbc_localDomainText = new GridBagConstraints();
    gbc_localDomainText.insets = new Insets(0, 0, 5, 0);
    gbc_localDomainText.fill = GridBagConstraints.HORIZONTAL;
    gbc_localDomainText.gridx = 1;
    gbc_localDomainText.gridy = 0;
    setDomain.add(localDomainText, gbc_localDomainText);
    localDomainText.setColumns(10);

    JLabel lblNewLabel_1 = new JLabel("\u670D\u52A1\u5668\u4E3B\u673A\u540D");
    GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
    gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel_1.insets = new Insets(0, 0, 0, 5);
    gbc_lblNewLabel_1.gridx = 0;
    gbc_lblNewLabel_1.gridy = 1;
    setDomain.add(lblNewLabel_1, gbc_lblNewLabel_1);

    localHostNameText = new JTextField();
    GridBagConstraints gbc_localHostNameText = new GridBagConstraints();
    gbc_localHostNameText.fill = GridBagConstraints.HORIZONTAL;
    gbc_localHostNameText.gridx = 1;
    gbc_localHostNameText.gridy = 1;
    setDomain.add(localHostNameText, gbc_localHostNameText);
    localHostNameText.setColumns(10);

    JPanel setConnect = new JPanel();
    setConnect.setBorder(
        new TitledBorder(
            null, "\u8FDE\u63A5\u8BBE\u7F6E", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_setConnect = new GridBagConstraints();
    gbc_setConnect.fill = GridBagConstraints.BOTH;
    gbc_setConnect.insets = new Insets(0, 0, 5, 0);
    gbc_setConnect.gridx = 0;
    gbc_setConnect.gridy = 2;
    tap1.add(setConnect, gbc_setConnect);
    GridBagLayout gbl_setConnect = new GridBagLayout();
    gbl_setConnect.columnWidths = new int[] {81, 0, 0};
    gbl_setConnect.rowHeights = new int[] {46, 0, 0};
    gbl_setConnect.columnWeights = new double[] {0.0, 1.0, Double.MIN_VALUE};
    gbl_setConnect.rowWeights = new double[] {0.0, 1.0, Double.MIN_VALUE};
    setConnect.setLayout(gbl_setConnect);

    JLabel lblNewLabel_2 = new JLabel("\u7B49\u5F85\u8FDE\u63A5\u65F6\u95F4");
    GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
    gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
    gbc_lblNewLabel_2.gridx = 0;
    gbc_lblNewLabel_2.gridy = 0;
    setConnect.add(lblNewLabel_2, gbc_lblNewLabel_2);

    connectLostTimeText = new JTextField();
    GridBagConstraints gbc_connectLostTimeText = new GridBagConstraints();
    gbc_connectLostTimeText.insets = new Insets(0, 0, 5, 0);
    gbc_connectLostTimeText.fill = GridBagConstraints.HORIZONTAL;
    gbc_connectLostTimeText.gridx = 1;
    gbc_connectLostTimeText.gridy = 0;
    setConnect.add(connectLostTimeText, gbc_connectLostTimeText);
    connectLostTimeText.setColumns(10);

    JLabel lblNewLabel_3 = new JLabel("\u54CD\u5E94\u65F6\u95F4");
    GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
    gbc_lblNewLabel_3.insets = new Insets(0, 0, 0, 5);
    gbc_lblNewLabel_3.gridx = 0;
    gbc_lblNewLabel_3.gridy = 1;
    setConnect.add(lblNewLabel_3, gbc_lblNewLabel_3);

    connectResponseTimeText = new JTextField();
    GridBagConstraints gbc_connectResponseTimeText = new GridBagConstraints();
    gbc_connectResponseTimeText.fill = GridBagConstraints.HORIZONTAL;
    gbc_connectResponseTimeText.gridx = 1;
    gbc_connectResponseTimeText.gridy = 1;
    setConnect.add(connectResponseTimeText, gbc_connectResponseTimeText);
    connectResponseTimeText.setColumns(10);

    JPanel setEmail = new JPanel();
    setEmail.setBorder(
        new TitledBorder(
            null, "\u90AE\u4EF6\u8BBE\u7F6E", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_setEmail = new GridBagConstraints();
    gbc_setEmail.fill = GridBagConstraints.BOTH;
    gbc_setEmail.insets = new Insets(0, 0, 5, 0);
    gbc_setEmail.gridx = 0;
    gbc_setEmail.gridy = 3;
    tap1.add(setEmail, gbc_setEmail);
    GridBagLayout gbl_setEmail = new GridBagLayout();
    gbl_setEmail.columnWidths = new int[] {0, 0, 0};
    gbl_setEmail.rowHeights = new int[] {25, 0};
    gbl_setEmail.columnWeights = new double[] {0.0, 1.0, Double.MIN_VALUE};
    gbl_setEmail.rowWeights = new double[] {0.0, Double.MIN_VALUE};
    setEmail.setLayout(gbl_setEmail);

    JLabel label = new JLabel("\u90AE\u4EF6\u5927\u5C0F\u9650\u5236");
    GridBagConstraints gbc_label = new GridBagConstraints();
    gbc_label.insets = new Insets(0, 0, 0, 5);
    gbc_label.anchor = GridBagConstraints.EAST;
    gbc_label.gridx = 0;
    gbc_label.gridy = 0;
    setEmail.add(label, gbc_label);

    emailSizeText = new JTextField();
    GridBagConstraints gbc_emailSizeText = new GridBagConstraints();
    gbc_emailSizeText.fill = GridBagConstraints.HORIZONTAL;
    gbc_emailSizeText.gridx = 1;
    gbc_emailSizeText.gridy = 0;
    setEmail.add(emailSizeText, gbc_emailSizeText);
    emailSizeText.setColumns(10);

    JPanel setButton = new JPanel();

    startButton = new JButton("\u542F\u52A8\u670D\u52A1\u5668");
    startButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveProp();
            ServerManager.getServerManager().startServer();
            startButton.setEnabled(false);
            // tabbedPane.setEnabledAt(2, true);
            tabbedPane.setEnabledAt(1, true);
          }
        });

    JButton savePropButton = new JButton("\u4FDD\u5B58\u8BBE\u7F6E");
    savePropButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveProp();
            JOptionPane.showMessageDialog(null, "保存成功");
          }
        });
    setButton.add(savePropButton);

    JButton readPropButton = new JButton("\u8BFB\u53D6\u8BBE\u7F6E");
    readPropButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            loadProp();
          }
        });
    setButton.add(readPropButton);
    setButton.add(startButton);
    GridBagConstraints gbc_setButton = new GridBagConstraints();
    gbc_setButton.anchor = GridBagConstraints.WEST;
    gbc_setButton.gridx = 0;
    gbc_setButton.gridy = 4;
    tap1.add(setButton, gbc_setButton);

    JPanel tap3 = new JPanel();
    tabbedPane.addTab("\u8D26\u53F7\u7BA1\u7406", null, tap3, null);
    tabbedPane.setEnabledAt(1, false);
    GridBagLayout gbl_tap3 = new GridBagLayout();
    gbl_tap3.columnWidths = new int[] {306, 0};
    gbl_tap3.rowHeights = new int[] {1, 0, 0};
    gbl_tap3.columnWeights = new double[] {1.0, Double.MIN_VALUE};
    gbl_tap3.rowWeights = new double[] {1.0, 0.0, Double.MIN_VALUE};
    tap3.setLayout(gbl_tap3);

    final JTextArea textArea = new JTextArea();
    textArea.setFont(new Font("Monospaced", Font.PLAIN, 18));
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    GridBagConstraints gbc_textArea = new GridBagConstraints();
    gbc_textArea.insets = new Insets(0, 0, 5, 0);
    gbc_textArea.fill = GridBagConstraints.BOTH;
    gbc_textArea.gridx = 0;
    gbc_textArea.gridy = 0;
    tap3.add(textArea, gbc_textArea);

    JPanel panel_1 = new JPanel();
    GridBagConstraints gbc_panel_1 = new GridBagConstraints();
    gbc_panel_1.fill = GridBagConstraints.BOTH;
    gbc_panel_1.gridx = 0;
    gbc_panel_1.gridy = 1;
    tap3.add(panel_1, gbc_panel_1);

    JButton btnNewButton = new JButton("\u663E\u793A\u8D26\u53F7");
    btnNewButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            UserListManager userListManager = UserListManager.getInstance();
            List<User> userList = userListManager.getUserList();
            textArea.setText("");
            for (User user : userList) {
              textArea.append("账号:" + user.getUserName() + " 邮件数量" + user.getEmailNumber() + "\n");
            }
          }
        });
    panel_1.add(btnNewButton);

    JButton btnNewButton_1 = new JButton("\u6DFB\u52A0\u8D26\u53F7");
    btnNewButton_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            AddUserDialog addUserDialog = new AddUserDialog();
            addUserDialog.setVisible(true);
          }
        });
    panel_1.add(btnNewButton_1);

    JPanel tap2 = new JPanel();
    tabbedPane.addTab("\u65E5\u5FD7", null, tap2, null);
    tabbedPane.setEnabledAt(2, true);
    GridBagLayout gbl_tap2 = new GridBagLayout();
    gbl_tap2.columnWidths = new int[] {4, 0};
    gbl_tap2.rowHeights = new int[] {24, 0, 0};
    gbl_tap2.columnWeights = new double[] {1.0, Double.MIN_VALUE};
    gbl_tap2.rowWeights = new double[] {1.0, 0.0, Double.MIN_VALUE};
    tap2.setLayout(gbl_tap2);

    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
    gbc_scrollPane.gridx = 0;
    gbc_scrollPane.gridy = 0;
    tap2.add(scrollPane, gbc_scrollPane);

    final JTextArea logTextArea = new JTextArea();
    scrollPane.setViewportView(logTextArea);
    logTextArea.setLineWrap(true);
    logTextArea.setEditable(false);

    JPanel panel = new JPanel();
    GridBagConstraints gbc_panel = new GridBagConstraints();
    gbc_panel.fill = GridBagConstraints.BOTH;
    gbc_panel.gridx = 0;
    gbc_panel.gridy = 1;
    tap2.add(panel, gbc_panel);

    JButton btnNewButton_2 = new JButton("\u8BFB\u53D6log_debug.log");
    btnNewButton_2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            logTextArea.setText("");
            BufferedReader reader = null;
            String content = null;
            try {
              File logFile = new File("src/server/log/log_debug.log");
              if (logFile.exists()) {
                reader = new BufferedReader(new FileReader(logFile));
                while ((content = reader.readLine()) != null) {
                  logTextArea.append(content + "\n");
                }
              } else {
                logTextArea.setText("file not found!");
              }
            } catch (FileNotFoundException e3) {
              e3.printStackTrace();
            } catch (IOException e1) {
              e1.printStackTrace();
            } finally {
              try {
                if (reader != null) {
                  reader.close();
                }
              } catch (IOException e1) {
                e1.printStackTrace();
              }
            }
          }
        });
    panel.add(btnNewButton_2);
  }
Example #20
0
  /** Create the dialog. */
  public SettingsDialog() {
    setBounds(100, 100, 400, 450);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(0, 0, 0, 0));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));
    {
      JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
      contentPanel.add(tabbedPane, BorderLayout.CENTER);
      {
        generalTab = new JPanel();
        tabbedPane.addTab("General", null, generalTab, "General settings.");
        tabbedPane.setEnabledAt(0, true);

        JLabel lblLauncherFilename = new JLabel("Launcher Filename:");
        launcherFileTextField = new JTextField(AppSettings.getLauncherFilename());
        launcherFileTextField.setColumns(10);
        launcherFileTextField.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                AppSettings.setLauncherFilename(launcherFileTextField.getText());
              }
            });

        JLabel lblConsoleSettings = new JLabel("Console Settings:");

        chckbxShowConsole = new JCheckBox("Show console");
        chckbxShowConsole.getModel().setSelected(AppSettings.getShowConsole());
        chckbxShowConsole
            .getModel()
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    AppSettings.setShowConsole(chckbxShowConsole.getModel().isSelected());
                  }
                });

        chckbxAutoCloseConsole = new JCheckBox("Close console when instance exits.");
        chckbxAutoCloseConsole.getModel().setSelected(AppSettings.getAutoCloseConsole());
        chckbxAutoCloseConsole
            .getModel()
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    AppSettings.setAutoCloseConsole(chckbxAutoCloseConsole.getModel().isSelected());
                  }
                });

        chckbxAutoUpdate = new JCheckBox("Automatically check for updates when MultiMC starts");
        chckbxAutoUpdate.getModel().setSelected(AppSettings.getAutoUpdate());
        chckbxAutoUpdate
            .getModel()
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    AppSettings.setCheckUpdates(chckbxAutoUpdate.getModel().isSelected());
                  }
                });

        GroupLayout gl_generalTab = new GroupLayout(generalTab);
        gl_generalTab.setHorizontalGroup(
            gl_generalTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_generalTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_generalTab
                                .createParallelGroup(Alignment.LEADING)
                                .addGroup(
                                    gl_generalTab
                                        .createSequentialGroup()
                                        .addComponent(lblLauncherFilename)
                                        .addPreferredGap(ComponentPlacement.RELATED)
                                        .addComponent(
                                            launcherFileTextField,
                                            GroupLayout.DEFAULT_SIZE,
                                            262,
                                            Short.MAX_VALUE))
                                .addGroup(
                                    gl_generalTab
                                        .createSequentialGroup()
                                        .addGap(6)
                                        .addGroup(
                                            gl_generalTab
                                                .createParallelGroup(Alignment.LEADING)
                                                .addComponent(chckbxAutoCloseConsole)
                                                .addComponent(chckbxShowConsole)))
                                .addComponent(chckbxAutoUpdate)
                                .addComponent(lblConsoleSettings))
                        .addContainerGap()));
        gl_generalTab.setVerticalGroup(
            gl_generalTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_generalTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_generalTab
                                .createParallelGroup(Alignment.BASELINE)
                                .addComponent(lblLauncherFilename)
                                .addComponent(
                                    launcherFileTextField,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                        .addGap(18)
                        .addComponent(lblConsoleSettings)
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addComponent(chckbxShowConsole)
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addComponent(chckbxAutoCloseConsole)
                        .addGap(18)
                        .addComponent(chckbxAutoUpdate)
                        .addContainerGap(198, Short.MAX_VALUE)));
        generalTab.setLayout(gl_generalTab);
      }
      {
        advancedTab = new JPanel();
        tabbedPane.addTab(
            "Advanced", null, advancedTab, "Advanced settings such as memory allocations.");

        initialMemorySpinner = new JSpinner();
        initialMemorySpinner.setModel(
            new SpinnerNumberModel(
                AppSettings.getInitialMemAlloc(), new Integer(512), null, new Integer(512)));
        initialMemorySpinner
            .getModel()
            .addChangeListener(
                new ChangeListener() {
                  @Override
                  public void stateChanged(ChangeEvent arg0) {
                    AppSettings.setInitialMemAlloc(
                        (Integer) initialMemorySpinner.getModel().getValue());
                  }
                });

        JLabel lblInitialMemoryAllocation = new JLabel("Initial Memory Allocation (MB): ");

        maxMemorySpinner = new JSpinner();
        maxMemorySpinner.setModel(
            new SpinnerNumberModel(
                AppSettings.getMaxMemAlloc(), new Integer(1024), null, new Integer(512)));
        maxMemorySpinner
            .getModel()
            .addChangeListener(
                new ChangeListener() {
                  @Override
                  public void stateChanged(ChangeEvent e) {
                    AppSettings.setMaxMemAlloc((Integer) maxMemorySpinner.getModel().getValue());
                  }
                });

        JLabel labelMaxMemAlloc = new JLabel("Maximum Memory Allocation (MB): ");
        GroupLayout gl_advancedTab = new GroupLayout(advancedTab);
        gl_advancedTab.setHorizontalGroup(
            gl_advancedTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_advancedTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.LEADING)
                                .addComponent(labelMaxMemAlloc)
                                .addComponent(lblInitialMemoryAllocation))
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.LEADING, false)
                                .addComponent(maxMemorySpinner)
                                .addComponent(initialMemorySpinner))
                        .addGap(144)));
        gl_advancedTab.setVerticalGroup(
            gl_advancedTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_advancedTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.BASELINE)
                                .addComponent(lblInitialMemoryAllocation)
                                .addComponent(
                                    initialMemorySpinner,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.BASELINE)
                                .addComponent(labelMaxMemAlloc)
                                .addComponent(
                                    maxMemorySpinner,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(276, Short.MAX_VALUE)));
        advancedTab.setLayout(gl_advancedTab);
      }
    }
    {
      JPanel buttonPane = new JPanel();
      buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
      getContentPane().add(buttonPane, BorderLayout.SOUTH);
      {
        JButton okButton = new JButton("Close");
        okButton.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                AppSettings.setLauncherFilename(launcherFileTextField.getText());
                setVisible(false);
              }
            });
        okButton.setMnemonic('C');
        okButton.setActionCommand("OK");
        buttonPane.add(okButton);
        getRootPane().setDefaultButton(okButton);
      }
    }
  }
Example #21
0
    private void createUI() {

      setThumbnailSubsampling();
      final Dimension imageSize = getScaledImageSize();
      thumbnailLoader =
          new ProgressMonitorSwingWorker<BufferedImage, Object>(
              this, "Loading thumbnail image...") {

            @Override
            protected BufferedImage doInBackground(ProgressMonitor pm) throws Exception {
              return createThumbNailImage(imageSize, pm);
            }

            @Override
            protected void done() {
              BufferedImage thumbnail = null;
              try {
                thumbnail = get();
              } catch (Exception e) {
                if (e instanceof IOException) {
                  showErrorDialog("Failed to load thumbnail image:\n" + e.getMessage());
                }
              }

              if (thumbnail != null) {
                imageCanvas.setImage(thumbnail);
              }
            }
          };
      thumbnailLoader.execute();
      imageCanvas = new SliderBoxImageDisplay(imageSize.width, imageSize.height, this);
      imageCanvas.setSize(imageSize.width, imageSize.height);
      setComponentName(imageCanvas, "ImageCanvas");

      imageScrollPane = new JScrollPane(imageCanvas);
      imageScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      imageScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
      imageScrollPane
          .getViewport()
          .setExtentSize(new Dimension(MAX_THUMBNAIL_WIDTH, 2 * MAX_THUMBNAIL_WIDTH));
      setComponentName(imageScrollPane, "ImageScrollPane");

      subsetWidthLabel = new JLabel("####", JLabel.RIGHT);
      subsetHeightLabel = new JLabel("####", JLabel.RIGHT);

      setToVisibleButton = new JButton("Use Preview"); /*I18N*/
      setToVisibleButton.setMnemonic('v');
      setToVisibleButton.setToolTipText("Use coordinates of visible thumbnail area"); /*I18N*/
      setToVisibleButton.addActionListener(this);
      setComponentName(setToVisibleButton, "UsePreviewButton");

      fixSceneWidthCheck = new JCheckBox("Fix full width");
      fixSceneWidthCheck.setMnemonic('w');
      fixSceneWidthCheck.setToolTipText("Checks whether or not to fix the full scene width");
      fixSceneWidthCheck.addActionListener(this);
      setComponentName(fixSceneWidthCheck, "FixWidthCheck");

      fixSceneHeightCheck = new JCheckBox("Fix full height");
      fixSceneHeightCheck.setMnemonic('h');
      fixSceneHeightCheck.setToolTipText("Checks whether or not to fix the full scene height");
      fixSceneHeightCheck.addActionListener(this);
      setComponentName(fixSceneHeightCheck, "FixHeightCheck");

      JPanel textInputPane = GridBagUtils.createPanel();
      setComponentName(textInputPane, "TextInputPane");
      final JTabbedPane tabbedPane = new JTabbedPane();
      setComponentName(tabbedPane, "coordinatePane");
      tabbedPane.addTab("Pixel Coordinates", createPixelCoordinatesPane());
      tabbedPane.addTab("Geo Coordinates", createGeoCoordinatesPane());
      tabbedPane.setEnabledAt(1, canUseGeoCoordinates(product));

      GridBagConstraints gbc =
          GridBagUtils.createConstraints("insets.left=7,anchor=WEST,fill=HORIZONTAL, weightx=1.0");
      GridBagUtils.setAttributes(gbc, "gridwidth=2");
      GridBagUtils.addToPanel(textInputPane, tabbedPane, gbc, "gridx=0,gridy=0");

      GridBagUtils.setAttributes(gbc, "insets.top=7,gridwidth=1");
      GridBagUtils.addToPanel(textInputPane, new JLabel("Scene step X:"), gbc, "gridx=0,gridy=1");
      GridBagUtils.addToPanel(
          textInputPane, UIUtils.createSpinner(paramSX, 1, "#0"), gbc, "gridx=1,gridy=1");
      GridBagUtils.setAttributes(gbc, "insets.top=1");
      GridBagUtils.addToPanel(textInputPane, new JLabel("Scene step Y:"), gbc, "gridx=0,gridy=2");
      GridBagUtils.addToPanel(
          textInputPane, UIUtils.createSpinner(paramSY, 1, "#0"), gbc, "gridx=1,gridy=2");

      GridBagUtils.setAttributes(gbc, "insets.top=4");
      GridBagUtils.addToPanel(
          textInputPane, new JLabel("Subset scene width:"), gbc, "gridx=0,gridy=3");
      GridBagUtils.addToPanel(textInputPane, subsetWidthLabel, gbc, "gridx=1,gridy=3");

      GridBagUtils.setAttributes(gbc, "insets.top=1");
      GridBagUtils.addToPanel(
          textInputPane, new JLabel("Subset scene height:"), gbc, "gridx=0,gridy=4");
      GridBagUtils.addToPanel(textInputPane, subsetHeightLabel, gbc, "gridx=1,gridy=4");

      GridBagUtils.setAttributes(gbc, "insets.top=4,gridwidth=1");
      GridBagUtils.addToPanel(
          textInputPane, new JLabel("Source scene width:"), gbc, "gridx=0,gridy=5");
      GridBagUtils.addToPanel(
          textInputPane,
          new JLabel(String.valueOf(product.getSceneRasterWidth()), JLabel.RIGHT),
          gbc,
          "gridx=1,gridy=5");

      GridBagUtils.setAttributes(gbc, "insets.top=1");
      GridBagUtils.addToPanel(
          textInputPane, new JLabel("Source scene height:"), gbc, "gridx=0,gridy=6");
      GridBagUtils.addToPanel(
          textInputPane,
          new JLabel(String.valueOf(product.getSceneRasterHeight()), JLabel.RIGHT),
          gbc,
          "gridx=1,gridy=6");

      GridBagUtils.setAttributes(gbc, "insets.top=7,gridwidth=1, gridheight=2");
      GridBagUtils.addToPanel(textInputPane, setToVisibleButton, gbc, "gridx=0,gridy=7");

      GridBagUtils.setAttributes(gbc, "insets.top=7,gridwidth=1, gridheight=1");
      GridBagUtils.addToPanel(textInputPane, fixSceneWidthCheck, gbc, "gridx=1,gridy=7");

      GridBagUtils.setAttributes(gbc, "insets.top=1,gridwidth=1");
      GridBagUtils.addToPanel(textInputPane, fixSceneHeightCheck, gbc, "gridx=1,gridy=8");

      setLayout(new BorderLayout(4, 4));
      add(imageScrollPane, BorderLayout.WEST);
      add(textInputPane, BorderLayout.CENTER);
      setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));

      updateUIState(null);
      imageCanvas.scrollRectToVisible(imageCanvas.getSliderBoxBounds());
    }
Example #22
0
  public static void createTabItem(ActionContext actionContext) {
    Thing self = (Thing) actionContext.get("self");
    JTabbedPane parent = (JTabbedPane) actionContext.get("parent");

    Thing thing = self.getThing("Component@0");
    if (thing != null) {
      try {
        Bindings bindings = actionContext.push();
        bindings.put("parent", null);

        for (Thing child : thing.getChilds()) {
          Component c = (Component) child.doAction("create", actionContext);
          if (c != null) {
            int index = parent.getTabCount();
            parent.setComponentAt(index, c);

            Color background = AwtCreator.createColor(thing, "background", actionContext);
            if (background != null) {
              parent.setBackgroundAt(index, background);
            }

            Icon disabledIcon = SwingCreator.createIcon(thing, "disabledIcon", actionContext);
            if (disabledIcon != null) {
              parent.setDisabledIconAt(index, disabledIcon);
            }

            Integer displayedMnemonicIndex =
                JavaCreator.createInteger(thing, "displayedMnemonicIndex");
            if (displayedMnemonicIndex != null) {
              parent.setDisplayedMnemonicIndexAt(index, displayedMnemonicIndex);
            }

            Boolean enabled = JavaCreator.createBoolean(thing, "enabled");
            if (enabled != null) {
              parent.setEnabledAt(index, enabled);
            }

            Color foreground = AwtCreator.createColor(thing, "foreground", actionContext);
            if (foreground != null) {
              parent.setForeground(foreground);
            }

            Icon icon = SwingCreator.createIcon(thing, "icon", actionContext);
            if (icon != null) {
              parent.setIconAt(index, icon);
            }

            Integer mnemonic = AwtCreator.createMnemonic(thing, "mnemonic");
            if (mnemonic != null) {
              parent.setMnemonicAt(index, mnemonic);
            }

            Boolean selected = JavaCreator.createBoolean(thing, "selected");
            if (selected != null && selected) {
              parent.setSelectedIndex(index);
            }

            String title = JavaCreator.createText(thing, "title", actionContext);
            if (title != null) {
              parent.setTitleAt(index, title);
            }

            String toolTipText = JavaCreator.createText(thing, "toolTipText", actionContext);
            if (toolTipText != null) {
              parent.setToolTipTextAt(index, toolTipText);
            }
            break;
          }
        }
      } finally {
        actionContext.pop();
      }
    }
  }
Example #23
0
  /** Create the frame. */
  public LaunchFrame(final int tab) {
    setFont(new Font("a_FuturaOrto", Font.PLAIN, 12));
    setResizable(false);
    setTitle("AZ Launcher v" + version);
    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));

    panel = new JPanel();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setBounds(100, 100, 850, 480);
    panel.setBounds(0, 0, 850, 480);
    panel.setLayout(null);
    footer.setBounds(0, 380, 850, 100);
    footer.setLayout(null);
    footer.setBackground(LauncherStyle.getCurrentStyle().footerColor);
    tabbedPane.setBounds(0, 0, 850, 380);
    panel.add(tabbedPane);
    panel.add(footer);
    setContentPane(panel);

    addWindowListener(
        new WindowListener() {
          @Override
          public void windowClosing(WindowEvent arg0) {
            // tracker.completeBackgroundTasks(1000);
            try {
              Thread.sleep(1100);
            } catch (InterruptedException e) {
            }
          }

          @Override
          public void windowActivated(WindowEvent arg0) {}

          @Override
          public void windowClosed(WindowEvent arg0) {}

          @Override
          public void windowDeactivated(WindowEvent arg0) {}

          @Override
          public void windowDeiconified(WindowEvent arg0) {}

          @Override
          public void windowIconified(WindowEvent arg0) {}

          @Override
          public void windowOpened(WindowEvent arg0) {}
        });

    // Footer
    footerLogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    footerLogo.setBounds(20, 20, 42, 42);
    footerLogo.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent event) {
            OSUtils.browse("http://www.feed-the-beast.com");
          }

          @Override
          public void mouseReleased(MouseEvent arg0) {}

          @Override
          public void mousePressed(MouseEvent arg0) {}

          @Override
          public void mouseExited(MouseEvent arg0) {}

          @Override
          public void mouseEntered(MouseEvent arg0) {}
        });

    footerCreeper.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    footerCreeper.setBounds(72, 20, 132, 42);
    footerCreeper.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent event) {
            OSUtils.browse("http://www.creeperhost.net/aff.php?aff=293");
          }

          @Override
          public void mouseReleased(MouseEvent arg0) {}

          @Override
          public void mousePressed(MouseEvent arg0) {}

          @Override
          public void mouseExited(MouseEvent arg0) {}

          @Override
          public void mouseEntered(MouseEvent arg0) {}
        });

    dropdown_[0] = I18N.getLocaleString("PROFILE_SELECT");
    dropdown_[1] = I18N.getLocaleString("PROFILE_CREATE");

    String[] dropdown =
        concatenateArrays(dropdown_, UserManager.getNames().toArray(new String[] {}));
    users = new JComboBox(dropdown);
    if (Settings.getSettings().getLastUser() != null) {
      for (int i = 0; i < dropdown.length; i++) {
        if (dropdown[i].equalsIgnoreCase(Settings.getSettings().getLastUser())) {
          users.setSelectedIndex(i);
        }
      }
    }

    donate = new JButton(I18N.getLocaleString("DONATE_BUTTON"));
    donate.setBounds(390, 20, 80, 30);
    donate.setEnabled(false);
    donate.setToolTipText("Coming Soon...");
    donate.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {}
        });

    users.setBounds(550, 20, 150, 30);
    users.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (users.getSelectedIndex() == 1) {
              ProfileAdderDialog p = new ProfileAdderDialog(getInstance(), true);
              users.setSelectedIndex(0);
              p.setVisible(true);
            }
            edit.setEnabled(users.getSelectedIndex() > 1);
          }
        });

    edit = new JButton(I18N.getLocaleString("EDIT_BUTTON"));
    edit.setBounds(480, 20, 60, 30);
    edit.setVisible(true);
    edit.setEnabled(users.getSelectedIndex() > 1);
    edit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (users.getSelectedIndex() > 1) {
              ProfileEditorDialog p =
                  new ProfileEditorDialog(getInstance(), (String) users.getSelectedItem(), true);
              users.setSelectedIndex(0);
              p.setVisible(true);
            }
            edit.setEnabled(users.getSelectedIndex() > 1);
          }
        });

    launch.setText(I18N.getLocaleString("LAUNCH_BUTTON"));
    launch.setBounds(711, 20, 100, 30);
    launch.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            if (users.getSelectedIndex() > 1 && modPacksPane.packPanels.size() > 0) {
              Settings.getSettings().setLastPack(ModPack.getSelectedPack().getDir());
              saveSettings();
              doLogin(
                  UserManager.getUsername(users.getSelectedItem().toString()),
                  UserManager.getPassword(users.getSelectedItem().toString()));
            } else if (users.getSelectedIndex() <= 1) {
              ErrorUtils.tossError("Please select a profile!");
            }
          }
        });

    serverbutton.setBounds(480, 20, 330, 30);
    serverbutton.setText(I18N.getLocaleString("DOWNLOAD_SERVER_PACK"));
    serverbutton.setVisible(false);
    serverbutton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (!ModPack.getSelectedPack().getServerUrl().isEmpty()) {
              if (modPacksPane.packPanels.size() > 0 && getSelectedModIndex() >= 0) {
                try {
                  String version =
                      (Settings.getSettings().getPackVer().equalsIgnoreCase("recommended version")
                              || Settings.getSettings()
                                  .getPackVer()
                                  .equalsIgnoreCase("newest version"))
                          ? ModPack.getSelectedPack().getVersion().replace(".", "_")
                          : Settings.getSettings().getPackVer().replace(".", "_");
                  OSUtils.browse(
                      DownloadUtils.getCreeperhostLink(
                          "modpacks%5E"
                              + ModPack.getSelectedPack().getDir()
                              + "%5E"
                              + version
                              + "%5E"
                              + ModPack.getSelectedPack().getServerUrl()));
                } catch (NoSuchAlgorithmException e) {
                }
              }
            }
          }
        });

    mapInstall.setBounds(650, 20, 160, 30);
    mapInstall.setText(I18N.getLocaleString("INSTALL_MAP"));
    mapInstall.setVisible(false);
    mapInstall.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            if (mapsPane.mapPanels.size() > 0 && getSelectedMapIndex() >= 0) {
              MapManager man = new MapManager(new JFrame(), true);
              man.setVisible(true);
              MapManager.cleanUp();
            }
          }
        });

    mapInstallLocation = new JComboBox();
    mapInstallLocation.setBounds(480, 20, 160, 30);
    mapInstallLocation.setToolTipText("Install to...");
    mapInstallLocation.setVisible(false);

    serverMap.setBounds(480, 20, 330, 30);
    serverMap.setText(I18N.getLocaleString("DOWNLOAD_MAP_SERVER"));
    serverMap.setVisible(false);
    serverMap.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (mapsPane.mapPanels.size() > 0 && getSelectedMapIndex() >= 0) {
              try {
                OSUtils.browse(
                    DownloadUtils.getCreeperhostLink(
                        Map.getMap(LaunchFrame.getSelectedMapIndex()).getUrl()));
              } catch (NoSuchAlgorithmException e) {
              }
            }
          }
        });

    tpInstall.setBounds(650, 20, 160, 30);
    tpInstall.setText(I18N.getLocaleString("INSTALL_TEXTUREPACK"));
    tpInstall.setVisible(false);
    tpInstall.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            TextureManager.installDir = (String) tpInstallLocation.getSelectedItem();
            TextureManager man = new TextureManager(new JFrame(), true);
            man.setVisible(true);
            TextureManager.cleanUp();
          }
        });

    tpInstallLocation = new JComboBox();
    tpInstallLocation.setBounds(480, 20, 160, 30);
    tpInstallLocation.setToolTipText("Install to...");
    tpInstallLocation.setVisible(false);

    tpInstallLocLbl.setText("Install to...");
    tpInstallLocLbl.setBounds(480, 20, 80, 30);
    tpInstallLocLbl.setVisible(false);

    footer.add(edit);
    footer.add(users);
    footer.add(footerLogo);
    footer.add(footerCreeper);
    footer.add(launch);
    footer.add(donate);
    footer.add(serverbutton);
    footer.add(mapInstall);
    footer.add(mapInstallLocation);
    footer.add(serverMap);
    footer.add(tpInstall);
    footer.add(tpInstallLocation);

    newsPane = new NewsPane();
    modPacksPane = new ModpacksPane();
    mapsPane = new MapsPane();
    tpPane = new TexturepackPane();
    optionsPane = new OptionsPane(Settings.getSettings());

    getRootPane().setDefaultButton(launch);
    updateLocale();

    tabbedPane.add(newsPane, 0);
    tabbedPane.add(optionsPane, 1);
    tabbedPane.add(modPacksPane, 2);
    tabbedPane.add(mapsPane, 3);
    tabbedPane.add(tpPane, 4);
    tabbedPane.setEnabledAt(4, false);
    setNewsIcon();
    tabbedPane.setIconAt(1, new ImageIcon(this.getClass().getResource("/image/tabs/options.png")));
    tabbedPane.setIconAt(2, new ImageIcon(this.getClass().getResource("/image/tabs/modpacks.png")));
    tabbedPane.setIconAt(3, new ImageIcon(this.getClass().getResource("/image/tabs/maps.png")));
    tabbedPane.setIconAt(
        4, new ImageIcon(this.getClass().getResource("/image/tabs/texturepacks.png")));
    tabbedPane.setSelectedIndex(tab);

    tabbedPane.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent event) {
            if (tabbedPane.getSelectedComponent() instanceof ILauncherPane) {
              ((ILauncherPane) tabbedPane.getSelectedComponent()).onVisible();
              currentPane = Panes.values()[tabbedPane.getSelectedIndex()];
              updateFooter();
            }
          }
        });
  }