public HDMColdAccountForm(final WalletListPanel walletListPanel) {
    this.walletListPanel = walletListPanel;

    inactiveBackGroundColor = Color.WHITE;
    selected = false;
    panelMain.setOpaque(true);
    panelMain.setFocusable(true);
    panelMain.setBackground(inactiveBackGroundColor);

    if (ColorAndFontConstants.isInverse()) {
      inactiveBackGroundColor =
          new Color(
              Math.min(255, Themes.currentTheme.detailPanelBackground().getRed() + 2 * COLOR_DELTA),
              Math.min(
                  255, Themes.currentTheme.detailPanelBackground().getBlue() + 2 * COLOR_DELTA),
              Math.min(
                  255, Themes.currentTheme.detailPanelBackground().getGreen() + 2 * COLOR_DELTA));
    } else {
      inactiveBackGroundColor =
          new Color(
              Math.max(0, Themes.currentTheme.detailPanelBackground().getRed() - COLOR_DELTA),
              Math.max(0, Themes.currentTheme.detailPanelBackground().getBlue() - COLOR_DELTA),
              Math.max(0, Themes.currentTheme.detailPanelBackground().getGreen() - COLOR_DELTA));
    }
    panelMain.applyComponentOrientation(
        ComponentOrientation.getOrientation(LocaliserUtils.getLocale()));

    updateFromModel();
    panelMain.addMouseListener(
        new WalletMouseListener(this.walletListPanel, HDMColdAccountForm.this));

    setSelected(false);
    setContent();
  }
Exemplo n.º 2
0
  /**
   * Constructs a <code>BoxLayout</code> object.
   *
   * @param container The container that needs to be laid out.
   * @param way The orientation of the components.
   * @exception AWTError If way has an invalid value.
   */
  public BoxLayout(Container container, int way) {
    int width = 0;
    int height = 0;
    ComponentOrientation orientation = container.getComponentOrientation();

    this.container = container;
    this.way = way;

    switch (way) {
      case X_AXIS:
        width = 1;
        break;
      case Y_AXIS:
        height = 1;
        break;
      case LINE_AXIS:
        if (orientation.isHorizontal()) height = 1;
        else width = 1;
        break;
      case PAGE_AXIS:
        if (!orientation.isHorizontal()) height = 1;
        else width = 1;
        break;
      default:
        throw new AWTError("Invalid value for way");
    }

    grid = new GridLayout(width, height);
  }
Exemplo n.º 3
0
 /**
  * Resolve the axis type of a component, given a layout orientation
  *
  * @param c a Swing Component, should be either a Box or a Container using a BoxLayout.
  * @param layout the layout orientation of the component. One of {@link
  *     javax.swing.BoxLayout#X_AXIS}, {@link javax.swing.BoxLayout#Y_AXIS}, {@link
  *     javax.swing.BoxLayout#LINE_AXIS}, or {@link javax.swing.BoxLayout#PAGE_AXIS}.
  * @return one of {@link javax.swing.BoxLayout#X_AXIS}, or {@link javax.swing.BoxLayout#Y_AXIS},
  */
 public static int getAxis(JComponent c, int layout) {
   ComponentOrientation o = c.getComponentOrientation();
   switch (layout) {
     case BoxLayout.LINE_AXIS:
       return o.isHorizontal() ? BoxLayout.X_AXIS : BoxLayout.Y_AXIS;
     case BoxLayout.PAGE_AXIS:
       return o.isHorizontal() ? BoxLayout.Y_AXIS : BoxLayout.X_AXIS;
     default:
       return layout;
   }
 }
Exemplo n.º 4
0
  /**
   * Constructs an instance of <code>AbstractFormBuilder</code> for the given FormLayout and layout
   * container.
   *
   * @param layout the {@link FormLayout} to use
   * @param container the layout container
   * @throws NullPointerException if the layout or container is null
   */
  public AbstractFormBuilder(FormLayout layout, Container container) {
    if (layout == null) throw new NullPointerException("The layout must not be null.");

    if (container == null) throw new NullPointerException("The layout container must not be null.");

    this.container = container;
    this.layout = layout;

    container.setLayout(layout);
    currentCellConstraints = new CellConstraints();
    ComponentOrientation orientation = container.getComponentOrientation();
    leftToRight = orientation.isLeftToRight() || !orientation.isHorizontal();
  }
Exemplo n.º 5
0
  /**
   * Paints this panel.
   *
   * @param g The graphics context.
   */
  protected void paintComponent(Graphics g) {

    super.paintComponent(g);

    Dimension dim = getSize();
    Color c1 = UIManager.getColor("Label.disabledShadow");
    Color c2 = UIManager.getColor("Label.disabledForeground");

    if (osxSizeGrip != null) {
      g.drawImage(osxSizeGrip, dim.width - 16, dim.height - 16, null);
      return;
    }

    ComponentOrientation orientation = getComponentOrientation();

    if (orientation.isLeftToRight()) {
      int width = dim.width -= 3;
      int height = dim.height -= 3;
      g.setColor(c1);
      g.fillRect(width - 9, height - 1, 3, 3);
      g.fillRect(width - 5, height - 1, 3, 3);
      g.fillRect(width - 1, height - 1, 3, 3);
      g.fillRect(width - 5, height - 5, 3, 3);
      g.fillRect(width - 1, height - 5, 3, 3);
      g.fillRect(width - 1, height - 9, 3, 3);
      g.setColor(c2);
      g.fillRect(width - 9, height - 1, 2, 2);
      g.fillRect(width - 5, height - 1, 2, 2);
      g.fillRect(width - 1, height - 1, 2, 2);
      g.fillRect(width - 5, height - 5, 2, 2);
      g.fillRect(width - 1, height - 5, 2, 2);
      g.fillRect(width - 1, height - 9, 2, 2);
    } else {
      int height = dim.height -= 3;
      g.setColor(c1);
      g.fillRect(10, height - 1, 3, 3);
      g.fillRect(6, height - 1, 3, 3);
      g.fillRect(2, height - 1, 3, 3);
      g.fillRect(6, height - 5, 3, 3);
      g.fillRect(2, height - 5, 3, 3);
      g.fillRect(2, height - 9, 3, 3);
      g.setColor(c2);
      g.fillRect(10, height - 1, 2, 2);
      g.fillRect(6, height - 1, 2, 2);
      g.fillRect(2, height - 1, 2, 2);
      g.fillRect(6, height - 5, 2, 2);
      g.fillRect(2, height - 5, 2, 2);
      g.fillRect(2, height - 9, 2, 2);
    }
  }
