├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── bither_log.png ├── build.gradle ├── calc_addrs.cl ├── settings.gradle ├── splash.png ├── src └── main │ ├── java │ └── net │ │ └── bither │ │ ├── ApplicationDataDirectoryLocator.java │ │ ├── ApplicationInstanceManager.java │ │ ├── Bither.java │ │ ├── BitherInExecutableJar.java │ │ ├── BitherSetting.java │ │ ├── BitherUI.java │ │ ├── core │ │ └── CoreMessageKey.java │ │ ├── db │ │ ├── AbstractDBHelper.java │ │ ├── AddressDBHelper.java │ │ ├── AddressProvider.java │ │ ├── BlockProvider.java │ │ ├── DesktopDbImpl.java │ │ ├── HDAccountProvider.java │ │ ├── PeerProvider.java │ │ ├── TxDBHelper.java │ │ ├── TxHelper.java │ │ └── TxProvider.java │ │ ├── exception │ │ └── UIException.java │ │ ├── factory │ │ ├── ImportHDSeedDesktop.java │ │ ├── ImportListener.java │ │ ├── ImportPrivateKeyDesktop.java │ │ └── MonitorAddress.java │ │ ├── fonts │ │ ├── AwesomeDecorator.java │ │ ├── AwesomeIcon.java │ │ ├── AwesomeSwingIcon.java │ │ ├── MonospacedFont.java │ │ └── TitleFontDecorator.java │ │ ├── implbitherj │ │ ├── AddressNotificationCenter.java │ │ ├── BlockNotificationCenter.java │ │ ├── DesktopImplAbstractApp.java │ │ ├── NotificationDesktopImpl.java │ │ ├── PeerNotificationCenter.java │ │ └── TxNotificationCenter.java │ │ ├── languages │ │ ├── LanguageKey.java │ │ ├── Languages.java │ │ └── MessageKey.java │ │ ├── logging │ │ ├── AsyncAppender.java │ │ ├── LogFormatter.java │ │ ├── LogbackFactory.java │ │ ├── LoggingConfiguration.java │ │ ├── LoggingFactory.java │ │ ├── PrefixedExtendedThrowableProxyConverter.java │ │ └── PrefixedThrowableProxyConverter.java │ │ ├── message │ │ └── Message.java │ │ ├── mnemonic │ │ └── MnemonicCodeDesktop.java │ │ ├── model │ │ ├── AddressCheck.java │ │ ├── AddressTableModel.java │ │ ├── BlockTableModel.java │ │ ├── Check.java │ │ ├── CheckPrivateKeyTableModel.java │ │ ├── Market.java │ │ ├── OpenCLDevice.java │ │ ├── PeerTableModel.java │ │ ├── RCheckTableModel.java │ │ ├── Ticker.java │ │ └── TxTableModel.java │ │ ├── network │ │ ├── ReplayManager.java │ │ ├── ReplayManagerTimerTask.java │ │ └── ReplayTask.java │ │ ├── platform │ │ ├── GenericApplication.java │ │ ├── GenericApplicationFactory.java │ │ ├── GenericApplicationSpecification.java │ │ ├── builder │ │ │ ├── OSUtils.java │ │ │ ├── generic │ │ │ │ ├── DefaultApplication.java │ │ │ │ └── DefaultApplicationBuilder.java │ │ │ ├── linux │ │ │ │ └── LinuxApplicationBuilder.java │ │ │ ├── mac │ │ │ │ ├── AboutHandlerInvocationHandler.java │ │ │ │ ├── BaseMacInvocationHandler.java │ │ │ │ ├── BaseMacResponseInvocationHandler.java │ │ │ │ ├── MacApplication.java │ │ │ │ ├── MacApplicationBuilder.java │ │ │ │ ├── OpenURIHandlerInvocationHandler.java │ │ │ │ ├── PreferencesHandlerInvocationHandler.java │ │ │ │ ├── QuitHandlerInvocationHandler.java │ │ │ │ └── QuitResponseInvocationHandler.java │ │ │ ├── solaris │ │ │ │ └── SolarisApplicationBuilder.java │ │ │ ├── unix │ │ │ │ └── UnixApplicationBuilder.java │ │ │ └── win │ │ │ │ └── WindowsApplicationBuilder.java │ │ ├── handler │ │ │ ├── DefaultAboutHandler.java │ │ │ ├── DefaultOpenURIHandler.java │ │ │ ├── DefaultPreferencesHandler.java │ │ │ ├── DefaultQuitHandler.java │ │ │ ├── GenericAboutHandler.java │ │ │ ├── GenericHandler.java │ │ │ ├── GenericOpenURIHandler.java │ │ │ ├── GenericPreferencesHandler.java │ │ │ └── GenericQuitHandler.java │ │ └── listener │ │ │ ├── GenericAboutEvent.java │ │ │ ├── GenericAboutEventListener.java │ │ │ ├── GenericEvent.java │ │ │ ├── GenericEventListener.java │ │ │ ├── GenericOpenURIEvent.java │ │ │ ├── GenericOpenURIEventListener.java │ │ │ ├── GenericPreferencesEvent.java │ │ │ ├── GenericPreferencesEventListener.java │ │ │ ├── GenericQuitEvent.java │ │ │ ├── GenericQuitEventListener.java │ │ │ └── GenericQuitResponse.java │ │ ├── preference │ │ ├── PersistentCookieStore.java │ │ ├── SerializableCookie.java │ │ └── UserPreference.java │ │ ├── qrcode │ │ ├── DisplayBitherQRCodePanel.java │ │ ├── DisplayQRCodePanle.java │ │ ├── GenerateUnsignedTxPanel.java │ │ ├── HDMServerUnsignedQRCodeListener.java │ │ ├── HDMServerUnsignedQRCodePanel.java │ │ ├── IReadQRCode.java │ │ ├── IScanQRCode.java │ │ ├── QRCodeEncoderDecoder.java │ │ ├── QRCodeGenerator.java │ │ ├── ScanQRCodeDialog.form │ │ ├── ScanQRCodeDialog.java │ │ ├── ScanTransportQRCodeDialog.java │ │ ├── SelectQRCodePanel.java │ │ └── SelectTransportQRCodePanel.java │ │ ├── runnable │ │ ├── BaseRunnable.java │ │ ├── CheckRunnable.java │ │ ├── CommitTransactionThread.java │ │ ├── CompleteTransactionRunnable.java │ │ ├── DownloadSpvRunnable.java │ │ ├── RCheckRunnable.java │ │ └── RunnableListener.java │ │ ├── utils │ │ ├── BackupUtil.java │ │ ├── BitcoinURI.java │ │ ├── BitherTimer.java │ │ ├── BitherVanitygen.java │ │ ├── Bluetooth.java │ │ ├── CheckUtil.java │ │ ├── DateUtils.java │ │ ├── DocumentMaxLengthFilter.java │ │ ├── ExceptionUtil.java │ │ ├── ExchangeUtil.java │ │ ├── FileUtil.java │ │ ├── HDMHotAddDesktop.java │ │ ├── HDMKeychainRecoveryUtil.java │ │ ├── HDMResetServerPasswordUtil.java │ │ ├── HDMSingularDesktop.java │ │ ├── HtmlUtils.java │ │ ├── ImageLoader.java │ │ ├── InputParser.java │ │ ├── KeyUtil.java │ │ ├── Localiser.java │ │ ├── LocaliserUtils.java │ │ ├── LogUtil.java │ │ ├── MarketUtil.java │ │ ├── Numbers.java │ │ ├── PasswordStrengthUtil.java │ │ ├── PeerUtil.java │ │ ├── StringUtil.java │ │ ├── SystemUtil.java │ │ ├── UnitUtilWrapper.java │ │ ├── UpgradeUtil.java │ │ ├── ViewUtil.java │ │ ├── WalletUtils.java │ │ └── WhitespaceTrimmer.java │ │ ├── viewsystem │ │ ├── CoreController.java │ │ ├── MainFrame.java │ │ ├── MainFrameUI.java │ │ ├── TextBoxes.java │ │ ├── ViewFactory.java │ │ ├── WizardCardLayout.java │ │ ├── action │ │ │ ├── AbstractExitAction.java │ │ │ ├── CopyAction.java │ │ │ ├── ExitAction.java │ │ │ ├── MnemonicUtil.java │ │ │ ├── PasteAddressAction.java │ │ │ ├── ShowTransactionDetailsAction.java │ │ │ ├── TextTransfer.java │ │ │ └── WalletMouseListener.java │ │ ├── animations │ │ │ └── RotatingIcon.java │ │ ├── base │ │ │ ├── AccessibilityDecorator.java │ │ │ ├── BitherLabel.java │ │ │ ├── ButtonDecorator.java │ │ │ ├── Buttons.java │ │ │ ├── ColorAndFontConstants.java │ │ │ ├── DisplayHint.java │ │ │ ├── FontSizer.java │ │ │ ├── IProgress.java │ │ │ ├── Labels.java │ │ │ ├── Panels.java │ │ │ ├── RadioButtons.java │ │ │ ├── ViewEnum.java │ │ │ ├── ViewSystem.java │ │ │ ├── Viewable.java │ │ │ ├── browser │ │ │ │ ├── ActivatedHyperlinkListener.java │ │ │ │ └── Browser.java │ │ │ └── renderer │ │ │ │ ├── AddressImage.java │ │ │ │ ├── AddressRenderer.java │ │ │ │ ├── CheckImageRenderer.java │ │ │ │ ├── CurrencyCenterJustifiedRenderer.java │ │ │ │ ├── CurrencyCenterJustifiedWithRightBorderRenderer.java │ │ │ │ ├── DecimalAlignRenderer.java │ │ │ │ ├── ImageRenderer.java │ │ │ │ ├── LanguageComboBoxRenderer.java │ │ │ │ ├── LeadingJustifiedRenderer.java │ │ │ │ ├── SelectAddressImage.java │ │ │ │ ├── TrailingJustifiedDateRenderer.java │ │ │ │ ├── TrailingJustifiedNumericRenderer.java │ │ │ │ └── TrailingJustifiedStringRenderer.java │ │ ├── components │ │ │ ├── ComboBoxes.java │ │ │ ├── ImageDecorator.java │ │ │ ├── Images.java │ │ │ ├── ScrollBarUIDecorator.java │ │ │ ├── borders │ │ │ │ └── TextBubbleBorder.java │ │ │ └── text_fields │ │ │ │ └── FormattedDecimalField.java │ │ ├── dialogs │ │ │ ├── BitherDialog.java │ │ │ ├── DialogConfirmTask.form │ │ │ ├── DialogConfirmTask.java │ │ │ ├── DialogProgress.java │ │ │ ├── ImportBIP38PrivateTextDialog.form │ │ │ ├── ImportBIP38PrivateTextDialog.java │ │ │ ├── ImportPrivateTextDialog.form │ │ │ ├── ImportPrivateTextDialog.java │ │ │ ├── MessageDialog.form │ │ │ ├── MessageDialog.java │ │ │ ├── PanelDialog.form │ │ │ ├── PanelDialog.java │ │ │ ├── RCheckDialog.form │ │ │ ├── RCheckDialog.java │ │ │ ├── SignTxDialg.form │ │ │ ├── SignTxDialg.java │ │ │ ├── TxDetailsDialog.form │ │ │ └── TxDetailsDialog.java │ │ ├── froms │ │ │ ├── AboutPanel.java │ │ │ ├── AddAddressPanel.java │ │ │ ├── AddressDetailPanel.java │ │ │ ├── AdvancePanel.java │ │ │ ├── BlockPanel.java │ │ │ ├── ChangePasswordPanel.java │ │ │ ├── CheckPrivateKeyPanel.java │ │ │ ├── ColdDefaultPanel.java │ │ │ ├── ExchangePreferencePanel.java │ │ │ ├── ExportPrivateKeyPanel.java │ │ │ ├── HDAccountAddPanel.java │ │ │ ├── HDAccountSendPanel.java │ │ │ ├── HDMAddAddressPanel.java │ │ │ ├── HDMColdAccountForm.form │ │ │ ├── HDMColdAccountForm.java │ │ │ ├── HDMColdDetailPanel.java │ │ │ ├── HDMColdPanel.java │ │ │ ├── HDMHotPanel.java │ │ │ ├── HDMSeedPhrasPanel.java │ │ │ ├── HDMSingularSeedPanel.java │ │ │ ├── HdmKeychainAddHotPanel.java │ │ │ ├── IAddressForm.java │ │ │ ├── ImportPrivateKeyPanel.java │ │ │ ├── MenuBar.java │ │ │ ├── MorePanel.java │ │ │ ├── PasswordPanel.java │ │ │ ├── PeersPanel.java │ │ │ ├── PrivateTextPanel.java │ │ │ ├── RestoreWalletSeedPhrasePanel.java │ │ │ ├── SelectAddressPanel.java │ │ │ ├── SendBitcoinConfirmPanel.java │ │ │ ├── SendBitcoinPanel.java │ │ │ ├── SendHDMBitcoinPanel.java │ │ │ ├── ShowTransactionHeaderForm.form │ │ │ ├── ShowTransactionHeaderForm.java │ │ │ ├── ShowTransactionsForm.form │ │ │ ├── ShowTransactionsForm.java │ │ │ ├── ShowTxHeaderPanel.java │ │ │ ├── SignMessagePanel.java │ │ │ ├── SingleColdWalletFrom.form │ │ │ ├── SingleColdWalletFrom.java │ │ │ ├── SingleWalletForm.form │ │ │ ├── SingleWalletForm.java │ │ │ ├── UnSignTxPanel.java │ │ │ ├── VanityOptionPanel.java │ │ │ ├── VanitygenPanel.java │ │ │ ├── VerifyMessagePanel.java │ │ │ └── WizardPanel.java │ │ ├── listener │ │ │ ├── ICheckPasswordListener.java │ │ │ └── IDialogPasswordListener.java │ │ ├── panels │ │ │ ├── BackgroundPanel.java │ │ │ ├── LightBoxPanel.java │ │ │ ├── PanelDecorator.java │ │ │ ├── RoundedPanel.java │ │ │ └── WalletListPanel.java │ │ └── themes │ │ │ ├── BaseTheme.java │ │ │ ├── BootstrapTheme.java │ │ │ ├── DarkTheme.java │ │ │ ├── LightTheme.java │ │ │ ├── NimbusDecorator.java │ │ │ ├── Theme.java │ │ │ ├── ThemeKey.java │ │ │ ├── Themes.java │ │ │ └── painters │ │ │ ├── AbstractNamedRegionPainter.java │ │ │ ├── NamedButtonRegionPainter.java │ │ │ ├── NamedComboBoxArrowButtonPainter.java │ │ │ ├── NamedComboBoxPainter.java │ │ │ ├── NamedComboBoxTextFieldPainter.java │ │ │ ├── NamedProgressBarRegionPainter.java │ │ │ ├── NamedTabbedPaneTabAreaPainter.java │ │ │ └── NamedTabbedPaneTabPainter.java │ │ └── xrandom │ │ ├── HDAccountUEntropyDialog.java │ │ ├── HDMKeychainColdUEntropyDialog.java │ │ ├── HDMKeychainHotUEntropyDialog.java │ │ ├── IUEntropy.java │ │ ├── IUEntropySource.java │ │ ├── LinuxSecureRandom.java │ │ ├── PrivateKeyUEntropyDialog.java │ │ ├── SeedUtils.java │ │ ├── UEntropyCollector.java │ │ ├── UEntropyDialog.form │ │ ├── UEntropyDialog.java │ │ ├── URandom.java │ │ └── XRandom.java │ └── resources │ ├── fonts │ ├── Corben-Regular.ttf │ ├── DroidSansMono.ttf │ ├── FontAwesome-4.2.0.ttf │ └── OpenSans-Semibold.ttf │ ├── https │ └── bithertruststore.jks │ ├── images │ ├── accept.png │ ├── address_type_hd.png │ ├── address_type_hdm.png │ ├── address_type_private.png │ ├── address_type_watchonly.png │ ├── bither_icon.png │ ├── card_corner_bottom_left.png │ ├── card_corner_bottom_right.png │ ├── card_corner_top_left.png │ ├── card_corner_top_right.png │ ├── checkKey.png │ ├── check_failed.png │ ├── checking_progress_light.png │ ├── checkmark.png │ ├── circleProgress0.png │ ├── circleProgress1.png │ ├── circleProgress2.png │ ├── circleProgress3.png │ ├── circleProgress4.png │ ├── circleProgress5.png │ ├── pickaxe.png │ ├── scan_button_normal.png │ ├── shapeHexagon.png │ ├── shapePentagon.png │ ├── shapeSquare.png │ ├── shapeTriangle.png │ ├── sidePanelHide.png │ ├── sidePanelHideRTL.png │ ├── sidePanelShow.png │ ├── sidePanelShowRTL.png │ ├── singleWallet.png │ ├── smallExclamationMark.png │ ├── symbol_bits.png │ ├── symbol_bits_slim.png │ ├── symbol_bits_slim_black.png │ ├── symbol_btc.png │ ├── symbol_btc_slim.png │ ├── symbol_btc_slim_black.png │ ├── tick.png │ ├── transaction_icon_small.png │ ├── transactions.png │ ├── transactionsExport.png │ ├── xrandom_address_label_normal.png │ ├── yourWallets.png │ └── zoom.png │ ├── logback.xml │ ├── version.properties │ ├── viewer.properties │ ├── viewer_zh_CN.properties │ ├── viewer_zh_TW.properties │ └── wordlist │ └── english.txt └── vanitygen ├── .gitignore ├── linux ├── oclvanitygen └── vanitygen ├── mac ├── oclvanitygen └── vanitygen └── windows ├── oclvanitygen.exe ├── oclvanitygen64.exe ├── pthreadVC2.dll ├── vanitygen.exe └── vanitygen64.exe /.gitignore: -------------------------------------------------------------------------------- 1 | */target/* 2 | */bin/* 3 | */gen/* 4 | */.classpath 5 | */.settings/* 6 | */.idea/* 7 | .idea/* 8 | .gradle/* 9 | */classes/* 10 | *.iml 11 | *.class 12 | */build/* 13 | build/* 14 | gradle/wrapper/* 15 | gradlew* 16 | local.properties 17 | gradle.properties 18 | desktop/net.bither.ApplicationDataDirectoryLocator* 19 | out 20 | gradle 21 | JWrapperBuild 22 | jwrapperlib 23 | wrappers 24 | gu_version 25 | JWrapperLaunchTemp 26 | LastExtractedJWrapperVersion 27 | jwrapper*.jar 28 | desktop/.gradle 29 | hs_err_pid10974.log 30 | jwrapper*.xml 31 | *.log 32 | release*.sh 33 | *.o 34 | *.oclbin 35 | /Makefile~ 36 | JRE-1.* 37 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "bitherj"] 2 | path = bitherj 3 | url = git@github.com:bither/bitherj.git 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bither-desktop-java 2 | Bither for desktop OS (Windows, Linux, MacOS and so on) 3 | 4 | *Issue is closed because of scammers* 5 | 6 | *Please contact [support@bither.net](mailto:support@bither.net) for support* 7 | -------------------------------------------------------------------------------- /bither_log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/bither_log.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'bither-desktop' 2 | 3 | 4 | 5 | include 'bitherj/bitherj' 6 | -------------------------------------------------------------------------------- /splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/splash.png -------------------------------------------------------------------------------- /src/main/java/net/bither/BitherInExecutableJar.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * 4 | * * Copyright 2014 http://Bither.net 5 | * * 6 | * * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * * you may not use this file except in compliance with the License. 8 | * * You may obtain a copy of the License at 9 | * * 10 | * * http://www.apache.org/licenses/LICENSE-2.0 11 | * * 12 | * * Unless required by applicable law or agreed to in writing, software 13 | * * distributed under the License is distributed on an "AS IS" BASIS, 14 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * * See the License for the specific language governing permissions and 16 | * * limitations under the License. 17 | * 18 | */ 19 | 20 | package net.bither; 21 | 22 | public final class BitherInExecutableJar { 23 | 24 | public static void main(String args[]) { 25 | Bither.main(args); 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/bither/db/DesktopDbImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 http://Bither.net 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.bither.db; 18 | 19 | import net.bither.bitherj.db.*; 20 | 21 | public class DesktopDbImpl extends AbstractDb { 22 | @Override 23 | public IBlockProvider initBlockProvider() { 24 | return BlockProvider.getInstance(); 25 | } 26 | 27 | @Override 28 | public IPeerProvider initPeerProvider() { 29 | return PeerProvider.getInstance(); 30 | } 31 | 32 | @Override 33 | public ITxProvider initTxProvider() { 34 | return TxProvider.getInstance(); 35 | } 36 | 37 | @Override 38 | public IAddressProvider initAddressProvider() { 39 | return AddressProvider.getInstance(); 40 | } 41 | 42 | @Override 43 | public IHDAccountProvider initHDAccountProvider() { 44 | return HDAccountProvider.getInstance(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/net/bither/exception/UIException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.exception; 20 | 21 | /** 22 | *

Runtime exception to provide the following to the UI:

23 | * 26 | * 27 | * @since 0.0.1 28 | *   29 | */ 30 | public class UIException extends RuntimeException { 31 | 32 | public UIException(Throwable cause) { 33 | super(cause.getMessage(), cause); 34 | } 35 | 36 | public UIException(String message, Throwable cause) { 37 | super(message, cause); 38 | } 39 | 40 | public UIException(String message) { 41 | super(message); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/bither/factory/ImportListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.factory; 20 | 21 | public interface ImportListener { 22 | public void importSuccess(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/bither/fonts/MonospacedFont.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.fonts; 20 | 21 | import com.google.common.base.Preconditions; 22 | import net.bither.exception.UIException; 23 | 24 | import java.awt.*; 25 | import java.io.InputStream; 26 | 27 | /** 28 | * Created by songchenwen on 14/12/18. 29 | */ 30 | public class MonospacedFont { 31 | private static Font F; 32 | 33 | static { 34 | 35 | try { 36 | InputStream in = AwesomeDecorator.class.getResourceAsStream("/fonts/DroidSansMono.ttf"); 37 | F = Font.createFont(Font.TRUETYPE_FONT, in); 38 | 39 | Preconditions.checkNotNull(F, "Font Awesome not loaded"); 40 | 41 | } catch (Exception e) { 42 | throw new UIException(e); 43 | } 44 | } 45 | 46 | public static Font instance() { 47 | return F; 48 | } 49 | 50 | public static Font fontWithSize(float size) { 51 | return F.deriveFont(size); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/net/bither/implbitherj/AddressNotificationCenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.implbitherj; 20 | 21 | import javax.swing.*; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | public class AddressNotificationCenter { 26 | public interface IAddressListener { 27 | public void addressLoadComplete(); 28 | } 29 | 30 | private static List addressListenerList = new ArrayList(); 31 | 32 | public static void notificationAddressLoadComplete() { 33 | SwingUtilities.invokeLater(new Runnable() { 34 | @Override 35 | public void run() { 36 | for (IAddressListener addressListener : addressListenerList) { 37 | addressListener.addressLoadComplete(); 38 | } 39 | } 40 | }); 41 | 42 | } 43 | 44 | public static void addAddressListener(IAddressListener addressListener) { 45 | if (!addressListenerList.contains(addressListener)) { 46 | addressListenerList.add(addressListener); 47 | } 48 | } 49 | 50 | public static void removeAddressListener(IAddressListener addressListener) { 51 | addressListenerList.remove(addressListener); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/net/bither/implbitherj/BlockNotificationCenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.implbitherj; 20 | 21 | import javax.swing.*; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | public class BlockNotificationCenter { 26 | public interface IBlockListener { 27 | public void blockChange(); 28 | } 29 | 30 | private static List blockChangeList = new ArrayList(); 31 | 32 | public static void notificationBlockChange() { 33 | SwingUtilities.invokeLater(new Runnable() { 34 | @Override 35 | public void run() { 36 | for (IBlockListener blockChange : blockChangeList) { 37 | blockChange.blockChange(); 38 | } 39 | } 40 | }); 41 | 42 | } 43 | 44 | public static void addBlockChange(IBlockListener blockChange) { 45 | if (!blockChangeList.contains(blockChange)) { 46 | blockChangeList.add(blockChange); 47 | } 48 | } 49 | 50 | public static void removeBlockChange(IBlockListener blockChange) { 51 | blockChangeList.remove(blockChange); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/net/bither/logging/LogFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.logging; 20 | 21 | import ch.qos.logback.classic.LoggerContext; 22 | import ch.qos.logback.classic.PatternLayout; 23 | 24 | import java.util.TimeZone; 25 | 26 | /** 27 | *

Pattern to provide the following to logging framework:

28 | *
    29 | *
  • Log entry format
  • 30 | *
31 | * 32 | * @since 0.0.1 33 | *   34 | */ 35 | public class LogFormatter extends PatternLayout { 36 | 37 | public LogFormatter(LoggerContext context, TimeZone timeZone) { 38 | super(); 39 | setOutputPatternAsHeader(false); 40 | getDefaultConverterMap().put("ex", PrefixedThrowableProxyConverter.class.getName()); 41 | getDefaultConverterMap().put("xEx", PrefixedExtendedThrowableProxyConverter.class.getName()); 42 | // This pattern allows time, log level then thread to be quickly located making unusual 43 | // activity such as WARN and ERROR stand out 44 | setPattern("[%d{ISO8601," + timeZone.getID() + "}] %-5level [%thread] %logger{16} - %msg %xEx%n"); 45 | setContext(context); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/net/bither/logging/PrefixedExtendedThrowableProxyConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.logging; 20 | 21 | import ch.qos.logback.classic.spi.StackTraceElementProxy; 22 | import ch.qos.logback.classic.spi.ThrowableProxyUtil; 23 | 24 | /** 25 | *

Converter to provide the following to logging framework:

26 | *
    27 | *
  • Additional information for Throwables
  • 28 | *
29 | * 30 | * @since 0.0.1 31 | *   32 | */ 33 | public class PrefixedExtendedThrowableProxyConverter extends PrefixedThrowableProxyConverter { 34 | 35 | @Override 36 | protected void extraData(StringBuilder builder, StackTraceElementProxy step) { 37 | if (step != null) { 38 | ThrowableProxyUtil.subjoinPackagingData(builder, step); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/net/bither/mnemonic/MnemonicCodeDesktop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * Copyright 2014 http://Bither.net 4 | * * 5 | * * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * * you may not use this file except in compliance with the License. 7 | * * You may obtain a copy of the License at 8 | * * 9 | * * http://www.apache.org/licenses/LICENSE-2.0 10 | * * 11 | * * Unless required by applicable law or agreed to in writing, software 12 | * * distributed under the License is distributed on an "AS IS" BASIS, 13 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * * See the License for the specific language governing permissions and 15 | * * limitations under the License. 16 | * 17 | */ 18 | 19 | package net.bither.mnemonic; 20 | 21 | import net.bither.bitherj.crypto.mnemonic.MnemonicCode; 22 | 23 | import java.io.IOException; 24 | import java.io.InputStream; 25 | 26 | public class MnemonicCodeDesktop extends MnemonicCode { 27 | private static final String WORDLIST_FILE = "/wordlist/english.txt"; 28 | 29 | public MnemonicCodeDesktop() throws IOException { 30 | super(); 31 | } 32 | 33 | @Override 34 | protected InputStream openWordList() throws IOException { 35 | return MnemonicCodeDesktop.class.getResourceAsStream(WORDLIST_FILE); 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/net/bither/model/AddressCheck.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.model; 20 | 21 | import net.bither.bitherj.core.Address; 22 | 23 | public class AddressCheck { 24 | public enum CheckStatus { 25 | Prepare, Success, Failed 26 | 27 | } 28 | 29 | public enum CheckType { 30 | Address, HDMKeyChain, HDAccount 31 | } 32 | 33 | private Address address; 34 | private CheckStatus checkStatus; 35 | 36 | private String dispalyName; 37 | private CheckType checkType; 38 | 39 | public AddressCheck(Address address, CheckStatus checkStatus) { 40 | this.address = address; 41 | this.checkStatus = checkStatus; 42 | this.dispalyName = address.getAddress(); 43 | this.checkType = CheckType.Address; 44 | 45 | } 46 | 47 | public AddressCheck(CheckType checkType, String dispalyName, CheckStatus checkStatus) { 48 | this.dispalyName = dispalyName; 49 | this.checkStatus = checkStatus; 50 | this.checkType = checkType; 51 | } 52 | 53 | public CheckStatus getCheckStatus() { 54 | return checkStatus; 55 | } 56 | 57 | public void setCheckStatus(CheckStatus checkStatus) { 58 | this.checkStatus = checkStatus; 59 | } 60 | 61 | 62 | public Address getAddress() { 63 | return address; 64 | } 65 | 66 | public void setAddress(Address address) { 67 | this.address = address; 68 | } 69 | 70 | public String getDispalyName() { 71 | return dispalyName; 72 | } 73 | 74 | public CheckType getCheckType() { 75 | return this.checkType; 76 | } 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/net/bither/model/AddressTableModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.model; 20 | 21 | import net.bither.bitherj.core.Address; 22 | import net.bither.bitherj.core.HDAccount; 23 | import net.bither.bitherj.utils.Utils; 24 | import net.bither.utils.LocaliserUtils; 25 | 26 | import javax.swing.table.AbstractTableModel; 27 | import java.util.List; 28 | 29 | public class AddressTableModel extends AbstractTableModel { 30 | 31 | private List
addressList; 32 | private String selectAddress; 33 | 34 | public AddressTableModel(List
addressList, String selectAddress) { 35 | this.addressList = addressList; 36 | this.selectAddress = selectAddress; 37 | } 38 | 39 | @Override 40 | public int getRowCount() { 41 | return this.addressList.size(); 42 | } 43 | 44 | @Override 45 | public Object getValueAt(int i, int i2) { 46 | Address address = this.addressList.get(i); 47 | switch (i2) { 48 | case 0: 49 | if (address instanceof HDAccount) { 50 | return LocaliserUtils.getString("add_hd_account_tab_hd"); 51 | } 52 | return address.getAddress(); 53 | case 1: 54 | 55 | return address.hasPrivKey(); 56 | case 2: 57 | return Utils.compareString(address.getAddress(), selectAddress); 58 | 59 | } 60 | 61 | return ""; 62 | } 63 | 64 | 65 | @Override 66 | public int getColumnCount() { 67 | return 3; 68 | } 69 | 70 | @Override 71 | public String getColumnName(int column) { 72 | return ""; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/net/bither/model/BlockTableModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.model; 20 | 21 | import net.bither.bitherj.core.Block; 22 | import net.bither.bitherj.utils.Utils; 23 | import net.bither.utils.DateUtils; 24 | import net.bither.utils.WalletUtils; 25 | 26 | import javax.swing.table.AbstractTableModel; 27 | import java.util.Date; 28 | import java.util.List; 29 | 30 | public class BlockTableModel extends AbstractTableModel { 31 | 32 | private List blockList; 33 | 34 | public BlockTableModel(List blocks) { 35 | this.blockList = blocks; 36 | 37 | } 38 | 39 | @Override 40 | public int getRowCount() { 41 | return this.blockList.size(); 42 | } 43 | 44 | @Override 45 | public Object getValueAt(int i, int i2) { 46 | Block block = this.blockList.get(i); 47 | switch (i2) { 48 | case 0: 49 | return Integer.toString(block.getBlockNo()); 50 | case 1: 51 | final long timeMs = block.getBlockTime() 52 | * DateUtils.SECOND_IN_MILLIS; 53 | return DateUtils.dateToRelativeTime(new Date(timeMs)); 54 | 55 | case 2: 56 | return WalletUtils.formatHash( 57 | Utils.bytesToHexString(Utils.reverseBytes(block.getBlockHash())), 8, 0, ' '); 58 | } 59 | 60 | 61 | return ""; 62 | } 63 | 64 | 65 | @Override 66 | public int getColumnCount() { 67 | return 3; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/net/bither/model/CheckPrivateKeyTableModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.model; 20 | 21 | import net.bither.utils.LocaliserUtils; 22 | 23 | import javax.swing.table.AbstractTableModel; 24 | import java.util.List; 25 | 26 | public class CheckPrivateKeyTableModel extends AbstractTableModel { 27 | private List addressCheckList; 28 | 29 | public CheckPrivateKeyTableModel(List addressCheckList) { 30 | this.addressCheckList = addressCheckList; 31 | 32 | } 33 | 34 | @Override 35 | public int getRowCount() { 36 | return this.addressCheckList.size(); 37 | } 38 | 39 | @Override 40 | public Object getValueAt(int i, int i2) { 41 | AddressCheck addressCheck = this.addressCheckList.get(i); 42 | switch (i2) { 43 | case 0: 44 | return addressCheck.getDispalyName(); 45 | case 1: 46 | return addressCheck.getCheckStatus(); 47 | } 48 | 49 | 50 | return ""; 51 | } 52 | 53 | 54 | @Override 55 | public int getColumnCount() { 56 | return 2; 57 | } 58 | 59 | @Override 60 | public String getColumnName(int column) { 61 | if (column == 0) { 62 | return LocaliserUtils.getString("address"); 63 | } else if (column == 1) { 64 | return LocaliserUtils.getString("tx_status_text"); 65 | } 66 | return ""; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/net/bither/model/OpenCLDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.model; 20 | 21 | /** 22 | * Created by songchenwen on 15/3/27. 23 | */ 24 | public class OpenCLDevice { 25 | 26 | private final String AMD_DEVICE = "amd"; 27 | private final String NVIDIA_DEVICE = "nvidia"; 28 | private int platform; 29 | private int device; 30 | private long keyPerSecond; 31 | private String platformName; 32 | private String deviceName; 33 | 34 | public OpenCLDevice(int platform, int device, String platformName, String deviceName) { 35 | this.platform = platform; 36 | this.device = device; 37 | this.platformName = platformName; 38 | this.deviceName = deviceName; 39 | } 40 | 41 | public int getPlatform() { 42 | return platform; 43 | } 44 | 45 | public int getDevice() { 46 | return device; 47 | } 48 | 49 | public String getPlatformName() { 50 | return platformName; 51 | } 52 | 53 | public String getDeviceName() { 54 | return deviceName; 55 | } 56 | 57 | public String getConfigureString() { 58 | return "" + platform + ":" + device; 59 | } 60 | 61 | public void setKeyPerSecond(long keyPerSecond) { 62 | this.keyPerSecond = keyPerSecond; 63 | } 64 | 65 | public long getKeyPerSecond() { 66 | return keyPerSecond; 67 | } 68 | 69 | public boolean isGPU() { 70 | String deviceLowerName = this.deviceName.toLowerCase(); 71 | if (deviceLowerName.contains(AMD_DEVICE)) { 72 | return true; 73 | } 74 | if (deviceLowerName.contains(NVIDIA_DEVICE)) { 75 | return true; 76 | } 77 | return false; 78 | } 79 | 80 | @Override 81 | public boolean equals(Object obj) { 82 | if (obj instanceof OpenCLDevice) { 83 | OpenCLDevice o = (OpenCLDevice) obj; 84 | return o.getDevice() == getDevice() && o.getPlatform() == getPlatform(); 85 | } 86 | return false; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/net/bither/model/PeerTableModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.model; 20 | 21 | import net.bither.bitherj.core.Peer; 22 | import net.bither.bitherj.utils.Utils; 23 | import net.bither.utils.LocaliserUtils; 24 | 25 | import javax.swing.table.AbstractTableModel; 26 | import java.net.InetAddress; 27 | import java.util.List; 28 | import java.util.Map; 29 | import java.util.WeakHashMap; 30 | 31 | public class PeerTableModel extends AbstractTableModel { 32 | private final Map hostnames = new WeakHashMap(); 33 | 34 | private List peerList; 35 | 36 | public PeerTableModel(List peers) { 37 | this.peerList = peers; 38 | 39 | } 40 | 41 | @Override 42 | public int getRowCount() { 43 | return this.peerList.size(); 44 | } 45 | 46 | @Override 47 | public Object getValueAt(int i, int i2) { 48 | Peer peer = this.peerList.get(i); 49 | switch (i2) { 50 | case 0: 51 | final InetAddress address = peer.getAddress().getAddr(); 52 | final String hostname = hostnames.get(address); 53 | return hostname != null ? hostname : address 54 | .getHostAddress(); 55 | case 1: 56 | final long bestHeight = peer.getDisplayLastBlockHeight(); 57 | return bestHeight > 0 ? bestHeight + " blocks" 58 | : null; 59 | 60 | case 2: 61 | return peer.getSubVersion(); 62 | case 3: 63 | return "protocol: " + peer.getClientVersion(); 64 | case 4: 65 | final long pingTime = peer.pingTime; 66 | return pingTime < Long.MAX_VALUE ? Utils.format(LocaliserUtils.getString("peer_list_row_ping_time"), pingTime) : null; 67 | } 68 | 69 | 70 | return ""; 71 | } 72 | 73 | 74 | @Override 75 | public int getColumnCount() { 76 | return 5; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/net/bither/model/RCheckTableModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.model; 20 | 21 | import net.bither.bitherj.core.AddressManager; 22 | 23 | import javax.swing.table.AbstractTableModel; 24 | import java.util.List; 25 | 26 | /** 27 | * Created by nn on 14/11/28. 28 | */ 29 | public class RCheckTableModel extends AbstractTableModel { 30 | private List addressCheckList; 31 | 32 | public RCheckTableModel(List addressCheckList) { 33 | this.addressCheckList = addressCheckList; 34 | 35 | } 36 | 37 | @Override 38 | public int getRowCount() { 39 | return AddressManager.getInstance().getPrivKeyAddresses().size(); 40 | } 41 | 42 | @Override 43 | public Object getValueAt(int i, int i2) { 44 | AddressCheck addressCheck = this.addressCheckList.get(i); 45 | switch (i2) { 46 | case 0: 47 | return addressCheck.getDispalyName(); 48 | case 1: 49 | return addressCheck.getCheckStatus(); 50 | } 51 | 52 | 53 | return ""; 54 | } 55 | 56 | 57 | @Override 58 | public int getColumnCount() { 59 | return 2; 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/GenericApplication.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform; 17 | 18 | /** 19 | *

Interface to provide the following to applications:

20 | *
    21 | *
  • Provision of simple platform identification methods
  • 22 | *
23 | * 24 | * @since 0.3.0 25 | *   26 | */ 27 | public interface GenericApplication { 28 | 29 | /** 30 | * @return True if the application is running on a Mac AND the Apple Extensions API classes are available. 31 | */ 32 | boolean isMac(); 33 | 34 | /** 35 | * @return True if the application is running on a Mac AND the Linux Extensions API classes are available. 36 | */ 37 | boolean isLinux(); 38 | 39 | /** 40 | * @return True if the application is running on a Windows machine AND the Windows Extensions API classes are available. 41 | */ 42 | boolean isWindows(); 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/GenericApplicationSpecification.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform; 17 | 18 | import net.bither.platform.listener.GenericAboutEventListener; 19 | import net.bither.platform.listener.GenericOpenURIEventListener; 20 | import net.bither.platform.listener.GenericPreferencesEventListener; 21 | import net.bither.platform.listener.GenericQuitEventListener; 22 | 23 | import java.util.HashSet; 24 | import java.util.Set; 25 | 26 | /** 27 | *

Specification value object to provide the following to {@link GenericApplicationFactory}:

28 | *
    29 | *
  • Provision of required references to external objects
  • 30 | *
31 | * 32 | * @since 0.3.0 33 | *   34 | */ 35 | public class GenericApplicationSpecification { 36 | 37 | private Set openURIEventListeners = new HashSet(); 38 | private Set preferencesEventListeners = new HashSet(); 39 | private Set aboutEventListeners = new HashSet(); 40 | private Set quitEventListeners = new HashSet(); 41 | 42 | public Set getOpenURIEventListeners() { 43 | return openURIEventListeners; 44 | } 45 | 46 | public Set getPreferencesEventListeners() { 47 | return preferencesEventListeners; 48 | } 49 | 50 | public Set getAboutEventListeners() { 51 | return aboutEventListeners; 52 | } 53 | 54 | public Set getQuitEventListeners() { 55 | return quitEventListeners; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/OSUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder; 17 | 18 | /** 19 | *

Utilities to provide the following to {@link net.bither.platform.GenericApplicationFactory}:

20 | *
    21 | *
  • Detection of operating system
  • 22 | *
23 | * 24 | * @since 0.2.0 25 | *   26 | */ 27 | public final class OSUtils { 28 | 29 | /** 30 | * Utility class should not have a public constructor 31 | */ 32 | private OSUtils() { 33 | } 34 | 35 | public static String getOsName() { 36 | return System.getProperty("os.name", "unknown"); 37 | } 38 | 39 | public static String platform() { 40 | String osName = System.getProperty("os.name", "generic").toLowerCase(); 41 | if (osName.startsWith("windows")) { 42 | return "win32"; 43 | } else if (osName.startsWith("linux")) { 44 | return "linux"; 45 | } else if (osName.startsWith("sunos")) { 46 | return "solaris"; 47 | } else if (osName.startsWith("mac") || osName.startsWith("darwin")) { 48 | return "mac"; 49 | } else return "generic"; 50 | } 51 | 52 | public static boolean isWindows() { 53 | return (getOsName().toLowerCase().contains("windows")); 54 | } 55 | 56 | public static boolean isLinux() { 57 | return getOsName().toLowerCase().contains("linux"); 58 | } 59 | 60 | public static boolean isUnix() { 61 | final String os = getOsName().toLowerCase(); 62 | 63 | // XXX: this obviously needs some more work to be "true" in general (see bottom of file) 64 | if ((os.contains("sunos")) || (os.contains("linux"))) { 65 | return true; 66 | } 67 | 68 | if (isMac() && (System.getProperty("os.version", "").startsWith("10."))) { 69 | return true; 70 | } 71 | 72 | return false; 73 | } 74 | 75 | public static boolean isMac() { 76 | final String os = getOsName().toLowerCase(); 77 | return os.startsWith("mac") || os.startsWith("darwin"); 78 | } 79 | 80 | public static boolean isSolaris() { 81 | final String os = getOsName().toLowerCase(); 82 | return os.contains("sunos"); 83 | } 84 | 85 | } -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/generic/DefaultApplication.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder.generic; 17 | 18 | import net.bither.platform.GenericApplication; 19 | 20 | /** 21 | *

GenericApplication to provide the following to {@link net.bither.platform.GenericApplicationFactory}:

22 | *
    23 | *
  • Provision of methods for the given platform
  • 24 | *
25 | * 26 | * @since 0.3.0 27 | *   28 | */ 29 | public class DefaultApplication implements GenericApplication { 30 | 31 | @Override 32 | public boolean isMac() { 33 | return false; 34 | } 35 | 36 | @Override 37 | public boolean isLinux() { 38 | return false; 39 | } 40 | 41 | @Override 42 | public boolean isWindows() { 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/generic/DefaultApplicationBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder.generic; 17 | 18 | import net.bither.platform.GenericApplicationSpecification; 19 | 20 | /** 21 | *

Builder to provide the following to {@link net.bither.platform.GenericApplicationFactory}:

22 | *
    23 | *
  • Builds a particular variant of the {@link net.bither.platform.GenericApplication} suitable for the current platform
  • 24 | *
25 | * 26 | * @since 0.2.0 27 | *   28 | */ 29 | public class DefaultApplicationBuilder { 30 | public DefaultApplication build(GenericApplicationSpecification specification) { 31 | return new DefaultApplication(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/linux/LinuxApplicationBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder.linux; 17 | 18 | import net.bither.platform.GenericApplicationSpecification; 19 | import net.bither.platform.builder.generic.DefaultApplication; 20 | 21 | /** 22 | *

Builder to provide the following to {@link net.bither.platform.GenericApplicationFactory}:

23 | *
    24 | *
  • Builds a particular variant of the {@link net.bither.platform.GenericApplication} suitable for the current platform
  • 25 | *
26 | * 27 | * @since 0.2.0 28 | *   29 | */ 30 | public class LinuxApplicationBuilder { 31 | 32 | public DefaultApplication build(GenericApplicationSpecification specification) { 33 | return new DefaultApplication(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/mac/AboutHandlerInvocationHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder.mac; 17 | 18 | import net.bither.platform.handler.GenericAboutHandler; 19 | import net.bither.platform.listener.GenericAboutEvent; 20 | 21 | /** 22 | *

Implementation of invocation handler for About event

23 | */ 24 | public class AboutHandlerInvocationHandler extends BaseMacInvocationHandler { 25 | 26 | AboutHandlerInvocationHandler(GenericAboutHandler genericHandler, Class genericEventClass) { 27 | super(genericHandler, genericEventClass); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/mac/OpenURIHandlerInvocationHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder.mac; 17 | 18 | import net.bither.platform.handler.GenericOpenURIHandler; 19 | import net.bither.platform.listener.GenericOpenURIEvent; 20 | 21 | /** 22 | *

Implementation of invocation handler for OpenURI

23 | */ 24 | public class OpenURIHandlerInvocationHandler extends BaseMacInvocationHandler { 25 | 26 | OpenURIHandlerInvocationHandler(GenericOpenURIHandler genericHandler, Class genericEventClass) { 27 | super(genericHandler, genericEventClass); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/mac/PreferencesHandlerInvocationHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder.mac; 17 | 18 | import net.bither.platform.handler.GenericPreferencesHandler; 19 | import net.bither.platform.listener.GenericPreferencesEvent; 20 | 21 | /** 22 | *

Implementation of invocation handler for Preferences

23 | */ 24 | public class PreferencesHandlerInvocationHandler extends BaseMacInvocationHandler { 25 | 26 | PreferencesHandlerInvocationHandler(GenericPreferencesHandler genericHandler, Class genericEventClass) { 27 | super(genericHandler, genericEventClass); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/mac/QuitHandlerInvocationHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder.mac; 17 | 18 | import net.bither.platform.handler.GenericQuitHandler; 19 | import net.bither.platform.listener.GenericQuitEvent; 20 | import net.bither.platform.listener.GenericQuitResponse; 21 | 22 | /** 23 | *

Implementation of invocation handler for Quit

24 | */ 25 | public class QuitHandlerInvocationHandler extends BaseMacResponseInvocationHandler { 26 | 27 | QuitHandlerInvocationHandler(GenericQuitHandler genericHandler, Class genericEventClass, Class genericResponseClass) { 28 | super(genericHandler, genericEventClass, genericResponseClass); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/mac/QuitResponseInvocationHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder.mac; 17 | 18 | import net.bither.platform.handler.GenericQuitHandler; 19 | import net.bither.platform.listener.GenericQuitResponse; 20 | 21 | /** 22 | *

Implementation of invocation handler for Quit response

23 | */ 24 | public class QuitResponseInvocationHandler extends BaseMacInvocationHandler { 25 | 26 | QuitResponseInvocationHandler(GenericQuitHandler genericHandler, Class genericEventClass) { 27 | super(genericHandler, genericEventClass); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/solaris/SolarisApplicationBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder.solaris; 17 | 18 | import net.bither.platform.GenericApplicationSpecification; 19 | import net.bither.platform.builder.generic.DefaultApplication; 20 | 21 | /** 22 | *

Builder to provide the following to {@link net.bither.platform.GenericApplicationFactory}:

23 | *
    24 | *
  • Builds a particular variant of the {@link net.bither.platform.GenericApplication} suitable for the current platform
  • 25 | *
26 | * 27 | * @since 0.2.0 28 | *   29 | */ 30 | public class SolarisApplicationBuilder { 31 | public DefaultApplication build(GenericApplicationSpecification specification) { 32 | return new DefaultApplication(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/unix/UnixApplicationBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder.unix; 17 | 18 | import net.bither.platform.GenericApplicationSpecification; 19 | import net.bither.platform.builder.generic.DefaultApplication; 20 | 21 | /** 22 | *

Builder to provide the following to {@link net.bither.platform.GenericApplicationFactory}:

23 | *
    24 | *
  • Builds a particular variant of the {@link net.bither.platform.GenericApplication} suitable for the current platform
  • 25 | *
26 | * 27 | * @since 0.2.0 28 | *   29 | */ 30 | public class UnixApplicationBuilder { 31 | public DefaultApplication build(GenericApplicationSpecification specification) { 32 | return new DefaultApplication(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/builder/win/WindowsApplicationBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.builder.win; 17 | 18 | import net.bither.platform.GenericApplicationSpecification; 19 | import net.bither.platform.builder.generic.DefaultApplication; 20 | 21 | /** 22 | *

Builder to provide the following to {@link net.bither.platform.GenericApplicationFactory}:

23 | *
    24 | *
  • Builds a particular variant of the {@link net.bither.platform.GenericApplication} suitable for the current platform
  • 25 | *
26 | * 27 | * @since 0.2.0 28 | *   29 | */ 30 | public class WindowsApplicationBuilder { 31 | public DefaultApplication build(GenericApplicationSpecification specification) { 32 | return new DefaultApplication(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/handler/DefaultAboutHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.handler; 17 | 18 | import net.bither.platform.listener.GenericAboutEvent; 19 | import net.bither.platform.listener.GenericAboutEventListener; 20 | import net.bither.platform.listener.GenericEventListener; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | import java.util.Collection; 25 | import java.util.HashSet; 26 | import java.util.Set; 27 | 28 | /** 29 | *

Generic event to provide the following to {@link net.bither.platform.GenericApplication}:

30 | *
    31 | *
  • Provision of application specific event handling code
  • 32 | *
33 | * 34 | * @since 0.3.0 35 | *   36 | */ 37 | public class DefaultAboutHandler implements GenericAboutHandler, GenericEventListener { 38 | private static final Logger log = LoggerFactory.getLogger(DefaultAboutHandler.class); 39 | 40 | // The event listeners 41 | private Set listeners = new HashSet(); 42 | 43 | @Override 44 | public void addListeners(Collection listeners) { 45 | this.listeners.addAll(listeners); 46 | } 47 | 48 | /** 49 | * Handles the process of broadcasting the event to listeners 50 | * allowing this process to be decoupled 51 | * 52 | * @param event The generic event (or it's proxy) 53 | */ 54 | @Override 55 | public void handleAbout(GenericAboutEvent event) { 56 | log.debug("Called"); 57 | if (event == null) { 58 | log.warn("Received a null event"); 59 | return; 60 | } 61 | log.debug("Event class is {}", event.getClass().getSimpleName()); 62 | log.debug("Broadcasting to {} listener(s)", listeners.size()); 63 | for (GenericAboutEventListener listener : listeners) { 64 | listener.onAboutEvent(event); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/handler/DefaultOpenURIHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.handler; 17 | 18 | import net.bither.platform.listener.GenericEventListener; 19 | import net.bither.platform.listener.GenericOpenURIEvent; 20 | import net.bither.platform.listener.GenericOpenURIEventListener; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | import java.util.Collection; 25 | import java.util.HashSet; 26 | import java.util.Set; 27 | 28 | /** 29 | *

Generic event to provide the following to {@link net.bither.platform.GenericApplication}:

30 | *
    31 | *
  • Provision of application specific event handling code
  • 32 | *
33 | * 34 | * @since 0.3.0 35 | *   36 | */ 37 | public class DefaultOpenURIHandler implements GenericOpenURIHandler, GenericEventListener { 38 | private static final Logger log = LoggerFactory.getLogger(DefaultOpenURIHandler.class); 39 | 40 | // The event listeners 41 | private Set listeners = new HashSet(); 42 | 43 | /** 44 | * Handles the process of broadcasting the event to listeners 45 | * allowing this process to be decoupled 46 | * 47 | * @param event The generic event (or it's proxy) 48 | */ 49 | @Override 50 | public void openURI(GenericOpenURIEvent event) { 51 | log.debug("Called"); 52 | if (event == null) { 53 | log.warn("Received a null event"); 54 | return; 55 | } 56 | log.debug("Event class is {}", event.getClass().getSimpleName()); 57 | log.debug("Received open URI request of '{}'", event.getURI()); 58 | log.debug("Broadcasting to {} listener(s)", listeners.size()); 59 | for (GenericOpenURIEventListener listener : listeners) { 60 | listener.onOpenURIEvent(event); 61 | } 62 | } 63 | 64 | @Override 65 | public void addListeners(Collection listeners) { 66 | this.listeners.addAll(listeners); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/handler/DefaultPreferencesHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.handler; 17 | 18 | import net.bither.platform.listener.GenericEventListener; 19 | import net.bither.platform.listener.GenericPreferencesEvent; 20 | import net.bither.platform.listener.GenericPreferencesEventListener; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | import java.util.Collection; 25 | import java.util.HashSet; 26 | import java.util.Set; 27 | 28 | /** 29 | *

Generic event to provide the following to {@link net.bither.platform.GenericApplication}:

30 | *
    31 | *
  • Provision of application specific event handling code
  • 32 | *
33 | * 34 | * @since 0.3.0 35 | *   36 | */ 37 | public class DefaultPreferencesHandler implements GenericPreferencesHandler, GenericEventListener { 38 | private static final Logger log = LoggerFactory.getLogger(DefaultPreferencesHandler.class); 39 | 40 | // The event listeners 41 | private Set listeners = new HashSet(); 42 | 43 | @Override 44 | public void addListeners(Collection listeners) { 45 | this.listeners.addAll(listeners); 46 | } 47 | 48 | /** 49 | * Handles the process of broadcasting the event to listeners 50 | * allowing this process to be decoupled 51 | * 52 | * @param event The generic event (or it's proxy) 53 | */ 54 | @Override 55 | public void handlePreferences(GenericPreferencesEvent event) { 56 | log.debug("Called"); 57 | if (event == null) { 58 | log.warn("Received a null event"); 59 | return; 60 | } 61 | log.debug("Event class is {}", event.getClass().getSimpleName()); 62 | log.debug("Broadcasting to {} listener(s)", listeners.size()); 63 | for (GenericPreferencesEventListener listener : listeners) { 64 | listener.onPreferencesEvent(event); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/handler/DefaultQuitHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.handler; 17 | 18 | import net.bither.platform.listener.GenericEventListener; 19 | import net.bither.platform.listener.GenericQuitEvent; 20 | import net.bither.platform.listener.GenericQuitEventListener; 21 | import net.bither.platform.listener.GenericQuitResponse; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | import java.util.Collection; 26 | import java.util.HashSet; 27 | import java.util.Set; 28 | 29 | /** 30 | *

Generic event to provide the following to {@link net.bither.platform.GenericApplication}:

31 | *
    32 | *
  • Provision of application specific event handling code
  • 33 | *
34 | * 35 | * @since 0.3.0 36 | *   37 | */ 38 | public class DefaultQuitHandler implements GenericQuitHandler, GenericEventListener { 39 | private static final Logger log = LoggerFactory.getLogger(DefaultQuitHandler.class); 40 | 41 | // The event listeners 42 | private Set listeners = new HashSet(); 43 | 44 | @Override 45 | public void addListeners(Collection listeners) { 46 | this.listeners.addAll(listeners); 47 | } 48 | 49 | /** 50 | * Handles the process of broadcasting the event to listeners 51 | * allowing this process to be decoupled 52 | * 53 | * @param event The generic event (or it's proxy) 54 | */ 55 | @Override 56 | public void handleQuitRequestWith(GenericQuitEvent event, GenericQuitResponse response) { 57 | log.debug("Called"); 58 | if (event == null) { 59 | log.warn("Received a null event"); 60 | return; 61 | } 62 | log.debug("Event class is {}", event.getClass().getSimpleName()); 63 | log.debug("Broadcasting to {} listener(s)", listeners.size()); 64 | for (GenericQuitEventListener listener : listeners) { 65 | listener.onQuitEvent(event, response); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/handler/GenericAboutHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.handler; 17 | 18 | import net.bither.platform.listener.GenericAboutEvent; 19 | 20 | /** 21 | *

Generic handler to provide the following to {@link net.bither.platform.GenericApplication}:

22 | *
    23 | *
  • Provision of application specific handling code
  • 24 | *
25 | * 26 | * @since 0.3.0 27 | *   28 | */ 29 | public interface GenericAboutHandler extends GenericHandler { 30 | /** 31 | * Called in response to receiving an About event 32 | * 33 | * @param event The generic About event 34 | */ 35 | void handleAbout(GenericAboutEvent event); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/handler/GenericHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.handler; 17 | 18 | /** 19 | *  

Signature interface for handlers:

20 | * 21 | * @since 0.3.0 22 | *   23 | */ 24 | public interface GenericHandler { 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/handler/GenericOpenURIHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.handler; 17 | 18 | import net.bither.platform.listener.GenericOpenURIEvent; 19 | 20 | /** 21 | *

Generic handler to provide the following to {@link net.bither.platform.GenericApplication}:

22 | *
    23 | *
  • Proxies any native handling code
  • 24 | *
25 | * 26 | * @since 0.3.0 27 | *   28 | */ 29 | public interface GenericOpenURIHandler extends GenericHandler { 30 | /** 31 | * Called in response to receiving an open URI event 32 | * 33 | * @param event The generic open URI event 34 | */ 35 | void openURI(GenericOpenURIEvent event); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/handler/GenericPreferencesHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.handler; 17 | 18 | import net.bither.platform.listener.GenericPreferencesEvent; 19 | 20 | /** 21 | *

Generic handler to provide the following to {@link net.bither.platform.GenericApplication}:

22 | *
    23 | *
  • Provision of application specific handling code
  • 24 | *
25 | * 26 | * @since 0.3.0 27 | *   28 | */ 29 | public interface GenericPreferencesHandler extends GenericHandler { 30 | /** 31 | * Called in response to receiving a Preferences event 32 | * 33 | * @param event The generic Preferences event 34 | */ 35 | void handlePreferences(GenericPreferencesEvent event); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/handler/GenericQuitHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.handler; 17 | 18 | import net.bither.platform.listener.GenericQuitEvent; 19 | import net.bither.platform.listener.GenericQuitResponse; 20 | 21 | /** 22 | *

Generic handler to provide the following to {@link net.bither.platform.GenericApplication}:

23 | *
    24 | *
  • Provision of application specific handling code
  • 25 | *
26 | * 27 | * @since 0.3.0 28 | *   29 | */ 30 | public interface GenericQuitHandler extends GenericHandler { 31 | /** 32 | * Called in response to receiving a Quit event 33 | * 34 | * @param event The generic Quit event 35 | * @param response The response containing the methods to call if quit can continue or not 36 | */ 37 | void handleQuitRequestWith(GenericQuitEvent event, GenericQuitResponse response); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/listener/GenericAboutEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.listener; 17 | 18 | /** 19 | *

Generic event to provide the following to {@link net.bither.platform.GenericApplication}:

20 | *
    21 | *
  • Proxies any native handling code
  • 22 | *
23 | * 24 | * @since 0.3.0 25 | *   26 | */ 27 | public interface GenericAboutEvent extends GenericEvent { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/listener/GenericAboutEventListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.listener; 17 | 18 | /** 19 | *

Listener to provide the following to applications:

20 | *
    21 | *
  • Notification of an About dialog event
  • 22 | *
23 | * 24 | * @since 0.3.0 25 | *   26 | */ 27 | public interface GenericAboutEventListener { 28 | /** 29 | * Received when the user requests the About display 30 | * 31 | * @param event The event 32 | */ 33 | void onAboutEvent(GenericAboutEvent event); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/listener/GenericEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.listener; 17 | 18 | /** 19 | *  

Signature interface for generic events:

20 | * 21 | * @since 0.3.0 22 | *   23 | */ 24 | public interface GenericEvent { 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/listener/GenericEventListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.listener; 17 | 18 | import java.util.Collection; 19 | 20 | /** 21 | *

Generic interface to provide the following to generic event handlers:

22 | *
    23 | *
  • Type safety for adding and removing listeners
  • 24 | *
25 | *

See {@link net.bither.platform.handler.DefaultOpenURIHandler} for an example of an implementation

26 | * 27 | * @since 0.3.0 28 | *   29 | */ 30 | public interface GenericEventListener { 31 | /** 32 | * @param listeners The listeners to add to the handler 33 | */ 34 | void addListeners(Collection listeners); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/listener/GenericOpenURIEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.listener; 17 | 18 | import java.net.URI; 19 | 20 | /** 21 | *

Generic event to provide the following to {@link net.bither.platform.GenericApplication}:

22 | *
    23 | *
  • Provision of application specific event handling code
  • 24 | *
25 | * 26 | * @since 0.3.0 27 | *   28 | */ 29 | public interface GenericOpenURIEvent extends GenericEvent { 30 | 31 | /** 32 | * @return The URI that should be opened 33 | */ 34 | URI getURI(); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/listener/GenericOpenURIEventListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.listener; 17 | 18 | /** 19 | *

Listener to provide the following to applications:

20 | *
    21 | *
  • Notification of an Open URI event
  • 22 | *
23 | *

Example:

24 | *
25 |  * 
26 | * 27 | * @since 0.3.0 28 | *   29 | */ 30 | public interface GenericOpenURIEventListener { 31 | /** 32 | * Received when the application receives an open URI event 33 | * 34 | * @param event The event 35 | */ 36 | void onOpenURIEvent(GenericOpenURIEvent event); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/listener/GenericPreferencesEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.listener; 17 | 18 | /** 19 | *

Generic event to provide the following to {@link net.bither.platform.GenericApplication}:

20 | *
    21 | *
  • Proxies any native handling code
  • 22 | *
23 | * 24 | * @since 0.3.0 25 | *   26 | */ 27 | public interface GenericPreferencesEvent extends GenericEvent { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/listener/GenericPreferencesEventListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.listener; 17 | 18 | /** 19 | *

Listener to provide the following to applications:

20 | *
    21 | *
  • Notification of a preferences event
  • 22 | *
23 | * 24 | * @since 0.3.0 25 | *   26 | */ 27 | public interface GenericPreferencesEventListener { 28 | /** 29 | * Received when the user requests the Preferences display 30 | * 31 | * @param event The event 32 | */ 33 | void onPreferencesEvent(GenericPreferencesEvent event); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/listener/GenericQuitEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.listener; 17 | 18 | /** 19 | *

Generic event to provide the following to {@link net.bither.platform.GenericApplication}:

20 | *
    21 | *
  • Proxies any native handling code
  • 22 | *
23 | * 24 | * @since 0.3.0 25 | *   26 | */ 27 | public interface GenericQuitEvent extends GenericEvent { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/listener/GenericQuitEventListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.listener; 17 | 18 | /** 19 | *

Listener to provide the following to applications:

20 | *
    21 | *
  • Notification of a Quit event
  • 22 | *
23 | * 24 | * @since 0.3.0 25 | *   26 | */ 27 | public interface GenericQuitEventListener { 28 | /** 29 | * Received when the user requests to Quit 30 | * 31 | * @param event The event 32 | * @param response The response to prevent the quit operation if necessary 33 | */ 34 | void onQuitEvent(GenericQuitEvent event, GenericQuitResponse response); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/bither/platform/listener/GenericQuitResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.platform.listener; 17 | 18 | /** 19 | *

Generic response to provide the following to {@link net.bither.platform.GenericApplication}:

20 | *
    21 | *
  • Proxies any native handling code for quit response
  • 22 | *
23 | * 24 | * @since 0.3.0 25 | */ 26 | public interface GenericQuitResponse extends GenericEvent { 27 | 28 | /** 29 | * Call if quit should be stopped due to application tasks 30 | */ 31 | void cancelQuit(); 32 | 33 | /** 34 | * Call if quit is OK to proceed 35 | */ 36 | void performQuit(); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/net/bither/qrcode/DisplayQRCodePanle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.qrcode; 20 | 21 | import net.bither.BitherUI; 22 | import net.bither.fonts.AwesomeIcon; 23 | import net.bither.languages.MessageKey; 24 | import net.bither.viewsystem.base.Labels; 25 | import net.bither.viewsystem.base.Panels; 26 | import net.bither.viewsystem.froms.WizardPanel; 27 | import net.miginfocom.swing.MigLayout; 28 | 29 | import javax.swing.*; 30 | import java.awt.*; 31 | import java.awt.image.BufferedImage; 32 | 33 | public class DisplayQRCodePanle extends WizardPanel { 34 | 35 | private String qrCodeString; 36 | 37 | 38 | public DisplayQRCodePanle(String qrCodeString) { 39 | super(MessageKey.QR_CODE, AwesomeIcon.QRCODE); 40 | this.qrCodeString = qrCodeString; 41 | } 42 | 43 | @Override 44 | public void initialiseContent(JPanel panel) { 45 | panel.setLayout(new MigLayout( 46 | Panels.migXYLayout(), 47 | "[]", // Column constraints 48 | "10[][][][]" // Row constraints 49 | )); 50 | BufferedImage qrCodeImage = null; 51 | panel.getMaximumSize(); 52 | int scaleWidth = BitherUI.POPOVER_MIN_WIDTH; 53 | int scaleHeight = BitherUI.POPOVER_MIN_WIDTH; 54 | Image image = QRCodeGenerator.generateQRcode(qrCodeString, null, null, 1); 55 | if (image != null) { 56 | int scaleFactor = (int) (Math.floor(Math.min(scaleHeight / image.getHeight(null), 57 | scaleWidth / image.getWidth(null)))); 58 | qrCodeImage = QRCodeGenerator.generateQRcode(qrCodeString, null, null, scaleFactor); 59 | } 60 | 61 | JLabel imageLabel = Labels.newImageLabel(qrCodeImage); 62 | panel.add(imageLabel, "align center,push,wrap"); 63 | 64 | 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/net/bither/qrcode/GenerateUnsignedTxPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.qrcode; 20 | 21 | import net.bither.fonts.AwesomeIcon; 22 | import net.bither.utils.LocaliserUtils; 23 | 24 | import javax.swing.*; 25 | import java.awt.event.ActionEvent; 26 | 27 | public class GenerateUnsignedTxPanel extends DisplayBitherQRCodePanel { 28 | private IScanQRCode scanQRCode; 29 | 30 | public GenerateUnsignedTxPanel(IScanQRCode scanQRCode, String codeString) { 31 | super(codeString); 32 | this.scanQRCode = scanQRCode; 33 | updateTitle(LocaliserUtils.getString("unsigned_transaction_qr_code_title")); 34 | setOkAction(new AbstractAction() { 35 | @Override 36 | public void actionPerformed(ActionEvent e) { 37 | onOK(); 38 | } 39 | }); 40 | modifOkButton(AwesomeIcon.CAMERA, LocaliserUtils.getString("unsigned_transaction_qr_code_complete")); 41 | 42 | } 43 | 44 | private void onOK() { 45 | closePanel(); 46 | SelectTransportQRCodePanel selectTransportQRCodePanel = new SelectTransportQRCodePanel(scanQRCode); 47 | selectTransportQRCodePanel.showPanel(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/net/bither/qrcode/HDMServerUnsignedQRCodeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.qrcode; 20 | 21 | /** 22 | * Created by nn on 15/3/9. 23 | */ 24 | public abstract class HDMServerUnsignedQRCodeListener implements IScanQRCode { 25 | public abstract void scanSignedHDMServerQRCodeCancel(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/net/bither/qrcode/HDMServerUnsignedQRCodePanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.qrcode; 20 | 21 | import net.bither.fonts.AwesomeIcon; 22 | import net.bither.utils.LocaliserUtils; 23 | 24 | import javax.swing.*; 25 | import java.awt.event.ActionEvent; 26 | 27 | public class HDMServerUnsignedQRCodePanel extends DisplayBitherQRCodePanel { 28 | 29 | 30 | private IScanQRCode scanQRCode; 31 | 32 | public HDMServerUnsignedQRCodePanel(IScanQRCode scanQRCode, String codeString) { 33 | super(codeString); 34 | this.scanQRCode = scanQRCode; 35 | updateTitle(LocaliserUtils.getString("hdm_keychain_add_unsigned_server_qr_code_title")); 36 | setOkAction(new AbstractAction() { 37 | @Override 38 | public void actionPerformed(ActionEvent e) { 39 | onOK(); 40 | } 41 | }); 42 | modifOkButton(AwesomeIcon.CAMERA, LocaliserUtils.getString("unsigned_transaction_qr_code_complete")); 43 | 44 | } 45 | 46 | private void onOK() { 47 | closePanel(); 48 | SelectTransportQRCodePanel selectTransportQRCodePanel = new SelectTransportQRCodePanel(scanQRCode); 49 | selectTransportQRCodePanel.showPanel(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/net/bither/qrcode/IReadQRCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.qrcode; 20 | 21 | public interface IReadQRCode { 22 | public void close(); 23 | 24 | public void reTry(String str); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/bither/qrcode/IScanQRCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.qrcode; 20 | 21 | public interface IScanQRCode { 22 | public void handleResult(String result, IReadQRCode readQRCode); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/bither/runnable/BaseRunnable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 http://Bither.net 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.bither.runnable; 18 | 19 | 20 | import javax.swing.*; 21 | 22 | public abstract class BaseRunnable implements Runnable { 23 | 24 | 25 | private RunnableListener runnableListener; 26 | 27 | public void setRunnableListener(RunnableListener runnableListener) { 28 | this.runnableListener = runnableListener; 29 | } 30 | 31 | protected void prepare() { 32 | SwingUtilities.invokeLater(new Runnable() { 33 | @Override 34 | public void run() { 35 | if (runnableListener != null) { 36 | runnableListener.prepare(); 37 | } 38 | } 39 | }); 40 | 41 | } 42 | 43 | protected void success(final Object obj) { 44 | 45 | SwingUtilities.invokeLater(new Runnable() { 46 | @Override 47 | public void run() { 48 | if (runnableListener != null) { 49 | runnableListener.success(obj); 50 | } 51 | } 52 | }); 53 | 54 | } 55 | 56 | protected void error(final int errorCode, final String errorMsg) { 57 | SwingUtilities.invokeLater(new Runnable() { 58 | @Override 59 | public void run() { 60 | if (runnableListener != null) { 61 | runnableListener.error(errorCode, errorMsg); 62 | } 63 | 64 | } 65 | }); 66 | 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/net/bither/runnable/CheckRunnable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 http://Bither.net 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.bither.runnable; 18 | 19 | import net.bither.model.Check; 20 | 21 | public class CheckRunnable extends BaseRunnable { 22 | private Check check; 23 | 24 | public CheckRunnable(Check check) { 25 | this.check = check; 26 | } 27 | 28 | @Override 29 | public void run() { 30 | prepare(); 31 | if (check.check()) { 32 | success(check); 33 | } else { 34 | error(0, ""); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/net/bither/runnable/DownloadSpvRunnable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 http://Bither.net 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.bither.runnable; 18 | 19 | import net.bither.bitherj.core.Block; 20 | import net.bither.bitherj.utils.BlockUtil; 21 | 22 | 23 | public class DownloadSpvRunnable extends BaseRunnable { 24 | @Override 25 | public void run() { 26 | prepare(); 27 | try { 28 | Block block = BlockUtil.dowloadSpvBlock(); 29 | if (block != null) { 30 | success(null); 31 | } else { 32 | error(0, null); 33 | } 34 | } catch (Exception e) { 35 | error(0, null); 36 | e.printStackTrace(); 37 | } 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/net/bither/runnable/RCheckRunnable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * Copyright 2014 http://Bither.net 4 | * * 5 | * * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * * you may not use this file except in compliance with the License. 7 | * * You may obtain a copy of the License at 8 | * * 9 | * * http://www.apache.org/licenses/LICENSE-2.0 10 | * * 11 | * * Unless required by applicable law or agreed to in writing, software 12 | * * distributed under the License is distributed on an "AS IS" BASIS, 13 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * * See the License for the specific language governing permissions and 15 | * * limitations under the License. 16 | * 17 | */ 18 | 19 | package net.bither.runnable; 20 | 21 | import net.bither.bitherj.core.Address; 22 | import net.bither.bitherj.core.Tx; 23 | 24 | public class RCheckRunnable extends BaseRunnable { 25 | private Address address; 26 | private Tx tx; 27 | 28 | public RCheckRunnable(Address address, Tx tx) { 29 | this.address = address; 30 | this.tx = tx; 31 | } 32 | 33 | @Override 34 | public void run() { 35 | 36 | success(tx); 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/net/bither/runnable/RunnableListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.runnable; 20 | 21 | public abstract class RunnableListener { 22 | public abstract void prepare(); 23 | 24 | public abstract void success(Object obj); 25 | 26 | public abstract void error(int errorCode, String errorMsg); 27 | 28 | public void other(int code) { 29 | 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/net/bither/utils/Bluetooth.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 http://Bither.net 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.bither.utils; 18 | 19 | import javax.annotation.Nonnull; 20 | import java.util.UUID; 21 | 22 | public class Bluetooth { 23 | public static final UUID BLUETOOTH_UUID = UUID 24 | .fromString("3357A7BB-762D-464A-8D9A-DCA592D57D5B"); 25 | public static final String MAC_URI_PARAM = "bt"; 26 | 27 | public static String compressMac(@Nonnull final String mac) { 28 | return mac.replaceAll(":", ""); 29 | } 30 | 31 | public static String decompressMac(@Nonnull final String compressedMac) { 32 | final StringBuilder mac = new StringBuilder(); 33 | for (int i = 0; i < compressedMac.length(); i += 2) 34 | mac.append(compressedMac.substring(i, i + 2)).append(':'); 35 | mac.setLength(mac.length() - 1); 36 | 37 | return mac.toString(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/net/bither/utils/DocumentMaxLengthFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.utils; 20 | 21 | import javax.swing.text.AttributeSet; 22 | import javax.swing.text.BadLocationException; 23 | import javax.swing.text.DocumentFilter; 24 | 25 | /** 26 | *

Document filter to provide the following to text fields/areas:

27 | *
    28 | *
  • Limiting input to a given maximum length
  • 29 | *
30 | * 31 | * @since 0.0.1 32 | */ 33 | public class DocumentMaxLengthFilter extends DocumentFilter { 34 | 35 | private final int maxCharacters; 36 | 37 | public DocumentMaxLengthFilter(int maxChars) { 38 | maxCharacters = maxChars; 39 | } 40 | 41 | public void insertString(FilterBypass fb, int offs, String str, AttributeSet a) throws BadLocationException { 42 | 43 | // Reject if the insertion would be too long 44 | if ((fb.getDocument().getLength() + str.length()) <= maxCharacters) { 45 | super.insertString(fb, offs, str, a); 46 | } 47 | } 48 | 49 | public void replace(FilterBypass fb, int offs, int length, String str, AttributeSet a) throws BadLocationException { 50 | 51 | // Reject if the replacement would be too long 52 | if ((fb.getDocument().getLength() + str.length() - length) <= maxCharacters) { 53 | super.replace(fb, offs, length, str, a); 54 | } 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /src/main/java/net/bither/utils/ExceptionUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.utils; 20 | 21 | import net.bither.bitherj.api.http.HttpSetting; 22 | 23 | public class ExceptionUtil { 24 | public static final String getHDMHttpExceptionMessage(int code) { 25 | switch (code) { 26 | case HttpSetting.HDMBIdIsAlready: 27 | return LocaliserUtils.getString("hdm_exception_bid_already_exists"); 28 | case HttpSetting.MessageSignatureIsWrong: 29 | return LocaliserUtils.getString("hdm_keychain_add_sign_server_qr_code_error"); 30 | default: 31 | return LocaliserUtils.getString("network_or_connection_error"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/bither/utils/HDMSingularDesktop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * Copyright 2014 http://Bither.net 4 | * * 5 | * * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * * you may not use this file except in compliance with the License. 7 | * * You may obtain a copy of the License at 8 | * * 9 | * * http://www.apache.org/licenses/LICENSE-2.0 10 | * * 11 | * * Unless required by applicable law or agreed to in writing, software 12 | * * distributed under the License is distributed on an "AS IS" BASIS, 13 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * * See the License for the specific language governing permissions and 15 | * * limitations under the License. 16 | * 17 | */ 18 | 19 | package net.bither.utils; 20 | 21 | import net.bither.Bither; 22 | import net.bither.bitherj.core.HDMAddress; 23 | import net.bither.bitherj.core.HDMKeychain; 24 | import net.bither.bitherj.delegate.HDMHotAdd; 25 | import net.bither.bitherj.delegate.HDMSingular; 26 | 27 | import javax.annotation.Nonnull; 28 | import javax.swing.*; 29 | import java.util.List; 30 | 31 | public class HDMSingularDesktop extends HDMSingular { 32 | 33 | public HDMSingularDesktop(@Nonnull HDMSingularDelegate delegate) { 34 | super(delegate); 35 | 36 | } 37 | 38 | @Override 39 | protected void runOnUIThread(Runnable runnable) { 40 | SwingUtilities.invokeLater(runnable); 41 | } 42 | 43 | public void server() { 44 | new Thread() { 45 | @Override 46 | public void run() { 47 | callInServer(new HDMHotAdd.IGenerateHDMKeyChain() { 48 | @Override 49 | public void generateHDMKeyChain(HDMKeychain hdmKeychain) { 50 | KeyUtil.setHDKeyChain(hdmKeychain); 51 | 52 | } 53 | 54 | @Override 55 | public void beginCompleteAddress() { 56 | PeerUtil.stopPeer(); 57 | } 58 | 59 | @Override 60 | public void completeAddrees(List hdmAddresses) { 61 | Bither.refreshFrame(); 62 | } 63 | 64 | 65 | }); 66 | } 67 | 68 | 69 | }.start(); 70 | } 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/net/bither/utils/LocaliserUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.utils; 20 | 21 | import net.bither.bitherj.utils.Utils; 22 | 23 | import java.util.Locale; 24 | 25 | public class LocaliserUtils { 26 | private static Localiser mLocaliser = new Localiser(Locale.ENGLISH); 27 | 28 | private LocaliserUtils() { 29 | 30 | } 31 | 32 | public static String getString(String key) { 33 | return mLocaliser.getString(key); 34 | 35 | } 36 | 37 | public static String getString(String key, String[] errorMessage) { 38 | return mLocaliser.getString(key, errorMessage); 39 | 40 | } 41 | 42 | public static String getString(String key, Object[] message) { 43 | return mLocaliser.getString(key, message); 44 | 45 | } 46 | 47 | public static Locale getLocale() { 48 | return mLocaliser.getLocale(); 49 | } 50 | 51 | 52 | public static void setLocale(Locale locale) { 53 | mLocaliser = new Localiser(locale); 54 | } 55 | 56 | public static void setLocaliser(Localiser localiser) { 57 | mLocaliser = localiser; 58 | } 59 | 60 | 61 | public static Localiser getLocaliser() { 62 | return mLocaliser; 63 | } 64 | 65 | public static boolean isChina() { 66 | String defaultCountry = Locale.getDefault().getCountry(); 67 | if (Utils.compareString(defaultCountry, "CN") || Utils.compareString 68 | (defaultCountry, "cn")) { 69 | return true; 70 | } else { 71 | return false; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/net/bither/utils/LogUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.utils; 20 | 21 | import net.bither.bitherj.BitherjSettings; 22 | import net.bither.bitherj.utils.Utils; 23 | 24 | /** 25 | * Created by nn on 15/5/4. 26 | */ 27 | public class LogUtil { 28 | public static void printlnOut(String str) { 29 | if (!BitherjSettings.LOG_DEBUG) { 30 | return; 31 | } 32 | if (Utils.isEmpty(str)) { 33 | return; 34 | } 35 | System.out.println(str); 36 | } 37 | 38 | public static void printlnError(String str) { 39 | if (!BitherjSettings.LOG_DEBUG) { 40 | return; 41 | } 42 | if (Utils.isEmpty(str)) { 43 | return; 44 | } 45 | System.err.println(str); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/net/bither/utils/StringUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.utils; 20 | 21 | import net.bither.bitherj.utils.Base58; 22 | 23 | import javax.swing.*; 24 | import java.awt.*; 25 | import java.awt.event.WindowEvent; 26 | import java.util.regex.Matcher; 27 | import java.util.regex.Pattern; 28 | 29 | public class StringUtil { 30 | 31 | 32 | public static boolean checkBackupFileOfCold(String fileName) { 33 | Pattern pattern = Pattern.compile("[^-]{6,6}_[^-]{6,6}.bak"); 34 | Matcher matcher = pattern.matcher(fileName); 35 | if (matcher.find()) { 36 | return true; 37 | } 38 | return false; 39 | } 40 | 41 | public static String validBicoinAddressBegin(String input) { 42 | final Pattern PATTERN_BITCOIN_ADDRESS = Pattern.compile("[^" 43 | + new String(Base58.ALPHABET) + "]{1,30}"); 44 | Matcher matcher = PATTERN_BITCOIN_ADDRESS.matcher(input); 45 | if (!matcher.find()) { 46 | return null; 47 | } else { 48 | return matcher.toMatchResult().group(); 49 | } 50 | 51 | 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/net/bither/utils/SystemUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.utils; 20 | 21 | import net.bither.bitherj.utils.Utils; 22 | 23 | /** 24 | * Created by nn on 15/5/4. 25 | */ 26 | public class SystemUtil { 27 | 28 | public static long maxUsed = 0; 29 | 30 | public static void maxUsedSize() { 31 | Runtime runtime = Runtime.getRuntime(); 32 | long total = runtime.totalMemory(); 33 | long free = runtime.freeMemory(); 34 | 35 | long used = total - free; 36 | if (used > maxUsed) { 37 | maxUsed = used; 38 | runtime.runFinalization(); 39 | runtime.gc(); 40 | LogUtil.printlnOut("maxUsed:" + Math.round(maxUsed / 1e3)); 41 | } 42 | } 43 | 44 | public static void callSystemGC() { 45 | 46 | Runtime runtime = Runtime.getRuntime(); 47 | long total = runtime.totalMemory(); 48 | long free = runtime.freeMemory(); 49 | long max = runtime.maxMemory(); 50 | long used = total - free; 51 | LogUtil.printlnOut(" " + Math.round(used / 1e3) + " KB used before GC,total :" + Math.round(total / 1e3) + ",free:" + Math.round(free / 1e3)); 52 | 53 | 54 | runtime.runFinalization(); 55 | runtime.gc(); 56 | runtime = Runtime.getRuntime(); 57 | total = runtime.totalMemory(); 58 | free = runtime.freeMemory(); 59 | max = runtime.maxMemory(); 60 | used = total - free; 61 | LogUtil.printlnOut(Math.round(used / 1e3) + " KB used after GC,total :" + Math.round(total / 1e3) + ",free:" + Math.round(free / 1e3)); 62 | 63 | } 64 | 65 | public static int getAvailableProcessors() { 66 | return Runtime.getRuntime().availableProcessors(); 67 | } 68 | 69 | public static boolean isSystem32() { 70 | return Utils.compareString("32", System.getProperty("sun.arch.data.model")); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/net/bither/utils/UpgradeUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 http://Bither.net 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | package net.bither.utils; 19 | 20 | import net.bither.bitherj.utils.UpgradeAddressUtil; 21 | import net.bither.preference.UserPreference; 22 | import net.bither.runnable.BaseRunnable; 23 | import net.bither.runnable.RunnableListener; 24 | 25 | public class UpgradeUtil { 26 | public static final int UPGRADE_ADDRESS_TO_DB = 131; 27 | 28 | private UpgradeUtil() { 29 | 30 | } 31 | 32 | public static boolean needUpgrade() { 33 | int verionCode = UserPreference.getInstance().getVerionCode(); 34 | return verionCode < UPGRADE_ADDRESS_TO_DB; 35 | } 36 | 37 | public static void upgradeNewVerion(final RunnableListener handler) { 38 | BaseRunnable baseRunnable = new BaseRunnable() { 39 | @Override 40 | public void run() { 41 | handler.prepare(); 42 | try { 43 | int verionCode = UserPreference.getInstance().getVerionCode(); 44 | if (verionCode < UPGRADE_ADDRESS_TO_DB) { 45 | UpgradeAddressUtil.upgradeAddress(); 46 | } 47 | handler.success(null); 48 | } catch (Exception e) { 49 | e.printStackTrace(); 50 | handler.error(0, null); 51 | } 52 | 53 | } 54 | }; 55 | new Thread(baseRunnable).start(); 56 | 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/net/bither/utils/ViewUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.utils; 20 | 21 | import net.bither.viewsystem.dialogs.MessageDialog; 22 | 23 | import javax.swing.*; 24 | import java.awt.*; 25 | import java.io.IOException; 26 | import java.net.URI; 27 | 28 | public class ViewUtil { 29 | private static final int WIDTH_DELTA = 8; 30 | private static final int HEIGHT_DELTA = 8; 31 | 32 | public static int getMax(int... args) { 33 | int max = Integer.MIN_VALUE; 34 | for (int i : args) { 35 | if (max < i) { 36 | max = i; 37 | } 38 | } 39 | return max; 40 | } 41 | 42 | 43 | public static void setDimension(JComponent component, Dimension dimension) { 44 | component.setPreferredSize(dimension); 45 | component.setMinimumSize(dimension); 46 | component.setMaximumSize(dimension); 47 | } 48 | 49 | 50 | public static void openURI(URI uri) { 51 | try { 52 | Desktop desktop = Desktop.getDesktop(); 53 | desktop.browse(uri); 54 | } catch (IOException ioe) { 55 | ioe.printStackTrace(); 56 | new MessageDialog(LocaliserUtils.getString("browser.unableToLoad", new String[]{uri.toString(), ioe.getMessage()})).showMsg(); 57 | 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/net/bither/utils/WhitespaceTrimmer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.utils; 17 | 18 | import java.util.regex.Matcher; 19 | import java.util.regex.Pattern; 20 | 21 | public class WhitespaceTrimmer { 22 | 23 | private static String whiteRange = "\\p{javaWhitespace}\\p{Zs}"; 24 | private static Pattern whiteStart = Pattern.compile("^[" + whiteRange + "]+"); 25 | private static Pattern whiteEnd = Pattern.compile("[" + whiteRange + "]+$"); 26 | 27 | private WhitespaceTrimmer() { 28 | } 29 | 30 | static String ltrim(String text) { 31 | if (text == null) { 32 | return ""; 33 | } 34 | Matcher mStart = whiteStart.matcher(text); 35 | return mStart.find() ? text.substring(mStart.end()) : text; 36 | } 37 | 38 | static String rtrim(String text) { 39 | if (text == null) { 40 | return ""; 41 | } 42 | Matcher mEnd = whiteEnd.matcher(text); 43 | if (mEnd.find()) { 44 | int matchStart = mEnd.start(); 45 | return text.substring(0, matchStart); 46 | } else { 47 | return text; 48 | } 49 | } 50 | 51 | public static String trim(String text) { 52 | return (rtrim(ltrim(text.trim()))).trim(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/ViewFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.viewsystem; 17 | 18 | import net.bither.viewsystem.base.ViewEnum; 19 | import net.bither.viewsystem.base.Viewable; 20 | import net.bither.viewsystem.froms.ColdDefaultPanel; 21 | import net.bither.viewsystem.froms.ShowTransactionsForm; 22 | 23 | import java.util.EnumMap; 24 | import java.util.Map; 25 | 26 | public class ViewFactory { 27 | private Map viewMap; 28 | 29 | public ViewFactory() { 30 | initialise(); 31 | } 32 | 33 | public final void initialise() { 34 | viewMap = new EnumMap(ViewEnum.class); 35 | } 36 | 37 | public Viewable getView(ViewEnum viewNumber) { 38 | Viewable viewToReturn = viewMap.get(viewNumber); 39 | 40 | if (viewToReturn == null) { 41 | viewToReturn = createView(viewNumber); 42 | } 43 | 44 | return viewToReturn; 45 | } 46 | 47 | private Viewable createView(ViewEnum viewNumber) { 48 | Viewable viewToReturn = null; 49 | 50 | switch (viewNumber) { 51 | 52 | case SAME_VIEW: { 53 | assert false; 54 | break; 55 | } 56 | case TRANSACTIONS_VIEW: { 57 | viewToReturn = new ShowTransactionsForm(); 58 | break; 59 | } 60 | case COLD_WALLET_VIEW: { 61 | viewToReturn = new ColdDefaultPanel(); 62 | break; 63 | } 64 | 65 | 66 | default: { 67 | } 68 | } 69 | 70 | if (viewToReturn != null) { 71 | viewMap.put(viewNumber, viewToReturn); 72 | } 73 | return viewToReturn; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/action/AbstractExitAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright 2013 Cameron Garnham. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package net.bither.viewsystem.action; 25 | 26 | import net.bither.utils.LocaliserUtils; 27 | 28 | import javax.swing.*; 29 | 30 | 31 | public abstract class AbstractExitAction extends AbstractAction { 32 | 33 | public AbstractExitAction() { 34 | super(LocaliserUtils.getString("exitAction.text")); 35 | 36 | MnemonicUtil mnemonicUtil = new MnemonicUtil(); 37 | putValue(MNEMONIC_KEY, mnemonicUtil.getMnemonic("exitAction.mnemonicKey")); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/action/CopyAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.viewsystem.action; 17 | 18 | import net.bither.utils.LocaliserUtils; 19 | import net.bither.viewsystem.dialogs.MessageDialog; 20 | 21 | import javax.swing.*; 22 | import java.awt.event.ActionEvent; 23 | 24 | /** 25 | * This {@link Action} represents the swing copy receive address action 26 | */ 27 | public class CopyAction extends AbstractAction { 28 | public interface ICopy { 29 | public String getCopyString(); 30 | } 31 | 32 | private ICopy copy; 33 | 34 | 35 | public CopyAction(ICopy copy) { 36 | 37 | this.copy = copy; 38 | } 39 | 40 | /** 41 | * Copy receive address to clipboard 42 | */ 43 | @Override 44 | public void actionPerformed(ActionEvent e) { 45 | // copy receive address to clipboard 46 | TextTransfer textTransfer = new TextTransfer(); 47 | //getReceiveAddress 48 | textTransfer.setClipboardContents(copy.getCopyString()); 49 | new MessageDialog(LocaliserUtils.getString("copy_address_success")).showMsg(); 50 | 51 | 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/action/ExitAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License 6 | * at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package net.bither.viewsystem.action; 17 | 18 | 19 | import net.bither.ApplicationInstanceManager; 20 | import net.bither.Bither; 21 | import net.bither.bitherj.core.PeerManager; 22 | import net.bither.utils.LocaliserUtils; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | import javax.swing.*; 27 | import java.awt.*; 28 | import java.awt.event.ActionEvent; 29 | 30 | /** 31 | * Exit the application. 32 | */ 33 | public class ExitAction extends AbstractExitAction { 34 | private static final Logger log = LoggerFactory.getLogger(ExitAction.class); 35 | 36 | /** 37 | * Creates a new {@link ExitAction}. 38 | */ 39 | public ExitAction() { 40 | super(); 41 | 42 | } 43 | 44 | @Override 45 | public void actionPerformed(ActionEvent arg0) { 46 | String shuttingDownTitle = LocaliserUtils.getString("BitherFrame.title.shuttingDown"); 47 | 48 | if (Bither.getMainFrame() != null) { 49 | Bither.getMainFrame().setTitle(shuttingDownTitle); 50 | 51 | if (EventQueue.isDispatchThread()) { 52 | Bither.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 53 | } else { 54 | SwingUtilities.invokeLater(new Runnable() { 55 | @Override 56 | public void run() { 57 | Bither.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 58 | } 59 | }); 60 | } 61 | 62 | } 63 | PeerManager.instance().stop(); 64 | ApplicationInstanceManager.shutdownSocket(); 65 | 66 | // Get rid of main display. 67 | if (Bither.getMainFrame() != null) { 68 | Bither.getMainFrame().setVisible(false); 69 | } 70 | 71 | if (Bither.getMainFrame() != null) { 72 | Bither.getMainFrame().dispose(); 73 | } 74 | ApplicationInstanceManager.txDBHelper.close(); 75 | 76 | 77 | System.exit(0); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/action/MnemonicUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.viewsystem.action; 17 | 18 | import net.bither.utils.LocaliserUtils; 19 | 20 | import javax.swing.*; 21 | import java.util.MissingResourceException; 22 | 23 | public class MnemonicUtil { 24 | 25 | 26 | /** 27 | * get the mnemonic key code for the passed in internationalisation key 28 | * 29 | * @param key 30 | * @return 31 | */ 32 | public int getMnemonic(String key) { 33 | if (LocaliserUtils.getLocaliser() != null) { 34 | try { 35 | return KeyStroke.getKeyStroke(LocaliserUtils.getLocaliser().getString(key)).getKeyCode(); 36 | } catch (NullPointerException npe) { 37 | return 0; 38 | } catch (ClassCastException cce) { 39 | return 0; 40 | } catch (MissingResourceException mre) { 41 | return 0; 42 | } 43 | } else { 44 | return 0; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/action/PasteAddressAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.viewsystem.action; 17 | 18 | import net.bither.Bither; 19 | import net.bither.bitherj.core.Address; 20 | import net.bither.utils.LocaliserUtils; 21 | import net.bither.utils.WhitespaceTrimmer; 22 | 23 | import javax.swing.*; 24 | import java.awt.event.ActionEvent; 25 | 26 | /** 27 | * This {@link Action} represents the swing paste address action 28 | */ 29 | public class PasteAddressAction extends AbstractAction { 30 | 31 | private JTextField jTextField; 32 | 33 | /** 34 | * Creates a new {@link PasteAddressAction}. 35 | */ 36 | public PasteAddressAction(JTextField jTextField) { 37 | 38 | this.jTextField = jTextField; 39 | 40 | 41 | MnemonicUtil mnemonicUtil = new MnemonicUtil(); 42 | putValue(SHORT_DESCRIPTION, LocaliserUtils.getString("pasteAddressAction.tooltip")); 43 | putValue(MNEMONIC_KEY, mnemonicUtil.getMnemonic("pasteAddressAction.mnemonicKey")); 44 | } 45 | 46 | /** 47 | * delegate to generic paste address action 48 | */ 49 | @Override 50 | public void actionPerformed(ActionEvent e) { 51 | // check to see if the wallet files have changed 52 | Address perWalletModelData = Bither.getActionAddress(); 53 | 54 | 55 | TextTransfer textTransfer = new TextTransfer(); 56 | String stringToPaste = textTransfer.getClipboardContents(); 57 | stringToPaste = WhitespaceTrimmer.trim(stringToPaste); 58 | jTextField.setText(stringToPaste); 59 | //Bither.getBitcoinController().displayView(Bither.getBitcoinController().getCurrentView()); 60 | 61 | } 62 | } -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/action/ShowTransactionDetailsAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.viewsystem.action; 17 | 18 | import net.bither.bitherj.core.Tx; 19 | import net.bither.utils.ImageLoader; 20 | import net.bither.utils.LocaliserUtils; 21 | import net.bither.viewsystem.dialogs.TxDetailsDialog; 22 | import net.bither.viewsystem.froms.ShowTransactionsForm; 23 | 24 | import javax.swing.*; 25 | import java.awt.event.ActionEvent; 26 | 27 | /** 28 | * This {@link Action} shows the transaction details dialog 29 | */ 30 | public class ShowTransactionDetailsAction extends AbstractAction { 31 | 32 | private static final long serialVersionUID = 1913592498732457765L; 33 | 34 | private ShowTransactionsForm showTransactionsPanel; 35 | 36 | /** 37 | * Creates a new {@link ShowTransactionDetailsAction}. 38 | */ 39 | public ShowTransactionDetailsAction(ShowTransactionsForm showTransactionsPanel) { 40 | super(LocaliserUtils.getString("showTransactionsDetailAction.text"), ImageLoader.createImageIcon(ImageLoader.TRANSACTIONS_ICON_FILE)); 41 | 42 | this.showTransactionsPanel = showTransactionsPanel; 43 | 44 | 45 | MnemonicUtil mnemonicUtil = new MnemonicUtil(); 46 | putValue(SHORT_DESCRIPTION, LocaliserUtils.getString("showTransactionsDetailAction.tooltip")); 47 | putValue(MNEMONIC_KEY, mnemonicUtil.getMnemonic("showTransactionsDetailAction.mnemonicKey")); 48 | } 49 | 50 | /** 51 | * show the show transaction details dialog 52 | */ 53 | @Override 54 | public void actionPerformed(ActionEvent e) { 55 | Tx rowTableData = showTransactionsPanel.getSelectedRowData(); 56 | 57 | final TxDetailsDialog transactionDetailsDialog = new TxDetailsDialog(rowTableData); 58 | //final TransactionDetailsDialog transactionDetailsDialog = new TransactionDetailsDialog(rowTableData); 59 | transactionDetailsDialog.setVisible(true); 60 | 61 | // Put the focus back on the table so that the up and down arrows work. 62 | showTransactionsPanel.getTable().requestFocusInWindow(); 63 | } 64 | } -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/action/WalletMouseListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.action; 20 | 21 | import net.bither.Bither; 22 | import net.bither.bitherj.utils.Utils; 23 | import net.bither.viewsystem.froms.IAddressForm; 24 | import net.bither.viewsystem.panels.WalletListPanel; 25 | 26 | import java.awt.event.MouseAdapter; 27 | import java.awt.event.MouseEvent; 28 | import java.awt.event.MouseListener; 29 | 30 | public class WalletMouseListener extends MouseAdapter implements MouseListener { 31 | private WalletListPanel walletListPanel; 32 | private IAddressForm singleWalletForm; 33 | 34 | public WalletMouseListener(WalletListPanel walletListPanel, IAddressForm singleWalletForm) { 35 | super(); 36 | this.walletListPanel = walletListPanel; 37 | this.singleWalletForm = singleWalletForm; 38 | } 39 | 40 | @Override 41 | public void mouseClicked(MouseEvent e) { 42 | if (this.singleWalletForm != null) { 43 | String activeAddress = null; 44 | if (Bither.getActionAddress() != null) { 45 | activeAddress = Bither.getActionAddress().getAddress(); 46 | } 47 | if (!Utils.compareString(this.singleWalletForm.getOnlyName() 48 | , activeAddress)) { 49 | walletListPanel.selectWalletPanelByFilename(this.singleWalletForm.getOnlyName()); 50 | Bither.getCoreController().fireDataChangedUpdateNow(); 51 | } 52 | this.singleWalletForm.getPanel().requestFocusInWindow(); 53 | 54 | } 55 | 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/BitherLabel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2012 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.viewsystem.base; 17 | 18 | import javax.swing.*; 19 | 20 | 21 | public class BitherLabel extends JLabel { 22 | 23 | private static final long serialVersionUID = -3434455262992702604L; 24 | 25 | public BitherLabel(String labelText) { 26 | super(labelText); 27 | 28 | setOpaque(false); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/ButtonDecorator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.base; 20 | 21 | import net.bither.BitherUI; 22 | import net.bither.fonts.AwesomeDecorator; 23 | import net.bither.fonts.AwesomeIcon; 24 | import net.bither.languages.MessageKey; 25 | 26 | import javax.swing.*; 27 | 28 | /** 29 | *

Decorator to provide the following to UI:

30 | *
    31 | *
  • Various button effects
  • 32 | *
  • Consistent iconography and accessibility
  • 33 | *
34 | * 35 | * @since 0.0.1 36 | */ 37 | public class ButtonDecorator { 38 | 39 | /** 40 | * Utilities have no public constructor 41 | */ 42 | private ButtonDecorator() { 43 | } 44 | 45 | /** 46 | *

Decorate the button so that clicking will cause a "show"

47 | *

The icon reflects the current state to make it more intuitive

48 | * 49 | * @param button The button 50 | */ 51 | public static void applyShow(JButton button) { 52 | 53 | // #53 Do not use an eye for reveal 54 | AwesomeDecorator.applyIcon( 55 | AwesomeIcon.LOCK, 56 | button, 57 | true, 58 | BitherUI.NORMAL_ICON_SIZE 59 | ); 60 | 61 | AccessibilityDecorator.apply(button, MessageKey.SHOW, MessageKey.SHOW); 62 | 63 | } 64 | 65 | /** 66 | *

Decorate the button so that clicking will cause a "hide"

67 | *

The icon reflects the current state to make it more intuitive

68 | * 69 | * @param button The button 70 | */ 71 | public static void applyHide(JButton button) { 72 | 73 | // #53 Do not use an eye for reveal 74 | AwesomeDecorator.applyIcon( 75 | AwesomeIcon.UNLOCK_ALT, 76 | button, 77 | true, 78 | BitherUI.NORMAL_ICON_SIZE 79 | ); 80 | 81 | AccessibilityDecorator.apply(button, MessageKey.HIDE, MessageKey.HIDE); 82 | 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/DisplayHint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.base; 20 | 21 | 22 | public enum DisplayHint { 23 | COMPLETE_REDRAW, 24 | WALLET_TRANSACTIONS_HAVE_CHANGED 25 | } -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/FontSizer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.viewsystem.base; 17 | 18 | import java.awt.*; 19 | 20 | public enum FontSizer { 21 | INSTANCE; 22 | 23 | 24 | private Font adjustedDefaultFont; 25 | 26 | public void initialise() { 27 | 28 | adjustedDefaultFont = createAdjustedDefaultFont(); 29 | } 30 | 31 | private Font createAdjustedDefaultFont() { 32 | String fontSizeString = null; 33 | 34 | int unadjustedFontSize = ColorAndFontConstants.BITHER_DEFAULT_FONT_SIZE; 35 | 36 | if (fontSizeString != null && !"".equals(fontSizeString)) { 37 | try { 38 | unadjustedFontSize = Integer.parseInt(fontSizeString); 39 | } catch (NumberFormatException nfe) { 40 | // use default 41 | } 42 | } 43 | 44 | String fontStyleString = null; 45 | int fontStyle = ColorAndFontConstants.BITHER_DEFAULT_FONT_STYLE; 46 | 47 | try { 48 | fontStyle = Integer.parseInt(fontStyleString); 49 | } catch (NumberFormatException nfe) { 50 | // use default 51 | } 52 | 53 | String fontName = null; 54 | if (fontName == null || "".equals(fontName)) { 55 | fontName = ColorAndFontConstants.BITHER_DEFAULT_FONT_NAME; 56 | } 57 | 58 | return new Font(fontName, fontStyle, unadjustedFontSize); 59 | } 60 | 61 | public Font getAdjustedDefaultFont() { 62 | return adjustedDefaultFont; 63 | } 64 | 65 | /** 66 | * Get the required scaled font using the currently specified font size plus a delta 67 | * 68 | * @param delta Delta from default font, in point size 69 | */ 70 | public Font getAdjustedDefaultFontWithDelta(int delta) { 71 | return adjustedDefaultFont.deriveFont(adjustedDefaultFont.getStyle(), adjustedDefaultFont.getSize() + delta); 72 | } 73 | } -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/IProgress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.base; 20 | 21 | public interface IProgress { 22 | public void beginProgress(); 23 | 24 | public void endProgress(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/ViewEnum.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); you may not use this file 5 | * except in compliance with the License. You may obtain a copy of the License 6 | * at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package net.bither.viewsystem.base; 17 | 18 | import net.bither.bitherj.BitherjSettings; 19 | import net.bither.preference.UserPreference; 20 | 21 | public enum ViewEnum { 22 | SAME_VIEW, // Not a real view - used to forward to the same view as calling 23 | UNKNOWN_VIEW, 24 | TRANSACTIONS_VIEW, 25 | COLD_WALLET_VIEW, 26 | SEND_BITCOIN_CONFIRM_VIEW, // obsolete - now done with Swing dialog 27 | 28 | 29 | OPEN_WALLET_VIEW, // obsolete - now done with Swing dialog 30 | SAVE_WALLET_AS_VIEW, // obsolete - now done with Swing dialog 31 | VALIDATION_ERROR_VIEW, // obsolete - now done with Swing dialog 32 | YOUR_WALLETS_VIEW, 33 | CREATE_BULK_ADDRESSES_VIEW, // obsolete 34 | 35 | 36 | ; 37 | 38 | public static ViewEnum DEFAULT_VIEW() { 39 | if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD) { 40 | return COLD_WALLET_VIEW; 41 | } 42 | return TRANSACTIONS_VIEW; 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/ViewSystem.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 multibit.org 3 | * 4 | * Licensed under the MIT license (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://opensource.org/licenses/mit-license.php 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.bither.viewsystem.base; 17 | 18 | 19 | import net.bither.bitherj.core.Address; 20 | 21 | public interface ViewSystem { 22 | /** 23 | * Display the view specified. 24 | */ 25 | public void displayView(ViewEnum viewToDisplay); 26 | 27 | /** 28 | * Navigate away from a view - gives the view the opportunity to tidy up/ disappear etc. 29 | * 30 | * @param viewToNavigateAwayFrom - current view to navigate away from -one of the View constants. 31 | */ 32 | public void navigateAwayFromView(ViewEnum viewToNavigateAwayFrom); 33 | 34 | /** 35 | * Tells the view system that the model data has changed (but the wallet is still the same). 36 | * Use this variant for when you want the UI to update immediately (typically after user generated events). 37 | */ 38 | public void fireDataChangedUpdateNow(DisplayHint displayHint); 39 | 40 | /** 41 | * Tells the view system to recreate all views e.g. after a language change or wallet change. 42 | * 43 | * @param initUI Completely redraw everything on all screens = true 44 | */ 45 | public void recreateAllViews(boolean initUI, ViewEnum initialView); 46 | 47 | /** 48 | * Tells the view system that an external process has modified one of the wallets. 49 | */ 50 | public void fireFilesHaveBeenChangedByAnotherProcess(Address perWalletModelData); 51 | 52 | 53 | /** 54 | * Set the help context to display. 55 | * 56 | * @param helpContextToDisplay 57 | */ 58 | public void setHelpContext(String helpContextToDisplay); 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/Viewable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright 2013 Cameron Garnham. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package net.bither.viewsystem.base; 25 | 26 | import javax.swing.*; 27 | 28 | public interface Viewable { 29 | 30 | void displayView(DisplayHint displayHint); 31 | 32 | ViewEnum getViewId(); 33 | 34 | JPanel getPanel(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/renderer/AddressImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.base.renderer; 20 | 21 | import net.bither.BitherUI; 22 | import net.bither.fonts.AwesomeDecorator; 23 | import net.bither.fonts.AwesomeIcon; 24 | import net.bither.viewsystem.themes.Themes; 25 | 26 | import javax.swing.*; 27 | import javax.swing.table.DefaultTableCellRenderer; 28 | import java.awt.*; 29 | 30 | public class AddressImage extends DefaultTableCellRenderer { 31 | private JLabel labPrivateKey; 32 | private JLabel labWatchOnly; 33 | 34 | public AddressImage() { 35 | labPrivateKey = new JLabel(); 36 | labWatchOnly = new JLabel(); 37 | 38 | labWatchOnly.setOpaque(true); 39 | labPrivateKey.setOpaque(true); 40 | 41 | AwesomeDecorator.applyIcon(AwesomeIcon.LOCK, labPrivateKey, true, BitherUI.SMALL_ICON_SIZE); 42 | AwesomeDecorator.applyIcon(AwesomeIcon.FA_EYE, labWatchOnly, true, BitherUI.SMALL_ICON_SIZE); 43 | labPrivateKey.setHorizontalTextPosition(SwingConstants.CENTER); 44 | labWatchOnly.setHorizontalTextPosition(SwingConstants.CENTER); 45 | } 46 | 47 | @Override 48 | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, 49 | int column) { 50 | 51 | if (row % 2 == 0) { 52 | labPrivateKey.setBackground(Themes.currentTheme.detailPanelBackground()); 53 | labWatchOnly.setBackground(Themes.currentTheme.detailPanelBackground()); 54 | 55 | } else { 56 | labPrivateKey.setBackground(Themes.currentTheme.sidebarPanelBackground()); 57 | labWatchOnly.setBackground(Themes.currentTheme.sidebarPanelBackground()); 58 | 59 | } 60 | if (Boolean.valueOf(value.toString())) { 61 | return labPrivateKey; 62 | } else { 63 | return labWatchOnly; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/renderer/CurrencyCenterJustifiedRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.base.renderer; 20 | 21 | import net.bither.viewsystem.base.BitherLabel; 22 | import net.bither.viewsystem.base.FontSizer; 23 | import net.bither.viewsystem.themes.Themes; 24 | 25 | import javax.swing.*; 26 | import javax.swing.table.DefaultTableCellRenderer; 27 | import java.awt.*; 28 | 29 | /** 30 | * Created by nn on 14-11-10. 31 | */ 32 | public class CurrencyCenterJustifiedRenderer extends DefaultTableCellRenderer { 33 | private static final long serialVersionUID = 1549545L; 34 | 35 | private int moduloRow = 0; 36 | 37 | public CurrencyCenterJustifiedRenderer(int moduloRow) { 38 | this.moduloRow = moduloRow; 39 | 40 | } 41 | 42 | BitherLabel label = new BitherLabel(""); 43 | 44 | @Override 45 | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, 46 | int column) { 47 | label.setHorizontalAlignment(SwingConstants.CENTER); 48 | label.setBackground(Themes.currentTheme.detailPanelBackground()); 49 | label.setOpaque(true); 50 | label.setText((String) value); 51 | label.setFont(FontSizer.INSTANCE.getAdjustedDefaultFontWithDelta(-1)); 52 | 53 | Color backgroundColor = (row % 2 == moduloRow ? Themes.currentTheme.detailPanelBackground() 54 | : Themes.currentTheme.detailPanelBackground()); 55 | label.setBackground(backgroundColor); 56 | label.setForeground(table.getForeground()); 57 | 58 | return label; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/renderer/CurrencyCenterJustifiedWithRightBorderRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.base.renderer; 20 | 21 | /** 22 | * Created by nn on 14-11-10. 23 | */ 24 | 25 | import net.bither.viewsystem.base.BitherLabel; 26 | import net.bither.viewsystem.base.FontSizer; 27 | import net.bither.viewsystem.themes.Themes; 28 | 29 | import javax.swing.*; 30 | import javax.swing.table.DefaultTableCellRenderer; 31 | import java.awt.*; 32 | 33 | public class CurrencyCenterJustifiedWithRightBorderRenderer extends DefaultTableCellRenderer { 34 | private static final long serialVersionUID = 9949545L; 35 | private int moduloRow = 0; 36 | 37 | public CurrencyCenterJustifiedWithRightBorderRenderer(int moduloRow) { 38 | this.moduloRow = moduloRow; 39 | 40 | } 41 | 42 | BitherLabel label = new BitherLabel(""); 43 | 44 | @Override 45 | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, 46 | int column) { 47 | label.setHorizontalAlignment(SwingConstants.CENTER); 48 | label.setBackground(Themes.currentTheme.detailPanelBackground()); 49 | label.setOpaque(true); 50 | label.setText((String) value); 51 | label.setFont(FontSizer.INSTANCE.getAdjustedDefaultFontWithDelta(-1)); 52 | 53 | Color backgroundColor = (row % 2 == moduloRow ? Themes.currentTheme.detailPanelBackground() 54 | : Themes.currentTheme.detailPanelBackground()); 55 | label.setBackground(backgroundColor); 56 | label.setForeground(table.getForeground()); 57 | 58 | return label; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/renderer/LeadingJustifiedRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.base.renderer; 20 | 21 | import net.bither.BitherSetting; 22 | import net.bither.viewsystem.base.BitherLabel; 23 | import net.bither.viewsystem.froms.ShowTransactionsForm; 24 | import net.bither.viewsystem.themes.Themes; 25 | 26 | import javax.swing.*; 27 | import javax.swing.border.EmptyBorder; 28 | import javax.swing.table.DefaultTableCellRenderer; 29 | import java.awt.*; 30 | 31 | /** 32 | * Created by nn on 14-11-7. 33 | */ 34 | public class LeadingJustifiedRenderer extends DefaultTableCellRenderer { 35 | private static final long serialVersionUID = 1549545L; 36 | 37 | 38 | private BitherLabel label; 39 | private ShowTransactionsForm showTransactionsFrom; 40 | 41 | public LeadingJustifiedRenderer(ShowTransactionsForm showTransactionsFrom) { 42 | this.showTransactionsFrom = showTransactionsFrom; 43 | label = new BitherLabel(""); 44 | } 45 | 46 | @Override 47 | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, 48 | int column) { 49 | label.setHorizontalAlignment(SwingConstants.LEADING); 50 | label.setOpaque(true); 51 | label.setBorder(new EmptyBorder(new Insets(0, BitherSetting.TABLE_BORDER, 1, BitherSetting.TABLE_BORDER))); 52 | 53 | label.setText(value.toString()); 54 | if (isSelected) { 55 | showTransactionsFrom.setSelectedRow(row); 56 | label.setBackground(table.getSelectionBackground()); 57 | label.setForeground(table.getSelectionForeground()); 58 | } else { 59 | label.setForeground(table.getForeground()); 60 | if (row % 2 == 1) { 61 | label.setBackground(Themes.currentTheme.detailPanelBackground()); 62 | } else { 63 | label.setBackground(Themes.currentTheme.sidebarPanelBackground()); 64 | label.setOpaque(true); 65 | } 66 | } 67 | 68 | return label; 69 | } 70 | } -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/renderer/SelectAddressImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.base.renderer; 20 | 21 | import net.bither.BitherUI; 22 | import net.bither.fonts.AwesomeDecorator; 23 | import net.bither.fonts.AwesomeIcon; 24 | import net.bither.viewsystem.themes.Themes; 25 | 26 | import javax.swing.*; 27 | import javax.swing.table.DefaultTableCellRenderer; 28 | import java.awt.*; 29 | 30 | public class SelectAddressImage extends DefaultTableCellRenderer { 31 | private JLabel labCheck; 32 | private JLabel labNull; 33 | 34 | public SelectAddressImage() { 35 | labCheck = new JLabel(); 36 | labNull = new JLabel(); 37 | labCheck.setOpaque(true); 38 | labNull.setOpaque(true); 39 | labNull.setText(""); 40 | 41 | AwesomeDecorator.applyIcon(AwesomeIcon.CHECK, labCheck, true, BitherUI.SMALL_ICON_SIZE); 42 | 43 | 44 | } 45 | 46 | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, 47 | int column) { 48 | if (row % 2 == 0) { 49 | labCheck.setBackground(Themes.currentTheme.detailPanelBackground()); 50 | labNull.setBackground(Themes.currentTheme.detailPanelBackground()); 51 | 52 | } else { 53 | labCheck.setBackground(Themes.currentTheme.sidebarPanelBackground()); 54 | labNull.setBackground(Themes.currentTheme.sidebarPanelBackground()); 55 | 56 | } 57 | 58 | if (Boolean.valueOf(value.toString())) { 59 | return labCheck; 60 | } else { 61 | return labNull; 62 | } 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/base/renderer/TrailingJustifiedStringRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.base.renderer; 20 | 21 | import net.bither.BitherSetting; 22 | import net.bither.viewsystem.base.BitherLabel; 23 | import net.bither.viewsystem.froms.ShowTransactionsForm; 24 | import net.bither.viewsystem.themes.Themes; 25 | 26 | import javax.swing.*; 27 | import javax.swing.border.EmptyBorder; 28 | import javax.swing.table.DefaultTableCellRenderer; 29 | import java.awt.*; 30 | 31 | /** 32 | * Created by nn on 14-11-7. 33 | */ 34 | public class TrailingJustifiedStringRenderer extends DefaultTableCellRenderer { 35 | private static final long serialVersionUID = 1549545L; 36 | 37 | private BitherLabel label; 38 | private ShowTransactionsForm showTransactionsFrom; 39 | 40 | public TrailingJustifiedStringRenderer(ShowTransactionsForm showTransactionsFrom) { 41 | this.showTransactionsFrom = showTransactionsFrom; 42 | label = new BitherLabel(""); 43 | } 44 | 45 | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, 46 | int column) { 47 | label.setHorizontalAlignment(SwingConstants.TRAILING); 48 | label.setOpaque(true); 49 | label.setBorder(new EmptyBorder(new Insets(0, BitherSetting.TABLE_BORDER, 1, BitherSetting.TABLE_BORDER))); 50 | 51 | label.setText(value + BitherSetting.THREE_SPACER); 52 | 53 | if (isSelected) { 54 | label.setForeground(table.getSelectionForeground()); 55 | } else { 56 | label.setForeground(Color.BLACK); 57 | } 58 | 59 | if (isSelected) { 60 | showTransactionsFrom.setSelectedRow(row); 61 | label.setBackground(table.getSelectionBackground()); 62 | } else { 63 | if (row % 2 == 1) { 64 | label.setBackground(Themes.currentTheme.detailPanelBackground()); 65 | } else { 66 | label.setBackground(Themes.currentTheme.sidebarPanelBackground()); 67 | label.setOpaque(true); 68 | } 69 | } 70 | 71 | return label; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/dialogs/DialogProgress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.dialogs; 20 | 21 | import net.bither.BitherUI; 22 | import net.bither.viewsystem.base.Labels; 23 | import net.bither.viewsystem.base.Panels; 24 | import net.bither.viewsystem.themes.Themes; 25 | import net.miginfocom.swing.MigLayout; 26 | 27 | import javax.swing.*; 28 | 29 | /** 30 | * Created by nn on 15/3/12. 31 | */ 32 | public class DialogProgress extends BitherDialog { 33 | 34 | private JPanel contentPane; 35 | 36 | public DialogProgress() { 37 | contentPane = Panels.newPanel(); 38 | setContentPane(contentPane); 39 | setModal(true); 40 | setUndecorated(true); 41 | setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 42 | initDialog(); 43 | contentPane.setLayout(new MigLayout( 44 | Panels.migXYLayout(), 45 | "[]", // Column constraints 46 | "[]" // Row constraints 47 | 48 | )); 49 | JLabel labelRefrsh = Labels.newSpinner(Themes.currentTheme.fadedText(), BitherUI.NORMAL_PLUS_ICON_SIZE); 50 | contentPane.add(labelRefrsh, "align center,span,wrap"); 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/dialogs/MessageDialog.form: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/froms/AboutPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.froms; 20 | 21 | import net.bither.BitherSetting; 22 | import net.bither.bitherj.api.http.BitherUrl; 23 | import net.bither.fonts.AwesomeIcon; 24 | import net.bither.languages.MessageKey; 25 | import net.bither.utils.LocaliserUtils; 26 | import net.bither.utils.ViewUtil; 27 | import net.bither.viewsystem.base.Buttons; 28 | import net.bither.viewsystem.base.Labels; 29 | import net.bither.viewsystem.base.Panels; 30 | import net.miginfocom.swing.MigLayout; 31 | 32 | import javax.swing.*; 33 | import java.awt.event.ActionEvent; 34 | import java.net.URI; 35 | 36 | public class AboutPanel extends WizardPanel { 37 | public AboutPanel() { 38 | super(MessageKey.ABOUT, AwesomeIcon.SMILE_O); 39 | } 40 | 41 | @Override 42 | public void initialiseContent(JPanel panel) { 43 | panel.setLayout(new MigLayout( 44 | Panels.migXYLayout(), 45 | "[][][][][][][]", // Column constraints 46 | "[]10[][][][][]80[]20[][][]" // Row constraints 47 | )); 48 | 49 | // String version = System.getProperties().getProperty("Implementation-Version"); 50 | //System.out.println(System.getProperties()); 51 | 52 | panel.add(Labels.newValueLabel(LocaliserUtils.getString("version") + ": " + BitherSetting.VERSION), "push,align center,wrap"); 53 | 54 | panel.add(Buttons.newLaunchBrowserButton(getLaunchBrowserAction(), MessageKey.VISIT_WEBSITE), "wrap,align center"); 55 | 56 | } 57 | 58 | private Action getLaunchBrowserAction() { 59 | 60 | return new AbstractAction() { 61 | @Override 62 | public void actionPerformed(ActionEvent e) { 63 | 64 | try { 65 | String url = BitherUrl.BITHER_DNS.BITHER_URL; 66 | ViewUtil.openURI(new URI(url)); 67 | } catch (Exception e1) { 68 | e1.printStackTrace(); 69 | } 70 | 71 | } 72 | }; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/froms/HDMSeedPhrasPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.froms; 20 | 21 | import net.bither.bitherj.BitherjSettings; 22 | import net.bither.fonts.AwesomeIcon; 23 | import net.bither.languages.MessageKey; 24 | import net.bither.preference.UserPreference; 25 | import net.bither.utils.LocaliserUtils; 26 | import net.bither.viewsystem.base.Panels; 27 | import net.miginfocom.swing.MigLayout; 28 | 29 | import javax.swing.*; 30 | import java.util.List; 31 | 32 | public class HDMSeedPhrasPanel extends WizardPanel { 33 | private JTextArea taPrivateText; 34 | private String worldString; 35 | 36 | public HDMSeedPhrasPanel(List worldList) { 37 | super(MessageKey.HDM_COLD_SEED_WORD_LIST, AwesomeIcon.BITBUCKET); 38 | worldString = ""; 39 | for (int i = 0; i < worldList.size(); i++) { 40 | if (i == worldList.size() - 1) { 41 | worldString += worldList.get(i); 42 | } else if ((i + 1) % 3 == 0) { 43 | worldString += worldList.get(i) + "-" + "\n"; 44 | 45 | } else { 46 | worldString += worldList.get(i) + "-"; 47 | } 48 | } 49 | 50 | if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.HOT) { 51 | updateTitle(LocaliserUtils.getString("hdm_hot_seed_word_list")); 52 | } 53 | 54 | 55 | } 56 | 57 | @Override 58 | public void initialiseContent(JPanel panel) { 59 | panel.setLayout(new MigLayout( 60 | Panels.migXYLayout(), 61 | "[][][][][]", // Column constraints 62 | "[]20[][][][][]80[]40[][]" // Row constraints 63 | )); 64 | 65 | taPrivateText = new JTextArea(); 66 | taPrivateText.setBorder(null); 67 | taPrivateText.setEditable(false); 68 | taPrivateText.setText(worldString); 69 | taPrivateText.setBackground(panel.getBackground()); 70 | taPrivateText.setFont(taPrivateText.getFont().deriveFont(20)); 71 | panel.add(taPrivateText, "align center,cell 2 2 ,grow"); 72 | 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/froms/IAddressForm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.froms; 20 | 21 | import net.bither.bitherj.core.Address; 22 | 23 | import javax.swing.*; 24 | 25 | /** 26 | * Created by nn on 14/11/26. 27 | */ 28 | public interface IAddressForm { 29 | public JPanel getPanel(); 30 | 31 | public void updateFromModel(); 32 | 33 | public Address getPerWalletModelData(); 34 | 35 | public String getOnlyName(); 36 | 37 | public void setSelected(boolean selected); 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/froms/PrivateTextPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.froms; 20 | 21 | import net.bither.bitherj.crypto.SecureCharSequence; 22 | import net.bither.bitherj.utils.Utils; 23 | import net.bither.fonts.AwesomeIcon; 24 | import net.bither.languages.MessageKey; 25 | import net.bither.utils.WalletUtils; 26 | import net.bither.viewsystem.base.Panels; 27 | import net.miginfocom.swing.MigLayout; 28 | 29 | import javax.swing.*; 30 | import java.awt.*; 31 | 32 | public class PrivateTextPanel extends WizardPanel { 33 | private JTextArea taPrivateText; 34 | private SecureCharSequence secureCharSequence; 35 | 36 | public PrivateTextPanel(SecureCharSequence secureCharSequence) { 37 | super(MessageKey.PRIVATE_KEY_TEXT, AwesomeIcon.FA_FILE_TEXT); 38 | this.secureCharSequence = Utils.formatHashFromCharSequence(secureCharSequence, 4, 16); 39 | secureCharSequence.wipe(); 40 | 41 | } 42 | 43 | @Override 44 | public void initialiseContent(JPanel panel) { 45 | panel.setLayout(new MigLayout( 46 | Panels.migXYLayout(), 47 | "[][][][][]", // Column constraints 48 | "[]20[][][][][]80[]40[][]" // Row constraints 49 | )); 50 | 51 | taPrivateText = new JTextArea(); 52 | taPrivateText.setBorder(null); 53 | taPrivateText.setEditable(false); 54 | taPrivateText.setFont(new Font("Monospaced", taPrivateText.getFont().getStyle(), taPrivateText.getFont().getSize())); 55 | taPrivateText.setText(this.secureCharSequence.toString()); 56 | taPrivateText.setBackground(panel.getBackground()); 57 | 58 | panel.add(taPrivateText, "align center,cell 2 2 ,grow"); 59 | 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/froms/ShowTransactionsForm.form: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/listener/ICheckPasswordListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.listener; 20 | 21 | import net.bither.bitherj.crypto.SecureCharSequence; 22 | 23 | public interface ICheckPasswordListener { 24 | public boolean checkPassword(SecureCharSequence password); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/listener/IDialogPasswordListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.listener; 20 | 21 | import net.bither.bitherj.crypto.SecureCharSequence; 22 | 23 | public interface IDialogPasswordListener { 24 | public void onPasswordEntered(SecureCharSequence password); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/panels/RoundedPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.panels; 20 | 21 | import net.bither.BitherUI; 22 | import net.bither.viewsystem.components.ImageDecorator; 23 | 24 | import javax.swing.*; 25 | import java.awt.*; 26 | 27 | /** 28 | *

Panel to provide the following to UI:

29 | *
    30 | *
  • Rounded corners for use with wizards/light boxes
  • 31 | *
32 | * 33 | * @since 0.0.1 34 | */ 35 | 36 | public class RoundedPanel extends JPanel { 37 | 38 | private final int cornerRadius; 39 | 40 | /** 41 | * @param layout The layout manager 42 | */ 43 | public RoundedPanel(LayoutManager2 layout) { 44 | super(layout); 45 | 46 | setOpaque(false); 47 | 48 | this.cornerRadius = BitherUI.COMPONENT_CORNER_RADIUS; 49 | 50 | } 51 | 52 | @Override 53 | protected void paintComponent(Graphics g) { 54 | 55 | super.paintComponent(g); 56 | 57 | // Get the dimensions 58 | int width = getWidth(); 59 | int height = getHeight(); 60 | 61 | // Ensure we render with smooth outcome 62 | Graphics2D g2 = (Graphics2D) g; 63 | g2.setRenderingHints(ImageDecorator.smoothRenderingHints()); 64 | 65 | // Fill in a solid rounded block of the panel 66 | g2.setColor(getBackground()); 67 | g2.fillRoundRect(0, 0, width, height, cornerRadius, cornerRadius); 68 | 69 | // Draw the panel foreground over the shadow with rounded corners to give a subtle border effect 70 | Stroke original = g2.getStroke(); 71 | g2.setColor(getForeground()); 72 | g2.setStroke(new BasicStroke(0)); 73 | g2.drawRoundRect(0, 0, width, height, cornerRadius, cornerRadius); 74 | g2.setStroke(original); 75 | 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/themes/BaseTheme.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.themes; 20 | 21 | import java.awt.*; 22 | 23 | /** 24 | *

Abstract base class to provide the following to themes:

25 | *
    26 | *
  • Access to common values
  • 27 | *
28 | * 29 | * @since 0.0.1 30 | */ 31 | public abstract class BaseTheme implements Theme { 32 | 33 | @Override 34 | public Color creditText() { 35 | // The status color value provides suitable contrast across all themes 36 | return statusGreen(); 37 | } 38 | 39 | @Override 40 | public Color debitText() { 41 | // The status color value provides suitable contrast across all themes 42 | return statusRed(); 43 | } 44 | 45 | @Override 46 | public Color statusRed() { 47 | return new Color(210, 50, 45); 48 | } 49 | 50 | @Override 51 | public Color statusAmber() { 52 | return new Color(237, 156, 40); 53 | } 54 | 55 | @Override 56 | public Color statusGreen() { 57 | return new Color(71, 164, 71); 58 | } 59 | 60 | @Override 61 | public Color tableRowBackground() { 62 | return sidebarPanelBackground(); 63 | } 64 | 65 | @Override 66 | public Color tableRowAltBackground() { 67 | return detailPanelBackground(); 68 | } 69 | 70 | @Override 71 | public Color tableRowSelectedBackground() { 72 | return sidebarSelectedText(); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/net/bither/viewsystem/themes/ThemeKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.viewsystem.themes; 20 | 21 | 22 | import net.bither.languages.Languages; 23 | import net.bither.languages.MessageKey; 24 | 25 | /** 26 | *

Enum to provide the following to Theme API:

27 | *
    28 | *
  • Provision of supporting meta-data for a theme
  • 29 | *
30 | * 31 | * @since 0.0.1 32 | */ 33 | public enum ThemeKey { 34 | 35 | LIGHT(new LightTheme()), 36 | DARK(new DarkTheme()), 37 | BOOTSTRAP(new BootstrapTheme()), 38 | 39 | // End of enum 40 | ; 41 | 42 | private final Theme theme; 43 | 44 | /** 45 | * @param theme The theme 46 | */ 47 | ThemeKey(Theme theme) { 48 | this.theme = theme; 49 | } 50 | 51 | /** 52 | * @return The associated singleton instance of the theme 53 | */ 54 | public Theme theme() { 55 | return theme; 56 | } 57 | 58 | /** 59 | * @return The names of the themes for the current locale 60 | */ 61 | public static String[] localisedNames() { 62 | 63 | return new String[]{ 64 | Languages.safeText(MessageKey.LIGHT_THEME), 65 | Languages.safeText(MessageKey.DARK_THEME), 66 | Languages.safeText(MessageKey.BOOTSTRAP_THEME), 67 | }; 68 | 69 | } 70 | 71 | /** 72 | * @param theme The theme 73 | * @return The matching theme key 74 | */ 75 | public static ThemeKey fromTheme(Theme theme) { 76 | 77 | // Simple approach for a few themes 78 | if (theme instanceof LightTheme) { 79 | return LIGHT; 80 | } 81 | if (theme instanceof DarkTheme) { 82 | return DARK; 83 | } 84 | if (theme instanceof BootstrapTheme) { 85 | return BOOTSTRAP; 86 | } 87 | throw new IllegalArgumentException("Unknown theme '" + theme.getClass().getName() + "'"); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/net/bither/xrandom/IUEntropy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 http://Bither.net 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.bither.xrandom; 18 | 19 | public interface IUEntropy { 20 | public byte[] nextBytes(int length); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/net/bither/xrandom/IUEntropySource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * Copyright 2014 http://Bither.net 4 | * * 5 | * * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * * you may not use this file except in compliance with the License. 7 | * * You may obtain a copy of the License at 8 | * * 9 | * * http://www.apache.org/licenses/LICENSE-2.0 10 | * * 11 | * * Unless required by applicable law or agreed to in writing, software 12 | * * distributed under the License is distributed on an "AS IS" BASIS, 13 | * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * * See the License for the specific language governing permissions and 15 | * * limitations under the License. 16 | * 17 | */ 18 | 19 | package net.bither.xrandom; 20 | 21 | public interface IUEntropySource { 22 | public void onResume(); 23 | 24 | public void onPause(); 25 | 26 | public UEntropyCollector.UEntropySource type(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/net/bither/xrandom/SeedUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 http://Bither.net 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * / 17 | */ 18 | 19 | package net.bither.xrandom; 20 | 21 | public class SeedUtils { 22 | 23 | public static byte seedInt8(long x) { 24 | return (byte) (x & 255); 25 | 26 | } 27 | 28 | public static byte[] seedInt16(long x) { 29 | byte[] bytes = new byte[2]; 30 | bytes[0] = seedInt8(x); 31 | bytes[1] = seedInt8(x >> 8); 32 | return bytes; 33 | } 34 | 35 | public static byte[] seedInt32(long x) { 36 | byte[] bytes = new byte[4]; 37 | bytes[0] = seedInt8(x); 38 | bytes[1] = seedInt8(x >> 8); 39 | bytes[2] = seedInt8(x >> 16); 40 | bytes[3] = seedInt8(x >> 24); 41 | 42 | return bytes; 43 | } 44 | 45 | public static byte[] seedTime() { 46 | return seedInt32(System.currentTimeMillis()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/net/bither/xrandom/URandom.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 http://Bither.net 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.bither.xrandom; 18 | 19 | import java.io.DataInputStream; 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.IOException; 23 | import java.security.SecureRandom; 24 | 25 | public class URandom { 26 | public static File urandomFile = new File("/dev/urandom"); 27 | 28 | public static synchronized byte[] nextBytes(int length) { 29 | byte[] bytes = new byte[length]; 30 | if (!urandomFile.exists()) { 31 | SecureRandom secureRandom = new SecureRandom(); 32 | secureRandom.nextBytes(bytes); 33 | } else { 34 | try { 35 | FileInputStream stream = new FileInputStream(urandomFile); 36 | DataInputStream dis = new DataInputStream(stream); 37 | dis.readFully(bytes); 38 | dis.close(); 39 | } catch (IOException e) { 40 | throw new RuntimeException("Unable to generate URandom bytes on this Android device", e); 41 | } 42 | } 43 | return bytes; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/net/bither/xrandom/XRandom.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 http://Bither.net 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.bither.xrandom; 18 | 19 | import java.security.SecureRandom; 20 | 21 | public class XRandom extends SecureRandom { 22 | 23 | private IUEntropy uEntropy; 24 | 25 | public XRandom(IUEntropy uEntropy) { 26 | this.uEntropy = uEntropy; 27 | } 28 | 29 | private byte[] getRandomBytes(int byteLength) { 30 | System.out.println(XRandom.class.getSimpleName() + ",Request " + byteLength + " bytes from XRandom"); 31 | byte[] uRandomBytes = getURandomBytes(byteLength); 32 | if (this.uEntropy == null) { 33 | return uRandomBytes; 34 | } else { 35 | byte[] result = new byte[byteLength]; 36 | byte[] userEntropyBytes = getUEntropyBytes(byteLength); 37 | for (int i = 0; i < uRandomBytes.length; i++) { 38 | result[i] = (byte) (uRandomBytes[i] ^ userEntropyBytes[i]); 39 | } 40 | return result; 41 | } 42 | } 43 | 44 | private byte[] getURandomBytes(int length) { 45 | return URandom.nextBytes(length); 46 | } 47 | 48 | private byte[] getUEntropyBytes(int length) { 49 | return this.uEntropy.nextBytes(length); 50 | } 51 | 52 | @Override 53 | public void setSeed(long seed) { 54 | 55 | } 56 | 57 | @Override 58 | public synchronized void nextBytes(byte[] bytes) { 59 | byte[] nextBytes = getRandomBytes(bytes.length); 60 | if (nextBytes.length != bytes.length) { 61 | throw new RuntimeException("xrandom bytes length not match"); 62 | } 63 | for (int i = 0; 64 | i < bytes.length && i < nextBytes.length; 65 | i++) { 66 | bytes[i] = nextBytes[i]; 67 | } 68 | } 69 | 70 | @Override 71 | public byte[] generateSeed(int numBytes) { 72 | return getRandomBytes(numBytes); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/resources/fonts/Corben-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/fonts/Corben-Regular.ttf -------------------------------------------------------------------------------- /src/main/resources/fonts/DroidSansMono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/fonts/DroidSansMono.ttf -------------------------------------------------------------------------------- /src/main/resources/fonts/FontAwesome-4.2.0.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/fonts/FontAwesome-4.2.0.ttf -------------------------------------------------------------------------------- /src/main/resources/fonts/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/fonts/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /src/main/resources/https/bithertruststore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/https/bithertruststore.jks -------------------------------------------------------------------------------- /src/main/resources/images/accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/accept.png -------------------------------------------------------------------------------- /src/main/resources/images/address_type_hd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/address_type_hd.png -------------------------------------------------------------------------------- /src/main/resources/images/address_type_hdm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/address_type_hdm.png -------------------------------------------------------------------------------- /src/main/resources/images/address_type_private.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/address_type_private.png -------------------------------------------------------------------------------- /src/main/resources/images/address_type_watchonly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/address_type_watchonly.png -------------------------------------------------------------------------------- /src/main/resources/images/bither_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/bither_icon.png -------------------------------------------------------------------------------- /src/main/resources/images/card_corner_bottom_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/card_corner_bottom_left.png -------------------------------------------------------------------------------- /src/main/resources/images/card_corner_bottom_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/card_corner_bottom_right.png -------------------------------------------------------------------------------- /src/main/resources/images/card_corner_top_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/card_corner_top_left.png -------------------------------------------------------------------------------- /src/main/resources/images/card_corner_top_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/card_corner_top_right.png -------------------------------------------------------------------------------- /src/main/resources/images/checkKey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/checkKey.png -------------------------------------------------------------------------------- /src/main/resources/images/check_failed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/check_failed.png -------------------------------------------------------------------------------- /src/main/resources/images/checking_progress_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/checking_progress_light.png -------------------------------------------------------------------------------- /src/main/resources/images/checkmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/checkmark.png -------------------------------------------------------------------------------- /src/main/resources/images/circleProgress0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/circleProgress0.png -------------------------------------------------------------------------------- /src/main/resources/images/circleProgress1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/circleProgress1.png -------------------------------------------------------------------------------- /src/main/resources/images/circleProgress2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/circleProgress2.png -------------------------------------------------------------------------------- /src/main/resources/images/circleProgress3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/circleProgress3.png -------------------------------------------------------------------------------- /src/main/resources/images/circleProgress4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/circleProgress4.png -------------------------------------------------------------------------------- /src/main/resources/images/circleProgress5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/circleProgress5.png -------------------------------------------------------------------------------- /src/main/resources/images/pickaxe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/pickaxe.png -------------------------------------------------------------------------------- /src/main/resources/images/scan_button_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/scan_button_normal.png -------------------------------------------------------------------------------- /src/main/resources/images/shapeHexagon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/shapeHexagon.png -------------------------------------------------------------------------------- /src/main/resources/images/shapePentagon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/shapePentagon.png -------------------------------------------------------------------------------- /src/main/resources/images/shapeSquare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/shapeSquare.png -------------------------------------------------------------------------------- /src/main/resources/images/shapeTriangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/shapeTriangle.png -------------------------------------------------------------------------------- /src/main/resources/images/sidePanelHide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/sidePanelHide.png -------------------------------------------------------------------------------- /src/main/resources/images/sidePanelHideRTL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/sidePanelHideRTL.png -------------------------------------------------------------------------------- /src/main/resources/images/sidePanelShow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/sidePanelShow.png -------------------------------------------------------------------------------- /src/main/resources/images/sidePanelShowRTL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/sidePanelShowRTL.png -------------------------------------------------------------------------------- /src/main/resources/images/singleWallet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/singleWallet.png -------------------------------------------------------------------------------- /src/main/resources/images/smallExclamationMark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/smallExclamationMark.png -------------------------------------------------------------------------------- /src/main/resources/images/symbol_bits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/symbol_bits.png -------------------------------------------------------------------------------- /src/main/resources/images/symbol_bits_slim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/symbol_bits_slim.png -------------------------------------------------------------------------------- /src/main/resources/images/symbol_bits_slim_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/symbol_bits_slim_black.png -------------------------------------------------------------------------------- /src/main/resources/images/symbol_btc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/symbol_btc.png -------------------------------------------------------------------------------- /src/main/resources/images/symbol_btc_slim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/symbol_btc_slim.png -------------------------------------------------------------------------------- /src/main/resources/images/symbol_btc_slim_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/symbol_btc_slim_black.png -------------------------------------------------------------------------------- /src/main/resources/images/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/tick.png -------------------------------------------------------------------------------- /src/main/resources/images/transaction_icon_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/transaction_icon_small.png -------------------------------------------------------------------------------- /src/main/resources/images/transactions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/transactions.png -------------------------------------------------------------------------------- /src/main/resources/images/transactionsExport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/transactionsExport.png -------------------------------------------------------------------------------- /src/main/resources/images/xrandom_address_label_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/xrandom_address_label_normal.png -------------------------------------------------------------------------------- /src/main/resources/images/yourWallets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/yourWallets.png -------------------------------------------------------------------------------- /src/main/resources/images/zoom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/src/main/resources/images/zoom.png -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %xEx%n 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/main/resources/version.properties: -------------------------------------------------------------------------------- 1 | version=${project.version} -------------------------------------------------------------------------------- /vanitygen/.gitignore: -------------------------------------------------------------------------------- 1 | *.oclbin 2 | *.o 3 | keyconv 4 | oclvanitygen 5 | oclvanityminer 6 | vanitygen 7 | *.obj 8 | oclvanitygen.pdb 9 | *.pdb 10 | -------------------------------------------------------------------------------- /vanitygen/linux/oclvanitygen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/vanitygen/linux/oclvanitygen -------------------------------------------------------------------------------- /vanitygen/linux/vanitygen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/vanitygen/linux/vanitygen -------------------------------------------------------------------------------- /vanitygen/mac/oclvanitygen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/vanitygen/mac/oclvanitygen -------------------------------------------------------------------------------- /vanitygen/mac/vanitygen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/vanitygen/mac/vanitygen -------------------------------------------------------------------------------- /vanitygen/windows/oclvanitygen.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/vanitygen/windows/oclvanitygen.exe -------------------------------------------------------------------------------- /vanitygen/windows/oclvanitygen64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/vanitygen/windows/oclvanitygen64.exe -------------------------------------------------------------------------------- /vanitygen/windows/pthreadVC2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/vanitygen/windows/pthreadVC2.dll -------------------------------------------------------------------------------- /vanitygen/windows/vanitygen.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/vanitygen/windows/vanitygen.exe -------------------------------------------------------------------------------- /vanitygen/windows/vanitygen64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bither/bither-desktop-java/6940271e48bfd6e0c3a814a60e9f10bebd743c85/vanitygen/windows/vanitygen64.exe --------------------------------------------------------------------------------