private void bloqueiaDesbloqueiaCampos(boolean opcao) {

    jTextFieldRazaoSocial.setEditable(opcao);
    jTextFieldFantasia.setEditable(opcao);
    jTextFieldFormatCnpj.setEditable(opcao);
    jTextFieldTelefone.setEditable(opcao);
    jTextFieldEndereco.setEditable(opcao);
    jTextFieldNumero.setEditable(opcao);
    jTextFieldQuantQuartos.setEditable(opcao);
  }
 private JFormattedTextField getJFormattedTextFieldRutEmpresa() {
   if (jFormattedTextFieldRutEmpresa == null) {
     jFormattedTextFieldRutEmpresa = new JFormattedTextField(Formato.getMaskRut());
     jFormattedTextFieldRutEmpresa.setEditable(false);
   }
   return jFormattedTextFieldRutEmpresa;
 }
  public FormattedTextFieldDemo() {
    super(new BorderLayout());
    setUpFormats();
    double payment = computePayment(amount, rate, numPeriods);

    // Create the labels.
    amountLabel = new JLabel(amountString);
    rateLabel = new JLabel(rateString);
    numPeriodsLabel = new JLabel(numPeriodsString);
    paymentLabel = new JLabel(paymentString);

    // Create the text fields and set them up.
    amountField = new JFormattedTextField(amountFormat);
    amountField.setValue(new Double(amount));
    amountField.setColumns(10);
    amountField.addPropertyChangeListener("value", this);

    rateField = new JFormattedTextField(percentFormat);
    rateField.setValue(new Double(rate));
    rateField.setColumns(10);
    rateField.addPropertyChangeListener("value", this);

    numPeriodsField = new JFormattedTextField();
    numPeriodsField.setValue(new Integer(numPeriods));
    numPeriodsField.setColumns(10);
    numPeriodsField.addPropertyChangeListener("value", this);

    paymentField = new JFormattedTextField(paymentFormat);
    paymentField.setValue(new Double(payment));
    paymentField.setColumns(10);
    paymentField.setEditable(false);
    paymentField.setForeground(Color.red);

    // Tell accessibility tools about label/textfield pairs.
    amountLabel.setLabelFor(amountField);
    rateLabel.setLabelFor(rateField);
    numPeriodsLabel.setLabelFor(numPeriodsField);
    paymentLabel.setLabelFor(paymentField);

    // Lay out the labels in a panel.
    JPanel labelPane = new JPanel(new GridLayout(0, 1));
    labelPane.add(amountLabel);
    labelPane.add(rateLabel);
    labelPane.add(numPeriodsLabel);
    labelPane.add(paymentLabel);

    // Layout the text fields in a panel.
    JPanel fieldPane = new JPanel(new GridLayout(0, 1));
    fieldPane.add(amountField);
    fieldPane.add(rateField);
    fieldPane.add(numPeriodsField);
    fieldPane.add(paymentField);

    // Put the panels in this panel, labels on left,
    // text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane, BorderLayout.CENTER);
    add(fieldPane, BorderLayout.LINE_END);
  }
  public void update() {
    mySaveTransientModelsCheckBox.setSelected(myGenerationSettings.isSaveTransientModels());
    myCheckModelsBeforeGenerationCheckBox.setSelected(
        myGenerationSettings.isCheckModelsBeforeGeneration());
    myUseNewGenerator.setSelected(myGenerationSettings.isParallelGenerator());
    myIncremental.setSelected(myGenerationSettings.isIncremental());
    myIncrementalCache.setSelected(myGenerationSettings.isIncrementalUseCache());
    if (InternalFlag.isInternalMode()) {
      myDebugIncrementalDependencies.setSelected(
          myGenerationSettings.isDebugIncrementalDependencies());
      myDebugIncrementalDependencies.setEnabled(
          myGenerationSettings.isStrictMode() && myGenerationSettings.isIncremental());
    }
    myInplaceTransform.setSelected(myGenerationSettings.useInplaceTransofrmations());

    myStrictMode.setSelected(myGenerationSettings.isStrictMode());
    myUseNewGenerator.setEnabled(myGenerationSettings.isStrictMode());
    myIncremental.setEnabled(myGenerationSettings.isStrictMode());
    myIncrementalCache.setEnabled(
        myGenerationSettings.isStrictMode() && myGenerationSettings.isIncremental());
    myNumberOfParallelThreads.setEditable(
        myGenerationSettings.isParallelGenerator() && myGenerationSettings.isStrictMode());
    myNumberOfParallelThreads.setValue(myGenerationSettings.getNumberOfParallelThreads());

    myShowInfo.setSelected(myGenerationSettings.isShowInfo());
    myShowWarnings.setSelected(myGenerationSettings.isShowWarnings());
    myKeepModelsWithWarnings.setEnabled(myGenerationSettings.isShowWarnings());
    myKeepModelsWithWarnings.setSelected(myGenerationSettings.isKeepModelsWithWarnings());
    myShowBadChildWarnings.setEnabled(myGenerationSettings.isShowWarnings());
    myShowBadChildWarnings.setSelected(myGenerationSettings.isShowBadChildWarning());
    myNumberOfModelsToKeep.setEditable(myGenerationSettings.getNumberOfModelsToKeep() != -1);
    myNumberOfModelsToKeep.setValue(
        myGenerationSettings.getNumberOfModelsToKeep() == -1
            ? 16
            : myGenerationSettings.getNumberOfModelsToKeep());
    myLimitNumberOfModels.setSelected(myGenerationSettings.getNumberOfModelsToKeep() != -1);

    myFailOnMissingTextgen.setSelected(myGenerationSettings.isFailOnMissingTextGen());
    myGenerateDebugInfo.setSelected(myGenerationSettings.isGenerateDebugInfo());

    final JRadioButton[] allbuttons = {myTraceNone, myTraceSteps, myTraceLanguages, myTraceTypes};
    allbuttons[myGenerationSettings.getPerformanceTracingLevel()].setSelected(true);

    myButtonState.reset(); // memorize the new state
  }
