Browse Source

alphafine 1

master
xiaoxia 8 years ago
parent
commit
46d31e9601
  1. 59
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  2. 34
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  3. 24
      designer/src/com/fr/design/mainframe/alphafine/CellType.java
  4. 56
      designer/src/com/fr/design/mainframe/alphafine/Main.java
  5. 30
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/ActionModel.java
  6. 61
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/AlphaCellModel.java
  7. 27
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/DocumentModel.java
  8. 29
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/FileModel.java
  9. 12
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/ModelHandle.java
  10. 76
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/MoreModel.java
  11. 77
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/PluginModel.java
  12. 48
      designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/CommonCellRender.java
  13. 42
      designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/TitleCellRender.java
  14. 607
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  15. 48
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java
  16. 62
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaTextField.java
  17. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/alphafine0.png
  18. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/alphafine1.png
  19. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/alphafine2.png
  20. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/alphafine3.png
  21. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/alphafine4.png
  22. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/alphafine_close.png
  23. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/bigsearch.png
  24. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/loading.gif
  25. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/opening.gif
  26. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/smallsearch.png
  27. 28
      designer/src/com/fr/design/mainframe/alphafine/listener/ComponentHandler.java
  28. 42
      designer/src/com/fr/design/mainframe/alphafine/listener/DocumentAdapter.java
  29. 39
      designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java
  30. 20
      designer/src/com/fr/design/mainframe/alphafine/model/SearchResult.java
  31. 7
      designer/src/com/fr/design/mainframe/alphafine/previewPane/ActionPreviewPane.java
  32. 45
      designer/src/com/fr/design/mainframe/alphafine/previewPane/DocumentPreviewPane.java
  33. 23
      designer/src/com/fr/design/mainframe/alphafine/previewPane/FilePreviewPane.java
  34. 58
      designer/src/com/fr/design/mainframe/alphafine/previewPane/PluginPreviewPane.java
  35. 63
      designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java
  36. 12
      designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaFineSearchProcessor.java
  37. 88
      designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java
  38. 31
      designer/src/com/fr/design/mainframe/alphafine/searchManager/ConcludeSearchManager.java
  39. 90
      designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java
  40. 137
      designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java
  41. 53
      designer/src/com/fr/design/mainframe/alphafine/searchManager/LatestSearchManager.java
  42. 104
      designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java
  43. 11
      designer/src/com/fr/start/Designer.java
  44. 34
      designer_base/src/com/fr/design/DesignerEnvManager.java
  45. 62
      designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineAction.java
  46. 204
      designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigManager.java
  47. 216
      designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigPane.java
  48. 4
      designer_base/src/com/fr/design/mainframe/DesignerFrame.java
  49. 2
      designer_base/src/com/fr/design/mainframe/hold/DefaultTitlePlace.java
  50. 50
      designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  51. 28
      designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionManager.java
  52. 4
      designer_base/src/com/fr/design/menu/MenuDef.java

59
designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java

@ -0,0 +1,59 @@
package com.fr.design.mainframe.alphafine;
import com.fr.general.SiteCenter;
import java.awt.*;
/**
* Created by XiaXiang on 2017/5/10.
*/
public class AlphaFineConstants {
public static final String SAVE_FILE_NAME = "alpha.coco";
public static final int SHOW_SIZE = 5;
public static final int LATEST_SHOW_SIZE = 3;
public static final int HEIGHT = 680;
public static final int WIDTH = 460;
public static final int LEFT_WIDTH = 300;
public static final int RIGHT_WIDTH = 380;
public static final int FIELD_HEIGHT = 55;
public static final int CONTENT_HEIGHT = 405;
public static final int CELL_HEIGHT = 32;
public static final Dimension FULL_SIZE = new Dimension(680, 460);
public static final Dimension CONTENT_SIZE = new Dimension(680, 405);
public static final Dimension FIELD_SIZE = new Dimension(680, 55);
public static final Dimension ICON_LABEL_SIZE = new Dimension(64, 64);
public static final Dimension CLOSE_BUTTON_SIZE = new Dimension(40, 40);
public static final Color GRAY = new Color(0xd2d2d2);
public static final Color BLUE = new Color(0x3394f0);
public static final Color BLACK = new Color(0x222222);
public static final String PLUGIN_SEARCH_URL = SiteCenter.getInstance().acquireUrlByKind("plugin.searchAPI");
public static final String PLUGIN_IMAGE_URL = "http://shop.finereport.com/plugin/";
public static final String REUSE_IMAGE_URL = "http://shop.finereport.com/reuse/";
public static final String DOCUMENT_SEARCH_URL = "http://help.finereport.com/doc-view-";
}

34
designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -0,0 +1,34 @@
package com.fr.design.mainframe.alphafine;
import com.fr.base.FRContext;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.alphafine.component.AlphaFineDialog;
import com.fr.stable.StableUtils;
import java.io.File;
/**
* Created by XiaXiang on 2017/5/8.
*/
public class AlphaFineHelper {
public static void showAlphaFineDialog() {
AlphaFineDialog dialog = new AlphaFineDialog(DesignerContext.getDesignerFrame());
dialog.setVisible(true);
}
public static File getInfoFile() {
return new File(StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), AlphaFineConstants.SAVE_FILE_NAME));
}
public static String findFolderName (String text) {
String[] textArray = text.split("/");
if (textArray != null && textArray.length > 1) {
return textArray[textArray.length - 2];
}
return null;
}
}

24
designer/src/com/fr/design/mainframe/alphafine/CellType.java

@ -0,0 +1,24 @@
package com.fr.design.mainframe.alphafine;
/**
* Created by XiaXiang on 2017/4/27.
*/
public enum CellType {
PLUGIN(0), DOCUMENT(1), FILE(2), ACTION(3), REUSE(4);
private int cellType;
CellType(int type) {
this.cellType = type;
}
public int getCellType() {
return cellType;
}
public void setCellType(int cellType) {
this.cellType = cellType;
}
}

56
designer/src/com/fr/design/mainframe/alphafine/Main.java

@ -0,0 +1,56 @@
package com.fr.design.mainframe.alphafine;//package com.fr.design.mainframe.alphafine;
//
//import javax.swing.*;
//import java.awt.*;
//import java.awt.image.ImageObserver;
//import java.util.Vector;
//
///**
// * Created by XiaXiang on 2017/5/10.
// */
//public class Main {
// public static void main(String args[]) {
// JFrame frame = new JFrame("JList Background Demonstration");
//
// JList list = new JList();
//
// String [] imageIcon = new String[] {
// "female.gif", "male.gif"
// };
//
// // create model
// Vector v = new Vector();
// for (int i=0; i<10; i++) {
// ImageIcon ii = new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/loading.gif"));
// ii.setImageObserver(new AnimatedObserver(list, i));
// v.addElement(ii);
// }
//
// list.setListData(v);
//
// frame.getContentPane().add(BorderLayout.CENTER, list); //new JScrollPane(list));
// frame.setDefaultCloseOperation(3);
// frame.pack();
// frame.setVisible(true);
// }
//}
//
//class AnimatedObserver implements ImageObserver
//{
// JList list;
// int index;
//
// public AnimatedObserver(JList list, int index) {
// this.list = list;
// this.index = index;
// }
//
// public boolean imageUpdate (Image img, int infoflags, int x, int y, int width, int height) {
// if ((infoflags & (FRAMEBITS|ALLBITS)) != 0) {
// Rectangle rect = list.getCellBounds(index, index);
// list.repaint(rect);
// }
//
// return (infoflags & (ALLBITS|ABORT)) == 0;
// }
//}

30
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/ActionModel.java

@ -0,0 +1,30 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.design.mainframe.alphafine.CellType;
import javax.swing.*;
import java.io.Serializable;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class ActionModel extends AlphaCellModel implements Serializable {
private Action action;
public ActionModel(String name, String content, CellType type) {
super(name, content, type);
}
public ActionModel(String name, Action action) {
super(name, null, CellType.ACTION);
this.action = action;
}
public Action getAction() {
return action;
}
public void setAction(Action action) {
this.action = action;
}
}

61
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/AlphaCellModel.java