Exemplo n.º 6
0
 /**
  * set / update the text of the displayLabels. these are the Week column headers above the days on
  * the Calendar part of the <code>CDateTime</code>.
  */
 private void updateDaysOfWeek() {
   if (dayPanel != null) {
     Calendar tmpcal = cdt.getCalendarInstance();
     tmpcal.set(Calendar.DAY_OF_WEEK, tmpcal.getFirstDayOfWeek());
     Locale locale = cdt.getLocale();
     boolean ltr =
         (ComponentOrientation.getOrientation(locale).isLeftToRight()
             && !locale.getLanguage().equals("zh")); // $NON-NLS-1$
     BreakIterator iterator = BreakIterator.getCharacterInstance(locale);
     for (int x = 0; x < dayLabels.length; x++) {
       String str = getFormattedDate("E", tmpcal.getTime()); // $NON-NLS-1$
       if (dayLabels[x].getData(CDT.Key.Compact, Boolean.class)) {
         iterator.setText(str);
         int start, end;
         if (ltr) {
           start = iterator.first();
           end = iterator.next();
         } else {
           end = iterator.last();
           start = iterator.previous();
         }
         dayLabels[x].setText(str.substring(start, end));
       } else {
         dayLabels[x].setText(str);
       }
       tmpcal.add(Calendar.DAY_OF_WEEK, 1);
     }
   }
 }
 /**
  * Returns the proper column specification for the given component orientation. The column
  * specification is provided in left-to-right format. When the orientation is left-to-right, the
  * string is returned as is. Otherwise the string is reworked to represent right-to-left.
  *
  * @param leftToRightColSpec The column specification for a left-to-right orientation.
  * @param orientation The orientation of the locale.
  * @return The proper column specification.
  */
 public static String getColSpec(String leftToRightColSpec, ComponentOrientation orientation) {
   if (orientation.isLeftToRight()) {
     return leftToRightColSpec;
   } else {
     return FormLayoutUtil.flip(leftToRightColSpec);
   }
 }
Exemplo n.º 8
0
 /**
  * @see
  *     edu.kit.joana.ui.ifc.sdg.graphviewer.controller.event.LanguageListener#languageChanged(edu.kit.joana.ui.ifc.sdg.graphviewer.controller.event.LanguageEvent)
  */
 public void languageChanged(LanguageEvent event) {
   if (this.toolTip != null) {
     this.setToolTipText(this.translator.getString(this.toolTip));
   }
   this.setLocale(event.getLanguage());
   this.setComponentOrientation(ComponentOrientation.getOrientation(event.getLanguage()));
 }
Exemplo n.º 9
0
  private void configurePopupMenu(Object node) {

    if (node != null) {

      if (popup == null) {
        popup = new JPopupMenu();
      } else {
        popup.removeAll();
      }

      AbstractWorkspaceTreeNode treeNode = (AbstractWorkspaceTreeNode) node;
      List<PopupContent> actions = treeNode.getPopupActions();
      for (PopupContent obj : actions) {
        if (obj instanceof PopupSubMenu) {
          popup.add((PopupSubMenu) obj);
        } else {
          Action action = (Action) obj;
          if (action == null) {
            popup.addSeparator();
          } else {
            popup.add(new JMenuItem(action));
          }
        }
      }

      ComponentOrientation o = ComponentOrientation.getOrientation(Locale.getDefault());
      popup.applyComponentOrientation(o);
    }
  }
 /**
  * Returns the proper cell constraints for the given column specification and orientation. This
  * means that when the orientation is left-to-right, the cell constraints are returned as is. When
  * it is right-to-left, the cell constraints are flipped horizontally.
  *
  * @param cc The cell constraints defined in left-to-right format.
  * @param colSpec The column specification for which the cell constraints are designed.
  * @param orientation The orientation of the locale.
  * @return The proper cell constraints.
  */
 public static CellConstraints flip(
     CellConstraints cc, String colSpec, ComponentOrientation orientation) {
   if (orientation.isLeftToRight()) {
     return cc;
   } else {
     int columnCount = colSpec.split(",").length;
     return flipHorizontally(cc, columnCount);
   }
 }
Exemplo n.º 11
0
  private JPanel createButtonPanel() {
    JPanel buttonPanel = new JPanel();
    buttonPanel.setOpaque(false);
    FlowLayout flowLayout = new FlowLayout();
    flowLayout.setAlignment(FlowLayout.LEADING);
    buttonPanel.setLayout(flowLayout);
    buttonPanel.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    verifyMessageSubmitAction =
        new VerifyMessageSubmitAction(
            this.bitcoinController,
            mainFrame,
            this,
            ImageLoader.createImageIcon(ImageLoader.MESSAGE_VERIFY_ICON_FILE));
    MultiBitButton submitButton = new MultiBitButton(verifyMessageSubmitAction, controller);
    submitButton.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    buttonPanel.add(submitButton);

    clearAllButton =
        new MultiBitButton(controller.getLocaliser().getString("signMessagePanel.clearAll.text"));
    clearAllButton.setToolTipText(
        controller.getLocaliser().getString("signMessagePanel.clearAll.tooltip"));
    clearAllButton.setIcon(ImageLoader.createImageIcon(ImageLoader.DELETE_ICON_FILE));
    clearAllButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addressTextArea.setText("");
            messageTextArea.setText("");
            signatureTextArea.setText("");
            messageLabel1.setText(" ");
            messageLabel2.setText(" ");
          }
        });
    clearAllButton.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    buttonPanel.add(clearAllButton);

    return buttonPanel;
  }
  /** Creates new form SwitchboardView */
  public SwitchboardView() {
    initComponents();

    btnSalesReport.addActionListener(this);
    btnBackOffice.addActionListener(this);
    btnClockOut.addActionListener(this);
    btnEditTicket.addActionListener(this);

    if (!"false".equals(AppConfig.getFeatureGroupTicketFlag())) {
      btnGroupSettle.addActionListener(this);
    }

    btnLogout.addActionListener(this);

    if (!"false".equals(AppConfig.getManagerMenuFlag())) {
      btnManager.addActionListener(this);
    }

    btnNewTicket.addActionListener(this);

    if (!"false".equals(AppConfig.getFeaturePenarikanFlag())) {
      btnPayout.addActionListener(this);
    }

    btnOrderInfo.addActionListener(this);
    btnReopenTicket.addActionListener(this);
    btnSettleTicket.addActionListener(this);
    btnShutdown.addActionListener(this);

    if (!"false".equals(AppConfig.getFeatureSplitTicketFlag())) {
      btnSplitTicket.addActionListener(this);
    }

    btnTakeout.addActionListener(this);
    btnVoidTicket.addActionListener(this);

    orderServiceExtension = Application.getPluginManager().getPlugin(OrderServiceExtension.class);

    if (orderServiceExtension == null) {
      //            btnHomeDelivery.setEnabled(false);
      //            btnPickup.setEnabled(false);
      //            btnDriveThrough.setEnabled(false);
      //            btnAssignDriver.setEnabled(false);
      //            btnCloseOrder.setEnabled(false);

      orderServiceExtension = new DefaultOrderServiceExtension();
    }
    //		ticketListUpdater = new Timer(30 * 1000, new TicketListUpdaterTask());

    applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));

    instance = this;
  }