Example #5
0
 public NumberSpinner(int value, int min, int max, int step) {
   super(new SpinnerNumberModel(value, min, max, step));
   JSpinner.NumberEditor editor = new JSpinner.NumberEditor(this, "0");
   this.setEditor(editor);
   JFormattedTextField textField = ((JSpinner.NumberEditor) this.getEditor()).getTextField();
   textField.setEditable(true);
   DefaultFormatterFactory factory = (DefaultFormatterFactory) textField.getFormatterFactory();
   NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter();
   formatter.setAllowsInvalid(false);
 }
  public TelaCadastrarConsulta(TelaPrincipal t) {
    initComponents();
    this.tp = t;

    // Spinner de Hora
    JSpinner.DateEditor editorHora = new JSpinner.DateEditor(spinHorario, "HH:mm");
    JFormattedTextField ftfHora = editorHora.getTextField();
    ftfHora.setEditable(false);
    ftfHora.setHorizontalAlignment(JTextField.CENTER);
    spinHorario.setEditor(editorHora);
  }
  private void displaySelectedValues() {
    DatabaseSrs refSys = srsComboBox.getSelectedItem();
    if (refSys == null) return;

    sridText.setValue(refSys.getSrid());
    gmlSrsNameText.setText(refSys.getGMLSrsName());
    descriptionText.setText(refSys.toString());
    srsComboBox.setToolTipText(refSys.getDescription());
    dbSrsNameText.setText(wrap(refSys.getDatabaseSrsName(), 40));
    dbSrsTypeText.setText(refSys.getType().toString());

    boolean isDBSrs = !srsComboBox.isDBReferenceSystemSelected();
    sridText.setEditable(isDBSrs);
    gmlSrsNameText.setEditable(isDBSrs);
    descriptionText.setEditable(isDBSrs);
    applyButton.setEnabled(isDBSrs);
    deleteButton.setEnabled(isDBSrs);
    copyButton.setEnabled(!dbPool.isConnected() ? isDBSrs : true);
  }
Example #8
0
 private void initComponents() {
   fecha = Binder.createDateComponent(model.getPagoMPModel().getModel("fecha"));
   formaDePago =
       CXCBindings.createFormaDePagoBinding(model.getPagoMPModel().getModel("formaDePago"));
   formaDePago.setEnabled(false);
   referencia =
       BasicComponentFactory.createTextField(
           model.getPagoMPModel().getComponentModel("referencia"));
   referencia.setEnabled(false);
   bancoOrigen = CXCBindings.createBancosBinding(model.getPagoMPModel().getModel("banco"));
   bancoOrigen.setEnabled(false);
   cuentaDeposito =
       CXCBindings.createCuentasDeposito(model.getPagoMPModel().getModel("cuentaDeposito"));
   cuentaDeposito.setEnabled(false);
   importe =
       Binder.createCantidadMonetariaBinding(model.getPagoMPModel().getComponentModel("importe"));
   importe.setEditable(false);
   disponible =
       Binder.createMonetariNumberBinding(model.getPagoMPModel().getComponentModel("disponible"));
   saldoTotal = Binder.createCantidadMonetariaBinding(model.getPorPagar());
   comentario =
       BasicComponentFactory.createTextArea(
           model.getPagoMPModel().getComponentModel("comentario"), false);
   condonar =
       BasicComponentFactory.createCheckBox(
           model.getPagoMPModel().getComponentModel("condonar"), "Pagar sin cargos");
   tipoDoctos =
       BasicComponentFactory.createTextField(
           model.getPagoMPModel().getComponentModel("tipoDeDocumento"));
   header =
       new HeaderPanel(
           "Pago de facturas " + model.getPagoMPModel().getValue("tipoDeDocumento"),
           model.getPagoMPModel().getValue("cliente").toString(),
           getIconFromResource("images/siipapwin/cxc64.gif"));
   saldoPendiente = new JFormattedTextField(FormatUtils.getMoneyFormatterFactory());
   saldoPendiente.setEnabled(false);
   saldoPendiente.setToolTipText("Saldo pendiente de todas las facturas ");
 }
  public static void chamaFuncionario(int idFunc) {
    Funcionario objFunc = new Funcionario();

    FuncionarioDao objDao = new FuncionarioDao();

    try {
      objFunc = objDao.procurarFuncionarioID(idFunc);
    } catch (DaoException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    textField.setText(String.valueOf(idFunc));
    textField_9.setText(objFunc.getNomeFunc());
    textField_1.setText(objFunc.getProfissaoFunc());

    textField_3.setText(String.valueOf(objFunc.getSalarioFunc()));
    textField_3.getText().replace(",", ".");
    textField_3.setEditable(false);

    // Gerar a comissão automaticamente
    textField_2.setText(String.valueOf(objFunc.getComissaoFunc()));
    textField_2.setEditable(false);
  }
Example #10
0
  /** Initialize */
  @Override
  public void init() {
    //	Content
    MigLayout layout = new MigLayout("ins 0 0", "[fill|fill|fill|fill]", "[nogrid]unrel[||]");
    setLayout(layout);

    Font bigFont = AdempierePLAF.getFont_Field().deriveFont(16f);

    String buttonSize = "w 50!, h 50!,";
    // NEW
    f_bNew = createButtonAction("New", KeyStroke.getKeyStroke(KeyEvent.VK_F2, Event.F2));
    add(f_bNew, buttonSize);

    // EDIT
    f_bEdit = createButtonAction("Edit", null);
    add(f_bEdit, buttonSize);
    f_bEdit.setEnabled(false);

    // HISTORY
    f_history = createButtonAction("History", null);
    add(f_history, buttonSize);

    // CANCEL
    f_process = createButtonAction("Cancel", null);
    add(f_process, buttonSize);
    f_process.setEnabled(false);

    // PAYMENT
    f_cashPayment = createButtonAction("Payment", null);
    f_cashPayment.setActionCommand("Cash");
    add(f_cashPayment, buttonSize);
    f_cashPayment.setEnabled(false);

    // PRINT
    f_print = createButtonAction("Print", null);
    add(f_print, buttonSize);
    f_print.setEnabled(false);

    // Settings
    f_bSettings = createButtonAction("Preference", null);
    add(f_bSettings, buttonSize);

    //
    f_logout = createButtonAction("Logout", null);
    add(f_logout, buttonSize + ", gapx 25, wrap");

    // DOC NO
    add(new CLabel(Msg.getMsg(Env.getCtx(), "DocumentNo")), "");

    f_DocumentNo = new CTextField("");
    f_DocumentNo.setName("DocumentNo");
    f_DocumentNo.setEditable(false);
    add(f_DocumentNo, "growx, pushx");

    CLabel lNet = new CLabel(Msg.translate(Env.getCtx(), "SubTotal"));
    add(lNet, "");
    f_net = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_net.setHorizontalAlignment(JTextField.TRAILING);
    f_net.setEditable(false);
    f_net.setFocusable(false);
    lNet.setLabelFor(f_net);
    add(f_net, "wrap, growx, pushx");
    f_net.setValue(Env.ZERO);
    //

    /*
    	// BPARTNER
    	f_bSearch = createButtonAction ("BPartner", KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.CTRL_MASK));
    	add (f_bSearch,buttonSize + ", spany 2");
    */

    /*
     * f_name.setName("Name");
    f_name.addActionListener(this);
    f_name.addFocusListener(this);
    add (f_name, "wrap");
    */

    // SALES REP
    add(new CLabel(Msg.translate(Env.getCtx(), "SalesRep_ID")), "");
    f_RepName = new CTextField("");
    f_RepName.setName("SalesRep");
    f_RepName.setEditable(false);
    add(f_RepName, "growx, pushx");

    CLabel lTax = new CLabel(Msg.translate(Env.getCtx(), "TaxAmt"));
    add(lTax);
    f_tax = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_tax.setHorizontalAlignment(JTextField.TRAILING);
    f_tax.setEditable(false);
    f_tax.setFocusable(false);
    lTax.setLabelFor(f_tax);
    add(f_tax, "wrap, growx, pushx");
    f_tax.setValue(Env.ZERO);
    //

    /*
    	f_location = new CComboBox();
    	add (f_location, " wrap");
    */

    // BP
    add(new CLabel(Msg.translate(Env.getCtx(), "C_BPartner_ID")), "");
    f_name = new CTextField();
    f_name.setEditable(false);
    f_name.setName("Name");
    add(f_name, "growx, pushx");

    //
    CLabel lTotal = new CLabel(Msg.translate(Env.getCtx(), "GrandTotal"));
    lTotal.setFont(bigFont);
    add(lTotal, "");
    f_total = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_total.setHorizontalAlignment(JTextField.TRAILING);
    f_total.setFont(bigFont);
    f_total.setEditable(false);
    f_total.setFocusable(false);
    lTotal.setLabelFor(f_total);
    add(f_total, "growx, pushx");
    f_total.setValue(Env.ZERO);
    /*
    //
    f_user = new CComboBox();
    add (f_user, "skip 1");
    */
  } //	init
Example #11
0
  /** Create the frame. */
  public Calculator() {
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 384, 259);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new BorderLayout(7, 3));

    displayField = new JFormattedTextField();
    displayField.setFont(new Font("Tahoma", Font.PLAIN, 14));
    displayField.setPreferredSize(new Dimension(6, 30));
    displayField.setMinimumSize(new Dimension(10, 10));
    displayField.setEditable(false);
    displayField.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPane.add(displayField, BorderLayout.NORTH);

    JPanel panel = new JPanel();
    contentPane.add(panel, BorderLayout.CENTER);
    panel.setLayout(new GridLayout(4, 3, 3, 3));

    CalculatorActionsListener calcListener = new CalculatorActionsListener(this);

    JButton btnNewButton7 = new JButton("7");
    btnNewButton7.setFont(new Font("Tahoma", Font.PLAIN, 14));
    btnNewButton7.setSize(new Dimension(25, 23));
    btnNewButton7.setMaximumSize(new Dimension(23, 23));
    btnNewButton7.setPreferredSize(new Dimension(25, 23));
    panel.add(btnNewButton7);
    btnNewButton7.addActionListener(calcListener);

    JButton btnNewButton8 = new JButton("8");
    btnNewButton8.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton8);
    btnNewButton8.addActionListener(calcListener);

    JButton btnNewButton9 = new JButton("9");
    btnNewButton9.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton9);
    btnNewButton9.addActionListener(calcListener);

    JButton btnNewButton4 = new JButton("4");
    btnNewButton4.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton4);
    btnNewButton4.addActionListener(calcListener);

    JButton btnNewButton5 = new JButton("A");
    btnNewButton5.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton5);
    btnNewButton5.addActionListener(calcListener);

    JButton btnNewButton6 = new JButton("6");
    btnNewButton6.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton6);
    btnNewButton6.addActionListener(calcListener);

    JButton btnNewButton1 = new JButton("1");
    btnNewButton1.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton1);
    btnNewButton1.addActionListener(calcListener);

    JButton btnNewButton2 = new JButton("2");
    btnNewButton2.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton2);
    btnNewButton2.addActionListener(calcListener);

    JButton btnNewButton3 = new JButton("3");
    btnNewButton3.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton3);
    btnNewButton3.addActionListener(calcListener);

    JButton btnNewButtonZero = new JButton("0");
    btnNewButtonZero.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonZero);
    btnNewButtonZero.addActionListener(calcListener);

    JButton btnNewButtonDot = new JButton(".");
    btnNewButtonDot.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonDot);
    btnNewButtonDot.addActionListener(calcListener);

    btnNewButtonEqual = new JButton("=");
    btnNewButtonEqual.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonEqual);
    btnNewButtonEqual.addActionListener(calcListener);

    JPanel panel_1 = new JPanel();
    panel_1.setPreferredSize(new Dimension(80, 10));
    panel_1.setBounds(new Rectangle(5, 5, 5, 5));
    contentPane.add(panel_1, BorderLayout.EAST);
    panel_1.setLayout(new GridLayout(4, 1, 3, 3));

    btnNewButtonDiv = new JButton("/");
    btnNewButtonDiv.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonDiv);
    btnNewButtonDiv.addActionListener(calcListener);

    btnNewButtonMult = new JButton("*");
    btnNewButtonMult.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonMult);
    btnNewButtonMult.addActionListener(calcListener);

    btnNewButtonSub = new JButton("-");
    btnNewButtonSub.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonSub);
    btnNewButtonSub.addActionListener(calcListener);

    btnNewButtonAdd = new JButton("+");
    btnNewButtonAdd.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonAdd);
    btnNewButtonAdd.addActionListener(calcListener);
  }
