Skip to content

Commit a5026af

Browse files
committed
修改打包不能读取配置问题
1 parent 212054e commit a5026af

File tree

10 files changed

+78
-51
lines changed

10 files changed

+78
-51
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*.tar.gz
2020
*.rar
2121
target
22+
out
2223

2324
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2425
hs_err_pid*

config/nbs-conf.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ nbs.client.merkle.root.hash=skjfhsafkdasfd
66

77
nbs.client.profile.root=profile
88
nbs.client.files.root=nbs
9-
9+
nbs.client.im.topic.subworld =disabled
10+
nbs.client.i18n.home=zh_cn
1011
nbs.server.address=/ip4/127.0.0.1/tcp/5001

pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,13 @@
147147
</execution>
148148
</executions>
149149
<configuration>
150-
<assembleDirectory>${project.build.directory}/nbs</assembleDirectory>
150+
<assembleDirectory>${project.basedir}/out</assembleDirectory>
151151
<repositoryLayout>flat</repositoryLayout>
152152
<repositoryName>lib</repositoryName>
153153
<binFolder>bin</binFolder>
154154
<configurationDirectory>conf</configurationDirectory>
155155
<configurationSourceDirectory>src/main/resources</configurationSourceDirectory>
156156
<configurationDirectory>true</configurationDirectory>
157-
158157
<includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
159158
<encoding>UTF-8</encoding>
160159
<logsDirectory>logs</logsDirectory>

src/main/java/UI/AppMainWindow.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.nbs.tools.ConfigHelper;
1616