Exemplo n.º 13
0
  /** Creates a new {@link IssueAssetDialog}. */
  public IssueAssetDialog(
      BitcoinController bitcoinController, MultiBitFrame mainFrame, TradeingPanel tradePanel) {
    super(mainFrame, bitcoinController.getLocaliser().getString("IssueAssetDialog.title"));
    this.bitcoinController = bitcoinController;
    this.controller = this.bitcoinController;
    this.tradePanel = tradePanel;

    initUI();

    issueAssetPanel.getCancelButton().requestFocusInWindow();
    applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
  }
Exemplo n.º 14
0
    private Icon getIcon(SynthContext context) {
      if (context != null) {
        ComponentOrientation co = context.getComponent().getComponentOrientation();
        SynthStyle style = context.getStyle();

        if (style != this.style) {
          this.style = style;
          loadedLTR = loadedRTL = false;
        }
        if (co == null || co.isLeftToRight()) {
          if (!loadedLTR) {
            loadedLTR = true;
            ltrIcon = ((GTKStyle) context.getStyle()).getStockIcon(context, key, size);
          }
          return ltrIcon;
        } else if (!loadedRTL) {
          loadedRTL = true;
          rtlIcon = ((GTKStyle) context.getStyle()).getStockIcon(context, key, size);
        }
        return rtlIcon;
      }
      return ltrIcon;
    }
Exemplo n.º 15
0
  /** Creates a new {@link VerifyMessagePanel}. */
  public VerifyMessagePanel(BitcoinController bitcoinController, MultiBitFrame mainFrame) {
    this.bitcoinController = bitcoinController;
    this.controller = this.bitcoinController;
    this.mainFrame = mainFrame;

    setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR);
    applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    initUI();

    walletBusyChange(this.bitcoinController.getModel().getActivePerWalletModelData().isBusy());
    this.bitcoinController.registerWalletBusyListener(this);
  }
Exemplo n.º 16
0
  private Icon getStockIcon(SynthContext context, String key, int type) {
    TextDirection direction = TextDirection.LTR;

    if (context != null) {
      ComponentOrientation co = context.getComponent().getComponentOrientation();

      if (co != null && !co.isLeftToRight()) {
        direction = TextDirection.RTL;
      }
    }

    // First try loading a theme-specific icon using the native
    // GTK libraries (native GTK handles the resizing for us).
    Icon icon = getStyleSpecificIcon(key, direction, type);
    if (icon != null) {
      return icon;
    }

    // In a failure case where native GTK (unexpectedly) returns a
    // null icon, we can try loading a default icon as a fallback.
    String propName =
        ICON_PROPERTY_PREFIX
            + key
            + '.'
            + type
            + '.'
            + (direction == TextDirection.RTL ? "rtl" : "ltr");
    Image img = (Image) Toolkit.getDefaultToolkit().getDesktopProperty(propName);
    if (img != null) {
      return new ImageIcon(img);
    }

    // In an extreme failure situation, just return null (callers are
    // already prepared to handle a null icon, so the worst that can
    // happen is that an icon won't be included in the button/dialog).
    return null;
  }
  /** Creates a new {@link CreateNewReceivingAddressDialog}. */
  public CreateNewReceivingAddressDialog(
      BitcoinController bitcoinController,
      MultiBitFrame mainFrame,
      ReceiveBitcoinPanel receiveBitcoinPanel) {
    super(
        mainFrame,
        bitcoinController.getLocaliser().getString("createNewReceivingAddressDialog.title"));
    this.bitcoinController = bitcoinController;
    this.controller = this.bitcoinController;
    this.receiveBitcoinPanel = receiveBitcoinPanel;

    initUI();

    createNewReceivingAddressPanel.getCancelButton().requestFocusInWindow();
    applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
  }
Exemplo n.º 18
0
  public TickerTablePanel(MultiBitFrame mainFrame, ExchangeController exchangeController) {
    this.exchangeController = exchangeController;
    this.controller = this.exchangeController;

    this.mainFrame = mainFrame;

    font = FontSizer.INSTANCE.getAdjustedDefaultFontWithDelta(-1);
    fontMetrics = getFontMetrics(font);

    // Switch the dark and light row highlighting for Windows.
    if (System.getProperty("os.name", "unknown").startsWith("Win")) {
      moduloRow = 1;
    } else {
      moduloRow = 0;
    }

    initUI();

    applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
  }