Example #12
0
 public void disable() {
   bloc.setEditable(false);
 }
Example #13
0
  /** make the view for this face */
  protected Component makeView() {
    final Box mainBox = new Box(BoxLayout.Y_AXIS);

    final JTable bpmTable = new JTable(BPM_TABLE_MODEL);

    final JSplitPane mainSplitPane =
        new JSplitPane(
            JSplitPane.VERTICAL_SPLIT, new JScrollPane(bpmTable), TARGET_PLOT.getPlotPanel());
    final Box mainSplitBox = new Box(BoxLayout.X_AXIS);
    mainSplitBox.add(mainSplitPane);
    mainBox.add(mainSplitBox);
    mainSplitPane.setOneTouchExpandable(true);
    mainSplitPane.addAncestorListener(
        new AncestorListener() {
          public void ancestorAdded(final AncestorEvent event) {
            // only set the divider location the first time it becomes visible
            if (mainSplitPane.getClientProperty("initialized") == null) {
              mainSplitPane.setDividerLocation(0.4);
              mainSplitPane.putClientProperty("initialized", true);
            }
          }

          public void ancestorRemoved(final AncestorEvent event) {}

          public void ancestorMoved(final AncestorEvent event) {}
        });

    final Box targetBox = new Box(BoxLayout.X_AXIS);
    mainBox.add(targetBox);
    targetBox.setBorder(BorderFactory.createTitledBorder("Target Beam Position"));

    final java.text.NumberFormat TARGET_NUMBER_FORMAT = new DecimalFormat("#,##0.0");
    final int NUMBER_WIDTH = 6;

    targetBox.add(new JLabel("X (mm):"));
    final JFormattedTextField xTargetField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    xTargetField.setToolTipText("Matching Target horizontal beam position");
    xTargetField.setEditable(false);
    xTargetField.setHorizontalAlignment(JTextField.RIGHT);
    xTargetField.setColumns(NUMBER_WIDTH);
    xTargetField.setMaximumSize(xTargetField.getPreferredSize());
    targetBox.add(xTargetField);

    targetBox.add(new JLabel("+/-"));
    final JFormattedTextField xTargetErrorField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    xTargetErrorField.setToolTipText("Estimated horizontal target beam position error.");
    xTargetErrorField.setEditable(false);
    xTargetErrorField.setHorizontalAlignment(JTextField.RIGHT);
    xTargetErrorField.setColumns(NUMBER_WIDTH);
    xTargetErrorField.setMaximumSize(xTargetErrorField.getPreferredSize());
    targetBox.add(xTargetErrorField);
    targetBox.add(Box.createHorizontalGlue());

    targetBox.add(new JLabel("Y (mm):"));
    final JFormattedTextField yTargetField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    yTargetField.setToolTipText("Matching Target vertical beam position");
    yTargetField.setEditable(false);
    yTargetField.setHorizontalAlignment(JTextField.RIGHT);
    yTargetField.setColumns(NUMBER_WIDTH);
    yTargetField.setMaximumSize(yTargetField.getPreferredSize());
    targetBox.add(yTargetField);

    targetBox.add(new JLabel("+/-"));
    final JFormattedTextField yTargetErrorField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    yTargetErrorField.setToolTipText("Estimated vertical target beam position error.");
    yTargetErrorField.setEditable(false);
    yTargetErrorField.setHorizontalAlignment(JTextField.RIGHT);
    yTargetErrorField.setColumns(NUMBER_WIDTH);
    yTargetErrorField.setMaximumSize(yTargetErrorField.getPreferredSize());
    targetBox.add(yTargetErrorField);
    targetBox.add(Box.createHorizontalGlue());

    final JButton clearButton = new JButton("Clear");
    clearButton.setToolTipText("Clear results and running average BPM statistics.");
    targetBox.add(clearButton);
    clearButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            TARGET_PLOT.clear();
            clearBeamPositionRunningAverage();
            xTargetField.setValue(null);
            xTargetErrorField.setValue(null);
            yTargetField.setValue(null);
            yTargetErrorField.setValue(null);
          }
        });

    final JButton startButton = new JButton("Start");
    startButton.setToolTipText("Start Beam Position Running Average after clearing it.");
    targetBox.add(startButton);
    startButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            for (final BpmAgent bpmAgent : BPM_AGENTS) {
              bpmAgent.startAveraging(); // automatically clears the running average each time
            }
          }
        });

    final JButton stopButton = new JButton("Stop");
    stopButton.setToolTipText("Stop Beam Position Running Average.");
    targetBox.add(stopButton);
    stopButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            stopRunningAverage();
          }
        });

    final JButton targetMatchButton = new JButton("Match");
    targetMatchButton.setToolTipText(
        "<html><body>Stop averaging the BPM beam position.<br>Match the target position to the BPM beam position data.</body></html>");
    targetBox.add(targetMatchButton);
    targetMatchButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            try {
              stopButton.doClick();

              final List<BpmAgent> enabledBpmAgents = BPM_TABLE_MODEL.getEnabledBpmAgents();
              final List<BpmAgent> xBpmAgents = new ArrayList<BpmAgent>(enabledBpmAgents.size());
              final List<BpmAgent> yBpmAgents = new ArrayList<BpmAgent>(enabledBpmAgents.size());
              final StringBuffer warningsBuffer = new StringBuffer("");

              if (enabledBpmAgents.size() < 2) {
                warningsBuffer.append(
                    "Only " + enabledBpmAgents.size() + " are enabled for matching.\n");
              }

              // only include BPM agents with running average samples for at least one valid channel
              for (final BpmAgent bpmAgent : enabledBpmAgents) {
                if (bpmAgent.hasRunningAverageSamplesInValidPlanes()) {
                  if (bpmAgent.isXAvgChannelValid()) {
                    xBpmAgents.add(bpmAgent);
                  } else {
                    warningsBuffer.append(
                        "Warning: Enabled BPM, "
                            + bpmAgent.name()
                            + " has an invalid X Avg channel, "
                            + bpmAgent.getXAvgChannel().channelName()
                            + " which will be exluded from analysis.\n");
                  }

                  if (bpmAgent.isYAvgChannelValid()) {
                    yBpmAgents.add(bpmAgent);
                  } else {
                    warningsBuffer.append(
                        "Warning: Enabled BPM, "
                            + bpmAgent.name()
                            + " has an invalid Y Avg channel, "
                            + bpmAgent.getYAvgChannel().channelName()
                            + " which will be exluded from analysis.\n");
                  }
                } else if (!bpmAgent.hasValidPlane()) {
                  warningsBuffer.append(
                      "Warning: Ignoring BPM, "
                          + bpmAgent.name()
                          + " because it has no valid X or Y channel.\n");
                } else {
                  warningsBuffer.append(
                      "Warning: Ignoring BPM, "
                          + bpmAgent.name()
                          + " because it has no samples in a valid channel.\n");
                }
              }

              // always post warnings to the console
              final String warningsMessage = warningsBuffer.toString();
              if (warningsMessage != null && warningsMessage.length() > 0) {
                System.out.print(warningsBuffer.toString());
              }

              // to match both X and Y, at least two BPMs must be valid for each of X and Y channels
              if (xBpmAgents.size() < 2 || yBpmAgents.size() < 2) {
                DOCUMENT.displayError(
                    "Matching Error",
                    "You must choose at least 2 BPMs that have valid channels for each plane.\n"
                        + warningsBuffer.toString());
                return;
              }

              if (_beamPositionMatcher == null) {
                _beamPositionMatcher = new TargetBeamPositionMatcher(RTBT_SEQUENCE);
              }
              final BeamPosition targetBeamPosition =
                  _beamPositionMatcher.getMatchingTargetBeamPosition(xBpmAgents, yBpmAgents);
              xTargetField.setValue(targetBeamPosition.X);
              xTargetErrorField.setValue(targetBeamPosition.X_RMS_ERROR);
              yTargetField.setValue(targetBeamPosition.Y);
              yTargetErrorField.setValue(targetBeamPosition.Y_RMS_ERROR);

              // update the main document so the values can be shared elsewhere
              DOCUMENT.xpos = targetBeamPosition.X;
              DOCUMENT.ypos = targetBeamPosition.Y;

              TARGET_PLOT.displayBeamPosition(
                  targetBeamPosition.X,
                  targetBeamPosition.Y,
                  targetBeamPosition.X_RMS_ERROR,
                  targetBeamPosition.Y_RMS_ERROR);
            } catch (Exception exception) {
              exception.printStackTrace();
              JOptionPane.showMessageDialog(
                  FACE_VIEW,
                  exception.getMessage(),
                  "Error matching target beam position.",
                  JOptionPane.ERROR_MESSAGE);
            }
          }
        });

    final JButton copyReportButton = new JButton("Report");
    copyReportButton.setToolTipText("Copy a report to the clipboard.");
    targetBox.add(copyReportButton);
    copyReportButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            final StringBuffer reportBuffer = new StringBuffer("Target Beam Position Report\n");
            reportBuffer.append(
                "Date:\t" + new SimpleDateFormat("MMM dd, yyyy HH:mm:ss").format(new Date()));
            reportBuffer.append("\n");
            reportBuffer.append("BPM Data:\n");
            BPM_TABLE_MODEL.appendReport(reportBuffer);
            reportBuffer.append(
                "Matching Target X (mm):\t"
                    + xTargetField.getText()
                    + "\t+/-\t"
                    + xTargetErrorField.getText()
                    + "\n");
            reportBuffer.append(
                "Matching Target Y (mm):\t"
                    + yTargetField.getText()
                    + "\t+/-\t"
                    + yTargetErrorField.getText()
                    + "\n");

            final String report = reportBuffer.toString();
            final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            final StringSelection contents = new StringSelection(report);
            clipboard.setContents(contents, contents);
          }
        });

    return mainBox;
  }