@ -0,0 +1,61 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.design.mainframe.alphafine.CellType;
import java.io.Serializable;
/**
* Created by XiaXiang on 2017/3/23.
*/
public class AlphaCellModel implements Serializable{
private String name;
private String content;
private String description;
private CellType type;
public AlphaCellModel(String name, String content, CellType type) {
this.name = name;
this.content = content;
this.type = type;
}
public AlphaCellModel(String name, String content) {
this.name = name;
this.content = content;
}
public CellType getType() {
return type;
}
public void setType(CellType type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

27
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/DocumentModel.java

@ -0,0 +1,27 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.design.mainframe.alphafine.CellType;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class DocumentModel extends AlphaCellModel {
private String documentUrl;
public DocumentModel(String name, String content, CellType type) {
super(name, content, type);
}
public DocumentModel(String name, String content, String documentUrl) {
super(name, content, CellType.DOCUMENT);
this.documentUrl = documentUrl;
}
public String getDocumentUrl() {
return documentUrl;
}
public void setDocumentUrl(String documentUrl) {
this.documentUrl = documentUrl;
}
}

29
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/FileModel.java

@ -0,0 +1,29 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class FileModel extends AlphaCellModel{
private String filePath;
public FileModel(String name, String content, CellType type) {
super(name, content, type);
}
public FileModel(String name, String content, String filePath) {
super(name, content, CellType.FILE);
this.filePath = filePath;
setDescription(AlphaFineHelper.findFolderName(content));
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
}

12
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/ModelHandle.java

@ -0,0 +1,12 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.design.mainframe.alphafine.CellType;
import java.io.Serializable;
/**
* Created by XiaXiang on 2017/4/27.
*/
public interface ModelHandle extends Serializable {
CellType getType();
}

76
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/MoreModel.java

@ -0,0 +1,76 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.design.mainframe.alphafine.CellType;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class MoreModel {
private String name;
private boolean needMore;
private String content;
private CellType type;
private boolean isLoading;
public MoreModel(String name, String content, boolean needMore, CellType type) {
this.name = name;
this.needMore = needMore;
this.content = content;
this.type = type;
}
public MoreModel(String name, CellType type) {
this.name = name;
this.needMore = false;
this.type = type;
}
public MoreModel(String name) {
this.name = name;
this.isLoading = true;
}
public MoreModel(String name, boolean isLoading) {
this.name = name;
this.isLoading = isLoading;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isNeedMore() {
return needMore;
}
public void setNeedMore(boolean needMore) {
this.needMore = needMore;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public CellType getType() {
return type;
}
public void setType(CellType type) {
this.type = type;
}
public boolean isLoading() {
return isLoading;
}
public void setLoading(boolean loading) {
isLoading = loading;
}
}

77
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/PluginModel.java

@ -0,0 +1,77 @@
package com.fr.design.mainframe.alphafine.cell.cellModel;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.general.ComparatorUtils;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class PluginModel extends AlphaCellModel {
private String pluginUrl;
private String imageUrl;
private String version;
private String jartime;
private String link;
private int price;
public PluginModel(String name, String content, CellType type) {
super(name, content, type);
}
public PluginModel(String name, String content, String pluginUrl, String imageUrl, String version, String jartime, CellType type, int price) {
super(name, content);
setType(type);
this.pluginUrl = pluginUrl;
this.imageUrl = imageUrl;
this.jartime = jartime;
this.version = version;
this.price = price;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getPluginUrl() {
return pluginUrl;
}
public void setPluginUrl(String pluginUrl) {
this.pluginUrl = pluginUrl;
}
public String getVersion() {
return version;
}
public void setVersion(String verSion) {
this.version = verSion;
}
public String getJartime() {
return jartime;
}
public void setJarTime(String jarTime) {
this.jartime = jarTime;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
}

48
designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/CommonCellRender.java

@ -0,0 +1,48 @@
package com.fr.design.mainframe.alphafine.cell.cellRender;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.cell.cellModel.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import javax.swing.*;
import java.awt.*;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class CommonCellRender implements ListCellRenderer<Object> {
private UILabel name;
private UILabel content;
public CommonCellRender() {
this.name = new UILabel();
this.content = new UILabel();
}
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof MoreModel) {
return new TitleCellRender().getListCellRendererComponent(list, value,index,isSelected,cellHasFocus);
}
JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(Color.white);
if (isSelected) {
panel.setBackground(new Color(0x3394f0));
}
panel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0));
AlphaCellModel model = (AlphaCellModel) value;
name.setText(model.getName());
String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getCellType() + ".png";
name.setIcon(new ImageIcon(getClass().getResource(iconUrl)));
name.setFont(new Font("Song_TypeFace",0,12));
name.setForeground(new Color(0x222222));
name.setVerticalTextPosition(SwingConstants.CENTER);
name.setHorizontalTextPosition(SwingConstants.RIGHT);
if (model.getDescription() != null) {
content.setText("-" + model.getDescription());
content.setForeground(new Color(0xcccccc));
panel.add(content, BorderLayout.CENTER);
}
panel.add(name, BorderLayout.WEST);
return panel;
}
}

42
designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/TitleCellRender.java

@ -0,0 +1,42 @@
package com.fr.design.mainframe.alphafine.cell.cellRender;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import javax.swing.*;
import java.awt.*;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class TitleCellRender implements ListCellRenderer<Object> {
private UILabel name;
private UILabel more;
public TitleCellRender() {
this.name = new UILabel();
this.more = new UILabel();
}
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
MoreModel moreModel = (MoreModel)value;
JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(new Color(0xf9f9f9));
panel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0));
name.setText(moreModel.getName());
name.setFont(new Font("Song_TypeFace",0,10));
more.setFont(new Font("Song_TypeFace",0,10));
more.setText(moreModel.getContent());
name.setForeground(new Color(0x666666));
more.setForeground(new Color(0x666666));
panel.add(name, BorderLayout.WEST);
if (moreModel.isNeedMore()) {
this.more.setBorder(BorderFactory.createEmptyBorder(0,0,0,10));
panel.add(this.more, BorderLayout.EAST);
}
if (moreModel.isLoading()) {
UILabel loadingLabel = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/loading.gif")));
panel.add(loadingLabel, BorderLayout.SOUTH);
}
return panel;
}
}

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