Exemplo n.º 19
0
  private void createTicker() {
    setBackground(ColorAndFontConstants.BACKGROUND_COLOR);
    setLayout(new GridBagLayout());
    setOpaque(false);
    setFocusable(false);

    setToolTipText(
        HelpContentsPanel.createMultilineTooltipText(
            new String[] {
              controller.getLocaliser().getString("tickerTablePanel.tooltip"),
              "\n ",
              controller.getLocaliser().getString("tickerTablePanel.tooltip.clickToConfigure")
            }));

    // on mouse click - view the exchanges tab
    MouseListener viewPreferencesMouseListener =
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent arg0) {
            controller.displayView(View.PREFERENCES_VIEW);
          }
        };

    String tickerTooltipText =
        HelpContentsPanel.createMultilineTooltipText(
            new String[] {
              controller.getLocaliser().getString("tickerTablePanel.tooltip"),
              "\n ",
              controller.getLocaliser().getString("tickerTablePanel.tooltip.clickToConfigure")
            });

    addMouseListener(viewPreferencesMouseListener);

    GridBagConstraints constraints = new GridBagConstraints();

    tickerTableModel = new TickerTableModel(this.exchangeController);

    table = new JTable(tickerTableModel);
    table.setOpaque(true);
    table.setShowGrid(true);
    table.setGridColor(Color.lightGray);
    table.setBackground(ColorAndFontConstants.BACKGROUND_COLOR);
    table.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, SystemColor.windowBorder));

    table.setComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    table.setRowHeight(getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight());

    table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(false);
    table.getTableHeader().setReorderingAllowed(false);

    table.setToolTipText(tickerTooltipText);
    table.addMouseListener(viewPreferencesMouseListener);
    table.getTableHeader().addMouseListener(viewPreferencesMouseListener);
    table.getTableHeader().setToolTipText(tickerTooltipText);
    table.getTableHeader().setFont(FontSizer.INSTANCE.getAdjustedDefaultFontWithDelta(-1));

    int tableHeaderHeight =
        fontMetrics.getHeight()
            + table.getTableHeader().getInsets().top
            + table.getTableHeader().getInsets().bottom;

    // Windows 8 has slightly taller headers so add a tweak for that.
    if (System.getProperty("os.name", "unknown").startsWith("Win")) {
      tableHeaderHeight = tableHeaderHeight + WINDOWS_TABLE_HEADER_HEIGHT_TWEAK;
    }

    int tickerWidth = setupColumnWidths();
    setupTableHeaders();

    idealHeight =
        (fontMetrics.getHeight() + table.getRowMargin()) * tickerTableModel.getRowCount()
            + tableHeaderHeight
            + tickerTableModel.getRowCount()
            + 10;

    setPreferredSize(new Dimension(tickerWidth, idealHeight));

    scrollPane =
        new JScrollPane(
            table,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    scrollPane.setComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    scrollPane.addMouseListener(viewPreferencesMouseListener);

    setupScrollPane(tickerWidth);

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.anchor = GridBagConstraints.CENTER;

    add(scrollPane, constraints);
  }
Exemplo n.º 20
0
 /**
  * Component orientation is Left To Right
  *
  * @return true if left-to-right
  */
 public boolean isLeftToRight() {
   if (m_leftToRight == null)
     //  returns true if language not iw, ar, fa, ur
     m_leftToRight = new Boolean(ComponentOrientation.getOrientation(m_locale).isLeftToRight());
   return m_leftToRight.booleanValue();
 } //  isLeftToRight
Exemplo n.º 21
0
 /**
  * Overridden to ensure that the cursor for this component is appropriate for the orientation.
  *
  * @param o The new orientation.
  */
 public void applyComponentOrientation(ComponentOrientation o) {
   possiblyFixCursor(o.isLeftToRight());
   super.applyComponentOrientation(o);
 }
 void setComponentOrientation(ComponentOrientation orientation) {
   horizontal = orientation.isHorizontal();
   leftToRight = orientation.isLeftToRight();
 }
Exemplo n.º 23
0
 TranscodingTab(PmsConfiguration configuration) {
   this.configuration = configuration;
   // Apply the orientation for the locale
   Locale locale = new Locale(configuration.getLanguage());
   orientation = ComponentOrientation.getOrientation(locale);
 }
Exemplo n.º 24
0
  public boolean initApp(AppProperties props) {

    m_props = props;
    // setPreferredSize(new java.awt.Dimension(800, 600));

    // support for different component orientation languages.
    applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));

    // Database start
    try {
      session = AppViewConnection.createSession(m_props);
    } catch (BasicException e) {
      JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_DANGER, e.getMessage(), e));
      return false;
    }

    m_dlSystem = (DataLogicSystem) getBean("com.openbravo.pos.forms.DataLogicSystem");

    // Create or upgrade the database if database version is not the expected
    String sDBVersion = readDataBaseVersion();
    if (!AppLocal.APP_VERSION.equals(sDBVersion)) {

      // Create or upgrade database

      String sScript =
          sDBVersion == null
              ? m_dlSystem.getInitScript() + "-create.sql"
              : m_dlSystem.getInitScript() + "-upgrade-" + sDBVersion + ".sql";

      if (JRootApp.class.getResource(sScript) == null) {
        JMessageDialog.showMessage(
            this,
            new MessageInf(
                MessageInf.SGN_DANGER,
                sDBVersion == null
                    ? AppLocal.getIntString(
                        "message.databasenotsupported",
                        session.DB
                            .getName()) // Create script does not exists. Database not supported
                    : AppLocal.getIntString(
                        "message.noupdatescript"))); // Upgrade script does not exist.
        session.close();
        return false;
      } else {
        // Create or upgrade script exists.
        if (JOptionPane.showConfirmDialog(
                this,
                AppLocal.getIntString(
                    sDBVersion == null ? "message.createdatabase" : "message.updatedatabase"),
                AppLocal.getIntString("message.title"),
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE)
            == JOptionPane.YES_OPTION) {

          try {
            BatchSentence bsentence = new BatchSentenceResource(session, sScript);
            bsentence.putParameter("APP_ID", Matcher.quoteReplacement(AppLocal.APP_ID));
            bsentence.putParameter("APP_NAME", Matcher.quoteReplacement(AppLocal.APP_NAME));
            bsentence.putParameter("APP_VERSION", Matcher.quoteReplacement(AppLocal.APP_VERSION));

            java.util.List l = bsentence.list();
            if (l.size() > 0) {
              JMessageDialog.showMessage(
                  this,
                  new MessageInf(
                      MessageInf.SGN_WARNING,
                      AppLocal.getIntString("Database.ScriptWarning"),
                      l.toArray(new Throwable[l.size()])));
            }
          } catch (BasicException e) {
            JMessageDialog.showMessage(
                this,
                new MessageInf(
                    MessageInf.SGN_DANGER, AppLocal.getIntString("Database.ScriptError"), e));
            session.close();
            return false;
          }
        } else {
          session.close();
          return false;
        }
      }
    }

    // Cargamos las propiedades de base de datos
    m_propsdb = m_dlSystem.getResourceAsProperties(m_props.getHost() + "/properties");

    // creamos la caja activa si esta no existe
    try {
      String sActiveCashIndex = m_propsdb.getProperty("activecash");
      Object[] valcash =
          sActiveCashIndex == null ? null : m_dlSystem.findActiveCash(sActiveCashIndex);
      if (valcash == null || !m_props.getHost().equals(valcash[0])) {
        // no la encuentro o no es de mi host por tanto creo una...
        setActiveCash(
            UUID.randomUUID().toString(),
            m_dlSystem.getSequenceCash(m_props.getHost()) + 1,
            new Date(),
            null);

        // creamos la caja activa
        m_dlSystem.execInsertCash(
            new Object[] {
              getActiveCashIndex(),
              m_props.getHost(),
              getActiveCashSequence(),
              getActiveCashDateStart(),
              getActiveCashDateEnd()
            });
      } else {
        setActiveCash(sActiveCashIndex, (Integer) valcash[1], (Date) valcash[2], (Date) valcash[3]);
      }
    } catch (BasicException e) {
      // Casco. Sin caja no hay pos
      MessageInf msg =
          new MessageInf(
              MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotclosecash"), e);
      msg.show(this);
      session.close();
      return false;
    }

    // Leo la localizacion de la caja (Almacen).
    m_sInventoryLocation = m_propsdb.getProperty("location");
    if (m_sInventoryLocation == null) {
      m_sInventoryLocation = "0";
      m_propsdb.setProperty("location", m_sInventoryLocation);
      m_dlSystem.setResourceAsProperties(m_props.getHost() + "/properties", m_propsdb);
    }

    // Inicializo la impresora...
    m_TP = new DeviceTicket(this, m_props);

    // Inicializamos
    m_TTP = new TicketParser(getDeviceTicket(), m_dlSystem);
    printerStart();

    // Inicializamos la bascula
    m_Scale = new DeviceScale(this, m_props);

    // Inicializamos la scanpal
    m_Scanner = DeviceScannerFactory.createInstance(m_props);

    // Leemos los recursos basicos
    BufferedImage imgicon = m_dlSystem.getResourceAsImage("Window.Logo");
    m_jLblTitle.setIcon(imgicon == null ? null : new ImageIcon(imgicon));
    m_jLblTitle.setText(m_dlSystem.getResourceAsText("Window.Title"));

    String sWareHouse;
    try {
      sWareHouse = m_dlSystem.findLocationName(m_sInventoryLocation);
    } catch (BasicException e) {
      sWareHouse = null; // no he encontrado el almacen principal
    }

    // Show Hostname, Warehouse and URL in taskbar
    String url;
    try {
      url = session.getURL();
    } catch (SQLException e) {
      url = "";
    }
    m_jHost.setText("<html>" + m_props.getHost() + " - " + sWareHouse + "<br>" + url);

    showLogin();

    return true;
  }
