Browse Source

alphafine 广告弹窗

master
XiaXiang 8 years ago
parent
commit
b1187cbd05
  1. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/check.png
  2. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/open.png
  3. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/remind.png
  4. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/remind_close.png
  5. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/uncheck.png
  6. 4
      designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaSearchManager.java
  7. 32
      designer_base/src/com/fr/aspectj/designerbase/AlphaFineReminder.aj
  8. 24
      designer_base/src/com/fr/aspectj/designerbase/TemplateProcessTracker.aj
  9. 33
      designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigManager.java
  10. 52
      designer_base/src/com/fr/design/actions/help/AlphaFine/RemindDialog.java
  11. 129
      designer_base/src/com/fr/design/actions/help/AlphaFine/RemindPane.java
  12. 118
      designer_form/src/com/fr/aspectj/designerform/TemplateProcessTracker.aj

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

4
designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaSearchManager.java

@ -37,12 +37,12 @@ public class AlphaSearchManager implements AlphaFineSearchProcessor {
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
SearchResult recentModelList = recentSearchManager.getLessSearchResult(searchText);
SearchResult concludeModelList = recommendSearchManager.getLessSearchResult(searchText);
SearchResult recommendModelList = recommendSearchManager.getLessSearchResult(searchText);
SearchResult actionModelList = actionSearchManager.getLessSearchResult(searchText);
SearchResult fileModelList = fileSearchManager.getLessSearchResult(searchText);
SearchResult documentModelList = documentSearchManager.getLessSearchResult(searchText);
SearchResult pluginModelList = pluginSearchManager.getLessSearchResult(searchText);
recentModelList.addAll(concludeModelList);
recentModelList.addAll(recommendModelList);
recentModelList.addAll(actionModelList);
recentModelList.addAll(fileModelList);
recentModelList.addAll(documentModelList);

32
designer_base/src/com/fr/aspectj/designerbase/AlphaFineReminder.aj

@ -1,5 +1,10 @@
package com.fr.aspectj.designerbase;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.AlphaFine.AlphafineConfigManager;
import com.fr.design.actions.help.AlphaFine.RemindDialog;
import com.fr.design.mainframe.DesignerContext;
import java.awt.event.ActionEvent;
/**
@ -15,9 +20,34 @@ public aspect AlphaFineReminder {
return;
}
if (e != null && e.getSource().getClass().getName().equals("com.fr.design.gui.imenu.UIMenuItem") && point.contains("com.fr.design.actions")) {
//System.out.print(thisJoinPoint + "\n");
remind();
}
}
/**
* 判断是否弹出广告框
*/
private static void remind() {
AlphafineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphafineConfigManager();
if (manager.isNeedRemind()) {
if (manager.getOperateCount() > 4) {
showReminderDialog();
} else {
manager.setOperateCount(manager.getOperateCount() + 1);
}
}
}
/**
* 弹框提醒使用AlphaFine
*/
private static void showReminderDialog() {
RemindDialog remindDialog = new RemindDialog(DesignerContext.getDesignerFrame());
remindDialog.setVisible(true);
}
}

24
designer_base/src/com/fr/aspectj/designerbase/TemplateProcessTracker.aj