@ -0,0 +1,607 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog;
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.mainframe.DesignerContext;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.cell.cellRender.CommonCellRender;
import com.fr.design.mainframe.alphafine.cell.cellModel.*;
import com.fr.design.mainframe.alphafine.listener.ComponentHandler;
import com.fr.design.mainframe.alphafine.listener.DocumentAdapter;
import com.fr.design.mainframe.alphafine.model.SearchListModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.previewPane.DocumentPreviewPane;
import com.fr.design.mainframe.alphafine.previewPane.FilePreviewPane;
import com.fr.design.mainframe.alphafine.previewPane.PluginPreviewPane;
import com.fr.design.mainframe.alphafine.searchManager.*;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.form.main.Form;
import com.fr.form.main.FormIO;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.ImageExporter;
import com.fr.main.impl.WorkBook;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.concurrent.ExecutionException;
/**
* Created by XiaXiang on 2017/3/21.
*/
public class AlphaFineDialog extends UIDialog {
private AlphaTextField searchTextField;
private UIButton closeButton;
private JPanel searchResultPane;
private Point pressedPoint;
private UIScrollPane leftSearchResultPane;
private JPanel rightSearchResultPane;
private JList searchResultList;
private SearchListModel searchListModel;
private SwingWorker searchWorker;
public AlphaFineDialog(Frame parent) {
super(parent);
initProperties();
initListener();
initComponents();
}
private void initComponents() {
searchTextField = new AlphaTextField("AlphaFine");
searchTextField.setFont(new Font("Song_TypeFace",0,20));
searchTextField.setBackground(Color.white);
searchTextField.setBorderPainted(false);
JPanel topPane = new JPanel(new BorderLayout());
UILabel iconLabel = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigsearch.png")));
iconLabel.setPreferredSize(AlphaFineConstants.ICON_LABEL_SIZE);
iconLabel.setOpaque(true);
iconLabel.setBackground(Color.white);
topPane.add(iconLabel, BorderLayout.WEST);
topPane.add(searchTextField, BorderLayout.CENTER);
closeButton = new UIButton() {
@Override
public void paintComponent(Graphics g) {
g.setColor( Color.white );
g.fillRect(0, 0, getSize().width, getSize().height);
super.paintComponent(g);
}
};
closeButton.setContentAreaFilled(false);
closeButton.setPreferredSize(AlphaFineConstants.CLOSE_BUTTON_SIZE);
closeButton.setIcon(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/alphafine_close.png")));
closeButton.set4ToolbarButton();
closeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
});
UILabel borderLabel = new UILabel();
borderLabel.setBackground(AlphaFineConstants.GRAY);
borderLabel.setPreferredSize(new Dimension(AlphaFineConstants.HEIGHT, 1));
topPane.add(closeButton, BorderLayout.EAST);
topPane.add(borderLabel, BorderLayout.SOUTH);
add(topPane, BorderLayout.CENTER);
searchTextField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
doSearch(searchTextField.getText());
}
});
}
private void initProperties() {
setUndecorated(true);
addComponentListener(new ComponentHandler());
setSize(AlphaFineConstants.FIELD_SIZE);
centerWindow(this);
}
private void centerWindow(Window win) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension winSize = win.getSize();
if (winSize.height > screenSize.height) {
winSize.height = screenSize.height;
}
if (winSize.width > screenSize.width) {
winSize.width = screenSize.width;
}
//这里设置位置:水平居中,竖直偏上
win.setLocation((screenSize.width - winSize.width ) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE);
}
private void doSearch(String text) {
if (text.length() < 2 || text.contains("'")) {
return;
}
if (StringUtils.isBlank(text) || text.equals("AlphaFine")) {
removeSearchResult();
} else {
showSearchResult(text);
}
}
private void removeSearchResult() {
if (searchResultPane != null) {
remove(searchResultPane);
searchResultPane = null;
}
setSize(AlphaFineConstants.FIELD_SIZE);
repaint();
}
// TODO: 2017/5/8 xiaxiang: 窗体圆角setShape()有毛边,重写paint方法可以解决毛边问题,但带来了别的问题,处理比较麻烦,暂用setShape();
// public void paint(Graphics g){
//
// Graphics2D g2 = (Graphics2D) g.create();
// RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
// g2.setRenderingHints(qualityHints);
// g2.setPaint(Color.WHITE);
// g2.fillRoundRect(0, 0, getWidth(), getHeight(), 25, 25);
// g2.dispose();
// }
private void showSearchResult(String searchText) {
if (searchResultPane == null) {
searchResultList = new JList();
searchResultPane = new JPanel();
searchResultPane.setPreferredSize(AlphaFineConstants.CONTENT_SIZE);
searchResultPane.setLayout(new BorderLayout());
searchResultList.setCellRenderer(new CommonCellRender());
searchResultList.setFixedCellHeight(AlphaFineConstants.CELL_HEIGHT);
searchResultList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int selectedIndex = searchResultList.getSelectedIndex();
Object selectedValue = searchResultList.getSelectedValue();
if (e.getClickCount() == 2) {
final int i = searchResultList.locationToIndex(e.getPoint());
searchResultList.setSelectedIndex(i);
doNavigate(selectedIndex);
if (selectedValue instanceof AlphaCellModel) {
SearchResult originalResultList = LatestSearchManager.getLatestSearchManager().getLatestModelList();
originalResultList.add(searchResultList.getSelectedValue());
LatestSearchManager.getLatestSearchManager().setLatestModelList(originalResultList);
//保存最近搜索
saveHistory(originalResultList);
}
} else if (e.getClickCount() == 1) {
if (selectedValue instanceof MoreModel && ((MoreModel) selectedValue).isNeedMore()) {
HandleMoreOrLessResult(selectedIndex, (MoreModel) selectedValue);
}
}
}
});
// TODO: 2017/5/8 xiaxiang: e.getClickCount() == 1 时,偶发性的不能触发,所以先放到valueChanged
searchResultList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
showResult(searchResultList.getSelectedIndex(), searchResultList.getSelectedValue());
}
}
});
leftSearchResultPane = new UIScrollPane(searchResultList);
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);
searchResultPane.add(leftSearchResultPane, BorderLayout.WEST);
rightSearchResultPane.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT));
searchResultPane.add(rightSearchResultPane, BorderLayout.EAST);
add(searchResultPane, BorderLayout.SOUTH);
setSize(AlphaFineConstants.FULL_SIZE);
}
searchResultList.setModel(new SearchListModel(AlphaSearchManager.getSearchManager().showDefaultSearchResult()));
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
}
this.searchWorker = new SwingWorker<SearchListModel, String>() {
@Override
protected SearchListModel doInBackground() throws Exception {
return setjListModel(new SearchListModel(AlphaSearchManager.getSearchManager().showLessSearchResult(searchText)));
}
@Override
protected void done() {
try {
if (!isCancelled()) {
searchResultList.setModel(get());
searchResultList.validate();
searchResultList.repaint();
validate();
repaint();
}
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
searchResultList.setModel(null);
FRLogger.getLogger().error(e.getMessage());
}
}
};
this.searchWorker.execute();
}
private void showResult(int index, Object selectedValue) {
if (selectedValue instanceof FileModel) {
String fileName = ((FileModel) selectedValue).getFilePath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
showDefaultPreviewPane();
if (fileName.endsWith("frm")) {
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
}
this.searchWorker = new SwingWorker<BufferedImage, Void>() {
@Override
protected BufferedImage doInBackground() throws Exception {
Form form = FormIO.readForm(FRContext.getCurrentEnv(), fileName);
return FormIO.exportFormAsImage(form);
}
@Override
protected void done() {
if (!isCancelled()) {
rightSearchResultPane.removeAll();
try {
rightSearchResultPane.add(new FilePreviewPane(get()));
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
FRLogger.getLogger().error(e.getMessage());
}
validate();
repaint();
}
}
};
this.searchWorker.execute();
} else if (fileName.endsWith("cpt")) {
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
}
this.searchWorker = new SwingWorker<BufferedImage, Void>() {
@Override
protected BufferedImage doInBackground() throws Exception {
WorkBook workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), fileName);
BufferedImage bufferedImage = new ImageExporter().export(workBook);
return bufferedImage;
}
@Override
protected void done() {
if (!isCancelled()) {
rightSearchResultPane.removeAll();
try {
rightSearchResultPane.add(new FilePreviewPane(get()));
validate();
repaint();
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
FRLogger.getLogger().error(e.getMessage());
}
}
}
};
this.searchWorker.execute();
}
} else if (selectedValue instanceof DocumentModel) {
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new DocumentPreviewPane(((DocumentModel) selectedValue).getName(), ((DocumentModel) selectedValue).getContent()));
validate();
repaint();
} else if (selectedValue instanceof PluginModel) {
showDefaultPreviewPane();
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
}
this.searchWorker = new SwingWorker<Image, Void>() {
@Override
protected Image doInBackground() throws Exception {
BufferedImage bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl()));
return bufferedImage;
}
@Override
protected void done() {
try {
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new PluginPreviewPane(((PluginModel) selectedValue).getName(), get(), ((PluginModel) selectedValue).getVersion(), ((PluginModel) selectedValue).getJartime(), ((PluginModel) selectedValue).getType(), ((PluginModel) selectedValue).getPrice()));
validate();
repaint();
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
FRLogger.getLogger().error(e.getMessage());
}
}
};
this.searchWorker.execute();
} else if (selectedValue instanceof ActionModel) {
showDefaultPreviewPane();
}
}
private void HandleMoreOrLessResult(int index, MoreModel selectedValue) {
if (selectedValue.getContent().equals("显示全部")) {
selectedValue.setContent("收起");
rebuildList(index, selectedValue);
} else {
selectedValue.setContent("显示全部");
rebuildList(index, selectedValue);
}
}
private void showDefaultPreviewPane() {
rightSearchResultPane.removeAll();
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();
}
private void initListener() {
initAWTEventListener();
initMouseListener();
}
private void initMouseListener() {
addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
doMouseDragged(e);
}
});
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
doMousePressed(e);
}
});
}
private void doMousePressed(MouseEvent e) {
pressedPoint = e.getPoint();
}
private void doMouseDragged(MouseEvent e) {
Point point = e.getPoint();// 获取当前坐标
Point locationPoint = getLocation();// 获取窗体坐标
int x = locationPoint.x + point.x - pressedPoint.x;// 计算移动后的新坐标
int y = locationPoint.y + point.y - pressedPoint.y;
setLocation(x, y);// 改变窗体位置
}
/**
* 当鼠标在搜索界面边界外点击时触发
*/
private void initAWTEventListener() {
Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent event) {
if (!AlphaFineDialog.this.isVisible()) {
return;
}
if (event instanceof MouseEvent) {
MouseEvent k = (MouseEvent) event;
if (SwingUtilities.isLeftMouseButton(k)) {
Point p = k.getLocationOnScreen();
Rectangle dialogRectangle = AlphaFineDialog.this.getBounds();
Rectangle paneRectangle = new Rectangle(AlphaFinePane.createAlphaFinePane().getLocationOnScreen(), AlphaFinePane.createAlphaFinePane().getSize());
if (!dialogRectangle.contains(p) && !paneRectangle.contains(p)) {
AlphaFineDialog.this.dispose();
}
}
}
}
}, AWTEvent.MOUSE_EVENT_MASK|AWTEvent.KEY_EVENT_MASK);
}
/**
* 全局快捷键
* @return
*/
public static AWTEventListener listener() {
return new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent event) {
if (event instanceof KeyEvent) {
KeyEvent e = (KeyEvent) event;
KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e);
KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphafineConfigManager().getShortCutKeyStore();
if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString())) {
doClickAction();
}
}
}
};
}
private static void doClickAction() {
AlphaFineHelper.showAlphaFineDialog();
}
@Override
public void checkValid() throws Exception {
}
private void doNavigate(int index) {
AlphaFineDialog.this.dispose();
final Object value = searchResultList.getSelectedValue();
if (value instanceof ActionModel) {
((ActionModel) value).getAction().actionPerformed(null);
} else if (value instanceof FileModel) {
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(((FileModel)value).getFilePath(), false)));
} else if (value instanceof PluginModel) {
String url = ((PluginModel) value).getPluginUrl();
try {
Desktop.getDesktop().browse(new URI(url));
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (URISyntaxException e) {
FRLogger.getLogger().error(e.getMessage());
}
} else if (value instanceof DocumentModel) {
String url = ((DocumentModel) value).getDocumentUrl();
try {
Desktop.getDesktop().browse(new URI(url));
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (URISyntaxException e) {
FRLogger.getLogger().error(e.getMessage());
}
}
}
/**
* todo:保存到本地的逻辑待修改
* @param searchResult
*/
private void saveHistory(SearchResult searchResult) {
try {
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(AlphaFineHelper.getInfoFile()));
os.writeObject(searchResult);
os.close();
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage());
}
sendToServer();
}
/**
*todo:还没做上传服务器
*/
private void sendToServer() {
}
private void rebuildList(int index, MoreModel selectedValue) {
SearchResult moreResult = getMoreResult(selectedValue);
if((selectedValue).getContent().equals("收起")) {
for (int i = 0; i < moreResult.size(); i++) {
this.searchListModel.insertElementAt(moreResult.get(i), index + 4 + i);
}
} else {
for (int i = 0; i < moreResult.size(); i++) {
this.searchListModel.removeElementAt(index + 4);
}
}
this.searchResultList.validate();
this.searchResultList.repaint();
validate();
repaint();
}
private SearchResult getMoreResult(MoreModel selectedValue) {
SearchResult moreResult;
switch (selectedValue.getType()) {
case PLUGIN:
moreResult = PluginSearchManager.getPluginSearchManager().showMoreSearchResult();
break;
case DOCUMENT:
moreResult = DocumentSearchManager.getDocumentSearchManager().showMoreSearchResult();
break;
case FILE:
moreResult = FileSearchManager.getFileSearchManager().showMoreSearchResult();
break;
case ACTION:
moreResult = ActionSearchManager.getActionSearchManager().showMoreSearchResult();
break;
default:
moreResult = AlphaSearchManager.getSearchManager().showMoreSearchResult();
}
return moreResult;
}
private SearchListModel getModel() {
return (SearchListModel) searchResultList.getModel();
}
//测试
public static void main(String[] args) {
AlphaFineDialog alphaFineDialog = new AlphaFineDialog(DesignerContext.getDesignerFrame());
alphaFineDialog.setSize(new Dimension(680,55));
alphaFineDialog.setVisible(true);
}
public SearchListModel setjListModel(SearchListModel jListModel) {
this.searchListModel = jListModel;
return this.searchListModel;
}
public SwingWorker getSearchWorker() {
return searchWorker;
}
public void setSearchWorker(SwingWorker searchWorker) {
this.searchWorker = searchWorker;
}
}

48
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java

@ -0,0 +1,48 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.base.BaseUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by XiaXiang on 2017/3/21.
*/
public class AlphaFinePane extends BasicPane {
private static AlphaFinePane alphaFinePane;
public static AlphaFinePane createAlphaFinePane() {
if (alphaFinePane == null) {
alphaFinePane = new AlphaFinePane();
}
return alphaFinePane;
}
public AlphaFinePane() {
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 14));
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isEnabled()) {
Toolkit.getDefaultToolkit().addAWTEventListener(AlphaFineDialog.listener(), AWTEvent.KEY_EVENT_MASK);
}
UIButton refreshButton = new UIButton();
refreshButton.setIcon(BaseUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png"));
refreshButton.setToolTipText("AlphaFine智能搜索");
refreshButton.set4ToolbarButton();
this.add(refreshButton);
refreshButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AlphaFineHelper.showAlphaFineDialog();
}
});
}
@Override
protected String title4PopupWindow() {
return "AlphaFine";
}
}