Exemplo n.º 25
0
  /** Creates a new {@link HelpAboutPanel}. */
  public HelpAboutPanel(Controller controller, MultiBitFrame mainFrame) {
    setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR);
    this.controller = controller;

    String versionNumber = controller.getLocaliser().getVersionNumber();

    String versionText =
        controller
            .getLocaliser()
            .getString("helpAboutAction.versionText", new Object[] {versionNumber});

    GridBagConstraints constraints = new GridBagConstraints();
    setLayout(new GridBagLayout());

    ImageIcon imageIcon = ImageLoader.createImageIcon(SPLASH_ICON_FILE);
    JLabel splashLabel = new JLabel();
    splashLabel.setIcon(imageIcon);
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.weightx = 1;
    constraints.weighty = 0.4;
    constraints.anchor = GridBagConstraints.CENTER;
    add(splashLabel, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 1;
    constraints.weightx = 1;
    constraints.weighty = 0.1;
    constraints.anchor = GridBagConstraints.CENTER;
    JPanel fillerPanel1 = new JPanel();
    fillerPanel1.setOpaque(false);
    add(fillerPanel1, constraints);

    MultiBitLabel titleLabel = new MultiBitLabel("");
    titleLabel.setHorizontalTextPosition(JLabel.CENTER);
    titleLabel.setText(controller.getLocaliser().getString("helpAboutAction.messageBoxTitle"));

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.weightx = 1;
    constraints.weighty = 0.1;
    constraints.anchor = GridBagConstraints.CENTER;
    add(titleLabel, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.gridwidth = 1;
    constraints.weightx = 1;
    constraints.weighty = 0.1;
    constraints.anchor = GridBagConstraints.CENTER;
    MultiBitLabel urlLabel = new MultiBitLabel(MULTIBIT_URL);
    add(urlLabel, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 4;
    constraints.gridwidth = 1;
    constraints.weightx = 1;
    constraints.weighty = 0.1;
    constraints.anchor = GridBagConstraints.CENTER;
    MultiBitLabel versionLabel = new MultiBitLabel(versionText);
    add(versionLabel, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 5;
    constraints.gridwidth = 1;
    constraints.weightx = 1;
    constraints.weighty = 0.2;
    constraints.anchor = GridBagConstraints.CENTER;
    JPanel fillerPanel2 = new JPanel();
    fillerPanel2.setOpaque(false);
    add(fillerPanel2, constraints);

    applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
  }
Exemplo n.º 26
0
  private JPanel createInstructionsPanel(int stentWidth) {
    MultiBitTitledPanel instructionsPanel =
        new MultiBitTitledPanel(
            controller.getLocaliser().getString("verifyMessagePanel.instructions.title"),
            ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    GridBagConstraints constraints = new GridBagConstraints();

    MultiBitTitledPanel.addLeftJustifiedTextAtIndent(
        controller.getLocaliser().getString("verifyMessagePanel.instructions.text1"),
        3,
        instructionsPanel);

    MultiBitTitledPanel.addLeftJustifiedTextAtIndent(
        controller.getLocaliser().getString("verifyMessagePanel.instructions.text2"),
        4,
        instructionsPanel);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 1;
    constraints.gridy = 5;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    instructionsPanel.add(
        MultiBitTitledPanel.createStent(stentWidth, ExportPrivateKeysPanel.STENT_HEIGHT),
        constraints);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 2;
    constraints.gridy = 6;
    constraints.weightx = 0.05;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.CENTER;
    instructionsPanel.add(
        MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS),
        constraints);

    JPanel filler3 = new JPanel();
    filler3.setOpaque(false);
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 1;
    constraints.gridy = 8;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    instructionsPanel.add(filler3, constraints);

    addressLabel =
        new MultiBitLabel(controller.getLocaliser().getString("sendBitcoinPanel.addressLabel"));
    addressLabel.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 9;
    constraints.weightx = 0.3;
    constraints.weighty = 0.4;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    instructionsPanel.add(addressLabel, constraints);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 2;
    constraints.gridy = 9;
    constraints.weightx = 0.05;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.CENTER;
    instructionsPanel.add(
        MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS),
        constraints);

    // addressTextArea = new MultiBitTextField("", 30, controller);
    JTextField aTextField = new JTextField();
    addressTextArea = new MultiBitTextArea("", 1, 30, controller);
    addressTextArea.setBorder(aTextField.getBorder());

    addressTextArea.setMinimumSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    addressTextArea.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    addressTextArea.setMaximumSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    addressTextArea.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 3;
    constraints.gridy = 9;
    constraints.weightx = 0.3;
    constraints.weighty = 0.4;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    instructionsPanel.add(addressTextArea, constraints);

    JPanel filler4 = new JPanel();
    filler4.setOpaque(false);
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 1;
    constraints.gridy = 10;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    instructionsPanel.add(filler4, constraints);

    JTextField secondTextField = new JTextField();
    messageTextArea =
        new MultiBitTextArea(
            "", AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS + 1, 20, controller);
    messageTextArea.setBorder(secondTextField.getBorder());

    messageTextArea.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    final JScrollPane messageScrollPane =
        new JScrollPane(
            messageTextArea,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    messageScrollPane.setOpaque(true);
    messageScrollPane.setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR);
    messageScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    messageScrollPane
        .getViewport()
        .addChangeListener(
            new ChangeListener() {
              @Override
              public void stateChanged(ChangeEvent e) {
                if (messageScrollPane.getVerticalScrollBar().isVisible()) {
                  messageScrollPane.setBorder(
                      BorderFactory.createMatteBorder(1, 1, 1, 1, Color.LIGHT_GRAY));
                } else {
                  messageScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
                }
              }
            });
    messageScrollPane.setMinimumSize(
        new Dimension(
            FIELD_WIDTH,
            (AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS + 1) * FIELD_HEIGHT + 6));
    messageScrollPane.setPreferredSize(
        new Dimension(
            FIELD_WIDTH,
            (AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS + 1) * FIELD_HEIGHT + 6));
    messageScrollPane.getHorizontalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT);
    messageScrollPane.getVerticalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT);
    if (messageScrollPane.getVerticalScrollBar().isVisible()) {
      messageScrollPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.LIGHT_GRAY));
    } else {
      messageScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    }

    messageLabel =
        new MultiBitLabel(controller.getLocaliser().getString("verifyMessagePanel.message.text"));
    messageLabel.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 11;
    constraints.weightx = 0.3;
    constraints.weighty = 0.4;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    instructionsPanel.add(messageLabel, constraints);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 2;
    constraints.gridy = 11;
    constraints.weightx = 0.05;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.CENTER;
    instructionsPanel.add(
        MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS),
        constraints);

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 3;
    constraints.gridy = 11;
    constraints.weightx = 0.3;
    constraints.weighty = 0.4;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    instructionsPanel.add(messageScrollPane, constraints);

    JPanel filler5 = new JPanel();
    filler5.setOpaque(false);
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 1;
    constraints.gridy = 12;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    instructionsPanel.add(filler5, constraints);

    signatureLabel =
        new MultiBitLabel(controller.getLocaliser().getString("verifyMessagePanel.signature.text"));
    signatureLabel.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 13;
    constraints.weightx = 0.3;
    constraints.weighty = 0.4;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    instructionsPanel.add(signatureLabel, constraints);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 2;
    constraints.gridy = 13;
    constraints.weightx = 0.05;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.CENTER;
    instructionsPanel.add(
        MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS),
        constraints);

    JTextField anotherTextField = new JTextField();
    signatureTextArea = new MultiBitTextArea("", 2, 30, controller);
    signatureTextArea.setBorder(anotherTextField.getBorder());
    signatureTextArea.setMinimumSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT * 2));
    signatureTextArea.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT * 2));
    signatureTextArea.setMaximumSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT * 2));
    signatureTextArea.setLineWrap(true);
    signatureTextArea.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 3;
    constraints.gridy = 13;
    constraints.weightx = 0.3;
    constraints.weighty = 0.4;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    instructionsPanel.add(signatureTextArea, constraints);

    return instructionsPanel;
  }
