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. 480
      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. 56
      designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  51. 28
      designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionManager.java
  52. 152
      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.itoolbar.UILargeToolbar;
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.UserInfoPane;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
@ -339,6 +340,16 @@ public class Designer extends BaseDesigner {
return userInfoPane;
}
/**
* 创建alphafine打开面板
*
* @return 面板组件
*/
public Component createAlphafinePane() {
return AlphaFinePane.createAlphaFinePane();
}
protected SplashPane createSplashPane() {
return new ReportSplashPane();
}

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

@ -3,11 +3,9 @@
*/
package com.fr.design;
import com.fr.base.BaseXMLUtils;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.base.*;
import com.fr.dav.LocalEnv;
import com.fr.design.actions.help.AlphaFine.AlphafineConfigManager;
import com.fr.design.constants.UIConstants;
import com.fr.env.RemoteEnv;
import com.fr.env.SignIn;
@ -29,8 +27,6 @@ import java.util.Map.Entry;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter;
/**
* The manager of Designer GUI.
@ -99,7 +95,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private int bbsUid;
//当前设计器用户的昵称显示(带消息)
private String inShowBBsName;
//上一次登录弹窗的时间, 为了控制一天只弹一次窗口
//上一次登录弹窗的时间, 为了控制一天只弹一次窗口
private String lastShowBBSTime;
//上一次资讯弹窗时间, 为了控制一天只弹一次
private String lastShowBBSNewsTime;
@ -109,6 +105,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private int activeKeyStatus = -1;
private boolean joinProductImprove = true;
/**
* alphafine
*/
private AlphafineConfigManager alphafineConfigManager = new AlphafineConfigManager();
public static final String CAS_CERTIFICATE_PATH = "certificatePath";
@ -290,32 +291,32 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @return 同上
*/
public boolean isHttps() {
return isHttps;
}
return isHttps;
}
public void setHttps(boolean isHttps) {
this.isHttps = isHttps;
}
public void setHttps(boolean isHttps) {
this.isHttps = isHttps;
}
public String getCertificatePath() {
return certificatePath;
}
public String getCertificatePath() {
return certificatePath;
}
public void setCertificatePath(String certificatePath) {
this.certificatePath = certificatePath;
}
public void setCertificatePath(String certificatePath) {
this.certificatePath = certificatePath;
}
public String getCertificatePass() {
return certificatePass;
}
public String getCertificatePass() {
return certificatePass;
}
public void setCertificatePass(String certificatePass){
this.certificatePass = certificatePass;
}
public void setCertificatePass(String certificatePass){
this.certificatePass = certificatePass;
}
/**
* 返回上次打开的模板文件
@ -534,38 +535,38 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
private void writeTempFile(File tempFile){
try{
OutputStream fout = new FileOutputStream(tempFile);
XMLTools.writeOutputStreamXML(this, fout);
fout.flush();
fout.close();
}catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
}
/**
* 保存设计器的配置文件, 该文件不在env的resource目录下
* 而是在Consts.getEnvHome() + File.separator + Consts.APP_NAME
*
*
* @date 2014-9-29-上午11:04:23
*
*/
try{
OutputStream fout = new FileOutputStream(tempFile);
XMLTools.writeOutputStreamXML(this, fout);
fout.flush();
fout.close();
}catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
}
/**
* 保存设计器的配置文件, 该文件不在env的resource目录下
* 而是在Consts.getEnvHome() + File.separator + Consts.APP_NAME
*
*
* @date 2014-9-29-上午11:04:23
*
*/
public void saveXMLFile() {
File xmlFile = this.getDesignerEnvFile();
if (xmlFile == null) {
return;
}
if (!xmlFile.getParentFile().exists()) {//建立目录.
StableUtils.mkdirs(xmlFile.getParentFile());
}
File xmlFile = this.getDesignerEnvFile();
if (xmlFile == null) {
return;
}
if (!xmlFile.getParentFile().exists()) {//建立目录.
StableUtils.mkdirs(xmlFile.getParentFile());
}
String tempName = xmlFile.getName() + ProjectConstants.TEMP_SUFFIX;
File tempFile = new File(xmlFile.getParentFile(), tempName);
String tempName = xmlFile.getName() + ProjectConstants.TEMP_SUFFIX;
File tempFile = new File(xmlFile.getParentFile(), tempName);
writeTempFile(tempFile);
IOUtils.renameTo(tempFile, xmlFile);
writeTempFile(tempFile);
IOUtils.renameTo(tempFile, xmlFile);
}
/**
@ -576,24 +577,24 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
/**
* 是否加入产品改良
*
* @return 是否加入产品改良
*
*/
public boolean isJoinProductImprove() {
return joinProductImprove;
}
* 是否加入产品改良
*
* @return 是否加入产品改良
*
*/
public boolean isJoinProductImprove() {
return joinProductImprove;
}
/**
* 设置加入产品改良
*
*/
public void setJoinProductImprove(boolean joinProductImprove) {
this.joinProductImprove = joinProductImprove;
}
/**
* 设置加入产品改良
*
*/
public void setJoinProductImprove(boolean joinProductImprove) {
this.joinProductImprove = joinProductImprove;
}
/**
/**
* 是否磁盘空间参数
*
* @return 是则返回true
@ -1141,20 +1142,20 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
public String getBBSName() {
return bbsName;
}
return bbsName;
}
public void setBBSName(String bbsName) {
this.bbsName = bbsName;
}
public void setBBSName(String bbsName) {
this.bbsName = bbsName;
}
public String getBBSPassword() {
return bbsPassword;
}
return bbsPassword;
}
public void setBBSPassword(String bbsPassword) {
this.bbsPassword = bbsPassword;
}
public void setBBSPassword(String bbsPassword) {
this.bbsPassword = bbsPassword;
}
public int getBbsUid() {
return bbsUid;
@ -1172,114 +1173,114 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
return inShowBBsName;
}
public String getLastShowBBSTime() {
return lastShowBBSTime;
}
public String getLastShowBBSTime() {
return lastShowBBSTime;
}
public void setLastShowBBSTime(String lastShowBBSTime) {
this.lastShowBBSTime = lastShowBBSTime;
}
public void setLastShowBBSTime(String lastShowBBSTime) {
this.lastShowBBSTime = lastShowBBSTime;
}
public String getLastShowBBSNewsTime() {
return lastShowBBSNewsTime;
}
public String getLastShowBBSNewsTime() {
return lastShowBBSNewsTime;
}
public void setLastShowBBSNewsTime(String lastShowBBSNewsTime) {
this.lastShowBBSNewsTime = lastShowBBSNewsTime;
}
public void setLastShowBBSNewsTime(String lastShowBBSNewsTime) {
this.lastShowBBSNewsTime = lastShowBBSNewsTime;
}
private void readXMLVersion(XMLableReader reader){
String tmpVal;
private void readXMLVersion(XMLableReader reader){
String tmpVal;
if ((tmpVal = reader.getElementValue()) != null) {
reader.setXmlVersionByString(tmpVal);
}
}
}
private void readActiveKey(XMLableReader reader){
String tmpVal;
private void readActiveKey(XMLableReader reader){
String tmpVal;
if ((tmpVal = reader.getElementValue()) != null) {
this.setActivationKey(tmpVal);
}
}
}
private void readLogLocation(XMLableReader reader){
String tmpVal;
private void readLogLocation(XMLableReader reader){
String tmpVal;
if ((tmpVal = reader.getElementValue()) != null) {
this.setLogLocation(tmpVal);
}
}
}
private void readLanguage(XMLableReader reader){
String tmpVal;
private void readLanguage(XMLableReader reader){
String tmpVal;
if ((tmpVal = reader.getElementValue()) != null) {
this.setLanguage(Integer.parseInt(tmpVal));
}
}
}
private void readJettyPort(XMLableReader reader){
String tmpVal;
private void readJettyPort(XMLableReader reader){
String tmpVal;
if ((tmpVal = reader.getElementValue()) != null) {
this.setJettyServerPort(Integer.parseInt(tmpVal));
}
}
}
private void readPageLengthUnit(XMLableReader reader){
String tmpVal;
private void readPageLengthUnit(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.pageLengthUnit = Short.parseShort(tmpVal);
}
}
}
private void readReportLengthUnit(XMLableReader reader){
String tmpVal;
private void readReportLengthUnit(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.reportLengthUnit = Short.parseShort(tmpVal);
}
}
}
private void readLastOpenFile(XMLableReader reader){
String tmpVal;
private void readLastOpenFile(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.lastOpenFilePath = tmpVal;
}
}
}
private void readEncrytionKey(XMLableReader reader){
String tmpVal;
private void readEncrytionKey(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.encryptionKey = tmpVal;
}
}
}
private void readBBSName(XMLableReader reader){
String tmpVal;
private void readBBSName(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.bbsName = tmpVal;
}
}
}
private void readBBSPassword(XMLableReader reader){
String tmpVal;
private void readBBSPassword(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.bbsPassword = CodeUtils.passwordDecode(tmpVal);
}
}
}
private void readLastBBSTime(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.lastShowBBSTime = tmpVal;
}
}
private void readLastBBSTime(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.lastShowBBSTime = tmpVal;
}
}
private void readLastBBSNewsTime(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.lastShowBBSNewsTime = tmpVal;
}
}
private void readLastBBSNewsTime(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.lastShowBBSNewsTime = tmpVal;
}
}
/**
/**
* Read XML.<br>
* The method will be invoked when read data from XML file.<br>
* May override the method to read the data that you saved.
@ -1291,7 +1292,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (reader.isChildNode()) {
String name = reader.getTagName();
if (name.equals("XMLVersion")) {// 兼容09.12.30前把XMLVersion写在根目录下的第一个标签中
readXMLVersion(reader);
readXMLVersion(reader);
} else if (name.equals("Attributes")) {
this.readAttributes(reader);
} else if (name.equals("ReportPaneAttributions")) {
@ -1301,55 +1302,61 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} else if ("Envs".equals(name) || name.equals("ReportServerMap")) {
this.readCurEnv(reader);
} else if (name.equals("ActivationKey")) {
readActiveKey(reader);
readActiveKey(reader);
} else if ("LogLocation".equals(name)) {
readLogLocation(reader);
readLogLocation(reader);
} else if ("LogLevel".equals(name)) {
this.readLogLevel(reader);
} else if ("Language".equals(name)) {
readLanguage(reader);
readLanguage(reader);
} else if ("JettyServerPort".equals(name)) {
readJettyPort(reader);
readJettyPort(reader);
} else if ("PLengthUnit".equals(name)) {
readPageLengthUnit(reader);
readPageLengthUnit(reader);
} else if ("RLengthUnit".equals(name)) {
readReportLengthUnit(reader);
readReportLengthUnit(reader);
} else if ("LastOpenFilePath".equals(name)) {
readLastOpenFile(reader);
readLastOpenFile(reader);
} else if ("EncryptionKey".equals(name)) {
readEncrytionKey(reader);
readEncrytionKey(reader);
} else if ("jdkHome".equals(name)) {
this.jdkHome = reader.getElementValue();
} else if ("bbsName".equals(name)){
readBBSName(reader);
readBBSName(reader);
} else if ("bbsPassword".equals(name)){
readBBSPassword(reader);
readBBSPassword(reader);
} else if ("lastBBSTime".equals(name)){
readLastBBSTime(reader);
readLastBBSTime(reader);
} else if ("lastBBSNewsTime".equals(name)){
readLastBBSNewsTime(reader);
readLastBBSNewsTime(reader);
}else if ("uuid".equals(name)){
readUUID(reader);
readUUID(reader);
} else if ("status".equals(name)){
readActiveStatus(reader);
readActiveStatus(reader);
} else if (ComparatorUtils.equals(CAS_PARAS,name)){
readHttpsParas(reader);
}else {
readHttpsParas(reader);
} else if (name.equals("AlphaFineConfigManager")) {
readAlphaFineAttr(reader);
} else {
readLayout(reader, name);
}
}
}
private void readAlphaFineAttr(XMLableReader reader) {
reader.readXMLObject(this.alphafineConfigManager = new AlphafineConfigManager());
}
private void readHttpsParas(XMLableReader reader){
String tempVal;
if((tempVal = reader.getAttrAsString(CAS_CERTIFICATE_PATH, null)) != null){
this.setCertificatePath(tempVal);
}
if((tempVal = reader.getAttrAsString(CAS_CERTIFICATE_PASSWORD, null)) != null){
this.setCertificatePass(tempVal);
}
String tempVal;
if((tempVal = reader.getAttrAsString(CAS_CERTIFICATE_PATH, null)) != null){
this.setCertificatePath(tempVal);
}
if((tempVal = reader.getAttrAsString(CAS_CERTIFICATE_PASSWORD, null)) != null){
this.setCertificatePass(tempVal);
}
this.setHttps(reader.getAttrAsBoolean("enable", false));
this.setHttps(reader.getAttrAsBoolean("enable", false));
}
@ -1367,7 +1374,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.setLastEastRegionToolPaneY(Integer.parseInt(tmpVal));
}
if ((tmpVal = reader.getAttrAsString("containerWidth", null)) != null) {
// bug33217,705是好的,不知道711里因为什么把这段代码注释了,现打开
// bug33217,705是好的,不知道711里因为什么把这段代码注释了,现打开
this.setLastEastRegionContainerWidth(Integer.parseInt(tmpVal));
}
}
@ -1512,11 +1519,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private void readLogLevel(XMLableReader reader) {
String level;
if ((level = reader.getElementValue()) != null) {
this.setLogLevel(FRLevel.getByName(level).getLevel());
}
}
String level;
if ((level = reader.getElementValue()) != null) {
this.setLogLevel(FRLevel.getByName(level).getLevel());
}
}
/**
@ -1539,52 +1546,59 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writeUUID(writer);
writeActiveStatus(writer);
writeHttpsParas(writer);
writeAlphaFineAttr(writer);
writer.end();
}
public String getUUID() {
return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid;
}
private void writeAlphaFineAttr(XMLPrintWriter writer) {
if (this.alphafineConfigManager != null) {
this.alphafineConfigManager.writeXML(writer);
}
}
public String getUUID() {
return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid;
}
public int getActiveKeyStatus() {
return activeKeyStatus;
}
public int getActiveKeyStatus() {
return activeKeyStatus;
}
public void setActiveKeyStatus(int activeKeyStatus) {
this.activeKeyStatus = activeKeyStatus;
}
public void setActiveKeyStatus(int activeKeyStatus) {
this.activeKeyStatus = activeKeyStatus;
}
//写入uuid
//写入uuid
private void writeUUID(XMLPrintWriter writer){
writer.startTAG("uuid");
writer.textNode(getUUID());
writer.end();
writer.startTAG("uuid");
writer.textNode(getUUID());
writer.end();
}
//读取uuid
private void readUUID(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.uuid = tmpVal;
}
}
//写入激活状态
private void writeActiveStatus(XMLPrintWriter writer){
if (this.activeKeyStatus == 0){
writer.startTAG("status");
writer.textNode(this.activeKeyStatus + "");
writer.end();
}
}
//读取激活状态
private void readActiveStatus(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.activeKeyStatus = Integer.parseInt(tmpVal);
}
}
private void readUUID(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.uuid = tmpVal;
}
}
//写入激活状态
private void writeActiveStatus(XMLPrintWriter writer){
if (this.activeKeyStatus == 0){
writer.startTAG("status");
writer.textNode(this.activeKeyStatus + "");
writer.end();
}
}
//读取激活状态
private void readActiveStatus(XMLableReader reader){
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.activeKeyStatus = Integer.parseInt(tmpVal);
}
}
private void writeRecentOpenFileAndEnvList(XMLPrintWriter writer) {
checkRecentOpenedFileNum();
@ -1633,7 +1647,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writer.attr("useOracleSystemSpace", this.isOracleSystemSpace());
}
if (!this.isJoinProductImprove()){
writer.attr("joinProductImprove", this.isJoinProductImprove());
writer.attr("joinProductImprove", this.isJoinProductImprove());
}
if (!this.isAutoBackUp()) {
writer.attr("autoBackUp", this.isAutoBackUp());
@ -1689,7 +1703,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (this.level != null) {
writer.startTAG("LogLevel");
writer.textNode(FRLevel.getByLevel(this.level).getName());
writer.textNode(FRLevel.getByLevel(this.level).getName());
writer.end();
}
if (StringUtils.isNotBlank(jdkHome)) {
@ -1719,42 +1733,42 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
//写论坛相关的两个属性
private void writeBBSRelated(XMLPrintWriter writer){
if (StringUtils.isNotBlank(bbsName)) {
writer.startTAG("bbsName");
writer.textNode(bbsName);
writer.end();
writer.startTAG("bbsName");
writer.textNode(bbsName);
writer.end();
}
if (StringUtils.isNotBlank(bbsPassword)){
writer.startTAG("bbsPassword");
writer.textNode(CodeUtils.passwordEncode(bbsPassword));
writer.end();
writer.startTAG("bbsPassword");
writer.textNode(CodeUtils.passwordEncode(bbsPassword));
writer.end();
}
if (StringUtils.isNotEmpty(this.lastShowBBSTime)){
writer.startTAG("lastBBSTime");
writer.textNode(lastShowBBSTime);
writer.end();
writer.startTAG("lastBBSTime");
writer.textNode(lastShowBBSTime);
writer.end();
}
if (StringUtils.isNotEmpty(this.lastShowBBSNewsTime)){
writer.startTAG("lastBBSNewsTime");
writer.textNode(lastShowBBSNewsTime);
writer.end();
writer.startTAG("lastBBSNewsTime");
writer.textNode(lastShowBBSNewsTime);
writer.end();
}
}
private void writeHttpsParas(XMLPrintWriter writer){
writer.startTAG(CAS_PARAS);
if(StringUtils.isNotBlank(certificatePath)){
writer.attr(CAS_CERTIFICATE_PATH, certificatePath);
}
if(StringUtils.isNotBlank(certificatePass)){
writer.attr(CAS_CERTIFICATE_PASSWORD, certificatePass);
}
if(isHttps){
writer.attr("enable", true);
}
writer.end();
writer.startTAG(CAS_PARAS);
if(StringUtils.isNotBlank(certificatePath)){
writer.attr(CAS_CERTIFICATE_PATH, certificatePath);
}
if(StringUtils.isNotBlank(certificatePass)){
writer.attr(CAS_CERTIFICATE_PASSWORD, certificatePass);
}
if(isHttps){
writer.attr("enable", true);
}
writer.end();
}
private void writeReportPaneAttributions(XMLPrintWriter writer) {
@ -1815,4 +1829,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
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());
}
});
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isEnabled()) {
northEastPane.add(ad.createAlphafinePane(), BorderLayout.CENTER);
}
return northEastPane;
}

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

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

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

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;
}
}

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

@ -33,7 +33,7 @@ public class MenuDef extends ShortCut {
protected UIMenu createdJMenu;
protected UIButton createdButton;
protected JPopupMenu popupMenu;
private boolean hasScrollSubMenu;
private boolean hasScrollSubMenu;
private String anchor;
@ -65,9 +65,9 @@ public class MenuDef extends ShortCut {
this.mnemonic = mnemonic;
}
public void setHasScrollSubMenu(boolean scrollSubMenu) {
this.hasScrollSubMenu = scrollSubMenu;
}
public void setHasScrollSubMenu(boolean scrollSubMenu) {
this.hasScrollSubMenu = scrollSubMenu;
}
public String getIconPath() {
return iconPath;
@ -93,38 +93,42 @@ public class MenuDef extends ShortCut {
this.anchor = anchor;
}
public List<ShortCut> getShortcutList() {
return this.shortcutList;
}
/**
* 插入菜单项
* @param index 插入的位置
* @param shortCut 菜单信息
*/
public void insertShortCut(int index, ShortCut shortCut) {
int size = this.shortcutList.size();
index = Math.min(index, size);
int size = this.shortcutList.size();
index = Math.min(index, size);
this.shortcutList.add(index, shortCut);
}
/**
* 用可变参数方便添加数组
* @param shortcut 参数 存储菜单项信息
*/
/**
* 用可变参数方便添加数组
* @param shortcut 参数 存储菜单项信息
*/
public void addShortCut(ShortCut... shortcut) {
for (ShortCut i : shortcut) {
this.shortcutList.add(i);
}
}
/**
* 清理
*/
public void clearShortCuts() {
/**
* 清理
*/
public void clearShortCuts() {
this.shortcutList.clear();
}
/**
* 生成UIButton
* @return 菜单按钮
*/
/**
* 生成UIButton
* @return 菜单按钮
*/
public UIButton createUIButton() {
if (createdButton == null) {
if (iconPath != null) {
@ -146,17 +150,17 @@ public class MenuDef extends ShortCut {
this.tooltip = text;
}
/**
* 生成JMenu
* @return 菜单
*/
/**
* 生成JMenu
* @return 菜单
*/
public UIMenu createJMenu() {
if (createdJMenu == null) {
if (hasScrollSubMenu) {
createdJMenu = new UIScrollMenu(this.getName());
} else {
createdJMenu = new UIMenu(this.getName());
}
if (hasScrollSubMenu) {
createdJMenu = new UIScrollMenu(this.getName());
} else {
createdJMenu = new UIMenu(this.getName());
}
createdJMenu.setMnemonic(this.getMnemonic());
if (this.iconPath != null) {
createdJMenu.setIcon(BaseUtils.readIcon(this.iconPath));
@ -174,20 +178,20 @@ public class MenuDef extends ShortCut {
protected ContainerListener getContainerListener() {
return null;
}
/**
* 生成 JPopupMenu
* @return 弹出菜单
*/
/**
* 生成 JPopupMenu
* @return 弹出菜单
*/
public JPopupMenu createJPopupMenu() {
UIMenu menu = createJMenu();
updateMenu();
return menu.getPopupMenu();
}
/**
* 设置是否可用
* @param b 布尔型
*/
/**
* 设置是否可用
* @param b 布尔型
*/
@Override
public void setEnabled(boolean b) {
this.enabled = b;
@ -201,10 +205,10 @@ public class MenuDef extends ShortCut {
}
}
/**
* 按钮状态
* @return 状态
*/
/**
* 按钮状态
* @return 状态
*/
@Override
public boolean isEnabled() {
return enabled;
@ -224,12 +228,12 @@ public class MenuDef extends ShortCut {
}
}
/**
* 更新菜单
* @param popupMenu 菜单
*/
/**
* 更新菜单
* @param popupMenu 菜单
*/
protected void updatePopupMenu(JPopupMenu popupMenu) {
removeComponent(popupMenu);
removeComponent(popupMenu);
this.popupMenu = popupMenu;
// 一开始是不能插入分隔符的
boolean nec_seperator = false;
@ -256,32 +260,32 @@ public class MenuDef extends ShortCut {
if (createdJMenu != null && createdJMenu.getPopupMenu() != null){
setEnabled(createdJMenu.getPopupMenu().getComponentCount() > 0 && enabled);
}
}
/**
* 删除所有组件 除了滚动条
* @param popupMenu 菜单
*/
public void removeComponent(JPopupMenu popupMenu){
UIScrollBar uiScrollBar = new UIScrollBar();
if(hasScrollSubMenu){
for(Component comp : popupMenu.getComponents()){
if(comp instanceof UIScrollBar){
uiScrollBar =(UIScrollBar) comp;
}
}
}
popupMenu.removeAll();
if(hasScrollSubMenu){
popupMenu.add(uiScrollBar);
}
}
/**
* 添加菜单项
* @param menu 菜单
*/
}
}
/**
* 删除所有组件 除了滚动条
* @param popupMenu 菜单
*/
public void removeComponent(JPopupMenu popupMenu){
UIScrollBar uiScrollBar = new UIScrollBar();
if(hasScrollSubMenu){
for(Component comp : popupMenu.getComponents()){
if(comp instanceof UIScrollBar){
uiScrollBar =(UIScrollBar) comp;
}
}
}
popupMenu.removeAll();
if(hasScrollSubMenu){
popupMenu.add(uiScrollBar);
}
}
/**
* 添加菜单项
* @param menu 菜单
*/
@Override
public void intoJPopupMenu(JPopupMenu menu) {
updateMenu();
@ -289,10 +293,10 @@ public class MenuDef extends ShortCut {
menu.add(this.createJMenu());
}
/**
* 添加
* @param toolBar 菜单条
*/
/**
* 添加
* @param toolBar 菜单条
*/
@Override
public void intoJToolBar(JToolBar toolBar) {
toolBar.add(this.createUIButton());

Loading…
Cancel
Save