62
designer/src/com/fr/design/mainframe/alphafine/component/AlphaTextField.java

@ -0,0 +1,62 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.report.web.button.Image;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
/**
* Created by XiaXiang on 2017/3/21.
*/
public class AlphaTextField extends UITextField {
private String placeHolder;
private Image image;
public AlphaTextField(String placeHolder) {
this.placeHolder = placeHolder;
}
public AlphaTextField() {
this.placeHolder = null;
}
@Override
public String getText() {
String text = super.getText();
if (text.trim().length() == 0 && placeHolder != null) {
text = placeHolder;
}
return text;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (super.getText().length() > 0 || placeHolder == null) {
return;
}
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(super.getDisabledTextColor());
g2.drawString(placeHolder, getInsets().left, g.getFontMetrics().getMaxAscent() + getInsets().top + 15);
}
public Image getImage() {
return image;
}
public void setImage(Image image) {
this.image = image;
}
}

BIN
designer/src/com/fr/design/mainframe/alphafine/images/alphafine0.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

BIN
designer/src/com/fr/design/mainframe/alphafine/images/alphafine1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

BIN
designer/src/com/fr/design/mainframe/alphafine/images/alphafine2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

BIN
designer/src/com/fr/design/mainframe/alphafine/images/alphafine3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

BIN
designer/src/com/fr/design/mainframe/alphafine/images/alphafine4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

BIN
designer/src/com/fr/design/mainframe/alphafine/images/alphafine_close.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

BIN
designer/src/com/fr/design/mainframe/alphafine/images/bigsearch.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

BIN
designer/src/com/fr/design/mainframe/alphafine/images/loading.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

BIN
designer/src/com/fr/design/mainframe/alphafine/images/opening.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

BIN
designer/src/com/fr/design/mainframe/alphafine/images/smallsearch.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

28
designer/src/com/fr/design/mainframe/alphafine/listener/ComponentHandler.java

@ -0,0 +1,28 @@
package com.fr.design.mainframe.alphafine.listener;
import com.sun.awt.AWTUtilities;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.geom.RoundRectangle2D;
/**
* Created by XiaXiang on 2017/5/4.
*/
public class ComponentHandler extends ComponentAdapter {
public void componentResized(ComponentEvent e) {
Window win = (Window) e.getSource();
Frame frame = (win instanceof Frame) ? (Frame) win : null;
if ((frame != null)
&& ((frame.getExtendedState() & Frame.MAXIMIZED_BOTH) != 0)) {
AWTUtilities.setWindowShape(win, null);
} else {
/** 设置圆角 */
AWTUtilities.setWindowShape(win,
new RoundRectangle2D.Double(0.0D, 0.0D, win.getWidth(),
win.getHeight(), 16.0D, 16.0D));
}
}
}

42
designer/src/com/fr/design/mainframe/alphafine/listener/DocumentAdapter.java

@ -0,0 +1,42 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fr.design.mainframe.alphafine.listener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
/**
* Created by XiaXiang on 2017/3/21.
*/
public abstract class DocumentAdapter implements DocumentListener {
@Override
public void insertUpdate(DocumentEvent e) {
textChanged(e);
}
@Override
public void removeUpdate(DocumentEvent e) {
textChanged(e);
}
@Override
public void changedUpdate(DocumentEvent e) {
textChanged(e);
}
protected abstract void textChanged(DocumentEvent e);
}

39
designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java

@ -0,0 +1,39 @@
package com.fr.design.mainframe.alphafine.model;
import javax.swing.*;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class SearchListModel extends DefaultListModel {
SearchResult myDelegate;
public SearchListModel( SearchResult searchResult) {
this.myDelegate = searchResult;
}
@Override
public void addElement(Object element) {
myDelegate.add(element);
}
@Override
public Object getElementAt(int index) {
return myDelegate.get(index);
}
@Override
public void insertElementAt(Object element, int index) {
this.myDelegate.add(index, element);
}
@Override
public void removeElementAt(int index) {
this.myDelegate.remove(index);
}
@Override
public int getSize() {
return this.myDelegate.size();
}
}

20
designer/src/com/fr/design/mainframe/alphafine/model/SearchResult.java

@ -0,0 +1,20 @@
package com.fr.design.mainframe.alphafine.model;
import java.util.ArrayList;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class SearchResult extends ArrayList<Object> {
private boolean needMore;
public boolean isNeedMore() {
return needMore;
}
public void setNeedMore(boolean needMore) {
this.needMore = needMore;
}
}

7
designer/src/com/fr/design/mainframe/alphafine/previewPane/ActionPreviewPane.java

@ -0,0 +1,7 @@
package com.fr.design.mainframe.alphafine.previewPane;
/**
* Created by XiaXiang on 2017/5/5.
*/
public class ActionPreviewPane {
}

45
designer/src/com/fr/design/mainframe/alphafine/previewPane/DocumentPreviewPane.java

@ -0,0 +1,45 @@
package com.fr.design.mainframe.alphafine.previewPane;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
/**
* Created by XiaXiang on 2017/5/2.
*/
public class DocumentPreviewPane extends JPanel {
public DocumentPreviewPane(String title, String summary) {
this.setLayout(new BorderLayout());
this.setBackground(Color.white);
UITextArea titleArea = new UITextArea(title);
UITextArea contentArea = new UITextArea(summary);
titleArea.setOpaque(false);
contentArea.setOpaque(false);
titleArea.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
titleArea.setForeground(AlphaFineConstants.BLUE);
contentArea.setForeground(AlphaFineConstants.BLACK);
titleArea.setPreferredSize(new Dimension(360, 30));
titleArea.setFont(new Font("Song_TypeFace",0,18));
contentArea.setFont(new Font("Song_TypeFace",0,12));
add(titleArea, BorderLayout.NORTH);
add(contentArea, BorderLayout.CENTER);
}
public static void main(String[] args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(null);
content.add(new DocumentPreviewPane("test", "ababababaabbababab"));
GUICoreUtils.centerWindow(jf);
jf.setSize(400, 400);
jf.setVisible(true);
}
}

23
designer/src/com/fr/design/mainframe/alphafine/previewPane/FilePreviewPane.java

@ -0,0 +1,23 @@
package com.fr.design.mainframe.alphafine.previewPane;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.*;
import java.awt.*;
/**
* Created by XiaXiang on 2017/5/2.
*/
public class FilePreviewPane extends JPanel {
public FilePreviewPane(Image image) {
UILabel label = new UILabel();
label.setOpaque(true);
label.setBackground(Color.white);
float scale = image.getWidth(null) / 380;
image = image.getScaledInstance(380, (int) (image.getHeight(null) / scale), Image.SCALE_SMOOTH);
label.setIcon(new ImageIcon(image));
add(label);
}
}

58
designer/src/com/fr/design/mainframe/alphafine/previewPane/PluginPreviewPane.java

@ -0,0 +1,58 @@
package com.fr.design.mainframe.alphafine.previewPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.CellType;
import javax.swing.*;
import java.awt.*;
/**
* Created by XiaXiang on 2017/5/2.
*/
public class PluginPreviewPane extends JPanel {
public PluginPreviewPane(String title, Image image, String version, String jartime, CellType type, int price) {
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(50,0,0,0));
this.setBackground(Color.white);
UILabel imageLabel = new UILabel();
image = image.getScaledInstance(200, 200, Image.SCALE_SMOOTH);
imageLabel.setIcon(new ImageIcon(image));
UILabel nameLabel = new UILabel(title);
nameLabel.setVerticalAlignment(SwingConstants.CENTER);
JPanel line = new JPanel();
line.setPreferredSize(new Dimension(200,1));
line.setBackground(new Color(0xd2d2d2));
JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(Color.white);
JPanel bottomPane = new JPanel(new BorderLayout());
bottomPane.setBackground(Color.white);
bottomPane.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
if (type == CellType.PLUGIN) {
UILabel versionLabel = new UILabel("V" + version);
versionLabel.setBorder(BorderFactory.createEmptyBorder(0,20,10,20));
versionLabel.setForeground(new Color(0x666666));
versionLabel.setFont(new Font("Song_TypeFace",0,12));
panel.add(versionLabel, BorderLayout.CENTER);
UILabel jartimeLabel = new UILabel(jartime.substring(0, 10));
jartimeLabel.setForeground(new Color(0x222222));
jartimeLabel.setFont(new Font("Song_TypeFace",0,12));
bottomPane.add(jartimeLabel, BorderLayout.EAST);
}
nameLabel.setFont(new Font("Song_TypeFace",0,18));
nameLabel.setBackground(new Color(0x3394f0));
nameLabel.setBorder(BorderFactory.createEmptyBorder(20,20,10,20));
line.setBorder(BorderFactory.createEmptyBorder(20, 0, 10, 0));
String price0 = price == 0 ? "免费" : String.valueOf(price);
UILabel priceLabel = new UILabel(price0);
priceLabel.setForeground(new Color(0xf46c4c));
priceLabel.setFont(new Font("Song_TypeFace",0,10));
bottomPane.add(priceLabel, BorderLayout.WEST);
panel.add(nameLabel, BorderLayout.NORTH);
panel.add(line, BorderLayout.SOUTH);
nameLabel.setForeground(new Color(0x3394f0));
add(imageLabel, BorderLayout.NORTH);
add(panel, BorderLayout.CENTER);
add(bottomPane, BorderLayout.SOUTH);
}
}

63
designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java