Exemplo n.º 27
0
  private void initUI() {
    setLayout(new BorderLayout());

    JPanel mainPanel = new JPanel();
    mainPanel.setMinimumSize(new Dimension(800, 480));
    mainPanel.setLayout(new GridBagLayout());
    mainPanel.setOpaque(false);
    mainPanel.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    String[] keys =
        new String[] {
          "sendBitcoinPanel.addressLabel",
          "verifyMessagePanel.message.text",
          "verifyMessagePanel.signature.text"
        };

    int stentWidth =
        MultiBitTitledPanel.calculateStentWidthForKeys(controller.getLocaliser(), keys, this)
            + ExportPrivateKeysPanel.STENT_DELTA;

    GridBagConstraints constraints = new GridBagConstraints();

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 2;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    JPanel instructionsPanel = createInstructionsPanel(stentWidth);
    mainPanel.add(instructionsPanel, constraints);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1;
    constraints.weighty = 0.1;
    constraints.anchor = GridBagConstraints.CENTER;
    mainPanel.add(MultiBitTitledPanel.createStent(12, 12), constraints);

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.weightx = 0.4;
    constraints.weighty = 0.06;
    constraints.anchor = GridBagConstraints.LINE_START;
    JPanel buttonPanel = createButtonPanel();
    mainPanel.add(buttonPanel, constraints);

    messageLabel1 = new MultiBitLabel(" ");
    messageLabel1.setOpaque(false);
    messageLabel1.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0));
    messageLabel1.setHorizontalAlignment(JLabel.LEADING);
    messageLabel1.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.gridwidth = 3;
    constraints.weightx = 1;
    constraints.weighty = 0.06;
    constraints.anchor = GridBagConstraints.LINE_START;
    mainPanel.add(messageLabel1, constraints);

    messageLabel2 = new MultiBitLabel(" ");
    messageLabel2.setOpaque(false);
    messageLabel2.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0));
    messageLabel2.setHorizontalAlignment(JLabel.LEADING);
    messageLabel2.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 4;
    constraints.gridwidth = 3;
    constraints.weightx = 1;
    constraints.weighty = 0.06;
    constraints.anchor = GridBagConstraints.LINE_START;
    mainPanel.add(messageLabel2, constraints);

    Action helpAction;
    if (ComponentOrientation.LEFT_TO_RIGHT
        == ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())) {
      helpAction =
          new HelpContextAction(
              controller,
              ImageLoader.HELP_CONTENTS_BIG_ICON_FILE,
              "multiBitFrame.helpMenuText",
              "multiBitFrame.helpMenuTooltip",
              "multiBitFrame.helpMenuText",
              HelpContentsPanel.HELP_SIGN_AND_VERIFY_MESSAGE_URL);
    } else {
      helpAction =
          new HelpContextAction(
              controller,
              ImageLoader.HELP_CONTENTS_BIG_RTL_ICON_FILE,
              "multiBitFrame.helpMenuText",
              "multiBitFrame.helpMenuTooltip",
              "multiBitFrame.helpMenuText",
              HelpContentsPanel.HELP_SIGN_AND_VERIFY_MESSAGE_URL);
    }
    HelpButton helpButton = new HelpButton(helpAction, controller);
    helpButton.setText("");

    String tooltipText =
        HelpContentsPanel.createMultilineTooltipText(
            new String[] {controller.getLocaliser().getString("multiBitFrame.helpMenuTooltip")});
    helpButton.setToolTipText(tooltipText);
    helpButton.setHorizontalAlignment(SwingConstants.LEADING);
    helpButton.setBorder(
        BorderFactory.createEmptyBorder(
            0,
            AbstractTradePanel.HELP_BUTTON_INDENT,
            AbstractTradePanel.HELP_BUTTON_INDENT,
            AbstractTradePanel.HELP_BUTTON_INDENT));
    helpButton.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 5;
    constraints.weightx = 1;
    constraints.weighty = 0.1;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.BASELINE_LEADING;
    mainPanel.add(helpButton, constraints);

    JLabel filler2 = new JLabel();
    filler2.setOpaque(false);
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 0;
    constraints.gridy = 6;
    constraints.gridwidth = 1;
    constraints.weightx = 1;
    constraints.weighty = 100;
    constraints.anchor = GridBagConstraints.CENTER;
    mainPanel.add(filler2, constraints);

    JScrollPane mainScrollPane =
        new JScrollPane(
            mainPanel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    mainScrollPane.setBorder(BorderFactory.createEmptyBorder());
    mainScrollPane.getViewport().setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR);
    mainScrollPane.getViewport().setOpaque(true);
    mainScrollPane.applyComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    mainScrollPane.getHorizontalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT);
    mainScrollPane.getVerticalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT);

    add(mainScrollPane, BorderLayout.CENTER);
  }