1717
import com.nbs.tools.DateHelper;
18+
import com.nbs.tools.PropertyUtil;
1819
import com.nbs.ui.frames.MainFrame;
1920
import com.nbs.utils.Base64CodecUtil;
2021
import com.nbs.utils.RadomCharactersHelper;
@@ -260,13 +261,14 @@ private void initialize(){
260261
* 加载环境配置
261262
*/
262263
private void loadEnv(){
264+
logger.info("=====>>>>>>> NBS Chain Client4J ENV initializing......");
263265
Properties props = ConfigHelper.getEnv();
264-
logger.info("ENV ============================>>");
266+
265267
for(String k : props.stringPropertyNames()){
266268
String v = props.getProperty(k);
267269
logger.info(k+"="+v);
268270
}
269-
logger.info("ENV ============================<<");
271+
270272
/**
271273
* 初始化文件目录
272274
*/
@@ -290,7 +292,9 @@ private void loadEnv(){
290292
SEFL_BASE = initCurrentPeerInfo();
291293
}
292294
SERVER_STAT = true;
293-
logger.info("NBS Client Start success.");
295+
String s = PropertyUtil.getProperty("PKUI_PANEL_ABOUT_LABEL");
296+
logger.info(ConstantsUI.BUTTON_ICON_ROOT);
297+
logger.info("=====>>>>>>> NBS Chain Client4J ENV initialized Success......");
294298
}
295299

296300

@@ -358,9 +362,6 @@ public void run() {
358362
}
359363

360364

361-
362-
363-
364365
/**
365366
*
366367
* @param m

src/main/java/UI/ConstantsUI.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package UI;
22

3+
import com.nbs.tools.ConfigHelper;
34
import com.nbs.tools.PropertyUtil;
45

56
import javax.swing.*;
@@ -19,8 +20,7 @@ public class ConstantsUI {
1920
* 软件名称、版本
2021
*/
2122
public final static String APP_NAME = "NBS Chain";
22-
public final static String APP_VERSION = "v0.1";
23-
public final static String CRLF_PANEL = "\\r\\n";
23+
2424

2525
public final static String ENTER_CHARACTER = "\n";
2626
public final static String WSPACE_CHARACTER4 = " ";
@@ -56,8 +56,7 @@ public class ConstantsUI {
5656
/**
5757
* 图标路径
5858
*/
59-
public static final String BUTTON_ICON_ROOT = "/icon"+File.separator
60-
+PropertyUtil.getProperty("nbs.button.dir","")+ File.separator;
59+
public static final String BUTTON_ICON_ROOT = "/icon/zh_cn/";
6160

6261
/**
6362
* 主图标
@@ -133,7 +132,8 @@ public class ConstantsUI {
133132
AppMainWindow.class.getResource("/icon/data.png"));
134133
public final static ImageIcon ICON_FILE_ENABLED = new ImageIcon(
135134
AppMainWindow.class.getResource("/icon/data_enabled.png"));
136-
public final static ImageIcon ICON_FILE_LS = new ImageIcon(AppMainWindow.class.getResource(BUTTON_ICON_ROOT+"file_ls_normal.png"));
135+
136+
public final static ImageIcon ICON_FILE_LS = new ImageIcon(AppMainWindow.class.getResource("/icon/zh_cn/" +"file_ls_normal.png"));
137137
public final static ImageIcon ICON_FILE_LS_ENABLED = new ImageIcon(AppMainWindow.class.getResource(BUTTON_ICON_ROOT+"file_ls_enabled.png"));
138138
public final static ImageIcon ICON_FILE_LS_DISABLED = new ImageIcon(AppMainWindow.class.getResource(BUTTON_ICON_ROOT+"file_ls_disabled.png"));
139139

src/main/java/UI/panel/fm/FilePanel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public void actionPerformed(ActionEvent e) {
151151
}
152152
} catch (IOException e1) {
153153
e1.printStackTrace();
154+
logger.error("Query Hash",e1.getMessage());
154155
}
155156

156157
}

src/main/java/com/nbs/tools/CnstTools.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/main/java/com/nbs/tools/ConfigHelper.java

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package com.nbs.tools;
22

3-
import UI.ConstantsUI;
4-
import com.nbs.utils.FormatCnst;
53
import org.apache.commons.lang3.StringUtils;
6-
import org.apache.commons.lang3.time.DateFormatUtils;
7-
import org.apache.commons.lang3.time.DateUtils;
4+
85
import org.slf4j.Logger;
96
import org.slf4j.LoggerFactory;
107

@@ -28,7 +25,9 @@ public class ConfigHelper {
2825
* 系统当前路径
2926
*/
3027
public final static String CURRENT_DIR = System.getProperty("user.dir");
28+
public final static String OS_FILE_SEPARATOR = File.separator;
3129
public static final String CONF_ROOT = CURRENT_DIR + File.separator+"config" + File.separator;
30+
private static final String CONF_FILE = "nbs-conf.properties";
3231
public static final String PROFILE_ROOT = CURRENT_DIR + File.separator+"profile" + File.separator;
3332
public static final String NBS_FILES_ROOT_PATH = CURRENT_DIR + File.separator +"nbs" + File.separator;
3433
public static final String NBS_FILES_IPFS_ROOT = NBS_FILES_ROOT_PATH + "ipfs"+ File.separator;
@@ -37,7 +36,7 @@ public class ConfigHelper {
3736
*/
3837
public static final String NBS_TEMP_ROOT = NBS_FILES_ROOT_PATH + "_temp" + File.separator;
3938
public static final String NBS_CACHE_AVATAR_ROOT_PATH = NBS_FILES_ROOT_PATH +"cache"+ File.separator+ "avatar" + File.separator;
40-
private static final String CONF_FILE = "nbs-conf.properties";
39+
4140

4241
public static final String PK_CFG_IPFS_ADDR = "nbs.server.address";
4342
private static final String CLIENT_ADD_FILE_ROOT = "nbs.client.merkle.root";
@@ -49,13 +48,13 @@ public class ConfigHelper {
4948
public static String JSON_AVATAR_NAME_KEY = "avatar-name";
5049
public static String JSON_AVATAR_SUFFIX_KEY = "suffix";
5150

52-
5351
private static Properties env = new Properties();
52+
private static Properties i18nProps = new Properties();
5453
static {
5554
InputStream is = null;
5655
try{
5756
is = new BufferedInputStream(new FileInputStream(
58-
CnstTools.PROPS_ROOT_PATH + CONF_FILE));
57+
CONF_ROOT + CONF_FILE));
5958
env.load(is);
6059
is.close();
6160
}catch (IOException ioe){
@@ -67,6 +66,18 @@ public class ConfigHelper {
6766
}
6867
}
6968
}
69+
if(is != null)is=null;
70+
/**
71+
* i18n
72+
*/
73+
try{
74+
is = new BufferedInputStream(new FileInputStream(
75+
CONF_ROOT + "zh-cn.properties"));
76+
i18nProps.load(is);
77+
is.close();
78+
}catch (Exception e){
79+
logger.error("load i18n config error.");
80+
}
7081
}
7182

7283
/**
@@ -196,4 +207,40 @@ public static boolean storeClientAddFileRootHash(String hash,String comments) th
196207
public static String getAddLogFileName(){
197208
return env.getProperty("nbs.client.merkle.add.log.name","");
198209
}
210+
211+
/**
212+
* 控制显示会员
213+
* @return
214+
*/
215+
public static boolean subWorldPeers(){
216+
String stats = env.getProperty("nbs.client.im.topic.subworld","enabled");
217+
return(stats.equalsIgnoreCase("enabled")
218+
|| stats.equalsIgnoreCase("true")
219+
|| stats.equalsIgnoreCase("1")
220+
) ? true : false;
221+
}
222+
223+
public static String getI18nResourceHome(){
224+
String i18nHome = env.getProperty("nbs.client.i18n.home","zh_cn");
225+
return OS_FILE_SEPARATOR+"icon"+OS_FILE_SEPARATOR+i18nHome+OS_FILE_SEPARATOR;
226+
}
227+
228+
/**
229+
*
230+
* @param key
231+
* @return
232+
*/
233+
public static String getI18nProperty(String key){
234+
return i18nProps.getProperty(key);
235+
}
236+
237+
/**
238+
*
239+
* @param key
240+
* @param defaultVal
241+
* @return
242+
*/
243+
public static String getI18nProperty(String key,String defaultVal){
244+
return i18nProps.getProperty(key,defaultVal);
245+
}
199246
}

src/main/java/com/nbs/tools/PropertyUtil.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
* All rights reserved.
1818
*/
1919
public class PropertyUtil {
20-
21-
22-
2320
/**
2421
* @Date : 2018/6/13 15:49
2522
* @Author : lanbery
@@ -35,6 +32,7 @@ public static String getProperty(String key){
3532

3633
InputStream in = new BufferedInputStream(
3734
new FileInputStream(ConfigHelper.CONF_ROOT+"zh-cn.properties"));
35+
System.out.println(ConfigHelper.CONF_ROOT+"zh-cn.properties");
3836
props.load(in);
3937
String v = props.getProperty(key);
4038
return v;

src/main/java/com/nbs/ui/panels/ContactsPanel.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ private List<ContactsEntity> getContacts(){
155155
IPFS ipfs = IPFSHelper.getInstance().getIpfs();
156156

157157
try {
158-
Object obj = ipfs.pubsub.peers();
158+
Object obj = null;
159+
if(ConfigHelper.subWorldPeers()){
160+
obj = ipfs.pubsub.peers(IPFSHelper.NBSWORLD_IMS_TOPIC);
161+
}else {
162+
obj = ipfs.pubsub.peers();
163+
}
159164
if(obj==null)return contacts;
160165
List<String> peers = (List<String>)JSONParser.getValue(obj,"Strings");
161166
if(peers!=null&&peers.size()>0){

0 commit comments

Comments
 (0)