@ -0,0 +1,63 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.ActionModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.toolbar.UpdateActionManager;
import java.util.List;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class ActionSearchManager implements AlphaFineSearchProcessor {
private static ActionSearchManager actionSearchManager = null;
private SearchResult filterModelList;
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static ActionSearchManager getActionSearchManager() {
if (actionSearchManager == null) {
actionSearchManager = new ActionSearchManager();
}
return actionSearchManager;
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
this.filterModelList = new SearchResult();
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainAction()) {
List<UpdateAction> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions();
for (UpdateAction updateAction : updateActions) {
if (updateAction.getName() != null && updateAction.getName().toLowerCase().contains(searchText.toLowerCase())) {
filterModelList.add(new ActionModel(updateAction.getName() ,updateAction));
}
}
final int length = Math.min(5, filterModelList.size());
for (int i = 0; i < length; i++) {
lessModelList.add(filterModelList.get(i));
}
for (int i = length; i < filterModelList.size(); i++) {
moreModelList.add(filterModelList.get(i));
}
if (filterModelList.size() > 0) {
if (filterModelList.size() > 5) {
lessModelList.add(0, new MoreModel("设置", "显示全部",true, CellType.ACTION));
} else {
lessModelList.add(0, new MoreModel("设置", CellType.ACTION));
}
}
}
return lessModelList;
}
@Override
public SearchResult showMoreSearchResult() {
return moreModelList;
}
}

12
designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaFineSearchProcessor.java

@ -0,0 +1,12 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.mainframe.alphafine.model.SearchResult;
/**
* Created by XiaXiang on 2017/3/27.
*/
public interface AlphaFineSearchProcessor {
SearchResult showLessSearchResult(String searchText);
SearchResult showMoreSearchResult();
}

88
designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java

@ -0,0 +1,88 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import java.io.*;
/**
* Created by XiaXiang on 2017/3/28.
*/
public class AlphaSearchManager implements AlphaFineSearchProcessor {
private static AlphaSearchManager searchManager;
private static PluginSearchManager pluginSearchManager;
private static DocumentSearchManager documentSearchManager;
private static FileSearchManager fileSearchManager;
private static ActionSearchManager actionSearchManager;
private static ConcludeSearchManager concludeSearchManager;
private static LatestSearchManager latestSearchManager;
public synchronized static AlphaSearchManager getSearchManager() {
init();
return searchManager;
}
private synchronized static void init() {
if (searchManager == null) {
searchManager = new AlphaSearchManager();
pluginSearchManager = PluginSearchManager.getPluginSearchManager();
documentSearchManager = DocumentSearchManager.getDocumentSearchManager();
fileSearchManager = FileSearchManager.getFileSearchManager();
actionSearchManager = ActionSearchManager.getActionSearchManager();
concludeSearchManager = ConcludeSearchManager.getConcludeSearchManager();
latestSearchManager = LatestSearchManager.getLatestSearchManager();
}
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
SearchResult latestModelList = latestSearchManager.showLessSearchResult(searchText);
SearchResult concludeModelList = concludeSearchManager.showLessSearchResult(searchText);
SearchResult actionModelList = actionSearchManager.showLessSearchResult(searchText);
SearchResult fileModelList = fileSearchManager.showLessSearchResult(searchText);
SearchResult documentModelList = documentSearchManager.showLessSearchResult(searchText);
SearchResult pluginModelList = pluginSearchManager.showLessSearchResult(searchText);
latestModelList.addAll(concludeModelList);
latestModelList.addAll(actionModelList);
latestModelList.addAll(fileModelList);
latestModelList.addAll(documentModelList);
latestModelList.addAll(pluginModelList);
return latestModelList;
}
public SearchResult showDefaultSearchResult() {
SearchResult searchResult = new SearchResult();
searchResult.add(new MoreModel("本地常用"));
searchResult.add(new MoreModel("猜您喜欢"));
searchResult.add(new MoreModel("设置"));
searchResult.add(new MoreModel("模板"));
searchResult.add(new MoreModel("帮助文档"));
searchResult.add(new MoreModel("应用中心"));
return searchResult;
}
@Override
public SearchResult showMoreSearchResult() {
return null;
}
public SearchResult getLatestSearchResult() {
ObjectInputStream is;
SearchResult searchResult;
try {
is = new ObjectInputStream(new FileInputStream(AlphaFineHelper.getInfoFile()));
searchResult = (SearchResult) is.readObject();
} catch (IOException e) {
searchResult = new SearchResult();
} catch (ClassNotFoundException e) {
searchResult = new SearchResult();
}
return searchResult;
}
}

31
designer/src/com/fr/design/mainframe/alphafine/searchManager/ConcludeSearchManager.java

@ -0,0 +1,31 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
/**
* Created by XiaXiang on 2017/3/31.
*/
public class ConcludeSearchManager implements AlphaFineSearchProcessor {
private static ConcludeSearchManager concludeSearchManager = null;
private SearchResult modelList;
public synchronized static ConcludeSearchManager getConcludeSearchManager() {
if (concludeSearchManager == null) {
concludeSearchManager = new ConcludeSearchManager();
}
return concludeSearchManager;
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
this.modelList = new SearchResult();
modelList.add(new MoreModel("猜您需要", false));
return modelList;
}
@Override
public SearchResult showMoreSearchResult() {
return null;
}
}

90
designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java

@ -0,0 +1,90 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.cellModel.DocumentModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.FRLogger;
import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import java.security.AlgorithmConstraints;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class DocumentSearchManager implements AlphaFineSearchProcessor {
private static DocumentSearchManager documentSearchManager = null;
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static DocumentSearchManager getDocumentSearchManager() {
if (documentSearchManager == null) {
documentSearchManager = new DocumentSearchManager();
}
return documentSearchManager;
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainDocument()) {
String result;
String url = "http://help.finereport.com/?api-search-title-" + searchText + "-1";
HttpClient httpClient = new HttpClient(url);
httpClient.setTimeout(5000);
httpClient.asGet();
result = httpClient.getResponseText();
try {
JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = null;
if (jsonObject.get("docdata") != null) {
jsonArray = (JSONArray) jsonObject.get("docdata");
}
if (jsonArray.length() > 0) {
if (jsonArray.length() > 5) {
lessModelList.add(new MoreModel("帮助文档", "显示全部",true, CellType.DOCUMENT));
} else {
lessModelList.add(new MoreModel("帮助文档", CellType.DOCUMENT));
}
}
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length());
for (int i = 0; i < length; i++) {
DocumentModel cellModel = getDocumentModel(jsonArray, i);
this.lessModelList.add(cellModel);
}
for (int i = length; i < jsonArray.length(); i++) {
DocumentModel cellModel = getDocumentModel(jsonArray, i);
this.moreModelList.add(cellModel);
}
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
return lessModelList;
}
}
return lessModelList;
}
private DocumentModel getDocumentModel(JSONArray jsonArray, int i) throws JSONException {
JSONObject object = jsonArray.getJSONObject(i);
String name = (String) object.get("title");
String content = ((String) object.get("summary"));
String documentUrl = AlphaFineConstants.DOCUMENT_SEARCH_URL + object.get("did") + ".html";
return new DocumentModel(name, content, documentUrl);
}
@Override
public SearchResult showMoreSearchResult() {
return moreModelList;
}
}

137
designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java

@ -0,0 +1,137 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.cellModel.FileModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.file.filetree.FileNode;
import com.fr.general.FRLogger;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class FileSearchManager implements AlphaFineSearchProcessor {
private SearchResult filterModelList;
private SearchResult lessModelList;
private SearchResult moreModelList;
private List<FileNode> fileNodes = null;
private static FileSearchManager fileSearchManager = null;
public synchronized static FileSearchManager getFileSearchManager() {
init();
return fileSearchManager;
}
public synchronized static void init() {
if (fileSearchManager == null) {
fileSearchManager = new FileSearchManager();
}
}
public synchronized SearchResult showLessSearchResult(String searchText) {
this.filterModelList = new SearchResult();
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
Env env = FRContext.getCurrentEnv();
fileNodes = new ArrayList<>();
fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true);
for (FileNode node : fileNodes) {
boolean hasName = false;
String fileEnvPath = node.getEnvPath();
String filePath = StableUtils.pathJoin(env.getPath(), fileEnvPath);
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) {
if (node.getName().toLowerCase().contains(searchText.toLowerCase())) {
FileModel model = new FileModel(node.getName(), node.getEnvPath().substring(node.getName().length(), node.getEnvPath().length()),node.getEnvPath());
this.filterModelList.add(model);
hasName = true;
}
}
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainFileContent()) {
//文件的内容搜索
try {
BufferedReader reader = new BufferedReader(new FileReader(filePath));
String line;
int columnNumber;
boolean test = false;
while ((line = reader.readLine()) != null) {
columnNumber = line.toLowerCase().indexOf(searchText);
if (columnNumber != -1) {
test = true;
}
}
if (test && !hasName) {
FileModel model = new FileModel(node.getName(), node.getEnvPath().substring(node.getName().length(), node.getEnvPath().length()),node.getEnvPath());
this.filterModelList.add(model);
}
reader.close();
} catch (FileNotFoundException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage());
}
}
}
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size());
for (int i = 0; i < length; i++) {
lessModelList.add(filterModelList.get(i));
}
for (int i = length; i< filterModelList.size(); i++) {
moreModelList.add(filterModelList.get(i));
}
if (filterModelList.size() > 0) {
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(0,new MoreModel("模板", "显示全部",true, CellType.FILE));
} else {
lessModelList.add(0,new MoreModel("模板", CellType.FILE));
}
}
return this.lessModelList;
}
@Override
public SearchResult showMoreSearchResult() {
return moreModelList;
}
private List<FileNode> listTpl(Env env, String rootFilePath, boolean recurse) {
List<FileNode> fileNodeList = new ArrayList<FileNode>();
try {
listAll(env, rootFilePath, fileNodeList, recurse);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
return fileNodeList;
}
private void listAll(Env env, String rootFilePath, List<FileNode> nodeList, boolean recurse) throws Exception {
FileNode[] fns = env.listFile(rootFilePath);
for (int i = 0; i < fns.length; i++) {
FileNode fileNode = fns[i];
if (fileNode.isDirectory()) {
if (recurse) {
listAll(env, rootFilePath + File.separator + fns[i].getName(), nodeList, true);
} else {
nodeList.add(fns[i]);
}
} else {
nodeList.add(fileNode);
}
}
}
}