Exemplo n.º 28
0
  @Override
  protected JPanel createFormPanel(JPanel formPanel, GridBagConstraints constraints) {
    formPanel.setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR);

    JPanel buttonPanel = new JPanel();
    FlowLayout flowLayout = new FlowLayout();
    flowLayout.setAlignment(FlowLayout.LEADING);
    buttonPanel.setLayout(flowLayout);

    formPanel.setLayout(new GridBagLayout());

    // create stents and forcers
    createFormPanelStentsAndForcers(formPanel, constraints);

    MultiBitLabel addressLabel =
        new MultiBitLabel(controller.getLocaliser().getString("sendBitcoinPanel.addressLabel"));
    addressLabel.setToolTipText(
        HelpContentsPanel.createTooltipText(
            controller.getLocaliser().getString("sendBitcoinPanel.addressLabel.tooltip")));
    addressLabel.setHorizontalAlignment(JLabel.TRAILING);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.weightx = 4.0;
    constraints.weighty = 0.2;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    formPanel.add(addressLabel, constraints);
    String receiveAddressText =
        controller.getLocaliser().getString("receiveBitcoinPanel.addressLabel");
    MultiBitLabel notUsedReceiveAddressLabel = new MultiBitLabel(receiveAddressText);
    formPanel.add(
        MultiBitTitledPanel.createStent(
            (int) notUsedReceiveAddressLabel.getPreferredSize().getWidth()),
        constraints);

    int longFieldWidth = fontMetrics.stringWidth(MultiBitFrame.EXAMPLE_LONG_FIELD_TEXT);
    addressTextField = new MultiBitTextField("", 24, controller);
    addressTextField.setHorizontalAlignment(JTextField.LEADING);
    addressTextField.setMinimumSize(
        new Dimension(
            longFieldWidth,
            getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight()
                + TEXTFIELD_VERTICAL_DELTA));
    addressTextField.setPreferredSize(
        new Dimension(
            longFieldWidth,
            getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight()
                + TEXTFIELD_VERTICAL_DELTA));
    addressTextField.setMaximumSize(
        new Dimension(
            longFieldWidth,
            getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight()
                + TEXTFIELD_VERTICAL_DELTA));

    addressTextField.addKeyListener(new QRCodeKeyListener());
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 2;
    constraints.gridy = 1;
    constraints.weightx = 1.0;
    constraints.weighty = 0.2;
    constraints.gridwidth = 3;
    constraints.anchor = GridBagConstraints.LINE_START;
    formPanel.add(addressTextField, constraints);

    ImageIcon copyIcon = ImageLoader.createImageIcon(ImageLoader.COPY_ICON_FILE);
    CopySendAddressAction copyAddressAction = new CopySendAddressAction(controller, this, copyIcon);
    MultiBitButton copyAddressButton = new MultiBitButton(copyAddressAction, controller);
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 6;
    constraints.gridy = 1;
    constraints.weightx = 1;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    formPanel.add(copyAddressButton, constraints);

    ImageIcon pasteIcon = ImageLoader.createImageIcon(ImageLoader.PASTE_ICON_FILE);
    PasteAddressAction pasteAddressAction =
        new PasteAddressAction(super.bitcoinController, this, pasteIcon);
    pasteAddressButton = new MultiBitButton(pasteAddressAction, controller);
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 8;
    constraints.gridy = 1;
    constraints.weightx = 10.0;
    constraints.weighty = 0.2;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    formPanel.add(pasteAddressButton, constraints);

    MultiBitLabel labelLabel =
        new MultiBitLabel(controller.getLocaliser().getString("sendBitcoinPanel.labelLabel"));
    labelLabel.setToolTipText(
        HelpContentsPanel.createTooltipText(
            controller.getLocaliser().getString("sendBitcoinPanel.labelLabel.tooltip")));
    labelLabel.setHorizontalAlignment(JLabel.TRAILING);
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.weightx = 0.1;
    constraints.weighty = 1.0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    formPanel.add(labelLabel, constraints);

    JTextField aTextField = new JTextField();
    labelTextArea =
        new MultiBitTextArea("", AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS, 20, controller);
    labelTextArea.setBorder(aTextField.getBorder());
    labelTextArea.addKeyListener(new QRCodeKeyListener());

    final JScrollPane labelScrollPane =
        new JScrollPane(
            labelTextArea,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    labelScrollPane.setOpaque(true);
    labelScrollPane.setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR);
    labelScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    labelScrollPane
        .getViewport()
        .addChangeListener(
            new ChangeListener() {
              @Override
              public void stateChanged(ChangeEvent e) {
                if (labelScrollPane.getVerticalScrollBar().isVisible()) {
                  labelScrollPane.setBorder(
                      BorderFactory.createMatteBorder(1, 1, 1, 1, Color.LIGHT_GRAY));
                } else {
                  labelScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
                }
              }
            });
    labelScrollPane.setMinimumSize(
        new Dimension(
            longFieldWidth,
            getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight()
                    * AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS
                + TEXTFIELD_VERTICAL_DELTA
                + 6));
    labelScrollPane.setPreferredSize(
        new Dimension(
            longFieldWidth,
            getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight()
                    * AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS
                + TEXTFIELD_VERTICAL_DELTA
                + 6));
    labelScrollPane.getHorizontalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT);
    labelScrollPane.getVerticalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT);

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 2;
    constraints.gridy = 3;
    constraints.weightx = 0.6;
    constraints.weighty = 1.0;
    constraints.gridwidth = 3;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    formPanel.add(labelScrollPane, constraints);

    MultiBitLabel amountLabel =
        new MultiBitLabel(controller.getLocaliser().getString("sendBitcoinPanel.amountLabel"));
    amountLabel.setToolTipText(
        HelpContentsPanel.createTooltipText(
            controller.getLocaliser().getString("sendBitcoinPanel.amountLabel.tooltip")));
    amountLabel.setHorizontalAlignment(JLabel.TRAILING);
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 5;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0.1;
    constraints.weighty = 0.20;
    constraints.anchor = GridBagConstraints.LINE_END;
    formPanel.add(amountLabel, constraints);

    JPanel amountPanel = createAmountPanel();
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 2;
    constraints.gridy = 5;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0.1;
    constraints.weighty = 0.20;
    constraints.anchor = GridBagConstraints.LINE_START;
    formPanel.add(amountPanel, constraints);

    notificationLabel = new MultiBitLabel("");
    notificationLabel.setForeground(Color.RED);
    // notificationLabel.setBorder(BorderFactory.createLineBorder(Color.GREEN));
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 2;
    constraints.gridy = 6;
    constraints.gridwidth = 8;
    constraints.gridheight = 3;
    constraints.weightx = 0.1;
    constraints.weighty = 0.1;
    constraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING;
    formPanel.add(notificationLabel, constraints);

    Action helpAction;
    if (ComponentOrientation.LEFT_TO_RIGHT
        == ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())) {
      helpAction =
          new HelpContextAction(
              controller,
              ImageLoader.HELP_CONTENTS_BIG_ICON_FILE,
              "multiBitFrame.helpMenuText",
              "multiBitFrame.helpMenuTooltip",
              "multiBitFrame.helpMenuText",
              HelpContentsPanel.HELP_SENDING_URL);
    } else {
      helpAction =
          new HelpContextAction(
              controller,
              ImageLoader.HELP_CONTENTS_BIG_RTL_ICON_FILE,
              "multiBitFrame.helpMenuText",
              "multiBitFrame.helpMenuTooltip",
              "multiBitFrame.helpMenuText",
              HelpContentsPanel.HELP_SENDING_URL);
    }
    HelpButton helpButton = new HelpButton(helpAction, controller);
    helpButton.setText("");

    String tooltipText =
        HelpContentsPanel.createMultilineTooltipText(
            new String[] {
              controller.getLocaliser().getString("sendBitcoinPanel.helpLabel1.message"),
              controller.getLocaliser().getString("sendBitcoinPanel.helpLabel2.message"),
              controller.getLocaliser().getString("sendBitcoinPanel.helpLabel3.message"),
              "\n",
              controller.getLocaliser().getString("multiBitFrame.helpMenuTooltip")
            });
    helpButton.setToolTipText(tooltipText);
    helpButton.setHorizontalAlignment(SwingConstants.LEADING);
    helpButton.setBorder(
        BorderFactory.createEmptyBorder(
            0, HELP_BUTTON_INDENT, HELP_BUTTON_INDENT, HELP_BUTTON_INDENT));
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 8;
    constraints.weightx = 1;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.BELOW_BASELINE_LEADING;
    formPanel.add(helpButton, constraints);

    sendBitcoinConfirmAction =
        new SendBitcoinConfirmAction(super.bitcoinController, mainFrame, this);
    sendBitcoinConfirmAction.setEnabled(enableSendButton);
    sendButton = new MultiBitButton(sendBitcoinConfirmAction, controller);
    if (enableSendButton) {
      sendButton.setEnabled(true);
      sendButton.setToolTipText(
          HelpContentsPanel.createTooltipText(
              controller.getLocaliser().getString("sendBitcoinAction.tooltip")));
    } else {
      sendButton.setEnabled(false);
      sendButton.setToolTipText(
          HelpContentsPanel.createTooltipText(
              controller.getLocaliser().getString("sendBitcoinAction.pleaseWait.tooltip")));
    }

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 6;
    constraints.gridy = 5;
    constraints.weightx = 0.1;
    constraints.weighty = 0.1;
    constraints.gridwidth = 3;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    formPanel.add(sendButton, constraints);

    Action sidePanelAction = new MoreOrLessAction(controller, this);
    sidePanelButton = new MultiBitButton(sidePanelAction, controller);
    sidePanelButton.setBorder(BorderFactory.createEmptyBorder());
    sidePanelButton.setBorderPainted(false);
    sidePanelButton.setFocusPainted(false);
    sidePanelButton.setContentAreaFilled(false);

    displaySidePanel();

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 4;
    constraints.gridy = 3;
    constraints.weightx = 0.1;
    constraints.weighty = 0.3;
    constraints.gridwidth = 7;
    constraints.gridheight = 3;
    constraints.anchor = GridBagConstraints.BASELINE_TRAILING;
    formPanel.add(sidePanelButton, constraints);

    return formPanel;
  }
Exemplo n.º 29
0
  /** Processes a change in the bound property RegistryBrowser.PROPERTY_LOCALE. */
  protected void processLocaleChange(Locale newLocale) {
    resourceBundle = JavaUIResourceBundle.getInstance();

    setLocale(newLocale);
    applyComponentOrientation(ComponentOrientation.getOrientation(newLocale));
  }