* commit 'f905d03d0e35146c784348f65715e202b8b23355': (41 commits) aspectJ编译 bug fix bug fix rt alphafine 广告 alphafine 广告弹框 bug fix bug fix alphafine 广告弹窗 PMD PMD PMD PMD REPORT-2773 mac中复制快捷键的修复 PMD PMD REPORT-2773 mac中复制快捷键的修复 REPORT-2773 mac中复制快捷键的修复 PMD 局部变量不行..还是改回去吧 ...master
Before Width: | Height: | Size: 369 B |
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 418 B |
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 418 B After Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 369 B |
After Width: | Height: | Size: 237 B |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 185 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 14 KiB |
@ -0,0 +1,69 @@
|
||||
|
||||
apply plugin: 'java' |
||||
tasks.withType(JavaCompile){ |
||||
options.encoding = 'UTF-8' |
||||
} |
||||
//指定构建的jdk版本 |
||||
sourceCompatibility=1.7 |
||||
//指定生成jar包版本 |
||||
version='8.0' |
||||
//生成jar包重命名 |
||||
jar{ |
||||
baseName='fr-designer-core' |
||||
} |
||||
|
||||
|
||||
def srcDir="." |
||||
def baseDir=".." |
||||
|
||||
//指定源码路径 |
||||
sourceSets{ |
||||
main{ |
||||
java{ |
||||
srcDirs=["${srcDir}/src"] |
||||
} |
||||
} |
||||
} |
||||
//获取什么分支名 |
||||
FileTree files =fileTree(dir:'./',include:'build.*.gradle') |
||||
def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\')) |
||||
buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\')) |
||||
def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1) |
||||
|
||||
//声明外部依赖 |
||||
dependencies{ |
||||
compile fileTree(dir:"../${baseDir}/lib",include:'**/*.jar') |
||||
compile fileTree(dir:"../${baseDir}",include:"**/build/libs/*.jar",exclude:"bi/**/*.jar") |
||||
testCompile 'junit:junit:4.12' |
||||
} |
||||
//复制非.java文件到classes文件夹下参与打包 |
||||
task copyFile(type:Copy,dependsOn:compileJava){ |
||||
copy{ |
||||
from ("${srcDir}/src"){ |
||||
exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' |
||||
} |
||||
into 'build/classes/main' |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
//压缩项目中的js文件 |
||||
task compressJS{ |
||||
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ |
||||
classpath { |
||||
fileset(dir:"../${baseDir}/lib4build",includes:'**/*.jar') |
||||
} |
||||
} |
||||
ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ |
||||
fileset (dir:"${srcDir}/src"){ |
||||
include (name:'**/*.js') |
||||
include (name:'**/*.css') |
||||
} |
||||
|
||||
} |
||||
} |
||||
jar.dependsOn compressJS |
||||
|
||||
|
||||
|
@ -0,0 +1,53 @@
|
||||
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; |
||||
|
||||
/** |
||||
* Created by XiaXiang on 2017/5/25. |
||||
*/ |
||||
public aspect AlphaFineReminder { |
||||
pointcut onActionPerformed(ActionEvent e) : |
||||
execution(* actionPerformed(ActionEvent)) && args(e); |
||||
|
||||
before(ActionEvent e) : onActionPerformed(e) { |
||||
String point = thisJoinPoint.toString(); |
||||
if (e != null && e.getSource().toString().contains("javax.swing.Timer")) { |
||||
return; |
||||
} |
||||
if (e != null && e.getSource().getClass().getName().equals("com.fr.design.gui.imenu.UIMenuItem") && point.contains("com.fr.design.actions")) { |
||||
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); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.fr.common.inputevent; |
||||
|
||||
import com.fr.stable.OperatingSystem; |
||||
|
||||
import java.awt.event.KeyEvent; |
||||
import java.awt.event.MouseEvent; |
||||
|
||||
/** |
||||
* Created by hzzz on 2017/5/26. |
||||
*/ |
||||
public class InputEventBaseOnOS { |
||||
private static final boolean IS_MACOS = OperatingSystem.isMacOS(); |
||||
|
||||
public static boolean isControlDown(MouseEvent e) { |
||||
return IS_MACOS ? e.isMetaDown() : e.isControlDown(); |
||||
} |
||||
|
||||
public static boolean isControlDown(KeyEvent e) { |
||||
return IS_MACOS ? e.isMetaDown() : e.isControlDown(); |
||||
} |
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.fr.design.actions.help.alphafine; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by XiaXiang on 2017/5/27. |
||||
*/ |
||||
public class AlphafineContext { |
||||
private static List<AlphafineListener> fireLoginContextListener = new ArrayList<AlphafineListener>(); |
||||
|
||||
/** |
||||
* 触发AlphaFine弹窗 |
||||
*/ |
||||
public static void fireAlphaFineContextListener() { |
||||
for (AlphafineListener l : fireLoginContextListener) { |
||||
l.showDialog(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 添加一个弹出AlphaFine的监听事件 |
||||
* |
||||
* @param l AlphaFine框弹出监听事件 |
||||
*/ |
||||
public static void addAlphafineContextListener(AlphafineListener l) { |
||||
fireLoginContextListener.add(l); |
||||
} |
||||
} |
@ -0,0 +1,8 @@
|
||||
package com.fr.design.actions.help.alphafine; |
||||
|
||||
/** |
||||
* Created by XiaXiang on 2017/5/27. |
||||
*/ |
||||
public interface AlphafineListener { |
||||
void showDialog(); |
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.fr.design.actions.help.alphafine; |
||||
|
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* 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, this); |
||||
this.add(remindPane); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
|
||||
} |
||||
|
||||
public RemindPane getRemindPane() { |
||||
return remindPane; |
||||
} |
||||
|
||||
public void setRemindPane(RemindPane remindPane) { |
||||
this.remindPane = remindPane; |
||||
} |
||||
} |
@ -0,0 +1,146 @@
|
||||
package com.fr.design.actions.help.alphafine; |
||||
|
||||
import com.fr.design.dialog.UIDialog; |
||||
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 { |
||||
|
||||
private UIButton openButton; |
||||
private JPanel backgroundPane; |
||||
private UILabel noRemindLabel; |
||||
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"); |
||||
|
||||
private static final int WIDTH = 600; |
||||
private static final int HEIGHT = 400; |
||||
private static final int CLOSE = 30; |
||||
|
||||
private static final Rectangle OPEN = new Rectangle(30, 300, 150, 40); |
||||
private static final Rectangle REMIND = new Rectangle(95, 350, 100, 20); |
||||
private static final Rectangle CHECK = new Rectangle(70, 350, 20, 20); |
||||
public static final Font MEDIUM_FONT = new Font("Song_TypeFace", 0, 12); |
||||
public static final Font LARGE_FONT = new Font("Song_TypeFace", 0, 18); |
||||
|
||||
public JComponent closeButton = new JComponent() { |
||||
protected void paintComponent(Graphics g) { |
||||
closeIcon.paintIcon(this, g, 0, 0); |
||||
} |
||||
}; |
||||
|
||||
public RemindPane(AlphafineConfigManager manager, UIDialog remindDialog) { |
||||
this.setPreferredSize(new Dimension(WIDTH, HEIGHT)); |
||||
initUI(manager, remindDialog); |
||||
this.setLayout(getAbsoluteLayout()); |
||||
} |
||||
|
||||
/** |
||||
* 初始化面板 |
||||
* @param manager |
||||
* @param dialog |
||||
*/ |
||||
private void initUI(final AlphafineConfigManager manager, final UIDialog dialog) { |
||||
|
||||
openButton = new UIButton(); |
||||
openButton.setIcon(openIcon); |
||||
openButton.set4ToolbarButton(); |
||||
openButton.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mousePressed(MouseEvent e) { |
||||
manager.setOperateCount(0); |
||||
dialog.dispose(); |
||||
AlphafineContext.fireAlphaFineContextListener(); |
||||
|
||||
} |
||||
}); |
||||
noRemindLabel = new UILabel(Inter.getLocText("FR-Designer-Alphafine_No_Remind")); |
||||
noRemindLabel.setFont(MEDIUM_FONT); |
||||
noRemindLabel.setForeground(Color.white); |
||||
checkLabel = new UILabel(); |
||||
checkLabel.setIcon(unCheckIcon); |
||||
checkLabel.addMouseListener(new MouseAdapter() { |
||||
private boolean isCheck = false; |
||||
|
||||
@Override |
||||
public void mousePressed(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); |
||||
closeButton.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mousePressed(MouseEvent e) { |
||||
manager.setOperateCount(0); |
||||
dialog.dispose(); |
||||
|
||||
} |
||||
}); |
||||
add(closeButton, 0); |
||||
add(checkLabel, 1); |
||||
add(openButton, 2); |
||||
add(noRemindLabel, 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(); |
||||
closeButton.setBounds((width - CLOSE), 0, CLOSE, CLOSE); |
||||
openButton.setBounds(OPEN); |
||||
noRemindLabel.setBounds(REMIND); |
||||
checkLabel.setBounds(CHECK); |
||||
backgroundPane.setBounds(0, 0, width, height); |
||||
} |
||||
|
||||
@Override |
||||
public void addLayoutComponent(String name, Component comp) { |
||||
} |
||||
}; |
||||
} |
||||
|
||||
} |
@ -1,311 +1,300 @@
|
||||
package com.fr.design.gui.ilist; |
||||
|
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.border.Border; |
||||
import javax.swing.border.EmptyBorder; |
||||
import java.awt.*; |
||||
import java.awt.event.*; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.EventListener; |
||||
import java.util.List; |
||||
|
||||
import javax.swing.JComponent; |
||||
import javax.swing.JList; |
||||
import javax.swing.ListCellRenderer; |
||||
import javax.swing.ListModel; |
||||
import javax.swing.ListSelectionModel; |
||||
import javax.swing.UIManager; |
||||
import javax.swing.border.Border; |
||||
import javax.swing.border.EmptyBorder; |
||||
|
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* CheckBoxs + JList. |
||||
*/ |
||||
public class CheckBoxList extends JComponent { |
||||
/** |
||||
* 选择状态----全选和全不选 |
||||
* |
||||
* @editor zhou |
||||
* @since 2012-4-1下午2:39:10 |
||||
*/ |
||||
public static enum SelectedState { |
||||
ALL, NONE |
||||
} |
||||
|
||||
private boolean[] selects; |
||||
private JList jlist; |
||||
private UICheckBox chooseAll; |
||||
|
||||
public CheckBoxList(Object[] items) { |
||||
this(items, SelectedState.NONE, StringUtils.EMPTY); |
||||
} |
||||
|
||||
public CheckBoxList(Object[] items, String name) { |
||||
this(items, SelectedState.NONE, name); |
||||
} |
||||
|
||||
/** |
||||
* Class constructor. |
||||
* |
||||
* @param items |
||||
* Items with which to populate the list. |
||||
* @param default_state |
||||
* default state, true or false |
||||
*/ |
||||
public CheckBoxList(Object[] items, SelectedState state, String name) { |
||||
jlist = new BOXLIST(items); |
||||
jlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
||||
this.selects = new boolean[items.length]; |
||||
boolean default_state = (state == SelectedState.ALL); |
||||
Arrays.fill(this.selects, default_state); |
||||
|
||||
jlist.setCellRenderer(new CheckListCellRenderer()); |
||||
jlist.addMouseListener(new MouseAdapter() { |
||||
public void mousePressed(MouseEvent e) { |
||||
doCheck(); |
||||
} |
||||
|
||||
public void mouseReleased(MouseEvent e) { |
||||
doCheck(); |
||||
} |
||||
}); |
||||
jlist.addKeyListener(new KeyAdapter() { |
||||
|
||||
@Override |
||||
public void keyTyped(KeyEvent e) { |
||||
if (e.getKeyChar() == ' ') { |
||||
doCheck(); |
||||
} |
||||
} |
||||
|
||||
}); |
||||
this.setLayout(new BorderLayout()); |
||||
chooseAll = new UICheckBox(name, default_state); |
||||
chooseAll.addActionListener(new ActionListener() { |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
if (chooseAll.isSelected()) { |
||||
setSelected(true); |
||||
} else { |
||||
setSelected(false); |
||||
} |
||||
} |
||||
}); |
||||
this.add(chooseAll, BorderLayout.NORTH); |
||||
this.add(jlist, BorderLayout.CENTER); |
||||
} |
||||
|
||||
/* |
||||
* 用于CellRenderer显示value为text |
||||
*/ |
||||
protected String value2Text(Object value) { |
||||
return value != null ? value.toString() : StringUtils.EMPTY; |
||||
} |
||||
|
||||
public void setItems(Object[] os) { |
||||
if (os == null) { |
||||
this.setSelected(false); |
||||
} else { |
||||
for (int i = 0, len = os.length; i < len; i++) { |
||||
Object o = os[i]; |
||||
for (int j = 0, jen = jlist.getModel().getSize(); j < jen; j++) { |
||||
if (o.equals(jlist.getModel().getElementAt(j))) { |
||||
this.setSelected(j, true); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
this.repaint(); |
||||
} |
||||
|
||||
/** |
||||
* Is selected |
||||
*/ |
||||
public boolean isSelected(int index) { |
||||
if (selects == null || index >= selects.length) { |
||||
return false; |
||||
} |
||||
|
||||
return selects[index]; |
||||
} |
||||
|
||||
public void setSelected(int index, boolean isSelected) { |
||||
if (selects == null || index >= selects.length) { |
||||
return; |
||||
} |
||||
|
||||
selects[index] = isSelected; |
||||
this.repaint(this.getBounds()); |
||||
|
||||
this.fireCheckBoxListSelectionChangeListener(); |
||||
} |
||||
|
||||
private void setSelected(boolean isSelected) { |
||||
if (selects == null) { |
||||
return; |
||||
} |
||||
for (int i = 0; i < selects.length; i++) { |
||||
selects[i] = isSelected; |
||||
} |
||||
this.repaint(this.getBounds()); |
||||
|
||||
this.fireCheckBoxListSelectionChangeListener(); |
||||
} |
||||
|
||||
/** |
||||
* Returns an array of the objects that have been selected. Overrides the |
||||
* JList method. |
||||
*/ |
||||
public Object[] getSelectedValues() { |
||||
return this.jlist.getSelectedValues(); |
||||
} |
||||
|
||||
private class BOXLIST extends JList { |
||||
public BOXLIST(Object[] items) { |
||||
super(items); |
||||
} |
||||
|
||||
@Override |
||||
protected void processMouseEvent(MouseEvent e) { |
||||
if (e.getX() < 20) { |
||||
if (e.isControlDown() || e.isAltDown() || e.isShiftDown() || e.isMetaDown()) { |
||||
int[] indices = getSelectedIndices(); |
||||
if (indices.length == 0) { |
||||
super.processMouseEvent(e); |
||||
} |
||||
} else { |
||||
super.processMouseEvent(e); |
||||
} |
||||
} else { |
||||
super.processMouseEvent(e); |
||||
} |
||||
int id = e.getID(); |
||||
switch (id) { |
||||
case MouseEvent.MOUSE_PRESSED: |
||||
break; |
||||
case MouseEvent.MOUSE_RELEASED: |
||||
break; |
||||
case MouseEvent.MOUSE_CLICKED: |
||||
doCheck(); |
||||
break; |
||||
case MouseEvent.MOUSE_EXITED: |
||||
break; |
||||
case MouseEvent.MOUSE_ENTERED: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected void processMouseMotionEvent(MouseEvent e) { |
||||
if (e.getX() < 20) { |
||||
return; |
||||
} |
||||
|
||||
super.processMouseEvent(e); |
||||
} |
||||
|
||||
@Override |
||||
public Object[] getSelectedValues() { |
||||
List<Object> list = new ArrayList<Object>(selects.length); |
||||
for (int i = 0; i < selects.length; i++) { |
||||
if (selects[i]) { |
||||
list.add(this.getModel().getElementAt(i)); |
||||
} |
||||
} |
||||
|
||||
return list.toArray(); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void doCheck() { |
||||
// p:这里必须改变所有选择checkbox.
|
||||
int index = jlist.getSelectedIndex(); |
||||
boolean sValue = !selects[index]; |
||||
|
||||
// p:开始设置所有选择的checkbox.
|
||||
int[] indices = jlist.getSelectedIndices(); |
||||
for (int i = 0; i < indices.length; i++) { |
||||
setSelected(indices[i], sValue); |
||||
} |
||||
for (boolean selected : selects) { |
||||
if (!selected) { |
||||
chooseAll.setSelected(false); |
||||
return; |
||||
} |
||||
} |
||||
chooseAll.setSelected(true); |
||||
repaint(); |
||||
} |
||||
|
||||
private static final Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); |
||||
|
||||
private class CheckListCellRenderer extends UICheckBox implements ListCellRenderer { |
||||
|
||||
public CheckListCellRenderer() { |
||||
this.setOpaque(true); |
||||
this.setBorder(noFocusBorder); |
||||
} |
||||
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
this.setText(value2Text(value)); |
||||
this.setSelected(selects[index]); |
||||
this.setFont(list.getFont()); |
||||
|
||||
if (isSelected) { |
||||
this.setBackground(list.getSelectionBackground()); |
||||
this.setForeground(list.getSelectionForeground()); |
||||
} else { |
||||
this.setBackground(list.getBackground()); |
||||
this.setForeground(list.getForeground()); |
||||
} |
||||
|
||||
if (cellHasFocus) { |
||||
this.setBorder(UIManager.getBorder("List.focusCellHighlightBorder")); |
||||
} else { |
||||
this.setBorder(noFocusBorder); |
||||
} |
||||
|
||||
return this; |
||||
} |
||||
} |
||||
|
||||
public void addCheckBoxListSelectionChangeListener(CheckBoxListSelectionChangeListener l) { |
||||
this.listenerList.add(CheckBoxListSelectionChangeListener.class, l); |
||||
} |
||||
|
||||
public void removeCheckBoxListSelectionChangeListener(CheckBoxListSelectionChangeListener l) { |
||||
this.listenerList.remove(CheckBoxListSelectionChangeListener.class, l); |
||||
} |
||||
|
||||
public void fireCheckBoxListSelectionChangeListener() { |
||||
// Guaranteed to return a non-null array
|
||||
Object[] listeners = listenerList.getListenerList(); |
||||
|
||||
// Process the listeners last to first, notifying
|
||||
// those that are interested in this event
|
||||
for (int i = listeners.length - 2; i >= 0; i -= 2) { |
||||
if (listeners[i] == CheckBoxListSelectionChangeListener.class) { |
||||
((CheckBoxListSelectionChangeListener)listeners[i + 1]).selectionChanged(this); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
public static interface CheckBoxListSelectionChangeListener extends EventListener { |
||||
public void selectionChanged(CheckBoxList target); |
||||
} |
||||
|
||||
public ListModel getModel() { |
||||
return jlist.getModel(); |
||||
} |
||||
private final static int X_COORDINATE = 20; |
||||
|
||||
/** |
||||
* 选择状态----全选和全不选 |
||||
* |
||||
* @editor zhou |
||||
* @since 2012-4-1下午2:39:10 |
||||
*/ |
||||
public static enum SelectedState { |
||||
ALL, NONE |
||||
} |
||||
|
||||
private boolean[] selects; |
||||
private JList jlist; |
||||
private UICheckBox chooseAll; |
||||
|
||||
public CheckBoxList(Object[] items) { |
||||
this(items, SelectedState.NONE, StringUtils.EMPTY); |
||||
} |
||||
|
||||
public CheckBoxList(Object[] items, String name) { |
||||
this(items, SelectedState.NONE, name); |
||||
} |
||||
|
||||
/** |
||||
* Class constructor. |
||||
* |
||||
* @param items Items with which to populate the list. |
||||
* @param state default state, true or false |
||||
*/ |
||||
public CheckBoxList(Object[] items, SelectedState state, String name) { |
||||
jlist = new BOXLIST(items); |
||||
jlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
||||
this.selects = new boolean[items.length]; |
||||
boolean default_state = (state == SelectedState.ALL); |
||||
Arrays.fill(this.selects, default_state); |
||||
|
||||
jlist.setCellRenderer(new CheckListCellRenderer()); |
||||
jlist.addMouseListener(new MouseAdapter() { |
||||
public void mousePressed(MouseEvent e) { |
||||
doCheck(); |
||||
} |
||||
|
||||
public void mouseReleased(MouseEvent e) { |
||||
doCheck(); |
||||
} |
||||
}); |
||||
jlist.addKeyListener(new KeyAdapter() { |
||||
|
||||
@Override |
||||
public void keyTyped(KeyEvent e) { |
||||
if (e.getKeyChar() == ' ') { |
||||
doCheck(); |
||||
} |
||||
} |
||||
|
||||
}); |
||||
this.setLayout(new BorderLayout()); |
||||
chooseAll = new UICheckBox(name, default_state); |
||||
chooseAll.addActionListener(new ActionListener() { |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
if (chooseAll.isSelected()) { |
||||
setSelected(true); |
||||
} else { |
||||
setSelected(false); |
||||
} |
||||
} |
||||
}); |
||||
this.add(chooseAll, BorderLayout.NORTH); |
||||
this.add(jlist, BorderLayout.CENTER); |
||||
} |
||||
|
||||
/* |
||||
* 用于CellRenderer显示value为text |
||||
*/ |
||||
protected String value2Text(Object value) { |
||||
return value != null ? value.toString() : StringUtils.EMPTY; |
||||
} |
||||
|
||||
public void setItems(Object[] os) { |
||||
if (os == null) { |
||||
this.setSelected(false); |
||||
} else { |
||||
for (int i = 0, len = os.length; i < len; i++) { |
||||
Object o = os[i]; |
||||
for (int j = 0, jen = jlist.getModel().getSize(); j < jen; j++) { |
||||
if (o.equals(jlist.getModel().getElementAt(j))) { |
||||
this.setSelected(j, true); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
this.repaint(); |
||||
} |
||||
|
||||
/** |
||||
* Is selected |
||||
*/ |
||||
public boolean isSelected(int index) { |
||||
if (selects == null || index >= selects.length) { |
||||
return false; |
||||
} |
||||
|
||||
return selects[index]; |
||||
} |
||||
|
||||
public void setSelected(int index, boolean isSelected) { |
||||
if (selects == null || index >= selects.length) { |
||||
return; |
||||
} |
||||
|
||||
selects[index] = isSelected; |
||||
this.repaint(this.getBounds()); |
||||
|
||||
this.fireCheckBoxListSelectionChangeListener(); |
||||
} |
||||
|
||||
private void setSelected(boolean isSelected) { |
||||
if (selects == null) { |
||||
return; |
||||
} |
||||
for (int i = 0; i < selects.length; i++) { |
||||
selects[i] = isSelected; |
||||
} |
||||
this.repaint(this.getBounds()); |
||||
|
||||
this.fireCheckBoxListSelectionChangeListener(); |
||||
} |
||||
|
||||
/** |
||||
* Returns an array of the objects that have been selected. Overrides the |
||||
* JList method. |
||||
*/ |
||||
public Object[] getSelectedValues() { |
||||
return this.jlist.getSelectedValues(); |
||||
} |
||||
|
||||
private class BOXLIST extends JList { |
||||
public BOXLIST(Object[] items) { |
||||
super(items); |
||||
} |
||||
|
||||
@Override |
||||
protected void processMouseEvent(MouseEvent e) { |
||||
if (e.getX() < X_COORDINATE) { |
||||
boolean anyMaskDown = e.isControlDown() || e.isAltDown() || e.isShiftDown() || e.isMetaDown(); |
||||
if (anyMaskDown) { |
||||
int[] indices = getSelectedIndices(); |
||||
if (indices.length == 0) { |
||||
super.processMouseEvent(e); |
||||
} |
||||
} else { |
||||
super.processMouseEvent(e); |
||||
} |
||||
} else { |
||||
super.processMouseEvent(e); |
||||
} |
||||
int id = e.getID(); |
||||
switch (id) { |
||||
case MouseEvent.MOUSE_PRESSED: |
||||
break; |
||||
case MouseEvent.MOUSE_RELEASED: |
||||
break; |
||||
case MouseEvent.MOUSE_CLICKED: |
||||
doCheck(); |
||||
break; |
||||
case MouseEvent.MOUSE_EXITED: |
||||
break; |
||||
case MouseEvent.MOUSE_ENTERED: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected void processMouseMotionEvent(MouseEvent e) { |
||||
if (e.getX() < X_COORDINATE) { |
||||
return; |
||||
} |
||||
|
||||
super.processMouseEvent(e); |
||||
} |
||||
|
||||
@Override |
||||
public Object[] getSelectedValues() { |
||||
List<Object> list = new ArrayList<Object>(selects.length); |
||||
for (int i = 0; i < selects.length; i++) { |
||||
if (selects[i]) { |
||||
list.add(this.getModel().getElementAt(i)); |
||||
} |
||||
} |
||||
|
||||
return list.toArray(); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void doCheck() { |
||||
// p:这里必须改变所有选择checkbox.
|
||||
int index = jlist.getSelectedIndex(); |
||||
boolean sValue = !selects[index]; |
||||
|
||||
// p:开始设置所有选择的checkbox.
|
||||
int[] indices = jlist.getSelectedIndices(); |
||||
for (int i = 0; i < indices.length; i++) { |
||||
setSelected(indices[i], sValue); |
||||
} |
||||
for (boolean selected : selects) { |
||||
if (!selected) { |
||||
chooseAll.setSelected(false); |
||||
return; |
||||
} |
||||
} |
||||
chooseAll.setSelected(true); |
||||
repaint(); |
||||
} |
||||
|
||||
private static final Border NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); |
||||
|
||||
private class CheckListCellRenderer extends UICheckBox implements ListCellRenderer { |
||||
|
||||
public CheckListCellRenderer() { |
||||
this.setOpaque(true); |
||||
this.setBorder(NO_FOCUS_BORDER); |
||||
} |
||||
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
this.setText(value2Text(value)); |
||||
this.setSelected(selects[index]); |
||||
this.setFont(list.getFont()); |
||||
|
||||
if (isSelected) { |
||||
this.setBackground(list.getSelectionBackground()); |
||||
this.setForeground(list.getSelectionForeground()); |
||||
} else { |
||||
this.setBackground(list.getBackground()); |
||||
this.setForeground(list.getForeground()); |
||||
} |
||||
|
||||
if (cellHasFocus) { |
||||
this.setBorder(UIManager.getBorder("List.focusCellHighlightBorder")); |
||||
} else { |
||||
this.setBorder(NO_FOCUS_BORDER); |
||||
} |
||||
|
||||
return this; |
||||
} |
||||
} |
||||
|
||||
public void addCheckBoxListSelectionChangeListener(CheckBoxListSelectionChangeListener l) { |
||||
this.listenerList.add(CheckBoxListSelectionChangeListener.class, l); |
||||
} |
||||
|
||||
public void removeCheckBoxListSelectionChangeListener(CheckBoxListSelectionChangeListener l) { |
||||
this.listenerList.remove(CheckBoxListSelectionChangeListener.class, l); |
||||
} |
||||
|
||||
public void fireCheckBoxListSelectionChangeListener() { |
||||
// Guaranteed to return a non-null array
|
||||
Object[] listeners = listenerList.getListenerList(); |
||||
|
||||
// Process the listeners last to first, notifying
|
||||
// those that are interested in this event
|
||||
for (int i = listeners.length - 2; i >= 0; i -= 2) { |
||||
if (listeners[i] == CheckBoxListSelectionChangeListener.class) { |
||||
((CheckBoxListSelectionChangeListener) listeners[i + 1]).selectionChanged(this); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
public static interface CheckBoxListSelectionChangeListener extends EventListener { |
||||
public void selectionChanged(CheckBoxList target); |
||||
} |
||||
|
||||
public ListModel getModel() { |
||||
return jlist.getModel(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,58 @@
|
||||
package com.fr.design.mainframe.toolbar; |
||||
|
||||
import com.fr.design.actions.UpdateAction; |
||||
|
||||
/** |
||||
* Created by XiaXiang on 2017/5/24. |
||||
*/ |
||||
|
||||
/** |
||||
* action对象 |
||||
*/ |
||||
public class UpdateActionModel { |
||||
private String parentName; |
||||
private String actionName; |
||||
private UpdateAction action; |
||||
|
||||
public UpdateActionModel(String parentName, UpdateAction action) { |
||||
this.parentName = parentName; |
||||
this.action = action; |
||||
this.actionName = action.getName(); |
||||
} |
||||
|
||||
/** |
||||
* 获取上一层级菜单name |
||||
* @return |
||||
*/ |
||||
public String getParentName() { |
||||
return parentName; |
||||
} |
||||
|
||||
public void setParentName(String parentName) { |
||||
this.parentName = parentName; |
||||
} |
||||
|
||||
/** |
||||
* 获取action |
||||
* @return |
||||
*/ |
||||
public UpdateAction getAction() { |
||||
return action; |
||||
} |
||||
|
||||
public void setAction(UpdateAction action) { |
||||
this.action = action; |
||||
} |
||||
|
||||
/** |
||||
* 获取actionName |
||||
* @return |
||||
*/ |
||||
public String getActionName() { |
||||
return actionName; |
||||
} |
||||
|
||||
public void setActionName(String actionName) { |
||||
this.actionName = actionName; |
||||
} |
||||
} |
@ -0,0 +1,69 @@
|
||||
|
||||
apply plugin: 'java' |
||||
tasks.withType(JavaCompile){ |
||||
options.encoding = 'UTF-8' |
||||
} |
||||
//指定构建的jdk版本 |
||||
sourceCompatibility=1.7 |
||||
//指定生成jar包版本 |
||||
version='8.0' |
||||
//生成jar包重命名 |
||||
jar{ |
||||
baseName='fr-designer-chart' |
||||
} |
||||
|
||||
|
||||
def srcDir="." |
||||
def baseDir=".." |
||||
|
||||
//指定源码路径 |
||||
sourceSets{ |
||||
main{ |
||||
java{ |
||||
srcDirs=["${srcDir}/src"] |
||||
} |
||||
} |
||||
} |
||||
//获取什么分支名 |
||||
FileTree files =fileTree(dir:'./',include:'build.*.gradle') |
||||
def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\')) |
||||
buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\')) |
||||
def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1) |
||||
|
||||
//声明外部依赖 |
||||
dependencies{ |
||||
compile fileTree(dir:"../${baseDir}/lib",include:'**/*.jar') |
||||
compile fileTree(dir:"../${baseDir}",include:"**/build/libs/*.jar",exclude:"bi/**/*.jar") |
||||
testCompile 'junit:junit:4.12' |
||||
} |
||||
//复制非.java文件到classes文件夹下参与打包 |
||||
task copyFile(type:Copy,dependsOn:compileJava){ |
||||
copy{ |
||||
from ("${srcDir}/src"){ |
||||
exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' |
||||
} |
||||
into 'build/classes/main' |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
//压缩项目中的js文件 |
||||
task compressJS{ |
||||
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ |
||||
classpath { |
||||
fileset(dir:"../${baseDir}/lib4build",includes:'**/*.jar') |
||||
} |
||||
} |
||||
ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ |
||||
fileset (dir:"${srcDir}/src"){ |
||||
include (name:'**/*.js') |
||||
include (name:'**/*.css') |
||||
} |
||||
|
||||
} |
||||
} |
||||
jar.dependsOn compressJS |
||||
|
||||
|
||||
|
@ -0,0 +1,83 @@
|
||||
|
||||
apply plugin: 'java' |
||||
tasks.withType(JavaCompile){ |
||||
options.encoding = 'UTF-8' |
||||
} |
||||
//指定构建的jdk版本 |
||||
sourceCompatibility=1.7 |
||||
//指定生成jar包版本 |
||||
version='8.0' |
||||
//生成jar包重命名 |
||||
jar{ |
||||
baseName='fr-designer-report' |
||||
} |
||||
|
||||
|
||||
def srcDir="." |
||||
def baseDir=".." |
||||
|
||||
//指定源码路径 |
||||
sourceSets{ |
||||
main{ |
||||
java{ |
||||
srcDirs=["${srcDir}/src", |
||||
"${srcDir}/../designer/src"] |
||||
} |
||||
} |
||||
} |
||||
//获取什么分支名 |
||||
FileTree files =fileTree(dir:'./',include:'build.*.gradle') |
||||
def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ('\\')) |
||||
buildDir=buildDir.substring(0,buildDir.lastIndexOf ('\\')) |
||||
def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1) |
||||
|
||||
//声明外部依赖 |
||||
dependencies{ |
||||
compile fileTree(dir:"../${baseDir}/lib",include:'**/*.jar') |
||||
compile fileTree(dir:"../${baseDir}",include:"**/build/libs/*.jar",exclude:"bi/**/*.jar") |
||||
testCompile 'junit:junit:4.12' |
||||
} |
||||
//复制非.java文件到classes文件夹下参与打包 |
||||
|
||||
//指明无法编译文件所在路径 |
||||
def dataContent ={def dir -> |
||||
copySpec{ |
||||
from ("${dir}"){ |
||||
exclude '**/.setting/**','.classpath','.project','**/*.java','**/*.db','**/*.g','**/package.html' |
||||
} |
||||
} |
||||
} |
||||
|
||||
task copyFile(type:Copy,dependsOn:compileJava){ |
||||
copy{ |
||||
with dataContent.call("${srcDir}/src") |
||||
with dataContent.call("${srcDir}/../designer/src") |
||||
into 'build/classes/main' |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
//压缩项目中的js文件 |
||||
task compressJS{ |
||||
ant.taskdef(name:'yuicompress',classname:'com.yahoo.platform.yui.compressor.YUICompressTask'){ |
||||
classpath { |
||||
fileset(dir:"../${baseDir}/lib4build",includes:'**/*.jar') |
||||
} |
||||
} |
||||
ant.yuicompress(linebreak:"500",warn:"false", munge:"yes",preserveallsemicolons:"false",charset:"utf-8",encoding:"utf-8",outputfolder:'build/classes/main'){ |
||||
fileset (dir:"${srcDir}/src"){ |
||||
include (name:'**/*.js') |
||||
include (name:'**/*.css') |
||||
} |
||||
fileset (dir:"${srcDir}/../designer/src"){ |
||||
include (name:'**/*.js') |
||||
include (name:'**/*.css') |
||||
} |
||||
|
||||
} |
||||
} |
||||
jar.dependsOn compressJS |
||||
|
||||
|
||||
|