53
designer/src/com/fr/design/mainframe/alphafine/searchManager/LatestSearchManager.java

@ -0,0 +1,53 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
/**
* Created by XiaXiang on 2017/3/31.
*/
public class LatestSearchManager implements AlphaFineSearchProcessor {
private static LatestSearchManager latestSearchManager = null;
private SearchResult modelList;
private SearchResult latestModelList;
public synchronized static LatestSearchManager getLatestSearchManager() {
if (latestSearchManager == null) {
latestSearchManager = new LatestSearchManager();
}
return latestSearchManager;
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
this.modelList = new SearchResult();
modelList.add(new MoreModel("本地常用", false));
if (getLatestModelList() != null && getLatestModelList().size() > 0) {
modelList.addAll(getLatestModelList());
}
return modelList;
}
@Override
public SearchResult showMoreSearchResult() {
return null;
}
public SearchResult getModelList() {
return modelList;
}
public void setModelList(SearchResult modelList) {
this.modelList = modelList;
}
public SearchResult getLatestModelList() {
if(this.latestModelList != null && this.latestModelList.size() > 0) {
return this.latestModelList;
}
return AlphaSearchManager.getSearchManager().getLatestSearchResult();
}
public void setLatestModelList(SearchResult latestModelList) {
this.latestModelList = latestModelList;
}
}

104
designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java

@ -0,0 +1,104 @@
package com.fr.design.mainframe.alphafine.searchManager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.cellModel.PluginModel;
import com.fr.design.mainframe.alphafine.cell.cellModel.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import java.net.URLEncoder;
/**
* Created by XiaXiang on 2017/3/27.
*/
public class PluginSearchManager implements AlphaFineSearchProcessor {
private static PluginSearchManager pluginSearchManager = null;
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static PluginSearchManager getPluginSearchManager() {
if (pluginSearchManager == null) {
pluginSearchManager = new PluginSearchManager();
}
return pluginSearchManager;
}
@Override
public synchronized SearchResult showLessSearchResult(String searchText) {
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainPlugin()) {
String result;
try {
String encodedKey = URLEncoder.encode(searchText, "UTF-8");
String url = AlphaFineConstants.PLUGIN_SEARCH_URL + "?keyword=" + encodedKey;
HttpClient httpClient = new HttpClient(url);
httpClient.setTimeout(5000);
httpClient.asGet();
result = httpClient.getResponseText();
JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = null;
if (jsonObject.get("result") != null) {
jsonArray = (JSONArray) jsonObject.get("result");
}
if (jsonArray.length() > 0) {
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(new MoreModel("应用中心", "显示全部",true, CellType.PLUGIN));
} else {
lessModelList.add(new MoreModel("应用中心", CellType.PLUGIN));
}
}
int length = Math.min(5, jsonArray.length());
for (int i = 0; i < length; i++) {
PluginModel cellModel = getPluginModel(jsonArray, i);
this.lessModelList.add(cellModel);
}
for (int i = length; i < jsonArray.length(); i++) {
PluginModel cellModel = getPluginModel(jsonArray, i);
this.moreModelList.add(cellModel);
}
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
return lessModelList;
}
}
return this.lessModelList;
}
private PluginModel getPluginModel(JSONArray jsonArray, int i) throws JSONException {
JSONObject object = jsonArray.getJSONObject(i);
String name = (String) object.get("name");
String content = ((String) object.get("description"));
String pluginUrl = AlphaFineConstants.REUSE_IMAGE_URL + object.get("id");
String imageUrl = ((String) object.get("pic"));
String version = null;
String jartime = null;
CellType type = CellType.REUSE;
String link = (String) object.get("link");
if (ComparatorUtils.equals(link, "plugin")) {
version = (String) object.get("version");
jartime = (String) object.get("jartime");
type = CellType.PLUGIN;
pluginUrl = AlphaFineConstants.PLUGIN_IMAGE_URL + object.get("id");
}
int price = (int) object.get("price");
return new PluginModel(name, content, pluginUrl, imageUrl, version, jartime, type, price);
}
@Override
public SearchResult showMoreSearchResult() {
return this.moreModelList;
}
}

11
designer/src/com/fr/start/Designer.java

@ -20,6 +20,7 @@ import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.itoolbar.UILargeToolbar; import com.fr.design.gui.itoolbar.UILargeToolbar;
import com.fr.design.mainframe.*; import com.fr.design.mainframe.*;
import com.fr.design.mainframe.alphafine.component.AlphaFinePane;
import com.fr.design.mainframe.bbs.UserInfoLabel; import com.fr.design.mainframe.bbs.UserInfoLabel;
import com.fr.design.mainframe.bbs.UserInfoPane; import com.fr.design.mainframe.bbs.UserInfoPane;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
@ -339,6 +340,16 @@ public class Designer extends BaseDesigner {
return userInfoPane; return userInfoPane;
} }
/**
* 创建alphafine打开面板
*
* @return 面板组件
*/
public Component createAlphafinePane() {
return AlphaFinePane.createAlphaFinePane();
}
protected SplashPane createSplashPane() { protected SplashPane createSplashPane() {
return new ReportSplashPane(); return new ReportSplashPane();
} }

34
designer_base/src/com/fr/design/DesignerEnvManager.java

@ -3,11 +3,9 @@
*/ */
package com.fr.design; package com.fr.design;
import com.fr.base.BaseXMLUtils; import com.fr.base.*;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
import com.fr.design.actions.help.AlphaFine.AlphafineConfigManager;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.env.RemoteEnv; import com.fr.env.RemoteEnv;
import com.fr.env.SignIn; import com.fr.env.SignIn;
@ -29,8 +27,6 @@ import java.util.Map.Entry;
import java.util.logging.FileHandler; import java.util.logging.FileHandler;
import java.util.logging.Handler; import java.util.logging.Handler;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter;
/** /**
* The manager of Designer GUI. * The manager of Designer GUI.
@ -109,6 +105,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private int activeKeyStatus = -1; private int activeKeyStatus = -1;
private boolean joinProductImprove = true; private boolean joinProductImprove = true;
/**
* alphafine
*/
private AlphafineConfigManager alphafineConfigManager = new AlphafineConfigManager();
public static final String CAS_CERTIFICATE_PATH = "certificatePath"; public static final String CAS_CERTIFICATE_PATH = "certificatePath";
@ -1334,12 +1335,18 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
readActiveStatus(reader); readActiveStatus(reader);
} else if (ComparatorUtils.equals(CAS_PARAS,name)){ } else if (ComparatorUtils.equals(CAS_PARAS,name)){
readHttpsParas(reader); readHttpsParas(reader);
} else if (name.equals("AlphaFineConfigManager")) {
readAlphaFineAttr(reader);
} else { } else {
readLayout(reader, name); readLayout(reader, name);
} }
} }
} }
private void readAlphaFineAttr(XMLableReader reader) {
reader.readXMLObject(this.alphafineConfigManager = new AlphafineConfigManager());
}
private void readHttpsParas(XMLableReader reader){ private void readHttpsParas(XMLableReader reader){
String tempVal; String tempVal;
if((tempVal = reader.getAttrAsString(CAS_CERTIFICATE_PATH, null)) != null){ if((tempVal = reader.getAttrAsString(CAS_CERTIFICATE_PATH, null)) != null){
@ -1539,9 +1546,16 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writeUUID(writer); writeUUID(writer);
writeActiveStatus(writer); writeActiveStatus(writer);
writeHttpsParas(writer); writeHttpsParas(writer);
writeAlphaFineAttr(writer);
writer.end(); writer.end();
} }
private void writeAlphaFineAttr(XMLPrintWriter writer) {
if (this.alphafineConfigManager != null) {
this.alphafineConfigManager.writeXML(writer);
}
}
public String getUUID() { public String getUUID() {
return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid; return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid;
} }
@ -1815,4 +1829,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
return env; return env;
} }
public AlphafineConfigManager getAlphafineConfigManager() {
return alphafineConfigManager;
}
public void setAlphafineConfigManager(AlphafineConfigManager alphafineConfigManager) {
this.alphafineConfigManager = alphafineConfigManager;
}
} }

62
designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineAction.java

@ -0,0 +1,62 @@
package com.fr.design.actions.help.AlphaFine;
import com.fr.base.BaseUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* Created by XiaXiang on 2017/4/1.
*/
public class AlphafineAction extends UpdateAction {
public AlphafineAction() {
this.setMenuKeySet(ALPHAFINE);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png"));
}
public static final MenuKeySet ALPHAFINE = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'D';
}
@Override
public String getMenuName() {
return Inter.getLocText("AlphaFine");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
@Override
public void actionPerformed(ActionEvent e) {
final DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final AlphafineConfigPane alphafineConfigPane = new AlphafineConfigPane();
alphafineConfigPane.populate(DesignerEnvManager.getEnvManager().getAlphafineConfigManager());
DialogActionListener dialogActionListener = new DialogActionAdapter() {
public void doOk() {
alphafineConfigPane.update();
designerFrame.refreshToolbar();
}
};
BasicDialog basicDialog = alphafineConfigPane.showMediumWindow(designerFrame, dialogActionListener);
basicDialog.setVisible(true);
}
}

204
designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigManager.java

