|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.fr.design.javascript; |
|
|
|
|
|
|
|
|
|
import com.fr.base.svg.IconUtils; |
|
|
|
|
import com.fr.design.border.UIRoundedBorder; |
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
import com.fr.design.gui.autocomplete.AutoCompleteExtraRefreshComponent; |
|
|
|
@ -12,7 +13,7 @@ import com.fr.design.gui.ibutton.UIButton;
|
|
|
|
|
import com.fr.design.gui.icontainer.UIScrollPane; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.gui.itextarea.UITextArea; |
|
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
|
import com.fr.design.gui.itextfield.PlaceholderTextField; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.javascript.jsapi.JSAPITreeHelper; |
|
|
|
|
import com.fr.design.javascript.jsapi.JSAPIUserObject; |
|
|
|
@ -26,8 +27,10 @@ import com.fr.json.JSONObject;
|
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.CardLayout; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.Cursor; |
|
|
|
|
import java.awt.Desktop; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
@ -69,7 +72,7 @@ import javax.swing.tree.TreePath;
|
|
|
|
|
public class JSContentWithDescriptionPane extends JSContentPane implements KeyListener { |
|
|
|
|
|
|
|
|
|
//搜索关键词输入框
|
|
|
|
|
private UITextField keyWordTextField = new UITextField(16); |
|
|
|
|
private PlaceholderTextField keyWordTextField = new PlaceholderTextField(16); |
|
|
|
|
//搜索出的提示列表
|
|
|
|
|
private JList tipsList; |
|
|
|
|
private DefaultListModel tipsListModel = new DefaultListModel(); |
|
|
|
@ -109,6 +112,11 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
|
|
|
|
|
|
|
|
|
|
private String currentValue; |
|
|
|
|
|
|
|
|
|
private static CardLayout card; |
|
|
|
|
|
|
|
|
|
private static final String RELOAD_CARD = "reloadCard"; |
|
|
|
|
private static final String DOC_LIST_CARD = "docListCard"; |
|
|
|
|
|
|
|
|
|
public JSContentWithDescriptionPane(String[] args) { |
|
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
|
//===============================
|
|
|
|
@ -156,6 +164,14 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
|
|
|
|
|
this.add(functionNameAndDescriptionPanel, BorderLayout.SOUTH); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void populate(String js) { |
|
|
|
|
contentTextArea.setText(js); |
|
|
|
|
ifHasBeenWriten = 1; |
|
|
|
|
currentPosition = contentTextArea.getCaretPosition(); |
|
|
|
|
beginPosition = getBeginPosition(); |
|
|
|
|
insertPosition = beginPosition; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initContextAreaListener() { |
|
|
|
|
contentTextArea.addKeyListener(new KeyAdapter() { |
|
|
|
|
@Override |
|
|
|
@ -186,6 +202,27 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
|
|
|
|
|
uninstallAutoCompletion(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
contentTextArea.addMouseListener(new MouseAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
insertPosition = contentTextArea.getCaretPosition(); |
|
|
|
|
if (ifHasBeenWriten == 0) { |
|
|
|
|
contentTextArea.setText(StringUtils.EMPTY); |
|
|
|
|
ifHasBeenWriten = 1; |
|
|
|
|
contentTextArea.setForeground(Color.black); |
|
|
|
|
insertPosition = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
|
currentPosition = contentTextArea.getCaretPosition(); |
|
|
|
|
if (currentPosition == insertPosition) { |
|
|
|
|
beginPosition = getBeginPosition(); |
|
|
|
|
insertPosition = beginPosition; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -281,9 +318,9 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
|
|
|
|
|
String value = ((JSAPIUserObject) userObject).getValue(); |
|
|
|
|
if (StringUtils.equals(value, directCategory)) { |
|
|
|
|
moduleTree.setSelectionPath(new TreePath(treeModel.getPathToRoot(node))); |
|
|
|
|
moduleTree.scrollPathToVisible(moduleTree.getSelectionPath()); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < node.getChildCount(); i++) { |
|
|
|
|
if (setModuleTreeSelection(node.getChildAt(i), directCategory, treeModel)) { |
|
|
|
@ -340,39 +377,60 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initHelpDocumentPane(JPanel descriptionAndDocumentPanel) { |
|
|
|
|
UIScrollPane helpDOCScrollPane; |
|
|
|
|
if (isNetworkOk()) { |
|
|
|
|
helpDOCList = new JList(new DefaultListModel()); |
|
|
|
|
initHelpDOCListRender(); |
|
|
|
|
initHelpDOCListListener(); |
|
|
|
|
helpDOCScrollPane = new UIScrollPane(helpDOCList); |
|
|
|
|
doHelpDocumentSearch(); |
|
|
|
|
} else { |
|
|
|
|
UILabel label1 = new UILabel(Toolkit.i18nText("Fine-Design_Net_Connect_Failed"), 0); |
|
|
|
|
label1.setPreferredSize(new Dimension(180, 20)); |
|
|
|
|
UILabel label2 = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Reload"), 0); |
|
|
|
|
label2.setPreferredSize(new Dimension(180, 20)); |
|
|
|
|
label2.setForeground(Color.blue); |
|
|
|
|
card = new CardLayout(); |
|
|
|
|
JPanel mainPane = new JPanel(card); |
|
|
|
|
initHelpDocumentList(); |
|
|
|
|
UIScrollPane helpDOCScrollPane = new UIScrollPane(helpDOCList); |
|
|
|
|
helpDOCScrollPane.setPreferredSize(new Dimension(200, 200)); |
|
|
|
|
helpDOCScrollPane.setBorder(null); |
|
|
|
|
mainPane.add(helpDOCScrollPane, DOC_LIST_CARD); |
|
|
|
|
|
|
|
|
|
UILabel imageLabel = new UILabel(); |
|
|
|
|
imageLabel.setIcon(IconUtils.readIcon("com/fr/design/javascript/jsapi/images/connectFailed.svg")); |
|
|
|
|
imageLabel.setPreferredSize(new Dimension(180, 65)); |
|
|
|
|
JPanel imagePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
imagePane.setBorder(BorderFactory.createEmptyBorder(0, 42, 0, 0)); |
|
|
|
|
imagePane.add(imageLabel); |
|
|
|
|
imagePane.setBackground(Color.WHITE); |
|
|
|
|
|
|
|
|
|
UILabel failedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Net_Connect_Failed"), 0); |
|
|
|
|
failedLabel.setPreferredSize(new Dimension(180, 20)); |
|
|
|
|
UILabel reloadLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Reload"), 0); |
|
|
|
|
reloadLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
|
|
|
|
reloadLabel.setPreferredSize(new Dimension(180, 20)); |
|
|
|
|
reloadLabel.setForeground(Color.blue); |
|
|
|
|
JPanel labelPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, 0, 0, 0); |
|
|
|
|
|
|
|
|
|
labelPane.setBorder(BorderFactory.createEmptyBorder(35, 45, 0, 0)); |
|
|
|
|
labelPane.setBackground(Color.WHITE); |
|
|
|
|
labelPane.add(label1); |
|
|
|
|
labelPane.add(label2); |
|
|
|
|
labelPane.add(imagePane); |
|
|
|
|
labelPane.add(failedLabel); |
|
|
|
|
labelPane.add(reloadLabel); |
|
|
|
|
JPanel containerPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
containerPanel.add(labelPane, BorderLayout.CENTER); |
|
|
|
|
helpDOCScrollPane = new UIScrollPane(containerPanel); |
|
|
|
|
label2.addMouseListener(new MouseAdapter() { |
|
|
|
|
reloadLabel.addMouseListener(new MouseAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
descriptionAndDocumentPanel.removeAll(); |
|
|
|
|
initHelpDocumentPane(descriptionAndDocumentPanel); |
|
|
|
|
|
|
|
|
|
if (isNetworkOk()) { |
|
|
|
|
doHelpDocumentSearch(); |
|
|
|
|
card.show(mainPane, DOC_LIST_CARD); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
mainPane.add(containerPanel, RELOAD_CARD); |
|
|
|
|
if (isNetworkOk()) { |
|
|
|
|
doHelpDocumentSearch(); |
|
|
|
|
card.show(mainPane, DOC_LIST_CARD); |
|
|
|
|
} else { |
|
|
|
|
card.show(mainPane, RELOAD_CARD); |
|
|
|
|
} |
|
|
|
|
descriptionAndDocumentPanel.add(this.createNamePane(Toolkit.i18nText("Fine-Design_Relevant_Cases"), mainPane), BorderLayout.EAST); |
|
|
|
|
} |
|
|
|
|
helpDOCScrollPane.setPreferredSize(new Dimension(200, 200)); |
|
|
|
|
helpDOCScrollPane.setBorder(null); |
|
|
|
|
descriptionAndDocumentPanel.add(this.createNamePane(Toolkit.i18nText("Fine-Design_Relevant_Cases"), helpDOCScrollPane), BorderLayout.EAST); |
|
|
|
|
|
|
|
|
|
private void initHelpDocumentList() { |
|
|
|
|
helpDOCList = new JList(new DefaultListModel()); |
|
|
|
|
initHelpDOCListRender(); |
|
|
|
|
initHelpDOCListListener(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initHelpDOCListListener() { |
|
|
|
@ -558,7 +616,12 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initInterfaceNameModule() { |
|
|
|
|
moduleTree.setSelectionPath(moduleTree.getPathForRow(0)); |
|
|
|
|
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) moduleTree.getModel(); |
|
|
|
|
TreeNode root = (TreeNode) defaultTreeModel.getRoot(); |
|
|
|
|
while (root.getChildCount() > 0){ |
|
|
|
|
root = root.getChildAt(0); |
|
|
|
|
} |
|
|
|
|
moduleTree.setSelectionPath(new TreePath(defaultTreeModel.getPathToRoot(root))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setDescription(String interfaceName) { |
|
|
|
@ -652,6 +715,7 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi
|
|
|
|
|
tipsPane.setBorder(BorderFactory.createEmptyBorder(30, 2, 0, 0)); |
|
|
|
|
JPanel searchPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
searchPane.setLayout(new BorderLayout(4, 4)); |
|
|
|
|
keyWordTextField.setPlaceholder(Toolkit.i18nText("Fine-Design_Search_Interface")); |
|
|
|
|
searchPane.add(keyWordTextField, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
//搜索按钮
|
|
|
|
|