@ -5,29 +5,27 @@ package com.fr.aspectj.designerbase;
* Created by plough on 2017/3/3.
*/
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
import org.aspectj.lang.reflect.SourceLocation;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.util.Date;
public aspect TemplateProcessTracker {
//声明一个pointcut,匹配你需要的方法
pointcut onMouseClicked(MouseEvent e) :
pointcut onMouseClicked(MouseEvent e):
execution(* mouseClicked(MouseEvent)) && args(e);
pointcut onMousePressed(MouseEvent e) :
pointcut onMousePressed(MouseEvent e):
execution(* mousePressed(MouseEvent)) && args(e);
pointcut onMouseReleased(MouseEvent e) :
pointcut onMouseReleased(MouseEvent e):
execution(* mouseReleased(MouseEvent)) && args(e);
pointcut onActionPerformed(ActionEvent e) :
pointcut onActionPerformed(ActionEvent e):
execution(* actionPerformed(ActionEvent)) && args(e);
pointcut onSetValueAt(Object v, int r, int c) :
pointcut onSetValueAt(Object v, int r, int c):
execution(* setValueAt(java.lang.Object, int, int)) && args(v, r, c);
//before表示之前的意思
//这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码
before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) {
before(MouseEvent e): onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) {
SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置
//String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource());
@ -35,10 +33,10 @@ public aspect TemplateProcessTracker {
//TemplateInfoCollector.appendProcess(log);
}
//同上
before(ActionEvent e) : onActionPerformed(e) {
before(ActionEvent e): onActionPerformed(e) {
SourceLocation sl = thisJoinPoint.getSourceLocation();
// !within(LogHandlerBar) 没用, 手动过滤
if (e.getSource().toString().contains("javax.swing.Timer")) {
if (e != null && e.getSource().toString().contains("javax.swing.Timer")) {
return;
}
@ -48,12 +46,12 @@ public aspect TemplateProcessTracker {
}
//同上
before(Object v, int r, int c) : onSetValueAt(v, r, c) {
before(Object v, int r, int c): onSetValueAt(v, r, c) {
SourceLocation sl = thisJoinPoint.getSourceLocation();
//String log = String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c);
//String log getSourceLocation= String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c);
String log = "";
// TemplateInfoCollector.appendProcess(log);
// TemplateInfoCollector.appendProcess(log);
}

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

@ -67,6 +67,15 @@ public class AlphafineConfigManager implements XMLable {
*/
private KeyStroke shortCutKeyStore;
/**
* 是否提醒
*/
private boolean isNeedRemind = true;
/**
* 直接操作菜单次数
*/
private int operateCount;
@ -92,7 +101,9 @@ public class AlphafineConfigManager implements XMLable {
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"));
this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts()));
this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true));
this.setOperateCount(reader.getAttrAsInt("operateCount", 0));
}
@ -109,7 +120,9 @@ public class AlphafineConfigManager implements XMLable {
.attr("isContainDocument", this.isContainDocument())
.attr("isContainTemplate", this.isContainTemplate())
.attr("isContainPlugin", this.isContainPlugin())
.attr("isContainFileContent", this.isContainFileContent());
.attr("isContainFileContent", this.isContainFileContent())
.attr("isNeedRemind", this.isNeedRemind())
.attr("operateCount", this.getOperateCount());
writer.end();
}
@ -214,4 +227,20 @@ public class AlphafineConfigManager implements XMLable {
public void setContainFileContent(boolean containFileContent) {
isContainFileContent = containFileContent;
}
public boolean isNeedRemind() {
return isNeedRemind;
}
public void setNeedRemind(boolean needRemind) {
isNeedRemind = needRemind;
}
public int getOperateCount() {
return operateCount;
}
public void setOperateCount(int operateCount) {
this.operateCount = operateCount;
}
}

52
designer_base/src/com/fr/design/actions/help/AlphaFine/RemindDialog.java

@ -0,0 +1,52 @@
package com.fr.design.actions.help.AlphaFine;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.gui.GUICoreUtils;
import java.awt.*;
import java.awt.event.*;
/**
* Created by XiaXiang on 2017/5/26.
*/
public class RemindDialog extends UIDialog {
private RemindPane remindPane;
private static final int WIDTH = 600;
private static final int HEIGHT = 400;
public RemindDialog(Frame parent) {
super(parent);
setUndecorated(true);
setSize(WIDTH, HEIGHT);
initComponent();
GUICoreUtils.centerWindow(this);
}
private void initComponent() {
final AlphafineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphafineConfigManager();
remindPane = new RemindPane(manager);
remindPane.navigateButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
dispose();
manager.setOperateCount(0);
}
});
this.add(remindPane);
}
@Override
public void checkValid() throws Exception {
}
public RemindPane getRemindPane() {
return remindPane;
}
public void setRemindPane(RemindPane remindPane) {
this.remindPane = remindPane;
}
}