@ -0,0 +1,204 @@
package com.fr.design.actions.help.AlphaFine;
import com.fr.stable.OperatingSystem;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader;
import javax.swing.*;
/**
* Created by XiaXiang on 2017/4/5.
*/
public class AlphafineConfigManager implements XMLable {
/**
* 是否开启alphafine
*/
private boolean isEnabled;
/**
* 是否联网搜索
*/
private boolean isSearchOnLine;
/**
* 快捷键设置
*/
private String shortcuts = "meta + F";
/**
* 搜索范围
*/
/**
* 猜您需要
*/
private boolean isContainConclude;
/**
* 设置
*/
private boolean isContainAction;
/**
* 帮助文档
*/
private boolean isContainDocument;
/**
* 模板
*/
private boolean isContainTemplate;
/**
* 模板内容
*/
private boolean isContainFileContent;
/**
* 应用中心
*/
private boolean isContainPlugin;
/**
* 快捷键
*/
private KeyStroke shortCutKeyStore;
private static AlphafineConfigManager alphafineConfigManager = new AlphafineConfigManager();
public static AlphafineConfigManager getInstance() {
return alphafineConfigManager;
}
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isAttr()) {
this.setEnabled(reader.getAttrAsBoolean("isEnabled", true));
this.setContainPlugin(reader.getAttrAsBoolean("isContainDocument", true));
this.setContainDocument(reader.getAttrAsBoolean("isContainDocument", true));
this.setContainConclude(reader.getAttrAsBoolean("isContainConclude", true));
this.setContainAction(reader.getAttrAsBoolean("isContainAction", true));
this.setContainTemplate(reader.getAttrAsBoolean("isContainTemplate", true));
this.setContainFileContent(reader.getAttrAsBoolean("isContainFileContent", false));
this.setShortcuts(reader.getAttrAsString("shortcuts", "meta + f"));
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG("AlphaFineConfigManager");
writer.attr("isEnabled", this.isEnabled())
.attr("isSearchOnline", this.isSearchOnLine())
.attr("shortcuts", this.getShortcuts())
.attr("isContainConclude", this.isContainConclude())
.attr("isContainAction", this.isContainAction())
.attr("isContainDocument", this.isContainDocument())
.attr("isContainTemplate", this.isContainTemplate())
.attr("isContainPlugin", this.isContainPlugin())
.attr("isContainFileContent", this.isContainFileContent());
writer.end();
}
public boolean isSearchOnLine() {
return isSearchOnLine;
}
public void setSearchOnLine(boolean searchOnLine) {
isSearchOnLine = searchOnLine;
}
public String getShortcuts() {
return shortcuts;
}
public void setShortcuts(String shortcuts) {
this.shortcuts = shortcuts;
this.shortCutKeyStore = convert2KeyStroke(this.shortcuts);
}
public boolean isContainAction() {
return isContainAction;
}
public void setContainAction(boolean containAction) {
this.isContainAction = containAction;
}
public boolean isContainDocument() {
return isContainDocument;
}
public void setContainDocument(boolean containDocument) {
this.isContainDocument = containDocument;
}
public boolean isContainTemplate() {
return isContainTemplate;
}
public void setContainTemplate(boolean containTemplate) {
this.isContainTemplate = containTemplate;
}
public boolean isContainPlugin() {
return isContainPlugin;
}
public void setContainPlugin(boolean containPlugin) {
this.isContainPlugin = containPlugin;
}
public boolean isContainConclude() {
return isContainConclude;
}
public void setContainConclude(boolean containConclude) {
isContainConclude = containConclude;
}
public boolean isEnabled() {
return isEnabled;
}
public void setEnabled(boolean isEnabled) {
this.isEnabled = isEnabled;
}
public KeyStroke getShortCutKeyStore() {
if (shortCutKeyStore == null) {
shortCutKeyStore = convert2KeyStroke(this.getShortcuts());
}
return shortCutKeyStore;
}
public void setShortCutKeyStore(KeyStroke shortCutKeyStore) {
this.shortCutKeyStore = shortCutKeyStore;
}
private KeyStroke convert2KeyStroke(String ks) {
return KeyStroke.getKeyStroke(ks.replace("+", "pressed"));
}
public boolean isContainFileContent() {
return isContainFileContent;
}
public void setContainFileContent(boolean containFileContent) {
isContainFileContent = containFileContent;
}
}

216
designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigPane.java

@ -0,0 +1,216 @@
package com.fr.design.actions.help.AlphaFine;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
/**
* Created by XiaXiang on 2017/4/6.
*/
public class AlphafineConfigPane extends BasicPane {
private static final String TYPE = "pressed";
private static final String DISPLAY_TYPE = "+";
private static final String BACK_SLASH = "BACK_SLASH";
private static final String DISPLAY_BACK_SLASH = "\\";
private static final String SLASH = "SLASH";
private static final String DISPLAY_SLASH = "/";
private static final String CONTROL = "CONTROL";
private static final String DISPLAY_CONTROL = "ctrl";
private static final String OPEN_BRACKET = "OPEN_BRACKET";
private static final String DISPLAY_OPEN_BRACKET = "{";
private static final String CLOSE_BRACKET = "CLOSE_BRACKET";
private static final String DISPLAY_CLOSE_BRACKET = "}";
private static final String COMMA = "COMMA";
private static final String DISPLAY_COMMA = ",";
private static final String PERIOD = "PERIOD";
private static final String DISPLAY_PERIOD = ".";
private static final String SEMICOLON = "SEMICOLON";
private static final String DISPLAY_SEMICOLON = ";";
private static final String QUOTE = "QUOTE";
private static final String DISPLAY_QUOTE = "'";
private static final String EQUALS = "EQUALS";
private static final String DISPLAY_EQUALS = "+";
private static final String MINUS = "MINUS";
private static final String DISPLAY_MINUS = "-";
private KeyStroke shortCutKeyStore = null;
private UICheckBox isEnabledCheckbox, isSearchOnlineCheckbox, isContainConcludeCheckbox, isContainActionCheckbox, isContainDocumentCheckbox, isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox;
private UITextField shortcutsField;
public AlphafineConfigPane() {
this.initComponents();
}
private void initComponents() {
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
createOpenPane(contentPane);
createOnlinePane(contentPane);
createShortcutsPane(contentPane);
createSearchConfigPane(contentPane);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(contentPane, BorderLayout.NORTH);
}
private Component[][] initsearchRangeComponents() {
Component[][] components = new Component[][]{
new Component[]{isContainConcludeCheckbox, isContainActionCheckbox, isContainDocumentCheckbox},
new Component[]{isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox}
};
return components;
}
private void createSearchConfigPane(JPanel contentPane) {
double p = 25;
double d = 180;
double[] rowSize = {p, p};
double[] columnSize = {d, d, d};
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane("搜索范围");
isContainConcludeCheckbox = new UICheckBox("猜您需要");
isContainActionCheckbox = new UICheckBox("设置");
isContainPluginCheckbox = new UICheckBox("应用中心");
isContainDocumentCheckbox = new UICheckBox("帮助文档");
isContainTemplateCheckbox = new UICheckBox("模板");
isContainFileContentCheckbox = new UICheckBox("模板内容");
JPanel searchConfigPane = TableLayoutHelper.createTableLayoutPane(initsearchRangeComponents(), rowSize, columnSize);
northPane.add(searchConfigPane);
contentPane.add(northPane);
}
private void createShortcutsPane(JPanel contentPane) {
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane("快捷键配置");
shortcutsField = new UITextField();
shortcutsField.setPreferredSize(new Dimension(100, 20));
shortcutsField.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
int modifier = e.getModifiers();
if (modifier == 0) {
return;
}
int keyCode = e.getKeyCode();
shortCutKeyStore = KeyStroke.getKeyStroke(keyCode, modifier);
String str = shortCutKeyStore.toString();
shortcutsField.setText(getDisplayShortCut(str));
}
});
northPane.add(new UILabel(Inter.getLocText("Open") + ":"));
northPane.add(shortcutsField);
contentPane.add(northPane);
}
private void createOnlinePane(JPanel contentPane) {
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane("联网");
isSearchOnlineCheckbox = new UICheckBox("联网搜索");
isSearchOnlineCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!isSearchOnlineCheckbox.isSelected()) {
isContainConcludeCheckbox.setEnabled(false);
isContainPluginCheckbox.setEnabled(false);
isContainDocumentCheckbox.setEnabled(false);
isContainConcludeCheckbox.setSelected(false);
isContainPluginCheckbox.setSelected(false);
isContainDocumentCheckbox.setSelected(false);
} else {
isContainConcludeCheckbox.setEnabled(true);
isContainPluginCheckbox.setEnabled(true);
isContainDocumentCheckbox.setEnabled(true);
}
}
});
northPane.add(isSearchOnlineCheckbox);
contentPane.add(northPane);
}
private void createOpenPane(JPanel contentPane) {
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane("开启");
isEnabledCheckbox = new UICheckBox("开启AlphaFine功能");
northPane.add(isEnabledCheckbox);
contentPane.add(northPane);
}
@Override
protected String title4PopupWindow() {
return "AlphaFine";
}
public void populate(AlphafineConfigManager alphafineConfigManager) {
this.isEnabledCheckbox.setSelected(alphafineConfigManager.isEnabled());
this.isSearchOnlineCheckbox.setSelected(alphafineConfigManager.isSearchOnLine());
this.isContainActionCheckbox.setSelected(alphafineConfigManager.isContainAction());
this.isContainTemplateCheckbox.setSelected(alphafineConfigManager.isContainTemplate());
this.isContainDocumentCheckbox.setSelected(alphafineConfigManager.isContainDocument() && alphafineConfigManager.isSearchOnLine());
this.isContainDocumentCheckbox.setEnabled(alphafineConfigManager.isSearchOnLine());
this.isContainPluginCheckbox.setSelected(alphafineConfigManager.isContainPlugin() && alphafineConfigManager.isSearchOnLine());
this.isContainPluginCheckbox.setEnabled(alphafineConfigManager.isSearchOnLine());
this.isContainConcludeCheckbox.setSelected(alphafineConfigManager.isContainConclude() && alphafineConfigManager.isSearchOnLine());
this.isContainConcludeCheckbox.setEnabled(alphafineConfigManager.isSearchOnLine());
this.shortcutsField.setText(alphafineConfigManager.getShortcuts());
shortCutKeyStore = convert2KeyStroke(alphafineConfigManager.getShortcuts());
}
public void update() {
DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager();
AlphafineConfigManager alphafineConfigManager = designerEnvManager.getAlphafineConfigManager();
alphafineConfigManager.setContainPlugin(this.isContainPluginCheckbox.isSelected());
alphafineConfigManager.setContainAction(this.isContainActionCheckbox.isSelected());
alphafineConfigManager.setContainDocument(this.isContainActionCheckbox.isSelected());
alphafineConfigManager.setContainConclude(this.isContainConcludeCheckbox.isSelected());
alphafineConfigManager.setEnabled(this.isEnabledCheckbox.isSelected());
alphafineConfigManager.setSearchOnLine(this.isSearchOnlineCheckbox.isSelected());
alphafineConfigManager.setContainTemplate(this.isContainTemplateCheckbox.isSelected());
alphafineConfigManager.setContainFileContent(this.isContainFileContentCheckbox.isSelected());
alphafineConfigManager.setShortcuts(shortCutKeyStore != null? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : this.shortcutsField.getText());
designerEnvManager.setAlphafineConfigManager(alphafineConfigManager);
try {
DesignerEnvManager.loadLogSetting();
DesignerEnvManager.getEnvManager().saveXMLFile();
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
}
private String getDisplayShortCut(String shotrCut) {
return shotrCut.replace(TYPE, DISPLAY_TYPE).replace(BACK_SLASH, DISPLAY_BACK_SLASH).replace(SLASH, DISPLAY_SLASH)
.replace(CONTROL, DISPLAY_CONTROL).replace(OPEN_BRACKET, DISPLAY_OPEN_BRACKET).replace(CLOSE_BRACKET, DISPLAY_CLOSE_BRACKET)
.replace(COMMA, DISPLAY_COMMA).replace(PERIOD, DISPLAY_PERIOD).replace(SEMICOLON, DISPLAY_SEMICOLON).replace(QUOTE, DISPLAY_QUOTE)
.replace(EQUALS, DISPLAY_EQUALS).replace(MINUS, DISPLAY_MINUS);
}
private KeyStroke convert2KeyStroke(String ks) {
return KeyStroke.getKeyStroke(ks.replace(DISPLAY_TYPE, TYPE));
}
public KeyStroke getShortCutKeyStore() {
return shortCutKeyStore;
}
public void setShortCutKeyStore(KeyStroke shortCutKeyStore) {
this.shortCutKeyStore = shortCutKeyStore;
}
public UICheckBox getIsContainFileContentCheckbox() {
return isContainFileContentCheckbox;
}
public void setIsContainFileContentCheckbox(UICheckBox isContainFileContentCheckbox) {
this.isContainFileContentCheckbox = isContainFileContentCheckbox;
}
}