Example #14
0
  public fileBackupProgram(JFrame frame) {
    super(new BorderLayout());
    this.frame = frame;

    errorDialog = new CustomDialog(frame, "Please enter a new name for the error log", this);
    errorDialog.pack();

    moveDialog = new CustomDialog(frame, "Please enter a new name for the move log", this);
    moveDialog.pack();

    printer = new FilePrinter();
    timers = new ArrayList<>();
    log = new JTextArea(5, 20);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    JScrollPane logScrollPane = new JScrollPane(log);
    Object obj;
    copy = true;
    listModel = new DefaultListModel();
    // destListModel = new DefaultListModel();
    directoryList = new directoryStorage();

    // Create a file chooser
    fc = new JFileChooser();

    // Create the menu bar.
    menuBar = new JMenuBar();

    // Build the first menu.
    menu = new JMenu("File");
    menu.getAccessibleContext()
        .setAccessibleDescription("The only menu in this program that has menu items");
    menuBar.add(menu);

    editError = new JMenuItem("Save Error Log As...");
    editError
        .getAccessibleContext()
        .setAccessibleDescription("Change the name of the error log file");
    editError.addActionListener(new ErrorListener());
    menu.add(editError);

    editMove = new JMenuItem("Save Move Log As...");
    editMove
        .getAccessibleContext()
        .setAccessibleDescription("Change the name of the move log file");
    editMove.addActionListener(new MoveListener());
    menu.add(editMove);

    exit = new JMenuItem("Exit");
    exit.getAccessibleContext().setAccessibleDescription("Exit the Program");
    exit.addActionListener(new CloseListener());
    menu.add(exit);
    frame.setJMenuBar(menuBar);
    // Uncomment one of the following lines to try a different
    // file selection mode.  The first allows just directories
    // to be selected (and, at least in the Java look and feel,
    // shown).  The second allows both files and directories
    // to be selected.  If you leave these lines commented out,
    // then the default mode (FILES_ONLY) will be used.
    //
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    openButton = new JButton(openString);
    openButton.setActionCommand(openString);
    openButton.addActionListener(new OpenListener());

    destButton = new JButton(destString);
    destButton.setActionCommand(destString);
    destButton.addActionListener(new DestListener());

    // Create the save button.  We use the image from the JLF
    // Graphics Repository (but we extracted it from the jar).
    saveButton = new JButton(saveString);
    saveButton.setActionCommand(saveString);
    saveButton.addActionListener(new SaveListener());

    URL imageURL = getClass().getResource(greenButtonIcon);
    ImageIcon greenSquare = new ImageIcon(imageURL);
    startButton = new JButton("Start", greenSquare);
    startButton.setSize(60, 20);
    startButton.setHorizontalTextPosition(AbstractButton.LEADING);
    startButton.setActionCommand("Start");
    startButton.addActionListener(new StartListener());

    imageURL = getClass().getResource(redButtonIcon);
    ImageIcon redSquare = new ImageIcon(imageURL);
    stopButton = new JButton("Stop", redSquare);
    stopButton.setSize(60, 20);
    stopButton.setHorizontalTextPosition(AbstractButton.LEADING);
    stopButton.setActionCommand("Stop");
    stopButton.addActionListener(new StopListener());

    copyButton = new JRadioButton("Copy");
    copyButton.setActionCommand("Copy");
    copyButton.setSelected(true);
    copyButton.addActionListener(new RadioListener());

    moveButton = new JRadioButton("Move");
    moveButton.setActionCommand("Move");
    moveButton.addActionListener(new RadioListener());

    ButtonGroup group = new ButtonGroup();
    group.add(copyButton);
    group.add(moveButton);

    // For layout purposes, put the buttons in a separate panel

    JPanel optionPanel = new JPanel();

    GroupLayout layout = new GroupLayout(optionPanel);
    optionPanel.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout.createSequentialGroup().addComponent(copyButton).addComponent(moveButton));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(copyButton)
                    .addComponent(moveButton)));

    JPanel buttonPanel = new JPanel(); // use FlowLayout

    layout = new GroupLayout(buttonPanel);
    buttonPanel.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(openButton)
                    .addComponent(optionPanel))
            .addComponent(destButton)
            .addComponent(startButton)
            .addComponent(stopButton)
        // .addComponent(saveButton)
        );
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(openButton)
                    .addComponent(destButton)
                    .addComponent(startButton)
                    .addComponent(stopButton)
                // .addComponent(saveButton)
                )
            .addComponent(optionPanel));

    buttonPanel.add(optionPanel);
    /*
    buttonPanel.add(openButton);
    buttonPanel.add(destButton);
    buttonPanel.add(startButton);
    buttonPanel.add(stopButton);
    buttonPanel.add(saveButton);
    buttonPanel.add(listLabel);
    buttonPanel.add(copyButton);
    buttonPanel.add(moveButton);
    */
    destButton.setEnabled(false);
    startButton.setEnabled(false);
    stopButton.setEnabled(false);

    // Add the buttons and the log to this panel.

    // add(logScrollPane, BorderLayout.CENTER);

    JLabel listLabel = new JLabel("Monitored Directory:");
    listLabel.setLabelFor(list);

    // Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);
    list.setVisibleRowCount(8);
    JScrollPane listScrollPane = new JScrollPane(list);
    JPanel listPane = new JPanel();
    listPane.setLayout(new BorderLayout());

    listPane.add(listLabel, BorderLayout.PAGE_START);
    listPane.add(listScrollPane, BorderLayout.CENTER);

    listSelectionModel = list.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    // monitored, destination, waitInt, check

    destination = new JLabel("Destination Directory: ");

    waitField = new JFormattedTextField();
    // waitField.setValue(240);
    waitField.setEditable(false);
    waitField.addPropertyChangeListener(new FormattedTextListener());

    waitInt = new JLabel("Wait Interval (in minutes)");
    // waitInt.setLabelFor(waitField);

    checkField = new JFormattedTextField();
    checkField.setSize(1, 10);
    // checkField.setValue(60);
    checkField.setEditable(false);
    checkField.addPropertyChangeListener(new FormattedTextListener());

    check = new JLabel("Check Interval (in minutes)");
    // check.setLabelFor(checkField);

    fireButton = new JButton(fireString);
    fireButton.setActionCommand(fireString);
    fireButton.addActionListener(new FireListener());

    JPanel fieldPane = new JPanel();
    // fieldPane.add(destField);
    layout = new GroupLayout(fieldPane);
    fieldPane.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(waitInt)
                    .addComponent(check))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(waitField, 60, 60, 60)
                    .addComponent(checkField, 60, 60, 60)));

    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(waitInt)
                    .addComponent(waitField))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(check)
                    .addComponent(checkField)));

    JPanel labelPane = new JPanel();

    labelPane.setLayout(new BorderLayout());

    labelPane.add(destination, BorderLayout.PAGE_START);
    labelPane.add(fieldPane, BorderLayout.CENTER);

    layout = new GroupLayout(labelPane);
    labelPane.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(destination)
                    .addComponent(fieldPane)));

    layout.setVerticalGroup(
        layout.createSequentialGroup().addComponent(destination).addComponent(fieldPane));
    // labelPane.add(destination);
    // labelPane.add(fieldPane);

    try {
      // Read from disk using FileInputStream
      FileInputStream f_in = new FileInputStream(LOG_DIRECTORY + "\\save.data");

      // Read object using ObjectInputStream
      ObjectInputStream obj_in = new ObjectInputStream(f_in);

      // Read an object
      directoryList = (directoryStorage) obj_in.readObject();
      ERROR_LOG_NAME = (String) obj_in.readObject();
      MOVE_LOG_NAME = (String) obj_in.readObject();

      if (ERROR_LOG_NAME instanceof String) {
        printer.changeErrorLogName(ERROR_LOG_NAME);
      }

      if (MOVE_LOG_NAME instanceof String) {
        printer.changeMoveLogName(MOVE_LOG_NAME);
      }

      if (directoryList instanceof directoryStorage) {
        System.out.println("found object");
        // directoryList = (directoryStorage) obj;

        Iterator<Directory> directories = directoryList.getDirectories();
        Directory d;
        while (directories.hasNext()) {
          d = directories.next();

          try {
            listModel.addElement(d.getDirectory().toRealPath());
          } catch (IOException x) {
            printer.printError(x.toString());
          }

          int index = list.getSelectedIndex();
          if (index == -1) {
            list.setSelectedIndex(0);
          }

          index = list.getSelectedIndex();
          Directory dir = directoryList.getDirectory(index);

          destButton.setEnabled(true);
          checkField.setValue(dir.getInterval());
          waitField.setValue(dir.getWaitInterval());
          checkField.setEditable(true);
          waitField.setEditable(true);

          // directoryList.addNewDirectory(d);
          // try {
          // listModel.addElement(d.getDirectory().toString());
          // } catch (IOException x) {
          // printer.printError(x.toString());
          // }

          // timer = new Timer();
          // timer.schedule(new CopyTask(d.directory, d.destination, d.getWaitInterval(), printer,
          // d.copy), 0, d.getInterval());
        }

      } else {
        System.out.println("did not find object");
      }
      obj_in.close();
    } catch (ClassNotFoundException x) {
      printer.printError(x.getLocalizedMessage());
      System.err.format("Unable to read");
    } catch (IOException y) {
      printer.printError(y.getLocalizedMessage());
    }

    // Layout the text fields in a panel.

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    buttonPane.add(fireButton);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(buttonPanel, BorderLayout.PAGE_START);
    add(listPane, BorderLayout.LINE_START);
    // add(destListScrollPane, BorderLayout.CENTER);

    add(fieldPane, BorderLayout.LINE_END);
    add(labelPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);
  }