129
designer_base/src/com/fr/design/actions/help/AlphaFine/RemindPane.java

@ -0,0 +1,129 @@
package com.fr.design.actions.help.AlphaFine;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* Created by XiaXiang on 2017/5/26.
*/
public class RemindPane extends JPanel {
public static final Font MEDIUM_FONT = new Font("Song_TypeFace", 0, 12);
public static final Font LARGE_FONT = new Font("Song_TypeFace", 0, 18);
private UIButton openButton;
private JPanel backgroundPane;
private UILabel backgroundLabel;
private UILabel checkLabel;
private Icon checkIcon = IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/check.png");
private Icon unCheckIcon = IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/uncheck.png");
private Icon closeIcon = IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/remind_close.png");
private Icon labelIcon = IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/remind.png");
private Icon openIcon = IOUtils.readIcon("com/fr/design/mainframe/alphafine/images/open.png");
public JComponent navigateButton = new JComponent() {
protected void paintComponent(Graphics g) {
closeIcon.paintIcon(this, g, 0, 0);
}
};
public RemindPane(AlphafineConfigManager manager) {
this.setPreferredSize(new Dimension(600, 400));
initUI(manager);
this.setLayout(getAbsoluteLayout());
}
private void initUI(final AlphafineConfigManager manager) {
openButton = new UIButton() {
@Override
public void paintComponent(Graphics g) {
g.setColor( Color.white );
g.fillRect(0, 0, getSize().width, getSize().height);
super.paintComponent(g);
}
};
openButton.setContentAreaFilled(false);
openButton.setForeground(new Color(0x3394F0));
openButton.setIcon(openIcon);
openButton.setFont(LARGE_FONT);
openButton.set4ToolbarButton();
openButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
}
});
backgroundLabel = new UILabel(Inter.getLocText("FR-Designer-Alphafine_No_Remind"));
backgroundLabel.setFont(MEDIUM_FONT);
backgroundLabel.setForeground(Color.white);
checkLabel = new UILabel();
checkLabel.setIcon(unCheckIcon);
checkLabel.addMouseListener(new MouseAdapter() {
private boolean isCheck = false;
@Override
public void mouseClicked(MouseEvent e) {
if (isCheck) {
checkLabel.setIcon(unCheckIcon);
manager.setNeedRemind(true);
isCheck = false;
} else {
checkLabel.setIcon(checkIcon);
manager.setNeedRemind(false);
isCheck = true;
}
}
});
backgroundPane = new JPanel(new BorderLayout());
backgroundPane.add(new UILabel(labelIcon), BorderLayout.CENTER);
add(navigateButton, 0);
add(checkLabel, 1);
add(openButton, 2);
add(backgroundLabel, 3);
add(backgroundPane, 4);
}
/**
* 控件排列用绝对布局
* @return
*/
protected LayoutManager getAbsoluteLayout() {
return new LayoutManager() {
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return parent.getPreferredSize();
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return null;
}
@Override
public void layoutContainer(Container parent) {
int width = parent.getWidth();
int height = parent.getHeight();
navigateButton.setBounds((width - 30), 0, 30, 30);
openButton.setBounds(30, 300, 150, 40);
backgroundLabel.setBounds(95, 350, 100, 20);
checkLabel.setBounds(70, 350, 20, 20);
backgroundPane.setBounds(0, 0, width, height);
}
@Override
public void addLayoutComponent(String name, Component comp) {
}
};
}
}

118
designer_form/src/com/fr/aspectj/designerform/TemplateProcessTracker.aj