4
designer_base/src/com/fr/design/mainframe/DesignerFrame.java

@ -197,6 +197,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
processor.hold(northEastPane, LogMessageBar.getInstance(), ad.createBBSLoginPane()); processor.hold(northEastPane, LogMessageBar.getInstance(), ad.createBBSLoginPane());
} }
}); });
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isEnabled()) {
northEastPane.add(ad.createAlphafinePane(), BorderLayout.CENTER);
}
return northEastPane; return northEastPane;
} }

2
designer_base/src/com/fr/design/mainframe/hold/DefaultTitlePlace.java

@ -8,7 +8,7 @@ public class DefaultTitlePlace extends AbstractTitleProcessor {
@Override @Override
public void hold(Container container, Component loggerComponent, Component loginComponent) { public void hold(Container container, Component loggerComponent, Component loginComponent) {
container.add(loggerComponent, BorderLayout.CENTER); container.add(loggerComponent, BorderLayout.WEST);
container.add(loginComponent, BorderLayout.EAST); container.add(loginComponent, BorderLayout.EAST);
} }
} }

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

@ -10,7 +10,10 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.community.*; import com.fr.design.actions.community.*;
import com.fr.design.actions.file.*; import com.fr.design.actions.file.*;
import com.fr.design.actions.help.*; import com.fr.design.actions.help.AboutAction;
import com.fr.design.actions.help.AlphaFine.AlphafineAction;
import com.fr.design.actions.help.TutorialAction;
import com.fr.design.actions.help.WebDemoAction;
import com.fr.design.actions.server.*; import com.fr.design.actions.server.*;
import com.fr.design.file.NewTemplatePane; import com.fr.design.file.NewTemplatePane;
import com.fr.design.fun.MenuHandler; import com.fr.design.fun.MenuHandler;
@ -28,17 +31,14 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.env.RemoteEnv; import com.fr.env.RemoteEnv;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays; import java.util.List;
import java.util.Locale;
import java.util.Set;
/** /**
* @author richer * @author richer
@ -55,6 +55,7 @@ public abstract class ToolBarMenuDock {
public static final int PANLE_HEIGNT = 26; public static final int PANLE_HEIGNT = 26;
private MenuDef[] menus; private MenuDef[] menus;
private ToolBarDef toolBarDef; private ToolBarDef toolBarDef;
private ArrayList<UpdateAction> shortCuts;
/** /**
* 更新菜单 * 更新菜单
@ -143,9 +144,34 @@ public abstract class ToolBarMenuDock {
// 添加社区菜单 // 添加社区菜单
addCommunityMenuDef(menuList); addCommunityMenuDef(menuList);
// 添加全部UpdateAction到actionmanager中
getAllUpdateActions(menuList);
UpdateActionManager.getUpdateActionManager().setUpdateActions(shortCuts);
return menuList.toArray(new MenuDef[menuList.size()]); return menuList.toArray(new MenuDef[menuList.size()]);
} }
private List<UpdateAction> getAllUpdateActions(List<MenuDef> menuList) {
shortCuts = new ArrayList<>();
for (MenuDef menuDef : menuList) {
addUpdateActionToList(menuDef);
}
return shortCuts;
}
private void addUpdateActionToList(MenuDef menuDef) {
if (menuDef instanceof OpenRecentReportMenuDef) {
return;
}
for (ShortCut shortCut : menuDef.getShortcutList()) {
if (shortCut instanceof UpdateAction) {
shortCuts.add((UpdateAction) shortCut);
} else if (shortCut instanceof MenuDef) {
addUpdateActionToList((MenuDef) shortCut);
}
}
}
public void addCommunityMenuDef(java.util.List<MenuDef> menuList){ public void addCommunityMenuDef(java.util.List<MenuDef> menuList){
Locale locale = FRContext.getLocale(); Locale locale = FRContext.getLocale();
Locale [] locales =supportCommunityLocales(); Locale [] locales =supportCommunityLocales();
@ -161,6 +187,7 @@ public abstract class ToolBarMenuDock {
return new Locale[]{ return new Locale[]{
Locale.CHINA, Locale.CHINA,
Locale.TAIWAN, Locale.TAIWAN,
Locale.US
}; };
} }
@ -264,6 +291,10 @@ public abstract class ToolBarMenuDock {
return new UILabel(); return new UILabel();
} }
public Component createAlphafinePane(){
return new UILabel();
}
protected MenuDef createServerMenuDef(ToolBarMenuDockPlus plus) { protected MenuDef createServerMenuDef(ToolBarMenuDockPlus plus) {
MenuDef menuDef = new MenuDef(Inter.getLocText("FR-Designer_M-Server"), 'S'); MenuDef menuDef = new MenuDef(Inter.getLocText("FR-Designer_M-Server"), 'S');
@ -312,9 +343,10 @@ public abstract class ToolBarMenuDock {
public ShortCut[] createHelpShortCuts() { public ShortCut[] createHelpShortCuts() {
java.util.List<ShortCut> shortCuts = new ArrayList<ShortCut>(); java.util.List<ShortCut> shortCuts = new ArrayList<ShortCut>();
shortCuts.add(new WebDemoAction()); shortCuts.add(new WebDemoAction());
// 英文,把 video 的链接放到 Help 下面 // 英文,把 video 和帮助文档放到 Help 下面
if (FRContext.getLocale().equals(Locale.US)) { if (FRContext.getLocale().equals(Locale.US)) {
shortCuts.add(new VideoAction()); shortCuts.add(new VideoAction());
shortCuts.add(new TutorialAction());
} }
shortCuts.add(SeparatorDef.DEFAULT); shortCuts.add(SeparatorDef.DEFAULT);
//shortCuts.add(new TutorialAction()); //shortCuts.add(new TutorialAction());
@ -329,6 +361,8 @@ public abstract class ToolBarMenuDock {
} }
shortCuts.add(SeparatorDef.DEFAULT); shortCuts.add(SeparatorDef.DEFAULT);
shortCuts.add(new AboutAction()); shortCuts.add(new AboutAction());
shortCuts.add(SeparatorDef.DEFAULT);
shortCuts.add(new AlphafineAction());
return shortCuts.toArray(new ShortCut[shortCuts.size()]); return shortCuts.toArray(new ShortCut[shortCuts.size()]);
} }
@ -400,7 +434,7 @@ public abstract class ToolBarMenuDock {
return toolBar; return toolBar;
} else { } else {
return polyToolBar(Inter.getLocText(new String[]{"Polybolck", "Edit"})); return polyToolBar(Inter.getLocText("FR-Designer_Polyblock_Edit"));
} }
} }

28
designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionManager.java

@ -0,0 +1,28 @@
package com.fr.design.mainframe.toolbar;
import com.fr.design.actions.UpdateAction;
import java.util.List;
/**
* Created by XiaXiang on 2017/4/13.
*/
public class UpdateActionManager {
private static UpdateActionManager updateActionManager = null;
private List<UpdateAction> updateActions;
public synchronized static UpdateActionManager getUpdateActionManager() {
if (updateActionManager == null) {
updateActionManager = new UpdateActionManager();
}
return updateActionManager;
}
public List<UpdateAction> getUpdateActions() {
return updateActions;
}
public void setUpdateActions(List<UpdateAction> updateActions) {
this.updateActions = updateActions;
}
}

4
designer_base/src/com/fr/design/menu/MenuDef.java

@ -93,6 +93,10 @@ public class MenuDef extends ShortCut {
this.anchor = anchor; this.anchor = anchor;
} }
public List<ShortCut> getShortcutList() {
return this.shortcutList;
}
/** /**
* 插入菜单项 * 插入菜单项
* @param index 插入的位置 * @param index 插入的位置

Loading…
Cancel
Save