Example #15
0
  /**
   * @param main
   * @param type
   */
  public GraphIso2(Bats main, String type) {
    this.main = main;
    this.data = main.data;
    h1 = Setting.getInt("/bat/general/font/h1");
    p = Setting.getInt("/bat/general/font/p");
    ft = Setting.getString("/bat/general/font/type");
    fTitel = new Font(ft, Font.PLAIN, h1);
    fAxes = new Font(ft, Font.PLAIN, p);
    fText = new Font(ft, Font.PLAIN, p);
    x = Setting.getString("/bat/isotope/graph/" + type + "/x_value");
    y = Setting.getString("/bat/isotope/graph/" + type + "/y_value");
    dataType = Setting.getString("/bat/isotope/graph/" + type + "/data");
    try {
      x_multi =
          Setting.getElement("/bat/isotope/graph/" + type + "/x_value")
              .getAttribute("multi")
              .getIntValue();
      y_multi =
          Setting.getElement("/bat/isotope/graph/" + type + "/y_value")
              .getAttribute("multi")
              .getIntValue();
    } catch (DataConversionException e) {
      x_multi = 1;
      y_multi = 1;
    }

    JLabel textLabel = new JLabel("Isobar correction on radioisotope:", JLabel.LEFT);
    textLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);

    JLabel textLabel2 =
        new JLabel(Setting.getString("/bat/isotope/graph/" + type + "/unit"), JLabel.LEFT);
    textLabel2.setAlignmentX(Component.RIGHT_ALIGNMENT);

    nf.setOverwriteMode(false);
    nf.setMinimum(0.000);
    textField = new JFormattedTextField(nf);
    try {
      textField.setValue(data.corrList.get(0).isoFact);
    } catch (IndexOutOfBoundsException e) {
      log.debug("Could not set isobar factor.");
    }
    textField.setColumns(5); // get some space

    textField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    textField
        .getActionMap()
        .put(
            "check",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                if (!textField.isEditValid()) { // The text is invalid.
                  Toolkit.getDefaultToolkit().beep();
                  textField.selectAll();
                } else
                  try { // The text is valid,
                    textField.commitEdit(); // so use it.
                    fieldChange();
                  } catch (java.text.ParseException exc) {
                  }
              }
            });

    textField2 = new JFormattedTextField(nf);
    textField2.setValue(data.corrList.get(0).isoErr);
    textField2.setColumns(5); // get some space

    textField2.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    textField2
        .getActionMap()
        .put(
            "check",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                if (!textField2.isEditValid()) { // The text is invalid.
                  Toolkit.getDefaultToolkit().beep();
                  textField2.selectAll();
                } else
                  try { // The text is valid,
                    textField2.commitEdit(); // so use it.
                    fieldChange2();
                  } catch (java.text.ParseException exc) {
                  }
              }
            });

    JPanel labelAndText = new JPanel();
    labelAndText.add(textLabel);
    labelAndText.add(textField);
    labelAndText.add(new JLabel("±"));
    labelAndText.add(textField2);
    labelAndText.add(textLabel2);

    JPanel regPane = new JPanel();
    regPane.add(new JLabel("slope: "));
    NumberFormatter nf = new NumberFormatter(new DecimalFormat("0.00E00"));
    slopeField = new JFormattedTextField(nf);
    slopeField.setPreferredSize(new Dimension(80, 20));
    slopeField.setEditable(false);
    regPane.add(slopeField);
    slopeErrField = new JFormattedTextField(nf);
    slopeErrField.setPreferredSize(new Dimension(80, 20));
    slopeErrField.setEditable(false);
    regPane.add(slopeErrField);
    regPane.add(new JLabel("R^2: "));
    nf = new NumberFormatter(new DecimalFormat("0.00E0"));
    rField = new JFormattedTextField(nf);
    rField.setPreferredSize(new Dimension(60, 20));
    rField.setEditable(false);
    regPane.add(rField);
    this.makeReg();

    JPanel regTextPanel = new JPanel(new GridLayout(1, 2));
    regTextPanel.add(labelAndText);
    regTextPanel.add(regPane);

    JPanel controlPanel = new JPanel(new GridLayout(1, 1));
    controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.PAGE_AXIS));
    controlPanel.setBorder(BorderFactory.createEmptyBorder(30, 10, 5, 10));
    controlPanel.add(regTextPanel);

    JDialog frame = new JDialog();
    frame.setModal(true);
    frame.setTitle("Correction");
    frame.setPreferredSize(
        new Dimension(
            Setting.getInt("/bat/general/frame/correction/width"),
            Setting.getInt("/bat/general/frame/correction/height")));
    frame.add(controlPanel, BorderLayout.SOUTH);
    dataSet = Func.getXY(data.get(dataType), null, x, y, x_multi, y_multi);
    chart = createChart(dataSet);
    frame.add(new ChartPanel(chart));
    frame.addWindowListener(this);
    frame.pack();
    frame.setVisible(true);
  }
  private void addInformationPanel() {
    // Create UI elements for connection information.
    JPanel informationPanel = new JPanel();
    informationPanel.setLayout(new BorderLayout());

    // Add the Host information
    JPanel connPanel = new JPanel();
    connPanel.setLayout(new GridBagLayout());
    connPanel.setBorder(BorderFactory.createTitledBorder("Connection information"));

    JLabel label = new JLabel("Host: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    JFormattedTextField field = new JFormattedTextField(connection.getServiceName());
    field.setMinimumSize(new java.awt.Dimension(150, 20));
    field.setMaximumSize(new java.awt.Dimension(150, 20));
    field.setEditable(false);
    field.setBorder(null);
    connPanel.add(
        field, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));

    // Add the Port information
    label = new JLabel("Port: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    field = new JFormattedTextField(connection.getPort());
    field.setMinimumSize(new java.awt.Dimension(150, 20));
    field.setMaximumSize(new java.awt.Dimension(150, 20));
    field.setEditable(false);
    field.setBorder(null);
    connPanel.add(
        field, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));

    // Add the connection's User information
    label = new JLabel("User: "******"Creation time: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    field = new JFormattedTextField(new SimpleDateFormat("yyyy.MM.dd hh:mm:ss:SS aaa"));
    field.setMinimumSize(new java.awt.Dimension(150, 20));
    field.setMaximumSize(new java.awt.Dimension(150, 20));
    field.setValue(creationTime);
    field.setEditable(false);
    field.setBorder(null);
    connPanel.add(
        field, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));

    // Add the connection's creationTime information
    label = new JLabel("Status: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    statusField = new JFormattedTextField();
    statusField.setMinimumSize(new java.awt.Dimension(150, 20));
    statusField.setMaximumSize(new java.awt.Dimension(150, 20));
    statusField.setValue("Active");
    statusField.setEditable(false);
    statusField.setBorder(null);
    connPanel.add(
        statusField,
        new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
    // Add the connection panel to the information panel
    informationPanel.add(connPanel, BorderLayout.NORTH);

    // Add the Number of sent packets information
    JPanel packetsPanel = new JPanel();
    packetsPanel.setLayout(new GridLayout(1, 1));
    packetsPanel.setBorder(BorderFactory.createTitledBorder("Transmitted Packets"));

    statisticsTable =
        new DefaultTableModel(
            new Object[][] {
              {"IQ", 0, 0}, {"Message", 0, 0}, {"Presence", 0, 0}, {"Other", 0, 0}, {"Total", 0, 0}
            },
            new Object[] {"Type", "Received", "Sent"}) {
          private static final long serialVersionUID = -6793886085109589269L;

          public boolean isCellEditable(int rowIndex, int mColIndex) {
            return false;
          }
        };
    JTable table = new JTable(statisticsTable);
    // Allow only single a selection
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    packetsPanel.add(new JScrollPane(table));

    // Add the packets panel to the information panel
    informationPanel.add(packetsPanel, BorderLayout.CENTER);

    tabbedPane.add("Information", new JScrollPane(informationPanel));
    tabbedPane.setToolTipTextAt(4, "Information and statistics about the debugged connection");
  }
  @Override
  public JComponent createControl() {
    layerCanvasModelChangeChangeHandler = new LayerCanvasModelChangeHandler();
    productNodeChangeHandler = createProductNodeListener();
    cursorSynchronizer = new CursorSynchronizer(VisatApp.getApp());

    final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH);
    scaleFormat = new DecimalFormat("#####.##", decimalFormatSymbols);
    scaleFormat.setGroupingUsed(false);
    scaleFormat.setDecimalSeparatorAlwaysShown(false);

    zoomInButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomIn24.gif"), false);
    zoomInButton.setToolTipText("Zoom in."); /*I18N*/
    zoomInButton.setName("zoomInButton");
    zoomInButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            zoom(getCurrentView().getZoomFactor() * 1.2);
          }
        });

    zoomOutButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomOut24.gif"), false);
    zoomOutButton.setName("zoomOutButton");
    zoomOutButton.setToolTipText("Zoom out."); /*I18N*/
    zoomOutButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            zoom(getCurrentView().getZoomFactor() / 1.2);
          }
        });

    zoomDefaultButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomPixel24.gif"), false);
    zoomDefaultButton.setToolTipText("Actual Pixels (image pixel = view pixel)."); /*I18N*/
    zoomDefaultButton.setName("zoomDefaultButton");
    zoomDefaultButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            zoomToPixelResolution();
          }
        });

    zoomAllButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomAll24.gif"), false);
    zoomAllButton.setName("zoomAllButton");
    zoomAllButton.setToolTipText("Zoom all."); /*I18N*/
    zoomAllButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            zoomAll();
          }
        });

    syncViewsButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/SyncViews24.png"), true);
    syncViewsButton.setToolTipText("Synchronise compatible product views."); /*I18N*/
    syncViewsButton.setName("syncViewsButton");
    syncViewsButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            maybeSynchronizeCompatibleProductViews();
          }
        });

    syncCursorButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/SyncCursor24.png"), true);
    syncCursorButton.setToolTipText("Synchronise cursor position."); /*I18N*/
    syncCursorButton.setName("syncCursorButton");
    syncCursorButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            cursorSynchronizer.setEnabled(syncCursorButton.isSelected());
          }
        });

    AbstractButton helpButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help24.gif"), false);
    helpButton.setToolTipText("Help."); /*I18N*/
    helpButton.setName("helpButton");

    final JPanel eastPane = GridBagUtils.createPanel();
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;

    gbc.gridy = 0;
    eastPane.add(zoomInButton, gbc);

    gbc.gridy++;
    eastPane.add(zoomOutButton, gbc);

    gbc.gridy++;
    eastPane.add(zoomDefaultButton, gbc);

    gbc.gridy++;
    eastPane.add(zoomAllButton, gbc);

    gbc.gridy++;
    eastPane.add(syncViewsButton, gbc);

    gbc.gridy++;
    eastPane.add(syncCursorButton, gbc);

    gbc.gridy++;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.VERTICAL;
    eastPane.add(new JLabel(" "), gbc); // filler
    gbc.fill = GridBagConstraints.NONE;
    gbc.weighty = 0.0;

    gbc.gridy++;
    eastPane.add(helpButton, gbc);

    zoomFactorField = new JTextField();
    zoomFactorField.setColumns(8);
    zoomFactorField.setHorizontalAlignment(JTextField.CENTER);
    zoomFactorField.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            handleZoomFactorFieldUserInput();
          }
        });
    zoomFactorField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(final FocusEvent e) {
            handleZoomFactorFieldUserInput();
          }
        });

    rotationAngleSpinner = new JSpinner(new SpinnerNumberModel(0.0, -1800.0, 1800.0, 5.0));
    final JSpinner.NumberEditor editor = (JSpinner.NumberEditor) rotationAngleSpinner.getEditor();
    rotationAngleField = editor.getTextField();
    final DecimalFormat rotationFormat;
    rotationFormat = new DecimalFormat("#####.##", decimalFormatSymbols);
    rotationFormat.setGroupingUsed(false);
    rotationFormat.setDecimalSeparatorAlwaysShown(false);
    rotationAngleField.setFormatterFactory(
        new JFormattedTextField.AbstractFormatterFactory() {
          @Override
          public JFormattedTextField.AbstractFormatter getFormatter(JFormattedTextField tf) {
            return new NumberFormatter(rotationFormat);
          }
        });
    rotationAngleField.setColumns(6);
    rotationAngleField.setEditable(true);
    rotationAngleField.setHorizontalAlignment(JTextField.CENTER);
    rotationAngleField.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            handleRotationAngleFieldUserInput();
          }
        });
    rotationAngleField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            handleRotationAngleFieldUserInput();
          }
        });
    rotationAngleField.addPropertyChangeListener(
        "value",
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            handleRotationAngleFieldUserInput();
          }
        });

    zoomSlider = new JSlider(JSlider.HORIZONTAL);
    zoomSlider.setValue(0);
    zoomSlider.setMinimum(MIN_SLIDER_VALUE);
    zoomSlider.setMaximum(MAX_SLIDER_VALUE);
    zoomSlider.setPaintTicks(false);
    zoomSlider.setPaintLabels(false);
    zoomSlider.setSnapToTicks(false);
    zoomSlider.setPaintTrack(true);
    zoomSlider.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(final ChangeEvent e) {
            if (!inUpdateMode) {
              zoom(sliderValueToZoomFactor(zoomSlider.getValue()));
            }
          }
        });

    final JPanel zoomFactorPane = new JPanel(new BorderLayout());
    zoomFactorPane.add(zoomFactorField, BorderLayout.WEST);

    final JPanel rotationAnglePane = new JPanel(new BorderLayout());
    rotationAnglePane.add(rotationAngleSpinner, BorderLayout.EAST);
    rotationAnglePane.add(new JLabel(" "), BorderLayout.CENTER);

    final JPanel sliderPane = new JPanel(new BorderLayout(2, 2));
    sliderPane.add(zoomFactorPane, BorderLayout.WEST);
    sliderPane.add(zoomSlider, BorderLayout.CENTER);
    sliderPane.add(rotationAnglePane, BorderLayout.EAST);

    canvas = createNavigationCanvas();
    canvas.setBackground(new Color(138, 133, 128)); // image background
    canvas.setForeground(new Color(153, 153, 204)); // slider overlay

    final JPanel centerPane = new JPanel(new BorderLayout(4, 4));
    centerPane.add(BorderLayout.CENTER, canvas);
    centerPane.add(BorderLayout.SOUTH, sliderPane);

    final JPanel mainPane = new JPanel(new BorderLayout(8, 8));
    mainPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPane.add(centerPane, BorderLayout.CENTER);
    mainPane.add(eastPane, BorderLayout.EAST);

    mainPane.setPreferredSize(new Dimension(320, 320));

    if (getDescriptor().getHelpId() != null) {
      HelpSys.enableHelpOnButton(helpButton, getDescriptor().getHelpId());
      HelpSys.enableHelpKey(mainPane, getDescriptor().getHelpId());
    }

    setCurrentView(VisatApp.getApp().getSelectedProductSceneView());

    updateState();

    // Add an internal frame listener to VISAT so that we can update our
    // navigation window with the information of the currently activated
    // product scene view.
    //
    VisatApp.getApp().addInternalFrameListener(new NavigationIFL());

    return mainPane;
  }