@ -1,59 +1,59 @@
package com.fr.aspectj.designerform;
/**
* Created by plough on 2017/3/3.
*/
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
import org.aspectj.lang.reflect.SourceLocation;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.util.Date;
public aspect TemplateProcessTracker {
//声明一个pointcut,匹配你需要的方法
pointcut onMouseClicked(MouseEvent e) :
execution(* mouseClicked(MouseEvent)) && args(e);
pointcut onMousePressed(MouseEvent e) :
execution(* mousePressed(MouseEvent)) && args(e);
pointcut onMouseReleased(MouseEvent e) :
execution(* mouseReleased(MouseEvent)) && args(e);
pointcut onActionPerformed(ActionEvent e) :
execution(* actionPerformed(ActionEvent)) && args(e);
pointcut onSetValueAt(Object v, int r, int c) :
execution(* setValueAt(java.lang.Object, int, int)) && args(v, r, c);
//before表示之前的意思
//这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码
before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) {
SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置
//String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource());
String log = "";
//TemplateInfoCollector.appendProcess(log);
}
//同上
before(ActionEvent e) : onActionPerformed(e) {
SourceLocation sl = thisJoinPoint.getSourceLocation();
// !within(LogHandlerBar) 没用, 手动过滤
if (e.getSource().toString().contains("javax.swing.Timer")) {
return;
}
//String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource());
String log = "";
//TemplateInfoCollector.appendProcess(log);
}
//同上
before(Object v, int r, int c) : onSetValueAt(v, r, c) {
SourceLocation sl = thisJoinPoint.getSourceLocation();
//String log = String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c);
String log = "";
//TemplateInfoCollector.appendProcess(log);
}
}
//package com.fr.aspectj.designerform;
//
///**
// * Created by plough on 2017/3/3.
// */
//import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
//import org.aspectj.lang.reflect.SourceLocation;
//
//import java.awt.event.ActionEvent;
//import java.awt.event.MouseEvent;
//import java.util.Date;
//
//public aspect TemplateProcessTracker {
// //声明一个pointcut,匹配你需要的方法
// pointcut onMouseClicked(MouseEvent e) :
// execution(* mouseClicked(MouseEvent)) && args(e);
// pointcut onMousePressed(MouseEvent e) :
// execution(* mousePressed(MouseEvent)) && args(e);
// pointcut onMouseReleased(MouseEvent e) :
// execution(* mouseReleased(MouseEvent)) && args(e);
// pointcut onActionPerformed(ActionEvent e) :
// execution(* actionPerformed(ActionEvent)) && args(e);
// pointcut onSetValueAt(Object v, int r, int c) :
// execution(* setValueAt(java.lang.Object, int, int)) && args(v, r, c);
//
// //before表示之前的意思
// //这整个表示在MouseAdapter的public void mouseXXX(MouseEvent)方法调用之前,你想要执行的代码
// before(MouseEvent e) : onMouseClicked(e) || onMousePressed(e) || onMouseReleased(e) {
// SourceLocation sl = thisJoinPoint.getSourceLocation();//切面对应的代码位置
//
// //String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource());
// String log = "";
// //TemplateInfoCollector.appendProcess(log);
// }
// //同上
// before(ActionEvent e) : onActionPerformed(e) {
// SourceLocation sl = thisJoinPoint.getSourceLocation();
// // !within(LogHandlerBar) 没用, 手动过滤
// if (e.getSource().toString().contains("javax.swing.Timer")) {
// return;
// }
//
// //String log = String.format("%s:\n%s\n%s\n%s\n\n", new Date(), sl, e, e.getSource());
// String log = "";
// //TemplateInfoCollector.appendProcess(log);
//
// }
// //同上
// before(Object v, int r, int c) : onSetValueAt(v, r, c) {
// SourceLocation sl = thisJoinPoint.getSourceLocation();
//
// //String log = String.format("%s:\n%s\nset value: %s at (%d, %d)\n\n", new Date(), sl, v, r, c);
// String log = "";
// //TemplateInfoCollector.appendProcess(log);
//
// }
//
//
//}

Loading…
Cancel
Save