Browse Source

Merge pull request #1186 in BA/design from ~XIAOXIA/design:release/9.0 to release/9.0

* commit '199d2645d36e91c6e1f4c67854937e6f5683bb31':
  rt
  搜索去除中文输入法的影响 多线程问题
  rt
  rt
  插件搜索问题
  rt
  键盘监听修改
  代码质量
  去掉功能点 换种方式
  搜索结果重复 改下代码质量
  rt
  视觉验收 字体调整
  pmd
  pmd
  bug fix
  rt
  国际化错了 改下代码质量
  国际化错了
master
superman 7 years ago
parent
commit
97d6520046
  1. 134
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  2. 4
      designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java
  3. 5
      designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java
  4. 7
      designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java
  5. 5
      designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java
  6. 8
      designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java
  7. 5
      designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  8. 6
      designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

134
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -71,6 +71,7 @@ public class AlphaFineDialog extends UIDialog {
private static final String PLUGIN_MARK_SHORT = "k:4 ";
private static final String PLUGIN_MARK = "k:shop ";
private static final String PLACE_HOLDER = Inter.getLocText("FR-Designer_AlphaFine");
private static final int MAX_SHOW_SIZE = 12;
private AlphaFineTextField searchTextField;
private UIButton closeButton;
@ -89,7 +90,6 @@ public class AlphaFineDialog extends UIDialog {
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
private boolean forceOpen;
public AlphaFineDialog(Frame parent, boolean forceOpen) {
super(parent);
this.forceOpen = forceOpen;
@ -161,12 +161,6 @@ public class AlphaFineDialog extends UIDialog {
});
topPane.add(closeButton, BorderLayout.EAST);
add(topPane, BorderLayout.CENTER);
searchTextField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
doSearch(searchTextField.getText());
}
});
}
/**
@ -174,7 +168,7 @@ public class AlphaFineDialog extends UIDialog {
*/
private void initSearchTextField() {
searchTextField = new AlphaFineTextField(PLACE_HOLDER);
initTextFieldKeyListener();
initTextFieldListener();
searchTextField.setFont(AlphaFineConstants.GREATER_FONT);
searchTextField.setBackground(Color.WHITE);
searchTextField.setBorderPainted(false);
@ -228,16 +222,11 @@ public class AlphaFineDialog extends UIDialog {
* @param text
*/
private void doSearch(String text) {
if (StringUtils.isBlank(text) || isNeedSearch(text)) {
removeSearchResult();
} else {
showSearchResult();
}
showSearchResult(text);
}
boolean isNeedSearch(String text) {
return ComparatorUtils.equals(PLACE_HOLDER, text) || text.contains("'");
boolean isNoNeedSearch(String text) {
return ComparatorUtils.equals(PLACE_HOLDER, text) || text.contains("'") || StringUtils.isBlank(text);
}
@Override
@ -272,17 +261,17 @@ public class AlphaFineDialog extends UIDialog {
searchResultPane = null;
}
setSize(AlphaFineConstants.FIELD_SIZE);
repaint();
refreshContainer();
}
/**
* 展示搜索结果
*/
private void showSearchResult() {
private void showSearchResult(String text) {
if (searchResultPane == null) {
initSearchResultComponents();
}
initSearchWorker();
initSearchWorker(text);
}
/**
@ -299,8 +288,8 @@ public class AlphaFineDialog extends UIDialog {
searchResultList.setCellRenderer(new ContentCellRender());
leftSearchResultPane = new UIScrollPane(searchResultList);
leftSearchResultPane.setBorder(null);
leftSearchResultPane.setBackground(Color.WHITE);
leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
leftSearchResultPane.setPreferredSize(new Dimension(AlphaFineConstants.LEFT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT));
rightSearchResultPane = new JPanel();
rightSearchResultPane.setBackground(Color.WHITE);
@ -317,7 +306,7 @@ public class AlphaFineDialog extends UIDialog {
/**
* 异步加载搜索结果
*/
private void initSearchWorker() {
private void initSearchWorker(final String text) {
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
@ -325,9 +314,7 @@ public class AlphaFineDialog extends UIDialog {
this.searchWorker = new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {
resumeLeftPane();
splitLabel.setIcon(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigloading.gif")));
rebuildList(searchTextField.getText().toLowerCase());
rebuildList(text);
return null;
}
@ -347,11 +334,9 @@ public class AlphaFineDialog extends UIDialog {
*/
private void resumeLeftPane() {
if (searchResultPane != null && defaultPane != null) {
rightSearchResultPane.removeAll();
searchResultPane.remove(defaultPane);
defaultPane = null;
searchResultPane.add(leftSearchResultPane, BorderLayout.WEST);
refreshContainer();
}
}
@ -394,25 +379,26 @@ public class AlphaFineDialog extends UIDialog {
*/
private void rebuildList(String searchText) {
resetContainer();
if (searchText.startsWith(ADVANCED_SEARCH_MARK)) {
if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) {
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length());
getActionList(storeText);
buildActionList(storeText);
} else if (searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) {
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length());
getDocumentList(storeText);
buildDocumentList(storeText);
} else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)) {
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length());
getFileList(storeText);
buildFileList(storeText);
} else if (searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)) {
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length());
getFileList(searchText);
buildFileList(searchText);
} else if (searchText.startsWith(DS_MARK)) {
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length());
getFileList(DS_NAME + storeText);
buildFileList(DS_NAME + storeText);
} else if (searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) {
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length());
getPluginList(storeText);
buildPluginList(storeText);
}
} else {
storeText = searchText.trim();
@ -425,9 +411,11 @@ public class AlphaFineDialog extends UIDialog {
* 重置面板
*/
private void resetContainer() {
rightSearchResultPane.removeAll();
splitLabel.setIcon(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigloading.gif")));
resumeLeftPane();
searchListModel.removeAllElements();
searchListModel.resetSelectedState();
rightSearchResultPane.removeAll();
refreshContainer();
}
@ -437,23 +425,22 @@ public class AlphaFineDialog extends UIDialog {
* @param searchText
*/
private void doNormalSearch(String searchText) {
getRecentList(searchText);
getRecommendList(searchText);
getActionList(searchText);
getFileList(searchText);
getDocumentList(searchText);
getPluginList(searchText);
buildRecentList(searchText);
buildRecommendList(searchText);
buildActionList(searchText);
buildFileList(searchText);
buildDocumentList(searchText);
buildPluginList(searchText);
}
private void getDocumentList(final String searchText) {
private void buildDocumentList(final String searchText) {
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText);
for (AlphaCellModel object : documentModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
}
private void getFileList(final String searchText) {
private void buildFileList(final String searchText) {
SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText);
for (AlphaCellModel object : fileModelList) {
AlphaFineHelper.checkCancel();
@ -461,34 +448,30 @@ public class AlphaFineDialog extends UIDialog {
}
}
private void getActionList(final String searchText) {
private void buildActionList(final String searchText) {
SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText);
for (AlphaCellModel object : actionModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
}
private void getPluginList(final String searchText) {
private void buildPluginList(final String searchText) {
SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText);
for (AlphaCellModel object : pluginModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
}
private void getRecommendList(final String searchText) {
private void buildRecommendList(final String searchText) {
SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText);
for (AlphaCellModel object : recommendModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
}
private void getRecentList(final String searchText) {
private void buildRecentList(final String searchText) {
SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText);
for (AlphaCellModel object : recentModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
@ -639,11 +622,10 @@ public class AlphaFineDialog extends UIDialog {
}
}
private void HandleMoreOrLessResult(int index, MoreModel selectedValue) {
if (selectedValue.getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowAll"))) {
private void dealWithMoreOrLessResult(int index, MoreModel selectedValue) {
if (ComparatorUtils.equals(Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), selectedValue.getContent())) {
selectedValue.setContent(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"));
rebuildShowMoreList(index, selectedValue);
} else {
selectedValue.setContent(Inter.getLocText("FR-Designer_AlphaFine_ShowAll"));
rebuildShowMoreList(index, selectedValue);
@ -655,8 +637,7 @@ public class AlphaFineDialog extends UIDialog {
UILabel label = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/opening.gif")));
label.setBorder(BorderFactory.createEmptyBorder(120, 0, 0, 0));
rightSearchResultPane.add(label, BorderLayout.CENTER);
validate();
repaint();
refreshContainer();
}
/**
@ -667,18 +648,15 @@ public class AlphaFineDialog extends UIDialog {
}
/**
* 为textfield添加键盘监听器
* 为textfield添加监听器
*/
private void initTextFieldKeyListener() {
private void initTextFieldListener() {
searchTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
searchResultList.requestFocus();
searchResultList.setSelectedIndex(searchResultList.getSelectedIndex() + 1);
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
doNavigate();
saveHistory(searchResultList.getSelectedValue());
}
}
@ -690,7 +668,25 @@ public class AlphaFineDialog extends UIDialog {
AlphaFineDialog.this.setVisible(false);
} else {
searchTextField.setText(null);
removeSearchResult();
}
}
}
});
searchTextField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
if (isNoNeedSearch(searchTextField.getText())) {
removeSearchResult();
} else {
try {
Thread.sleep(10);
doSearch(searchTextField.getText());
} catch (InterruptedException e1) {
FRLogger.getLogger().error(e1.getMessage());
}
}
}
});
@ -726,7 +722,7 @@ public class AlphaFineDialog extends UIDialog {
@Override
public void checkValid() throws Exception {
//不处理
}
private void doNavigate() {
@ -778,7 +774,6 @@ public class AlphaFineDialog extends UIDialog {
if (!httpClient.isServerAlive()) {
FRLogger.getLogger().error("Failed to sent data to server!");
}
httpClient.setTimeout(5000);
}
@ -935,7 +930,7 @@ public class AlphaFineDialog extends UIDialog {
saveHistory(selectedValue);
} else if (e.getClickCount() == 1) {
if (selectedValue instanceof MoreModel && ((MoreModel) selectedValue).isNeedMore()) {
HandleMoreOrLessResult(selectedIndex, (MoreModel) selectedValue);
dealWithMoreOrLessResult(selectedIndex, (MoreModel) selectedValue);
}
}
}
@ -971,10 +966,23 @@ public class AlphaFineDialog extends UIDialog {
@Override
public void addElement(AlphaCellModel element) {
AlphaFineHelper.checkCancel();
int index = myDelegate.size();
myDelegate.add(element);
fireContentsChanged(this, index, index);
fireSelectedStateChanged(element, index);
}
@Override
protected void fireContentsChanged(Object source, int index0, int index1) {
if (myDelegate.size() > MAX_SHOW_SIZE) {
leftSearchResultPane.getVerticalScrollBar().setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 2));
} else {
leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
}
super.fireContentsChanged(source, index0, index1);
}
/**

4
designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java

@ -49,10 +49,10 @@ public class PluginPreviewPane extends JPanel {
nameLabel.setBackground(AlphaFineConstants.BLUE);
nameLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20));
line.setBorder(BorderFactory.createEmptyBorder(20, 0, 10, 0));
String price0 = price == 0 ? Inter.getLocText("FR-Designer-Collect_Information_free") : String.valueOf(price);
String price0 = price == 0 ? Inter.getLocText("FR-Designer-Collect_Information_free") : "¥" + String.valueOf(price);
UILabel priceLabel = new UILabel(price0);
priceLabel.setForeground(AlphaFineConstants.RED);
priceLabel.setFont(AlphaFineConstants.SMALL_FONT);
priceLabel.setFont(AlphaFineConstants.MEDIUM_FONT);
bottomPane.add(priceLabel, BorderLayout.WEST);
panel.add(nameLabel, BorderLayout.NORTH);
panel.add(line, BorderLayout.SOUTH);

5
designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java

@ -75,10 +75,9 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
result.add(object);
}
}
if (result.size() == 0) {
if (result.isEmpty()) {
return lessModelList;
}
if (result.size() > 0 && result.size() < AlphaFineConstants.SHOW_SIZE + 1) {
} else if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set")));
lessModelList.addAll(result);
} else {

7
designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java

@ -61,7 +61,6 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
if (!httpClient.isServerAlive()) {
return getNoConnectList();
}
httpClient.setTimeout(5000);
result = httpClient.getResponseText();
AlphaFineHelper.checkCancel();
try {
@ -76,10 +75,9 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
searchResult.add(cellModel);
}
}
if (searchResult.size() == 0) {
if (searchResult.isEmpty()) {
return lessModelList;
}
if (searchResult.size() > 0 && searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) {
} else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP")));
lessModelList.addAll(searchResult);
} else {
@ -90,7 +88,6 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
}
} catch (JSONException e) {
FRLogger.getLogger().error("document search error: " + e.getMessage());
return lessModelList;
}
}
return lessModelList;

5
designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java

@ -100,10 +100,9 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
}
}
if (result.size() == 0) {
if (result.isEmpty()) {
return lessModelList;
}
if (result.size() > 0 && result.size() < AlphaFineConstants.SHOW_SIZE + 1) {
} else if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Templates")));
lessModelList.addAll(result);
} else {

8
designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java

@ -96,7 +96,6 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
if (!httpClient.isServerAlive()) {
return getNoConnectList();
}
httpClient.setTimeout(5000);
result = httpClient.getResponseText();
AlphaFineHelper.checkCancel();
JSONObject jsonObject = new JSONObject(result);
@ -109,11 +108,10 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
searchResult.add(cellModel);
}
}
if (searchResult.size() == 0) {
if (searchResult.isEmpty()) {
return this.lessModelList;
}
if (searchResult.size() > 0 && searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Templates")));
} else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon")));
lessModelList.addAll(searchResult);
} else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.PLUGIN));

5
designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java

@ -202,10 +202,7 @@ public class AlphaFineConfigManager implements XMLable {
}
public boolean isEnabled() {
if (VT4FR.isLicAvailable(FRCoreContext.getBytes()) && VT4FR.ALPHA_FINE.support()) {
return isEnabled;
}
return false;
return isEnabled;
}
public void setEnabled(boolean isEnabled) {

6
designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -381,10 +381,8 @@ public abstract class ToolBarMenuDock {
// shortCuts.add(new ForumAction());
}
shortCuts.add(SeparatorDef.DEFAULT);
if (VT4FR.isLicAvailable(FRCoreContext.getBytes()) && VT4FR.ALPHA_FINE.support()) {
shortCuts.add(new AlphaFineAction());
shortCuts.add(SeparatorDef.DEFAULT);
}
shortCuts.add(new AlphaFineAction());
shortCuts.add(SeparatorDef.DEFAULT);
shortCuts.add(new AboutAction());
return shortCuts.toArray(new ShortCut[shortCuts.size()]);
}

Loading…
Cancel
Save