Browse Source

插件商店搜索

master
vito 9 years ago
parent
commit
805dc06959
  1. 4
      designer_base/src/com/fr/design/actions/server/PluginManagerAction.java
  2. 1
      designer_base/src/com/fr/design/dialog/BasicDialog.java
  3. 24
      designer_base/src/com/fr/design/dialog/BasicPane.java
  4. 18
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  5. 26
      designer_base/src/com/fr/design/extra/ShopDialog.java
  6. 46
      designer_base/src/com/fr/design/extra/exe/searchExecutor.java

4
designer_base/src/com/fr/design/actions/server/PluginManagerAction.java

@ -6,6 +6,7 @@ import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.PluginManagerPane;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.extra.ShopDialog;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
@ -30,8 +31,7 @@ public class PluginManagerAction extends UpdateAction {
@Override
public void actionPerformed(ActionEvent e) {
final PluginManagerPane managerPane = new PluginManagerPane();
//// TODO: 16/4/11 重新写下这个界面窗口.
BasicDialog dlg = managerPane.showCustomSizeWindow(DesignerContext.getDesignerFrame(), null, BasicDialog.LARGE_SHOP);
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(),managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
}

1
designer_base/src/com/fr/design/dialog/BasicDialog.java

@ -10,7 +10,6 @@ public abstract class BasicDialog extends UIDialog {
public static final Dimension MEDIUM = new Dimension(600, 400);
public static final Dimension DEFAULT = new Dimension(660, 600);
public static final Dimension LARGE = new Dimension(900, 600);
public static final Dimension LARGE_SHOP = new Dimension(900, 760);
public static final Dimension CHART = new Dimension(760, 560);
public static final Dimension MAP_SIZE = new Dimension(760, 450);
public static final Dimension UPDATE_ONLINE_SIZE = new Dimension(600,300);

24
designer_base/src/com/fr/design/dialog/BasicPane.java

@ -171,30 +171,6 @@ public abstract class BasicPane extends JPanel {
return dg;
}
/**
* 显示自定义大小的窗口
*
* @param window 窗口
* @param l 对话框监听器
* @param dimension 窗口大小
* @return 对话框
*/
public BasicDialog showCustomSizeWindow(Window window, DialogActionListener l, Dimension dimension) {
BasicDialog dg;
if (window instanceof Frame) {
dg = new DIALOG((Frame) window);
} else {
dg = new DIALOG((Dialog) window);
}
if (l != null) {
dg.addDialogActionListener(l);
}
dg.setBasicDialogSize(dimension);
GUICoreUtils.centerWindow(dg);
dg.setResizable(false);
return dg;
}
/**
* 显示窗口
*

18
designer_base/src/com/fr/design/extra/PluginWebBridge.java

@ -31,6 +31,8 @@ public class PluginWebBridge {
private UIDialog uiDialog;
public static final String PLUGIN_SHOP = "http://127.0.0.1:8080/ShopServer?pg=plist";
public static PluginWebBridge getHelper() {
if (helper != null) {
return helper;
@ -196,7 +198,7 @@ public class PluginWebBridge {
public String getPluginFromStore(String category, String seller, String fee) {
StringBuilder url = new StringBuilder("http://127.0.0.1:8080/ShopServer?pg=plist");
StringBuilder url = new StringBuilder(PLUGIN_SHOP);
if (StringUtils.isNotBlank(category)) {
url.append("&cid=").append(category.split("-")[1]);
}
@ -217,6 +219,20 @@ public class PluginWebBridge {
return resText == null ? StringUtils.EMPTY : resText;
}
/**
* 搜索在线插件
*
* @param keyword 关键字
*/
public String searchPlugin(String keyword) {
try {
HttpClient httpClient = new HttpClient(PluginWebBridge.PLUGIN_SHOP + "&keyword=" + keyword);
return httpClient.getResponseText();
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
return StringUtils.EMPTY;
}
public void showRestartMessage(String message){
int rv = JOptionPane.showOptionDialog(

26
designer_base/src/com/fr/design/extra/ShopDialog.java

@ -0,0 +1,26 @@
package com.fr.design.extra;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.gui.GUICoreUtils;
import java.awt.*;
/**
* Created by vito on 16/4/18.
*/
public class ShopDialog extends UIDialog{
private static final Dimension DEFAULT_SHOP = new Dimension(900, 760);
public ShopDialog(Frame frame, BasicPane pane) {
super(frame, pane,false);
setSize(DEFAULT_SHOP);
GUICoreUtils.centerWindow(this);
setResizable(false);
}
@Override
public void checkValid() throws Exception {
}
}

46
designer_base/src/com/fr/design/extra/exe/searchExecutor.java

@ -0,0 +1,46 @@
package com.fr.design.extra.exe;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.extra.Process;
import com.fr.general.FRLogger;
import com.fr.general.http.HttpClient;
import com.fr.stable.StringUtils;
/**
* Created by vito on 16/4/18.
*/
public class SearchExecutor implements Executor {
private String result;
private String keyword;
public SearchExecutor(String keyword) {
this.keyword = keyword;
}
@Override
public String getTaskFinishMessage() {
return result;
}
@Override
public Command[] getCommands() {
return new Command[]{
new Command() {
@Override
public String getExecuteMessage() {
return StringUtils.EMPTY;
}
@Override
public void run(Process<String> process) {
try {
HttpClient httpClient = new HttpClient(PluginWebBridge.PLUGIN_SHOP + "&keyword=" + keyword);
result = httpClient.getResponseText();
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
}
}
};
}
}
Loading…
Cancel
Save